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

Tools/demo/redemo.py broken #74907

Closed
csarn mannequin opened this issue Jun 21, 2017 · 13 comments
Closed

Tools/demo/redemo.py broken #74907

csarn mannequin opened this issue Jun 21, 2017 · 13 comments
Labels
3.7 (EOL) end of life type-bug An unexpected behavior, bug, or error

Comments

@csarn
Copy link
Mannequin

csarn mannequin commented Jun 21, 2017

BPO 30722
Nosy @ezio-melotti, @berkerpeksag, @serhiy-storchaka, @mlouielu, @csarn
PRs
  • bpo-30722: adjust to new RegexFlags enum, remove LOCALE checkbox #2311
  • [3.6] bpo-30722: Make redemo work with Python 3.6+ (GH-2311) #4090
  • bpo-30722: Fix NEWS entries #8501
  • [3.7] bpo-30722: Fix NEWS entries (GH-8501) #8503
  • [3.6] bpo-30722: Fix NEWS entry (GH-8501) #8504
  • 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 = None
    closed_at = <Date 2018-07-27.16:18:23.283>
    created_at = <Date 2017-06-21.08:57:43.914>
    labels = ['type-bug', '3.7']
    title = 'Tools/demo/redemo.py broken'
    updated_at = <Date 2018-07-27.16:18:23.282>
    user = 'https://github.com/csarn'

    bugs.python.org fields:

    activity = <Date 2018-07-27.16:18:23.282>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-07-27.16:18:23.283>
    closer = 'berker.peksag'
    components = ['Demos and Tools']
    creation = <Date 2017-06-21.08:57:43.914>
    creator = 'Christoph Sarnowski2'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30722
    keywords = ['patch']
    message_count = 13.0
    messages = ['296530', '296532', '296533', '296535', '296543', '296547', '304825', '304827', '304828', '309024', '322503', '322504', '322506']
    nosy_count = 6.0
    nosy_names = ['ezio.melotti', 'mrabarnett', 'berker.peksag', 'serhiy.storchaka', 'louielu', 'Christoph Sarnowski2']
    pr_nums = ['2311', '4090', '8501', '8503', '8504']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue30722'
    versions = ['Python 3.6', 'Python 3.7']

    @csarn
    Copy link
    Mannequin Author

    csarn mannequin commented Jun 21, 2017

    In Python 3.6, the flags in the "re" module became members of an enum.IntFlag, whereas before they were just ints.

    This breaks the regex demo in Tools/demo/redemo.py.

    To fix this, in line 86 of redemo.py,

        getattr(re, name)

    has to be replaced by

    getattr(re, name).value
    

    Also, the checkbox for "LOCALE" can be removed (or fixed), as re.LOCALE is invalid for str patterns.

    @csarn csarn mannequin added topic-regex 3.7 (EOL) end of life type-bug An unexpected behavior, bug, or error labels Jun 21, 2017
    @mlouielu
    Copy link
    Mannequin

    mlouielu mannequin commented Jun 21, 2017

    Hi Christoph, chould you provide a small example that breaks the regex demo? thanks!

    @mlouielu
    Copy link
    Mannequin

    mlouielu mannequin commented Jun 21, 2017

    Also, would you like to contribute with PR on GitHub?

    @csarn
    Copy link
    Mannequin Author

    csarn mannequin commented Jun 21, 2017

    Hi, sorry for forgetting steps to reproduce the bug.

    Easiest way to see it is to start redemo.py from a console (important on windows), so you can see stdout/stderr.
    Then just a click on any of those flag checkboxes leads to an exception backtrace printed on the console.

    And to demonstrate that the flag checkbox does not work, enter ".*" (without quotes) as the pattern, and any multiline string as the string to search, and activate the checkbox "MULTILINE".
    Correct behaviour: no exception, all lines of the string get highlighted as the first match
    Erroneous (actual) behaviour: An exception traceback gets printed: '_tkinter.TclError: expected integer but got "RegexFlag.MULTILINE"'
    and only the first line is highlighted as first match, demonstrating that the MULTILINE flag is in fact not active.

    When it comes to a pull request, I could do that for the change that I proposed. But regarding the "LOCALE" flag, the better solution (in my opinion) would be to make it work instead of just removing it, but that is a more elaborate change that I am not able to spend time on.

    What would you suggest?
    a) I provide a pull request, leaving "LOCALE" flag behaviour broken
    b) I provide a pull request, removing "LOCALE" flag (to be introduced again when someone is willing to fix it)

    @serhiy-storchaka
    Copy link
    Member

    I think ideally it would be nice to provide a switch between Unicode and bytes and disable the LOCALE flag in the Unicode mode. But this is too complex task. I think it is better to remove LOCALE.

    @csarn
    Copy link
    Mannequin Author

    csarn mannequin commented Jun 21, 2017

    By the way, I confused the flags, in my error-reproduction steps, instead of the re.MULTILINE flag, it is the re.DOTALL flag that should lead to all lines being matched by ".*".

    @berkerpeksag
    Copy link
    Member

    New changeset 62adc55 by Berker Peksag (Christoph Sarnowski) in branch 'master':
    bpo-30722: Make redemo work with Python 3.6+ (GH-2311)
    62adc55

    @berkerpeksag
    Copy link
    Member

    New changeset a5f9d24 by Berker Peksag (Miss Islington (bot)) in branch '3.6':
    bpo-30722: Make redemo work with Python 3.6+ (GH-2311)
    a5f9d24

    @berkerpeksag
    Copy link
    Member

    Thank you, Christoph. I wasn't aware of Tools/demo/redemo.py and I must say it was fun to play with while reviewing PR 2311.

    @serhiy-storchaka
    Copy link
    Member

    The news message is verbose but looks misleading to me. There is nothing invalid with usages like getattr(re, 'DOTALL'). It is the same as re.DOTALL, and using enums haven't changed this.

    @berkerpeksag
    Copy link
    Member

    New changeset 612dbef by Berker Peksag in branch 'master':
    bpo-30722: Fix NEWS entries (GH-8501)
    612dbef

    @berkerpeksag
    Copy link
    Member

    New changeset 7cbde0e by Berker Peksag (Miss Islington (bot)) in branch '3.7':
    bpo-30722: Fix NEWS entries (GH-8501)
    7cbde0e

    @berkerpeksag
    Copy link
    Member

    New changeset 9d85856 by Berker Peksag in branch '3.6':
    bpo-30722: Fix NEWS entry (GH-8501)
    9d85856

    @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 (EOL) end of life type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants