Nick Coghlan added the comment:
I realised I wasn't entirely clear about the "warning misattribution" problem
that's implied by Chi Hsuan's problem report, so here's the behaviour when
using "-W all" rather than "-W error":
$ echo "print('\d')" > bad_escape.py
$ echo "import bad_escape" > escape_warning.py
$ ./python -W all escape_warning.py
_frozen_importlib:205: DeprecationWarning: invalid escape sequence '\d'
\d
That's a misattribution - the warning should be reported against the module
being imported, not against the import system itself.
Compare that to the attribution of the old SyntaxWarning for assignments prior
to a scope declaration:
$ cat syntax_warning.py
def f():
x = 1
global x
$ python3 -c "import syntax_warning"
/home/ncoghlan/devel/py36/syntax_warning.py:3: SyntaxWarning: name 'x' is
assigned to before global declaration
global x
(Run with 3.5, as that became a full SyntaxError for 3.6)
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue28128>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com