Issue 14250: for string patterns regex.flags is never equal to 0 (original) (raw)

Created on 2012-03-11 00:46 by py.user, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
regexflags.patch georg.brandl,2012-03-14 06:58 review
Messages (10)
msg155362 - (view) Author: py.user (py.user) * Date: 2012-03-11 00:46
http://docs.python.org/py3k/library/re.html#re.regex.flags "or 0 if no flags were provided" >>> import re >>> p = re.compile(r'', 0) >>> p.flags 32 >>>
msg155363 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-03-11 02:01
32 is re.U, which is always ored with the passed in flags, unless re.A is set in the passed in flags. The flag docs should certinaly be updated to reflect this.
msg155558 - (view) Author: py.user (py.user) * Date: 2012-03-13 02:17
>>> import re >>> p = re.compile(br'') >>> p.flags 0 >>>
msg155559 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-03-13 02:20
Heh. Good point. Documenting this is a clear way may be non-trivial.
msg155561 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2012-03-13 02:55
Issue #13358 may be related
msg155562 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-03-13 03:03
It doesn't look like it. Is that the right issue number?
msg155564 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2012-03-13 03:18
Oh, sorry I meant http://bugs.python.org/issue13385
msg155727 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2012-03-14 06:58
There is even more wrongness here: if you give flags inline in the pattern, they also show up in .flags (since they are global, at least in the current implementation). Suggested patch attached.
msg156172 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-03-17 16:29
New changeset b3b3a4a7d7b2 by Georg Brandl in branch '3.2': Closes #14250: regex.flags has not only explicit flags but also implicit flags and those from the pattern http://hg.python.org/cpython/rev/b3b3a4a7d7b2
msg156173 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-03-17 16:31
New changeset ac00531a63aa by Georg Brandl in branch '2.7': Closes #14250: regex.flags has not only explicit flags but also those from the pattern http://hg.python.org/cpython/rev/ac00531a63aa
History
Date User Action Args
2022-04-11 14:57:27 admin set github: 58458
2012-03-17 16:31:32 python-dev set messages: +
2012-03-17 16:29:44 python-dev set status: open -> closednosy: + python-devmessages: + resolution: fixedstage: patch review -> resolved
2012-03-17 04:39:18 eli.bendersky set nosy: - eli.bendersky
2012-03-16 19:03:57 terry.reedy set stage: needs patch -> patch review
2012-03-14 06:58:19 georg.brandl set files: + regexflags.patchnosy: + georg.brandlmessages: + keywords: + patch
2012-03-13 03🔞41 eli.bendersky set messages: +
2012-03-13 03:03:20 r.david.murray set messages: +
2012-03-13 02:55:44 eli.bendersky set nosy: + eli.benderskymessages: +
2012-03-13 02:20:36 r.david.murray set messages: +
2012-03-13 02:17:01 py.user set messages: + title: regex.flags is never equal to 0 -> for string patterns regex.flags is never equal to 0
2012-03-12 00:32:26 benjamin.peterson set keywords: + easy
2012-03-11 10:21:09 eric.araujo set nosy: + eric.araujo
2012-03-11 02:01:12 r.david.murray set versions: + Python 3.3nosy: + r.david.murraymessages: + stage: needs patch
2012-03-11 00:46:31 py.user create