[Python-checkins] r60576 - in python/branches/release25-maint: Misc/NEWS Modules/_sre.c
guido.van.rossum
python-checkins at python.org
Mon Feb 4 23:00:36 CET 2008
Author: guido.van.rossum
Date: Mon Feb 4 23:00:35 2008
New Revision: 60576
Modified:
python/branches/release25-maint/Misc/NEWS
python/branches/release25-maint/Modules/_sre.c
Log:
Backport r59862 (issue #712900): make long regexp matches interruptable
by signals.
Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS (original)
+++ python/branches/release25-maint/Misc/NEWS Mon Feb 4 23:00:35 2008
@@ -212,6 +212,8 @@
Extension Modules
-----------------
+- Backport r59862 (issue #712900): make long regexp matches interruptable.
+
- #1940: make it possible to use curses.filter() before curses.initscr()
as the documentation says.
Modified: python/branches/release25-maint/Modules/_sre.c
==============================================================================
--- python/branches/release25-maint/Modules/_sre.c (original)
+++ python/branches/release25-maint/Modules/_sre.c Mon Feb 4 23:00:35 2008
@@ -99,6 +99,7 @@
#define SRE_ERROR_STATE -2 /* illegal state */
#define SRE_ERROR_RECURSION_LIMIT -3 /* runaway recursion */
#define SRE_ERROR_MEMORY -9 /* out of memory */
+#define SRE_ERROR_INTERRUPTED -10 /* signal handler raised exception */
#if defined(VERBOSE)
#define TRACE(v) printf v
@@ -809,6 +810,7 @@
Py_ssize_t alloc_pos, ctx_pos = -1;
Py_ssize_t i, ret = 0;
Py_ssize_t jump;
+ unsigned int sigcount=0;
SRE_MATCH_CONTEXT* ctx;
SRE_MATCH_CONTEXT* nextctx;
@@ -837,6 +839,9 @@
}
for (;;) {
+ ++sigcount;
+ if ((0 == (sigcount & 0xfff)) && PyErr_CheckSignals())
+ RETURN_ERROR(SRE_ERROR_INTERRUPTED);
switch (*ctx->pattern++) {
@@ -1834,6 +1839,9 @@
case SRE_ERROR_MEMORY:
PyErr_NoMemory();
break;
+ case SRE_ERROR_INTERRUPTED:
+ /* An exception has already been raised, so let it fly */
+ break;
default:
/* other error codes indicate compiler/engine bugs */
PyErr_SetString(
More information about the Python-checkins
mailing list