New issue 2917: Deformed enough PYTHONWARNINGS makes pypy crash on startup
https://bitbucket.org/pypy/pypy/issues/2917/deformed-enough-pythonwarnings-makes-pypy
Julian Berman:
```
#!terminal
⊙ /usr/local/bin/pypy --version && env -i PYTHONWARNINGS='ignore:*:*:foo.py'
/usr/local/bin/pypy
julian@Air
Python 2.7.13 (ab0b9caf307db6592905a80b8faffd69b39005b8, Jun 24 2018, 08:19:27)
[PyPy 6.0.0 with GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)]
debug: OperationError:
debug: operror-type: ValueError
debug: operror-value: Empty module name
```
In CPython this also blows up, but only once you import the warnings module
(presumably the same thing happening, just early enough in PyPy startup to make
the interpreter freak out a bit?):
```
⊙ /usr/bin/python --version && env -i PYTHONWARNINGS='ignore:*:*:foo.py'
/usr/bin/python
julian@Air
Python 2.7.10
Python 2.7.10 (default, Aug 17 2018, 17:41:52)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import warnings
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/warnings.py",
line 388, in <module>
_processoptions(sys.warnoptions)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/warnings.py",
line 110, in _processoptions
_setoption(arg)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/warnings.py",
line 126, in _setoption
category = _getcategory(category)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/warnings.py",
line 166, in _getcategory
m = __import__(module, None, None, [klass])
ValueError: Empty module name
```
ISTM that probably the best behavior here is to not fail at all and to just do
the same thing that happens when you provide slightly less deformed
PYTHONWARNINGS -- i.e., ignore it.
```
⊙ PYTHONWARNINGS=foo:bar:bar:bar pypy
julian@Air
Invalid -W option ignored: invalid action: 'foo'
```
```
_______________________________________________
pypy-issue mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-issue