IronLanguages / main

Work for this repo has moved to https://github.com/IronLanguages/ironpython2
1.16k stars 347 forks source link

Strange behavior of symbolic group name on regular expression module. #1664

Closed utgwkk closed 7 years ago

utgwkk commented 7 years ago

The duplication of symbolic group names on regular expression is prohibited on CPython's re module. https://docs.python.org/2/library/re.html#regular-expression-syntax

Group names must be valid Python identifiers, and each group name must be defined only once within a regular expression.

However, the following code returns no error on IronPython 2.7.7, and yields a strange value. This code should be an error.

IronPython 2.7.7 (2.7.7.0) on .NET 4.0.30319.1 (32-bit)
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> ptn = re.compile(r'(?P<hoge>\w+):(?P<hoge>\w+)')
>>> ptn.match('hoge:fuga')
<RE_Match object at 0x000000000000006D>
>>> _.group('hoge')
'fuga'
slide commented 7 years ago

This issue was moved to IronLanguages/ironpython2#21