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: re.compile of non-string misleading
Type: Stage:
Components: Regular Expressions Versions:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: effbot Nosy List: bescoto, effbot
Priority: normal Keywords:

Created on 2001-07-15 07:30 by bescoto, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Messages (2)
msg5410 - (view) Author: Ben Escoto (bescoto) Date: 2001-07-15 07:30
re.compile(foo) returns foo, instead of raising an
error or returning a regular expression object, if foo
isn't a string.  For instance:

>>> import re
>>> re.compile(5)
5
Instead, it seems an exception should be raised.  This
is especially confusing when foo is a UserString or
another class that subclasses it.
msg5411 - (view) Author: Fredrik Lundh (effbot) * (Python committer) Date: 2001-10-18 19:08
Logged In: YES 
user_id=38376

you're supposed to be allowed to pass compiled patterns
as the pattern.  in 2.2b1 and later, the test has been
changed to look for patterns instead of non-strings.

thanks /F
History
Date User Action Args
2022-04-10 16:04:12adminsetgithub: 34756
2001-07-15 07:30:54bescotocreate