Comment 12 for bug 1828595

Andrew Lutsenko (qu1ck) wrote :

I did a bit more research.

Something like this should work:

if SubDirname in sys.modules:
  reload(SubDirname)
else:
  __import__(SubDirname, locals(), globals())

where reload has same conditionals as in your patch, probably extracting it into helper function is good idea.