Extending on b68222e4e7 to ensure that it still has the exact same behaviour as the previous code, as discussed with @hpvb. (cherry picked from commit 03e11c13bf)
b68222e4e7
03e11c13bf