This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mrabarnett
Recipients Patrick Foley, ezio.melotti, mrabarnett, r.david.murray
Date 2017-04-22.01:17:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1492823878.85.0.370150986412.issue30133@psf.upfronthosting.co.za>
In-reply-to
Content
Yes, the second argument is a replacement template, not a literal.

This issue does point out a different problem, though: re.escape will add backslashes that will then be treated as literals in the template, for example:

>>> re.sub(r'a', re.escape('(A)'), 'a')
'\\(A\\)'

re.escape doesn't always help.

The solution here is to pass a replacement function instead:

>>> re.sub(r'a', lambda m: '(A)', 'a')
'(A)'
History
Date User Action Args
2017-04-22 01:17:58mrabarnettsetrecipients: + mrabarnett, ezio.melotti, r.david.murray, Patrick Foley
2017-04-22 01:17:58mrabarnettsetmessageid: <1492823878.85.0.370150986412.issue30133@psf.upfronthosting.co.za>
2017-04-22 01:17:58mrabarnettlinkissue30133 messages
2017-04-22 01:17:58mrabarnettcreate