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.

Author bcorfman
Recipients bcorfman
Date 2007-12-19.15:40:02
SpamBayes Score 0.02431837
Marked as misclassified No
Message-id <1198078803.93.0.586517631888.issue1661@psf.upfronthosting.co.za>
In-reply-to
Content
Python's documentation for the re.match function is match(pattern,
string, [flags]) where pattern can be either a regex string or a
compiled regex object. If it's a compiled regex object, then supplying
an optional flag to re.match (in my case, re.IGNORECASE) doesn't work
and, more to the point, fails silently. I think this should throw an
exception if it's not going to work.

See
http://mysite.verizon.net/bcorfman/2007/12/something-i-hate-about-pythons-re.html
for a discussion.

A possible change (proposed by effbot) is below:
Index: re.py
===================================================================
--- re.py       (revision 52330)
+++ re.py       (working copy)
@@ -224,6 +224,7 @@
         return p
     pattern, flags = key
     if isinstance(pattern, _pattern_type):
+        assert not flags
         return pattern
     if not sre_compile.isstring(pattern):
         raise TypeError, "first argument must be string or compiled
pattern"
History
Date User Action Args
2007-12-19 15:40:04bcorfmansetspambayes_score: 0.0243184 -> 0.02431837
recipients: + bcorfman
2007-12-19 15:40:03bcorfmansetspambayes_score: 0.0243184 -> 0.0243184
messageid: <1198078803.93.0.586517631888.issue1661@psf.upfronthosting.co.za>
2007-12-19 15:40:03bcorfmanlinkissue1661 messages
2007-12-19 15:40:02bcorfmancreate