XPost: linux.debian.maint.python
Hi,
I was constantly shaking my had above bug #1061802 featuring
Syntaxwarnings like
SyntaxWarning: invalid escape sequence '\.'
573s CLI_INPUT_RE = re.compile('[a-zA-Z0-9_:\.\-\+; /#%]')
573s /tmp/autopkgtest.G4v4eK/autopkgtest_tmp/hatop.py:215:
SyntaxWarning: invalid escape sequence '\s'
573s 'software_name': re.compile('^Name:\s*(?P<value>\S+)'),
which is even in contrast with Regular expression operations
documentation for Python3.12[1] where
\s
For Unicode (str) patterns:
Matches Unicode whitespace characters (which includes [ \t\n\r\f\v], and also many other characters, for example the non-breaking spaces mandated by typography rules in many languages).
Matches [ \t\n\r\f\v] if the ASCII flag is used.
For 8-bit (bytes) patterns:
Matches characters considered whitespace in the ASCII character set; this is equivalent to [ \t\n\r\f\v].
remains what I know \s is meaning in regular expressions. (I admit '\.'
is unusual inside [] and I think just '.' is appropriate here.) I tried
simple things like
$ python3.12
Python 3.12.2 (main, Feb 7 2024, 20:47:03) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
import re
software_name = re.compile('^Name:\s*(?P<value>\S+)')
<stdin>:1: SyntaxWarning: invalid escape sequence '\s'
software_name = re.compile('^Name:[\s\t\n]*(?P<value>\S+)')
<stdin>:1: SyntaxWarning: invalid escape sequence '\s'
which makes me scratching my head what else we should write
for "any kind of space" now in Python3.12.
Kind regards
Andreas.
[1]
https://docs.python.org/3/library/re.html
--
http://fam-tille.de
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)