ironpython2
ironpython2 copied to clipboard
Mangled group names in RE_Match.groupdict()
Description
In IronPython 2.7.12 (and 3.4.0-beta1) RE_Match.groupdict() contains the mangled names of orginally unnamed groups, when both named and unnamed groups are present in the expression. CPython only lists the explicitly named groups. This is, of course, trivial to work around, but I still thought it worth the report.
Expected behavior:
Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import re; re.match('(?P<foo>.*)(.*)', 'bar').groupdict()
{'foo': 'bar'}
Actual behavior:
IronPython 2.7.12 DEBUG (2.7.12.1000)
[.NETFramework,Version=v4.5 on .NET Framework 4.8.4510.0 (64-bit)]
Type "help", "copyright", "credits" or "license" for more information.
>>> import re; re.match('(?P<foo>.*)(.*)', 'bar').groupdict()
{'foo': 'bar', '___PyRegexNameMangled2127356294': ''}
Thanks for the report!