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

Make re.compile() locale agnostic #74401

Closed
serhiy-storchaka opened this issue Apr 30, 2017 · 3 comments
Closed

Make re.compile() locale agnostic #74401

serhiy-storchaka opened this issue Apr 30, 2017 · 3 comments
Assignees
Labels
3.7 expert-regex extension-modules stdlib type-bug

Comments

@serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Apr 30, 2017

BPO 30215
Nosy @ezio-melotti, @serhiy-storchaka
PRs
  • #1361
  • 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 2017-05-05.06:42:44.843>
    created_at = <Date 2017-04-30.05:21:39.777>
    labels = ['extension-modules', 'expert-regex', 'type-bug', 'library', '3.7']
    title = 'Make re.compile() locale agnostic'
    updated_at = <Date 2017-05-05.06:42:44.842>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2017-05-05.06:42:44.842>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2017-05-05.06:42:44.843>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules', 'Library (Lib)', 'Regular Expressions']
    creation = <Date 2017-04-30.05:21:39.777>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30215
    keywords = []
    message_count = 3.0
    messages = ['292618', '292970', '293044']
    nosy_count = 3.0
    nosy_names = ['ezio.melotti', 'mrabarnett', 'serhiy.storchaka']
    pr_nums = ['1361']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue30215'
    versions = ['Python 3.7']

    @serhiy-storchaka
    Copy link
    Member Author

    @serhiy-storchaka serhiy-storchaka commented Apr 30, 2017

    Currently the result of re.compile() with the re.LOCALE flag depends on the locale at compile time. The locale at matching time should be the same as the locale at compile time, otherwise the matching can work incorrectly. This complicates caching in module global functions and increase the chance of race condition.

    Proposed patch makes re.compile() not depending on locale. Only the locale at matching time affects the result of matching.

    This is more comprehensive solution of bpo-22410.

    @serhiy-storchaka serhiy-storchaka added 3.7 extension-modules stdlib expert-regex type-bug labels Apr 30, 2017
    @serhiy-storchaka serhiy-storchaka self-assigned this May 4, 2017
    @serhiy-storchaka
    Copy link
    Member Author

    @serhiy-storchaka serhiy-storchaka commented May 4, 2017

    This change can be considered as a bug fix, but I hesitate to apply it to maintained releases because the effect on the performance of case-sensitive locale-depending bytes matching is hardly predicable. Some matches become 5 times faster, others become 1.5 times slower, depending on the cases of the pattern and the matched bytestring.

    @serhiy-storchaka
    Copy link
    Member Author

    @serhiy-storchaka serhiy-storchaka commented May 5, 2017

    New changeset 898ff03 by Serhiy Storchaka in branch 'master':
    bpo-30215: Make re.compile() locale agnostic. (bpo-1361)
    898ff03

    @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
    3.7 expert-regex extension-modules stdlib type-bug
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant