Kaydet (Commit) 034c2a9f authored tarafından Fred Drake's avatar Fred Drake

Add support for "import re" -- it uses pre, but user code does not need

to.
üst 410cb6be
...@@ -153,6 +153,9 @@ class RExec(ihooks._Verbose): ...@@ -153,6 +153,9 @@ class RExec(ihooks._Verbose):
self.make_sys() self.make_sys()
self.loader = RModuleLoader(self.hooks, verbose) self.loader = RModuleLoader(self.hooks, verbose)
self.importer = RModuleImporter(self.loader, verbose) self.importer = RModuleImporter(self.loader, verbose)
# but since re isn't normally built-in, we can add it at the end;
# we need the imported to be set before this can be imported.
self.make_re()
def set_trusted_path(self): def set_trusted_path(self):
# Set the path from which dynamic modules may be loaded. # Set the path from which dynamic modules may be loaded.
...@@ -198,6 +201,13 @@ class RExec(ihooks._Verbose): ...@@ -198,6 +201,13 @@ class RExec(ihooks._Verbose):
for key, value in os.environ.items(): for key, value in os.environ.items():
e[key] = value e[key] = value
def make_re(self):
dst = self.add_module("re")
src = self.r_import("pre")
for name in dir(src):
if name != "__name__":
setattr(dst, name, getattr(src, name))
def make_sys(self): def make_sys(self):
m = self.copy_only(sys, self.ok_sys_names) m = self.copy_only(sys, self.ok_sys_names)
m.modules = self.modules m.modules = self.modules
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment