Re: Unexpected behaviour with DeprecationWarning, Python 3.7 and escape codes
On 2018-08-23 06:08 AM, Peter via Python-list wrote: > I understand that Python 3.7 now issues DeprecationWarning for code > entered in the interactive shell and also for single-module programs. I > see this behaviour with: > > C:\wrk> python > python 3.7.0 (v3.7.0:... import imp > __main__:1: DeprecationWarning: the imp module is deprecated... Valid warning. > But if I use an unknown escape code, then the expected warning doesn't > issue: > print('Hello \world') > Hello \world > > But if I explicitly turn on default warnings, then I do get it: > > C:\wrk> python -Wd print('Hello \world') > :1: DeprecationWarning: invalid escape sequence \w > Hello \world I don't know why it issues DeprecationWarning but this is not the same as the previous line. In this case \w is invalid and, as far as I know, has always been invalid. I think it should be a different warning but I do understand why it is in a different code path in Python. It doesn't issue any warning in 2.7 by the way. It still prints the same thing so it is still an invalid escape sequence. -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:da...@vex.net VoIP: sip:da...@vybenetworks.com -- https://mail.python.org/mailman/listinfo/python-list
Unexpected behaviour with DeprecationWarning, Python 3.7 and escape codes
I understand that Python 3.7 now issues DeprecationWarning for code entered in the interactive shell and also for single-module programs. I see this behaviour with: C:\wrk> python python 3.7.0 (v3.7.0:... import imp __main__:1: DeprecationWarning: the imp module is deprecated... But if I use an unknown escape code, then the expected warning doesn't issue: print('Hello \world') Hello \world But if I explicitly turn on default warnings, then I do get it: C:\wrk> python -Wd print('Hello \world') :1: DeprecationWarning: invalid escape sequence \w Hello \world Shouldn't I see the "invalid escape sequence" deprecation warning under 3.7 without having to turn on default warnings? They are both warnings of class DeprecationWarning. Am I not seeing something? Is this a bug? I suspect it might have something to do with /when/ the warning is evaluated (parsing time vs runtime), but I'm not sure, and I'm not sure if that should be relevant to whether the warning is in fact raised. (I am aware of PEP 565) Running CPython 3.7.0 on Windows 10, standard Thanks for your insights. Peter -- https://mail.python.org/mailman/listinfo/python-list