Apply #4441 fix to 3.9

#4441