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 vstinner
Recipients serhiy.storchaka, vstinner
Date 2017-04-14.12:36:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1492173364.71.0.473594285494.issue30072@psf.upfronthosting.co.za>
In-reply-to
Content
The re API seems commonly misused. Example passing a re flag to re.sub():

>>> re.sub("A", "B", "ahah", re.I)
'ahah'

No error, no warning, but it doesn't work. Oh, sub has 5 paramters, no 4...

I suggest to convert count and flags to keyword-only parameters. To not break the world, especially legit code passing the count parameter as a position argument, an option is to have a deprecation period if these two parameters are passed a positional-only parameter.

--

Another option would be to rely on the fact that re flags are now enums instead of raw integers, and so add basic type check...

Is there are risk of applications using re flags serialized by pickle from Pyhon < 3.6 and so getting integers?

Maybe the check should only be done if flags are passing as positional-only argument... but the implementation of such check seems may be overkill for such simple and performance-critical function, no?

See issue #30067 for a recent bug in the Python stdlib!
History
Date User Action Args
2017-04-14 12:36:04vstinnersetrecipients: + vstinner, serhiy.storchaka
2017-04-14 12:36:04vstinnersetmessageid: <1492173364.71.0.473594285494.issue30072@psf.upfronthosting.co.za>
2017-04-14 12:36:04vstinnerlinkissue30072 messages
2017-04-14 12:36:03vstinnercreate