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

re.escape escapes underscore (Python 2.7) #62981

Closed
vajrasky mannequin opened this issue Aug 19, 2013 · 2 comments
Closed

re.escape escapes underscore (Python 2.7) #62981

vajrasky mannequin opened this issue Aug 19, 2013 · 2 comments
Assignees
Labels
topic-regex type-bug An unexpected behavior, bug, or error

Comments

@vajrasky
Copy link
Mannequin

vajrasky mannequin commented Aug 19, 2013

BPO 18781
Nosy @ezio-melotti, @vajrasky
Files
  • dont_escape_underscore_in_regex_27.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/ezio-melotti'
    closed_at = <Date 2013-08-19.15:18:33.942>
    created_at = <Date 2013-08-19.15:05:40.429>
    labels = ['expert-regex', 'type-bug']
    title = 're.escape escapes underscore (Python 2.7)'
    updated_at = <Date 2013-08-19.15:18:33.941>
    user = 'https://github.com/vajrasky'

    bugs.python.org fields:

    activity = <Date 2013-08-19.15:18:33.941>
    actor = 'ezio.melotti'
    assignee = 'ezio.melotti'
    closed = True
    closed_date = <Date 2013-08-19.15:18:33.942>
    closer = 'ezio.melotti'
    components = ['Regular Expressions']
    creation = <Date 2013-08-19.15:05:40.429>
    creator = 'vajrasky'
    dependencies = []
    files = ['31373']
    hgrepos = []
    issue_num = 18781
    keywords = ['patch']
    message_count = 2.0
    messages = ['195638', '195640']
    nosy_count = 3.0
    nosy_names = ['ezio.melotti', 'mrabarnett', 'vajrasky']
    pr_nums = []
    priority = 'normal'
    resolution = 'rejected'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue18781'
    versions = ['Python 2.7']

    @vajrasky
    Copy link
    Mannequin Author

    vajrasky mannequin commented Aug 19, 2013

    $ ./python --version
    Python 2.7.5+
    $ ./python
    Python 2.7.5+ (2.7:062533327ad2, Aug 19 2013, 22:44:52) 
    [GCC 4.7.2 20121109 (Red Hat 4.7.2-8)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import re
    >>> re.escape('_')
    '\\_'

    Python 3.3 and 3.4 got it right and don't escape the underscore.

    Because many people are still doing their livelihoods with Python 2.7 and I am a compassionate person, here is the patch to fix the bug in Python 2.7.

    @vajrasky vajrasky mannequin added topic-regex type-bug An unexpected behavior, bug, or error labels Aug 19, 2013
    @ezio-melotti
    Copy link
    Member

    This was considered a new feature when it was added in 3.2 (see bpo-2650), so it was not backported to 2.7 because -- even if it was a minor change -- it was not 100% backward compatible.

    @ezio-melotti ezio-melotti self-assigned this Aug 19, 2013
    @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
    topic-regex type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant