1. Pypy
  2. Untitled project
  3. pypy


Antonio Cuni  committed 538b58a

there is no need to import the full applevel warnings module to implement space.warn: warnings.warn is replaced by _warning.warn anyway, so just use that instead. As a consequence, we need to make _warnings an essential module, but I think this is fine since emitting warnings is required by some places in the core interpreter

  • Participants
  • Parent commits 402fe7b
  • Branches default

Comments (0)

Files changed (2)

File pypy/config/pypyoption.py

View file
                and not p.basename.startswith('test')]
 essential_modules = dict.fromkeys(
-    ["exceptions", "_file", "sys", "__builtin__", "posix"]
+    ["exceptions", "_file", "sys", "__builtin__", "posix", "_warnings"]
 default_modules = essential_modules.copy()

File pypy/interpreter/baseobjspace.py

View file
     def warn(self, msg, w_warningcls):
         self.appexec([self.wrap(msg), w_warningcls], """(msg, warningcls):
-            import warnings
-            warnings.warn(msg, warningcls, stacklevel=2)
+            import _warnings
+            _warnings.warn(msg, warningcls, stacklevel=2)
     def resolve_target(self, w_obj):