homepage

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 serhiy.storchaka
Recipients The Compiler, effbot, ezio.melotti, mrabarnett, pitrou, serhiy.storchaka
Date 2015年11月04日.15:54:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1446652495.92.0.0678488602676.issue25550@psf.upfronthosting.co.za>
In-reply-to
Content
re.compile can also raise ValueError and OverflowError. Agree that may be these exceptions can be converted to re.error.
But it can also raise MemoryError, and KeyboardInterrupt. And these exceptions can't be converted to re.error.
RecursionError is closer to the latter case. It depends not only on the pattern itself, but on the place where it is called. A pattern that is compiled successfully at top level can produce a RecursionError if it is compiled deeply in the recursion.
>>> import re
>>> def r(n):
... if not n:
... return re.compile('x')
... return r(n-1)
... 
>>> r(990)
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "<stdin>", line 4, in r
 File "<stdin>", line 4, in r
...
 File "<stdin>", line 4, in r
 File "<stdin>", line 3, in r
 File "/home/serhiy/py/cpython/Lib/re.py", line 224, in compile
 return _compile(pattern, flags)
 File "/home/serhiy/py/cpython/Lib/re.py", line 293, in _compile
 p = sre_compile.compile(pattern, flags)
 File "/home/serhiy/py/cpython/Lib/sre_compile.py", line 555, in compile
 p = sre_parse.parse(p, flags)
 File "/home/serhiy/py/cpython/Lib/sre_parse.py", line 822, in parse
 source = Tokenizer(str)
 File "/home/serhiy/py/cpython/Lib/sre_parse.py", line 225, in __init__
 self.__next()
RecursionError: maximum recursion depth exceeded
>>> re.compile('x')
re.compile('x')
History
Date User Action Args
2015年11月04日 15:54:55serhiy.storchakasetrecipients: + serhiy.storchaka, effbot, pitrou, ezio.melotti, mrabarnett, The Compiler
2015年11月04日 15:54:55serhiy.storchakasetmessageid: <1446652495.92.0.0678488602676.issue25550@psf.upfronthosting.co.za>
2015年11月04日 15:54:55serhiy.storchakalinkissue25550 messages
2015年11月04日 15:54:55serhiy.storchakacreate

AltStyle によって変換されたページ (->オリジナル) /