This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Tools/demo/redemo.py broken
Type: behavior Stage: resolved
Components: Demos and Tools Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Christoph Sarnowski2, berker.peksag, ezio.melotti, louielu, mrabarnett, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2017-06-21 08:57 by Christoph Sarnowski2, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 2311 merged python-dev, 2017-06-21 12:50
PR 4090 merged python-dev, 2017-10-23 17:11
PR 8501 merged berker.peksag, 2018-07-27 13:06
PR 8503 merged miss-islington, 2018-07-27 15:50
PR 8504 merged berker.peksag, 2018-07-27 15:59
Messages (13)
msg296530 - (view) Author: Christoph Sarnowski (Christoph Sarnowski2) * Date: 2017-06-21 08:57
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.
msg296532 - (view) Author: Louie Lu (louielu) * Date: 2017-06-21 09:21
Hi Christoph, chould you provide a small example that breaks the regex demo? thanks!
msg296533 - (view) Author: Louie Lu (louielu) * Date: 2017-06-21 09:21
Also, would you like to contribute with PR on GitHub?
msg296535 - (view) Author: Christoph Sarnowski (Christoph Sarnowski2) * Date: 2017-06-21 09:31
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)
msg296543 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-06-21 10:59
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.
msg296547 - (view) Author: Christoph Sarnowski (Christoph Sarnowski2) * Date: 2017-06-21 11:54
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 ".*".
msg304825 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-10-23 17:10
New changeset 62adc55aff0b78447568f73bd1abc610d2784bf8 by Berker Peksag (Christoph Sarnowski) in branch 'master':
bpo-30722: Make redemo work with Python 3.6+ (GH-2311)
https://github.com/python/cpython/commit/62adc55aff0b78447568f73bd1abc610d2784bf8
msg304827 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-10-23 17:40
New changeset a5f9d24c171c7e3a3715161fd16b747c7dcaf76f by Berker Peksag (Miss Islington (bot)) in branch '3.6':
bpo-30722: Make redemo work with Python 3.6+ (GH-2311)
https://github.com/python/cpython/commit/a5f9d24c171c7e3a3715161fd16b747c7dcaf76f
msg304828 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-10-23 17:42
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.
msg309024 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-12-25 01:41
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.
msg322503 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-07-27 15:50
New changeset 612dbefe9dfce0f67bce358613e472e913be8a57 by Berker Peksag in branch 'master':
bpo-30722: Fix NEWS entries (GH-8501)
https://github.com/python/cpython/commit/612dbefe9dfce0f67bce358613e472e913be8a57
msg322504 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-07-27 16:17
New changeset 7cbde0e09daba4259565738e48f141851287fe29 by Berker Peksag (Miss Islington (bot)) in branch '3.7':
bpo-30722: Fix NEWS entries (GH-8501)
https://github.com/python/cpython/commit/7cbde0e09daba4259565738e48f141851287fe29
msg322506 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-07-27 16:17
New changeset 9d85856044a2c7d681ea38b5ff99af375b228a0f by Berker Peksag in branch '3.6':
bpo-30722: Fix NEWS entry (GH-8501)
https://github.com/python/cpython/commit/9d85856044a2c7d681ea38b5ff99af375b228a0f
History
Date User Action Args
2022-04-11 14:58:48adminsetgithub: 74907
2018-07-27 16:18:23berker.peksagsetstatus: open -> closed
stage: patch review -> resolved
2018-07-27 16:17:55berker.peksagsetmessages: + msg322506
2018-07-27 16:17:24berker.peksagsetmessages: + msg322504
2018-07-27 15:59:00berker.peksagsetpull_requests: + pull_request8023
2018-07-27 15:50:14miss-islingtonsetpull_requests: + pull_request8022
2018-07-27 15:50:04berker.peksagsetmessages: + msg322503
2018-07-27 13:06:51berker.peksagsetstage: resolved -> patch review
pull_requests: + pull_request8019
2017-12-25 01:41:35serhiy.storchakasetstatus: closed -> open

messages: + msg309024
2017-10-23 17:42:56berker.peksagsetstatus: open -> closed
messages: + msg304828

components: + Demos and Tools, - Regular Expressions
resolution: fixed
stage: patch review -> resolved
2017-10-23 17:40:38berker.peksagsetmessages: + msg304827
2017-10-23 17:11:59python-devsetkeywords: + patch
stage: patch review
pull_requests: + pull_request4060
2017-10-23 17:10:50berker.peksagsetnosy: + berker.peksag
messages: + msg304825
2017-06-21 12:50:41python-devsetpull_requests: + pull_request2356
2017-06-21 11:54:48Christoph Sarnowski2setmessages: + msg296547
2017-06-21 10:59:10serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg296543
2017-06-21 09:31:55Christoph Sarnowski2setmessages: + msg296535
2017-06-21 09:21:53louielusetmessages: + msg296533
2017-06-21 09:21:30louielusetnosy: + louielu
messages: + msg296532
2017-06-21 08:57:43Christoph Sarnowski2create