[1.7.x] Fixed #22577: Python 3 broke on non-module migrations directory
[1.7.x] Fix previous commit on python 2