[issue28905] re.sub appears not to check count optional argument for integerness

2016-12-08 Thread R. David Murray
R. David Murray added the comment: See issue 28082. -- nosy: +r.david.murray resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> re: convert re flags to (much friendlier) IntFlag constants ___ Python tracker

[issue28905] re.sub appears not to check count optional argument for integerness

2016-12-08 Thread Danny Yoo
Danny Yoo added the comment: Alternatively, change the representation of flag values from integers to some class extension that supports the common bitwise operators. As a very rough sketch: >>> class FlagInt(int): ... def __or__(self, other): ... return FlagInt(int(self) | int(oth

[issue28905] re.sub appears not to check count optional argument for integerness

2016-12-08 Thread Danny Yoo
Danny Yoo added the comment: Ugh. I suddenly realize that this is complicated by the fact that flag values are themselves represented as integers, and Python's type system isn't rich enough to label flag values as a distinct type for the purposes. It may be worthwhile to add a warning in the

[issue28905] re.sub appears not to check count optional argument for integerness

2016-12-08 Thread Danny Yoo
New submission from Danny Yoo: This comes from diagnosing a beginner's question on Python-tutor. https://mail.python.org/pipermail/tutor/2016-December/110066.html It appears that re.sub is not checking whether the count argument is integer or not, and silently accepts a nonsensical argument.