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 arigo
Recipients
Date 2005-11-25.21:38:57
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=4771

The patch looks good, but I wonder if it is safe.  The SRE_STATE structure that SRE_SEARCH_INNER uses is potentially visible to the application-level Python code, via the (undocumented) scanner objects:

>>> r = re.compile(r"hello")
>>> s = r.scanner("big string in which to search")
>>> s.search()
<_sre.SRE_Match object at 0x12345678>

Each call to s.search() continues the previous search with the same SRE_STATE.  The problem with releasing the GIL as you do is that several threads could call s.search() concurrently, which would most probably crash CPython.

This probably means that you need to add a lock in SRE_STATE and acquire it while searching, to serialize its usage.  Of course, we should then be careful about what overhead this gives to applications that use regexps on a lot of small strings...

Another note: for consistency, match() should also release the GIL if search() does.
History
Date User Action Args
2007-08-23 15:44:46adminlinkissue1366311 messages
2007-08-23 15:44:46admincreate