Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r95424:8f0f4e09382a
Date: 2018-12-05 10:57 +0200
http://bitbucket.org/pypy/pypy/changeset/8f0f4e09382a/

Log:    Issue #2917

        Try to handle a bit better bogus PYTHONWARNINGS

diff --git a/lib-python/2.7/warnings.py b/lib-python/2.7/warnings.py
--- a/lib-python/2.7/warnings.py
+++ b/lib-python/2.7/warnings.py
@@ -182,6 +182,8 @@
         module = category[:i]
         klass = category[i+1:]
         try:
+            if not module:
+                raise ImportError   # instead of the ValueError we'd get
             m = __import__(module, None, None, [klass])
         except ImportError:
             raise _OptionError("invalid module name: %r" % (module,))
diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py
--- a/pypy/interpreter/app_main.py
+++ b/pypy/interpreter/app_main.py
@@ -609,8 +609,14 @@
         warnoptions.extend(pythonwarnings.split(','))
     if warnoptions:
         sys.warnoptions[:] = warnoptions
-        from warnings import _processoptions
-        _processoptions(sys.warnoptions)
+        try:
+            if 'warnings' in sys.modules:
+                from warnings import _processoptions
+                _processoptions(sys.warnoptions)
+            else:
+                import warnings
+        except ImportError as e:
+            pass   # CPython just eats any exception here
 
     # set up the Ctrl-C => KeyboardInterrupt signal handler, if the
     # signal module is available
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to