Forever-Young / mrab-regex-hg

Automatically exported from code.google.com/p/mrab-regex-hg
0 stars 0 forks source link

bad named character escape sequences like "\\N{1}" treats as "N" #58

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
>>> import regex
>>> try:
...     print(regex.search("\\N{1}", "N", flags=regex.V1).group(0))
... except regex.error as e:
...     print("Error:", e)
...
N
>>> try:
...     print(regex.search("\\N", "N", flags=regex.V1).group(0))
... except regex.error as e:
...     print("Error:", e)
...
N
>>>

What is the expected output? What do you see instead?
The expected output is the following:
>>> import regex
>>> try:
...     print(regex.search("\\N{1}", "N", flags=regex.V1).group(0))
... except regex.error as e:
...     print("Error:", e)
...
Error: undefined character name
>>> try:
...     print(regex.search("\\N", "N", flags=regex.V1).group(0))
... except regex.error as e:
...     print("Error:", e)
...
Error: bad named character escape
>>>

What version of the product are you using? On what operating system?
Windows XP Home SP3 (32-bit version)
Python 3.2.2 (default, Sep  4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win
32
regex 0.1.20120129

Please provide any additional information below.
In this case, I think the regex module should put more weight on 
understandability than backward compatibility with the current re module.
It seems "\\p" and "\\P" also has the same problem.

Original issue reported on code.google.com by msm...@gmail.com on 5 Feb 2012 at 2:13

GoogleCodeExporter commented 9 years ago
In regex 0.1.20120208, regex.compile(r"\N{1}") now complains "undefined 
character name".

I'm not sure whether making the other changes would be a good idea; I'll have 
to think about it.

Would it affect backwards compatibility? Should it be stricter only in the 
version 1 behaviour?

Original comment by re...@mrabarnett.plus.com on 8 Feb 2012 at 3:14