Skip to content

Commit b9c7593

Browse files
committed
future.standard_library.install_aliases(): patch in dbm.* and test.support in addition to urllib.*
1 parent 6c7846e commit b9c7593

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

future/standard_library/__init__.py

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -482,14 +482,39 @@ def install_aliases():
482482
sys.modules['urllib.error'] = error
483483
sys.modules['urllib.robotparser'] = robotparser
484484

485-
from future.moves import http
486-
sys.modules['http'] = http
487-
488-
from future.moves import xmlrpc
489-
sys.modules['xmlrpc'] = xmlrpc
485+
# Patch the test module so it appears to have the same structure on Py2 as on Py3
486+
try:
487+
import test
488+
except ImportError:
489+
pass
490+
else:
491+
from future.moves.test import support
492+
test.support = support
493+
sys.modules['test.support'] = support
490494

491-
from future.moves import html
492-
sys.modules['html'] = html
495+
# Patch the dbm module so it appears to have the same structure on Py2 as on Py3
496+
try:
497+
import dbm
498+
except ImportError:
499+
pass
500+
else:
501+
from future.moves.dbm import dumb
502+
dbm.dumb = dumb
503+
sys.modules['dbm.dumb'] = dumb
504+
try:
505+
from future.moves.dbm import gnu
506+
except ImportError:
507+
pass
508+
else:
509+
dbm.gnu = gnu
510+
sys.modules['dbm.gnu'] = gnu
511+
try:
512+
from future.moves.dbm import ndbm
513+
except ImportError:
514+
pass
515+
else:
516+
dbm.ndbm = ndbm
517+
sys.modules['dbm.ndbm'] = ndbm
493518

494519
# install_aliases.run_already = True
495520

0 commit comments

Comments
 (0)