classification
Title: Incomplete documentation for re.sub
Type: Stage: resolved
Components: Regular Expressions Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Misleading/inaccurate documentation about unknown escape sequences in regular expressions
View: 28450
Assigned To: Nosy List: Windson Yang, ezio.melotti, mrabarnett, pbugnion, serhiy.storchaka
Priority: normal Keywords:

Created on 2019-01-29 08:06 by pbugnion, last changed 2019-02-14 16:47 by serhiy.storchaka. This issue is now closed.

Messages (3)
msg334504 - (view) Author: Pascal Bugnion (pbugnion) Date: 2019-01-29 08:06
The documentation for `re.sub` states that "Unknown escapes such as ``\&`` are left alone.". This is only true for escapes which are not ascii characters, as far as I can tell (c.f. source on https://github.com/python/cpython/blob/master/Lib/sre_parse.py#L1047).

Would there be value in amending that documentation to either remove that sentence or to clarify it? If so, I'm happy to submit a PR on GitHub.
msg334642 - (view) Author: Windson Yang (Windson Yang) * Date: 2019-02-01 01:46
I wonder if possible that c not in ASCIILETTERS when we get KeyError?

    if c in ASCIILETTERS:
        raise s.error('bad escape %s' % this, len(this))
msg335543 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-02-14 16:47
This is a duplicate of issue28450.
History
Date User Action Args
2019-02-14 16:47:40serhiy.storchakasetstatus: open -> closed

superseder: Misleading/inaccurate documentation about unknown escape sequences in regular expressions

nosy: + serhiy.storchaka
messages: + msg335543
resolution: duplicate
stage: resolved
2019-02-01 01:46:34Windson Yangsetnosy: + Windson Yang
messages: + msg334642
2019-01-29 08:06:08pbugnioncreate