You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's not correct for a repl function to return None, but I encountered some code doing that and the stdlib re silently allows it and regex raises an error. Should it be made consistent? Thanks
$ python
Python 3.7.10 (default, Feb 24 2021, 20:00:24)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import regex, re
>>> def repl(m):
... return None
...
>>> re.sub(r'a', repl, 'abc')
'bc'
>>> regex.sub(r'a', repl, 'abc')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/var/local/env-py37/lib/python3.7/site-packages/regex/regex.py", line 278, in sub
return pat.sub(repl, string, count, pos, endpos, concurrent, timeout)
TypeError: expected str instance, NoneType found
The text was updated successfully, but these errors were encountered:
For compatibility with re, perhaps regex should do the same, even though it could hide a bug.
I'm a little unsure at this point.
Has re's behaviour ever been reported on the Python bug tracker? If re isn't going to change, if it's intentional behaviour, then I might as well copy it.
It's not correct for a repl function to return None, but I encountered some code doing that and the stdlib
re
silently allows it andregex
raises an error. Should it be made consistent? ThanksThe text was updated successfully, but these errors were encountered: