Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7ec28d2

Browse files
author
Greg Stein
committed
turn SysPathImporter into PathImporter.
1 parent 72ee435 commit 7ec28d2

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

Lib/imputil.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import imp
2222
import sys
2323
import strop
24-
import __builtin__ ### why this instead of just using __builtins__ ??
24+
import __builtin__
2525

2626
# for the DirectoryImporter
2727
import struct
@@ -588,10 +588,11 @@ def __repr__(self):
588588

589589
######################################################################
590590
#
591-
# Emulate the standard sys.path import mechanism
591+
# Emulate the standard path-style import mechanism
592592
#
593-
class SysPathImporter(Importer):
594-
def __init__(self):
593+
class PathImporter(Importer):
594+
def __init__(self, path=sys.path):
595+
self.path = path
595596

596597
# we're definitely going to be importing something in the future,
597598
# so let's just load the OS-related facilities.
@@ -604,7 +605,7 @@ def get_code(self, parent, modname, fqname):
604605
return _fs_import(parent.__pkgdir__, modname)
605606

606607
# scan sys.path, looking for the requested module
607-
for dir in sys.path:
608+
for dir in self.path:
608609
result = _fs_import(dir, modname)
609610
if result:
610611
return result
@@ -649,7 +650,7 @@ def _test_dir():
649650
def _test_revamp():
650651
"Debug/test function for the revamped import system."
651652
BuiltinImporter().install()
652-
SysPathImporter().install()
653+
PathImporter().install()
653654

654655
def _print_importers():
655656
items = sys.modules.items()

0 commit comments

Comments
 (0)