Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate unrecognized backslash+letter escapes in re #67810

Closed
serhiy-storchaka opened this issue Mar 9, 2015 · 3 comments
Closed

Deprecate unrecognized backslash+letter escapes in re #67810

serhiy-storchaka opened this issue Mar 9, 2015 · 3 comments
Assignees
Labels
expert-regex stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Mar 9, 2015

BPO 23622
Nosy @pitrou, @ezio-melotti, @serhiy-storchaka
Files
  • re_deprecate_escaped_letters.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2015-03-24.21:18:22.382>
    created_at = <Date 2015-03-09.13:28:27.035>
    labels = ['expert-regex', 'type-feature', 'library']
    title = 'Deprecate unrecognized backslash+letter escapes in re'
    updated_at = <Date 2015-03-24.23:35:06.524>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2015-03-24.23:35:06.524>
    actor = 'python-dev'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2015-03-24.21:18:22.382>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)', 'Regular Expressions']
    creation = <Date 2015-03-09.13:28:27.035>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['38406']
    hgrepos = []
    issue_num = 23622
    keywords = ['patch']
    message_count = 3.0
    messages = ['237645', '239181', '239197']
    nosy_count = 6.0
    nosy_names = ['pitrou', 'ezio.melotti', 'mrabarnett', 'cvrebert', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue23622'
    versions = ['Python 3.5']

    @serhiy-storchaka
    Copy link
    Member Author

    serhiy-storchaka commented Mar 9, 2015

    Regular expressions use the backslash character for two functions:

    1. to indicate special forms;
    2. to allow special characters to be used without invoking their special meaning.

    If backslash + character is not recognized as special form (1), it interpreted in meaning (2).

    Usually new special forms have form backslash + ASCII letter, because unlike to other characters single ASCII letters do not have special meaning in any regular expression engine or programming language. This using the backslash with inner ASCII letter dangerous. Currently it means just this letter literally, but in future it can mean special form. For example \u and \U forms were added in 3.3 and this could break regular expression patters that use \u and \U before.

    To avoid possible breaking it makes sense to reject unrecognized backslash + ASCII letter sequences. Proposed patch adds deprecation warnings when unknown escape of ASCII letter is used. The idea was proposed by Matthew Barnett [1].

    [1] http://permalink.gmane.org/gmane.comp.python.devel/151657

    @serhiy-storchaka serhiy-storchaka self-assigned this Mar 9, 2015
    @serhiy-storchaka serhiy-storchaka added stdlib Python modules in the Lib dir expert-regex type-feature A feature request or enhancement labels Mar 9, 2015
    @serhiy-storchaka serhiy-storchaka changed the title Deprecate unrecognized backslash+letter escapes Deprecate unrecognized backslash+letter escapes in re Mar 13, 2015
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 24, 2015

    New changeset 014031a4d398 by Serhiy Storchaka in branch 'default':
    Issue bpo-23622: Unknown escapes in regular expressions that consist of '\'
    https://hg.python.org/cpython/rev/014031a4d398

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 24, 2015

    New changeset 7384db2fce8a by Serhiy Storchaka in branch 'default':
    Fixed using deprecated escaping in regular expression in _strptime.py (bpo-23622).
    https://hg.python.org/cpython/rev/7384db2fce8a

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    expert-regex stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant