Forward port of issue #33994 to 2.7.x.

Comment From: philwebb

Thanks for fixing the strange forward-port @wilkinsona, I'm not sure what happened here.