[reportlab-users] deprecation warning

Robin Becker robin at reportlab.com
Fri Mar 19 07:05:36 EDT 2021


On 19/03/2021 10:21, Christoph Zwerschke wrote:
> On 19.03.2021 10:45, Robin Becker wrote:
>  > I don't know how many tests I have to run, but I don't see this
>  > warning in 2.7.18, 3.7.5, 3.8.6, 3.9.2 & 3.10.0a6. It doesn't show in
>  > the various github action / appveyor wheel builds.
>  >
>  > Jürgen can you say what OS, exact version of python 3.8 and what
>  > command line options if any were used?
>  >
>  > I will put this into the latest release.
> 
> Robin, this warning will certainly only show up since Python 3.8.
> 
How strange, I run all the tests in many pythons including 3.8.6 etc etc and don't see this warning; I'm just wondering 
if I need to excite it somehow. I run on linux mostly, but the appveyor is windows and the github actions include OS X.

I've made the regex raw, but in my python 3.8 it worked as expected eg

> $ python
> Python 3.8.6 (default, Dec  4 2020, 10:19:20) 
> [GCC 10.2.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import re
>>>> _re_unit = re.compile('^\s*(.*)(i|in|cm|mm|pt|pica)\s*$')
>>>> _re_unit
> re.compile('^\\s*(.*)(i|in|cm|mm|pt|pica)\\s*$')
>>>> 

which is a bit odd since I don't see how the regex even sees the \s as double escaped; I assume some python magic is 
delaying interpretation of the \s somehow. The python is compiled by me following the Arch Linux build process. The 
standard arch linux python3 works the same eg
> $ /usr/bin/python3
> Python 3.9.2 (default, Feb 20 2021, 18:40:11) 
> [GCC 10.2.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import re
>>>> _re_unit = re.compile('^\s*(.*)(i|in|cm|mm|pt|pica)\s*$')
>>>> _re_unit
> re.compile('^\\s*(.*)(i|in|cm|mm|pt|pica)\\s*$')
>>>>



> The docs for the re module say since Python 3.8: "Please note that any invalid escape sequences in Python’s usage of the 
> backslash in string literals now generate a DeprecationWarning and in the future this will become a SyntaxError. This 
> behaviour will happen even if it is a valid escape sequence for a regular expression."
> 
> So it's important to fix this.
> 
> If you run flake8 on the source, you should find all such instances of invalid escape sequences (reported as warning W605).
I just ran pylint and have 30000 + warnings and errors about 500 hours work should fix it :(
adding flake can't make the work any better :(
> 
> -- Christoph

thanks anyway

-- 
Robin Becker


More information about the reportlab-users mailing list