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 eric.araujo, eric.smith, ezio.melotti, mindauga, mmilkin, mrabarnett, python-dev, rhettinger, serhiy.storchaka, terry.reedy, umi, vstinner
Date 2017-04-14.12:50:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1492174246.86.0.394574699581.issue11957@psf.upfronthosting.co.za>
In-reply-to
Content
My issue #30072 has been marked as a duplicate of this one. Copy of my msg291650:

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:50:47vstinnersetrecipients: + vstinner, rhettinger, terry.reedy, eric.smith, ezio.melotti, eric.araujo, mrabarnett, python-dev, mindauga, serhiy.storchaka, mmilkin, umi
2017-04-14 12:50:46vstinnersetmessageid: <1492174246.86.0.394574699581.issue11957@psf.upfronthosting.co.za>
2017-04-14 12:50:46vstinnerlinkissue11957 messages
2017-04-14 12:50:46vstinnercreate