]> granicus.if.org Git - python/commit
_compile(): raise an exception if downcasting to SRE_CODE
authorTim Peters <tim.peters@gmail.com>
Sat, 21 Jan 2006 02:47:53 +0000 (02:47 +0000)
committerTim Peters <tim.peters@gmail.com>
Sat, 21 Jan 2006 02:47:53 +0000 (02:47 +0000)
commit3d5635091069c2fce4896429bca1e063ea223c48
treee5488edaa7579bab97f1dc46ecf24992f639bfed
parent887c080a800215250a9ebdcc589becc0bf6cac0d
_compile():  raise an exception if downcasting to SRE_CODE
loses information:

    OverflowError: regular expression code size limit exceeded

Otherwise the compiled code is gibberish, possibly leading at
least to wrong results or (as reported on c.l.py) internal
sre errors at match time.

I'm not sure how to test this.  SRE_CODE is a 2-byte type on
my box, and it's easy to create a regexp that causes the new
exception to trigger here.  But it may be a 4-byte type on
other boxes, and creating a regexp large enough to trigger
problems there would be pretty crazy.

Bugfix candidate.
Modules/_sre.c