Author py.user
Recipients ezio.melotti, mrabarnett, py.user
Date 2012-03-12.21:37:17
SpamBayes Score 1.32785e-06
Marked as misclassified No
Message-id <1331588238.77.0.980984426494.issue14260@psf.upfronthosting.co.za>
In-reply-to
Content
Matthew Barnett wrote:
> The re module creates the dict purely for the benefit of the user

this dict affects on regex.sub()

>>> import re
>>> p = re.compile(r'abc(?P<n>def)')
>>> p.groupindex
{'n': 1}
>>> p.groupindex['n'] = 2
>>> p.sub(r'\g<n>', 'abcdef')
Traceback (most recent call last):
  File "/usr/local/lib/python3.2/sre_parse.py", line 811, in expand_template
    literals[index] = s = g(group)
IndexError: no such group

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.2/re.py", line 286, in filter
    return sre_parse.expand_template(template, match)
  File "/usr/local/lib/python3.2/sre_parse.py", line 815, in expand_template
    raise error("invalid group reference")
sre_constants.error: invalid group reference
>>>
History
Date User Action Args
2012-03-12 21:37:18py.usersetrecipients: + py.user, ezio.melotti, mrabarnett
2012-03-12 21:37:18py.usersetmessageid: <1331588238.77.0.980984426494.issue14260@psf.upfronthosting.co.za>
2012-03-12 21:37:18py.userlinkissue14260 messages
2012-03-12 21:37:17py.usercreate