You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Christoph, chould you provide a small example that breaks the regex demo? thanks!
mlouielu commented on Jun 21, 2017
mlouielumannequin
Mannequin
More actions
Also, would you like to contribute with PR on GitHub?
csarn commented on Jun 21, 2017
csarnmannequin
MannequinAuthor
More actions
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)
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 commented on Jun 21, 2017
csarnmannequin
MannequinAuthor
More actions
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 ".*".
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.
A comment on a closed (and somewhat unrelated) issue is unlikely to receive much feedback.
If you want to improve redemo.py, I would suggest creating a new issue and then address the problems with one (or more) PR(s) instead.
Also note that "refactoring" issues -- especially on a demo like redemo.py -- might be rejected, so you might also want to post on https://discuss.python.org/ for feedback before creating issues/PRs.
Activity
csarn commentedon 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,
has to be replaced by
Also, the checkbox for "LOCALE" can be removed (or fixed), as re.LOCALE is invalid for str patterns.
mlouielu commentedon Jun 21, 2017
Hi Christoph, chould you provide a small example that breaks the regex demo? thanks!
mlouielu commentedon Jun 21, 2017
Also, would you like to contribute with PR on GitHub?
csarn commentedon 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 commentedon Jun 21, 2017
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 commentedon 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 commentedon Oct 23, 2017
New changeset 62adc55 by Berker Peksag (Christoph Sarnowski) in branch 'master':
bpo-30722: Make redemo work with Python 3.6+ (GH-2311)
62adc55
berkerpeksag commentedon Oct 23, 2017
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 commentedon Oct 23, 2017
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 commentedon Dec 25, 2017
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 commentedon Jul 27, 2018
New changeset 612dbef by Berker Peksag in branch 'master':
bpo-30722: Fix NEWS entries (GH-8501)
612dbef
berkerpeksag commentedon Jul 27, 2018
New changeset 7cbde0e by Berker Peksag (Miss Islington (bot)) in branch '3.7':
bpo-30722: Fix NEWS entries (GH-8501)
7cbde0e
berkerpeksag commentedon Jul 27, 2018
New changeset 9d85856 by Berker Peksag in branch '3.6':
bpo-30722: Fix NEWS entry (GH-8501)
9d85856
Blastus commentedon May 30, 2025
The program redemo.py just recently received a fairly thorough code review here:
What can be done to ReDemo to bring it up-to-date with modern Python?
ezio-melotti commentedon May 31, 2025
A comment on a closed (and somewhat unrelated) issue is unlikely to receive much feedback.
If you want to improve
redemo.py, I would suggest creating a new issue and then address the problems with one (or more) PR(s) instead.Also note that "refactoring" issues -- especially on a demo like
redemo.py-- might be rejected, so you might also want to post on https://discuss.python.org/ for feedback before creating issues/PRs.