mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Merged revisions 59843-59863 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r59844 | raymond.hettinger | 2008-01-07 21:56:05 +0100 (Mon, 07 Jan 2008) | 1 line Use get() instead of pop() for the optimized version of _replace(). ........ r59847 | raymond.hettinger | 2008-01-07 22:33:51 +0100 (Mon, 07 Jan 2008) | 1 line Documentation nits. ........ r59849 | raymond.hettinger | 2008-01-08 03:02:05 +0100 (Tue, 08 Jan 2008) | 1 line Expand comment. ........ r59850 | raymond.hettinger | 2008-01-08 03:24:15 +0100 (Tue, 08 Jan 2008) | 1 line Docs on named tuple's naming conventions and limits of subclassing ........ r59851 | christian.heimes | 2008-01-08 04:40:04 +0100 (Tue, 08 Jan 2008) | 1 line It's verbose, not debug ........ r59852 | facundo.batista | 2008-01-08 13:25:20 +0100 (Tue, 08 Jan 2008) | 4 lines Issue #1757: The hash of a Decimal instance is no longer affected by the current context. Thanks Mark Dickinson. ........ r59853 | andrew.kuchling | 2008-01-08 15:30:55 +0100 (Tue, 08 Jan 2008) | 1 line Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects ........ r59854 | andrew.kuchling | 2008-01-08 15:56:02 +0100 (Tue, 08 Jan 2008) | 1 line Patch 1114: fix compilation of curses module on 64-bit AIX, and any other LP64 platforms where attr_t isn't a C long ........ r59856 | thomas.heller | 2008-01-08 16:15:09 +0100 (Tue, 08 Jan 2008) | 5 lines Use relative instead of absolute filenames in the C-level tracebacks. This prevents traceback prints pointing to files in this way: File "\loewis\25\python\Modules\_ctypes\callbacks.c", line 206, in 'calling callback function' ........ r59857 | christian.heimes | 2008-01-08 16:46:10 +0100 (Tue, 08 Jan 2008) | 2 lines Added __enter__ and __exit__ functions to HKEY object Added ExpandEnvironmentStrings to the _winreg module. ........ r59858 | georg.brandl | 2008-01-08 17:18:26 +0100 (Tue, 08 Jan 2008) | 2 lines Fix markup errors from r59857 and clarify key.__enter__/__exit__ docs ........ r59860 | georg.brandl | 2008-01-08 20:42:30 +0100 (Tue, 08 Jan 2008) | 2 lines Better method for associating .py files with the interpreter. ........ r59862 | facundo.batista | 2008-01-08 22:10:12 +0100 (Tue, 08 Jan 2008) | 9 lines Issue 846388. Adds a call to PyErr_CheckSignals to SRE_MATCH so that signal handlers can be invoked during long regular expression matches. It also adds a new error return value indicating that an exception occurred in a signal handler during the match, allowing exceptions in the signal handler to propagate up to the main loop. Thanks Josh Hoyt and Ralf Schmitt. ........
This commit is contained in:
parent
790c823201
commit
2380ac740e
18 changed files with 436 additions and 72 deletions
|
@ -197,7 +197,7 @@ static void _CallPythonObject(void *mem,
|
|||
}
|
||||
|
||||
#define CHECK(what, x) \
|
||||
if (x == NULL) _AddTraceback(what, __FILE__, __LINE__ - 1), PyErr_Print()
|
||||
if (x == NULL) _AddTraceback(what, "_ctypes/callbacks.c", __LINE__ - 1), PyErr_Print()
|
||||
|
||||
result = PyObject_CallObject(callable, arglist);
|
||||
CHECK("'calling callback function'", result);
|
||||
|
|
|
@ -755,7 +755,7 @@ static PyObject *GetResult(PyObject *restype, void *result, PyObject *checker)
|
|||
|
||||
v = PyObject_CallFunctionObjArgs(checker, retval, NULL);
|
||||
if (v == NULL)
|
||||
_AddTraceback("GetResult", __FILE__, __LINE__-2);
|
||||
_AddTraceback("GetResult", "_ctypes/callproc.c", __LINE__-2);
|
||||
Py_DECREF(retval);
|
||||
return v;
|
||||
}
|
||||
|
|
|
@ -322,9 +322,6 @@ Window_NoArg2TupleReturnFunction(getbegyx, int, "ii")
|
|||
Window_NoArg2TupleReturnFunction(getmaxyx, int, "ii")
|
||||
Window_NoArg2TupleReturnFunction(getparyx, int, "ii")
|
||||
|
||||
Window_OneArgNoReturnFunction(wattron, attr_t, "l;attr")
|
||||
Window_OneArgNoReturnFunction(wattroff, attr_t, "l;attr")
|
||||
Window_OneArgNoReturnFunction(wattrset, attr_t, "l;attr")
|
||||
Window_OneArgNoReturnFunction(clearok, int, "i;True(1) or False(0)")
|
||||
Window_OneArgNoReturnFunction(idlok, int, "i;True(1) or False(0)")
|
||||
#if defined(__NetBSD__)
|
||||
|
@ -379,6 +376,7 @@ PyCursesWindow_AddCh(PyCursesWindowObject *self, PyObject *args)
|
|||
PyObject *temp;
|
||||
chtype ch = 0;
|
||||
attr_t attr = A_NORMAL;
|
||||
long lattr;
|
||||
|
||||
switch (PyTuple_Size(args)) {
|
||||
case 1:
|
||||
|
@ -386,8 +384,9 @@ PyCursesWindow_AddCh(PyCursesWindowObject *self, PyObject *args)
|
|||
return NULL;
|
||||
break;
|
||||
case 2:
|
||||
if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &attr))
|
||||
if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
break;
|
||||
case 3:
|
||||
if (!PyArg_ParseTuple(args,"iiO;y,x,ch or int", &y, &x, &temp))
|
||||
|
@ -396,8 +395,9 @@ PyCursesWindow_AddCh(PyCursesWindowObject *self, PyObject *args)
|
|||
break;
|
||||
case 4:
|
||||
if (!PyArg_ParseTuple(args,"iiOl;y,x,ch or int, attr",
|
||||
&y, &x, &temp, &attr))
|
||||
&y, &x, &temp, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
use_xy = TRUE;
|
||||
break;
|
||||
default:
|
||||
|
@ -425,6 +425,7 @@ PyCursesWindow_AddStr(PyCursesWindowObject *self, PyObject *args)
|
|||
int x, y;
|
||||
char *str;
|
||||
attr_t attr = A_NORMAL , attr_old = A_NORMAL;
|
||||
long lattr;
|
||||
int use_xy = FALSE, use_attr = FALSE;
|
||||
|
||||
switch (PyTuple_Size(args)) {
|
||||
|
@ -433,8 +434,9 @@ PyCursesWindow_AddStr(PyCursesWindowObject *self, PyObject *args)
|
|||
return NULL;
|
||||
break;
|
||||
case 2:
|
||||
if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &attr))
|
||||
if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
use_attr = TRUE;
|
||||
break;
|
||||
case 3:
|
||||
|
@ -443,8 +445,9 @@ PyCursesWindow_AddStr(PyCursesWindowObject *self, PyObject *args)
|
|||
use_xy = TRUE;
|
||||
break;
|
||||
case 4:
|
||||
if (!PyArg_ParseTuple(args,"iisl;int,int,str,attr", &y, &x, &str, &attr))
|
||||
if (!PyArg_ParseTuple(args,"iisl;int,int,str,attr", &y, &x, &str, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
use_xy = use_attr = TRUE;
|
||||
break;
|
||||
default:
|
||||
|
@ -471,6 +474,7 @@ PyCursesWindow_AddNStr(PyCursesWindowObject *self, PyObject *args)
|
|||
int rtn, x, y, n;
|
||||
char *str;
|
||||
attr_t attr = A_NORMAL , attr_old = A_NORMAL;
|
||||
long lattr;
|
||||
int use_xy = FALSE, use_attr = FALSE;
|
||||
|
||||
switch (PyTuple_Size(args)) {
|
||||
|
@ -479,8 +483,9 @@ PyCursesWindow_AddNStr(PyCursesWindowObject *self, PyObject *args)
|
|||
return NULL;
|
||||
break;
|
||||
case 3:
|
||||
if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &attr))
|
||||
if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
use_attr = TRUE;
|
||||
break;
|
||||
case 4:
|
||||
|
@ -489,8 +494,9 @@ PyCursesWindow_AddNStr(PyCursesWindowObject *self, PyObject *args)
|
|||
use_xy = TRUE;
|
||||
break;
|
||||
case 5:
|
||||
if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &attr))
|
||||
if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
use_xy = use_attr = TRUE;
|
||||
break;
|
||||
default:
|
||||
|
@ -517,6 +523,7 @@ PyCursesWindow_Bkgd(PyCursesWindowObject *self, PyObject *args)
|
|||
PyObject *temp;
|
||||
chtype bkgd;
|
||||
attr_t attr = A_NORMAL;
|
||||
long lattr;
|
||||
|
||||
switch (PyTuple_Size(args)) {
|
||||
case 1:
|
||||
|
@ -524,8 +531,9 @@ PyCursesWindow_Bkgd(PyCursesWindowObject *self, PyObject *args)
|
|||
return NULL;
|
||||
break;
|
||||
case 2:
|
||||
if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &attr))
|
||||
if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError, "bkgd requires 1 or 2 arguments");
|
||||
|
@ -540,12 +548,40 @@ PyCursesWindow_Bkgd(PyCursesWindowObject *self, PyObject *args)
|
|||
return PyCursesCheckERR(wbkgd(self->win, bkgd | attr), "bkgd");
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
PyCursesWindow_AttrOff(PyCursesWindowObject *self, PyObject *args)
|
||||
{
|
||||
long lattr;
|
||||
if (!PyArg_ParseTuple(args,"l;attr", &lattr))
|
||||
return NULL;
|
||||
return PyCursesCheckERR(wattroff(self->win, (attr_t)lattr), "attroff");
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
PyCursesWindow_AttrOn(PyCursesWindowObject *self, PyObject *args)
|
||||
{
|
||||
long lattr;
|
||||
if (!PyArg_ParseTuple(args,"l;attr", &lattr))
|
||||
return NULL;
|
||||
return PyCursesCheckERR(wattron(self->win, (attr_t)lattr), "attron");
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
PyCursesWindow_AttrSet(PyCursesWindowObject *self, PyObject *args)
|
||||
{
|
||||
long lattr;
|
||||
if (!PyArg_ParseTuple(args,"l;attr", &lattr))
|
||||
return NULL;
|
||||
return PyCursesCheckERR(wattrset(self->win, (attr_t)lattr), "attrset");
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
PyCursesWindow_BkgdSet(PyCursesWindowObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *temp;
|
||||
chtype bkgd;
|
||||
attr_t attr = A_NORMAL;
|
||||
long lattr;
|
||||
|
||||
switch (PyTuple_Size(args)) {
|
||||
case 1:
|
||||
|
@ -553,8 +589,9 @@ PyCursesWindow_BkgdSet(PyCursesWindowObject *self, PyObject *args)
|
|||
return NULL;
|
||||
break;
|
||||
case 2:
|
||||
if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &attr))
|
||||
if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError, "bkgdset requires 1 or 2 arguments");
|
||||
|
@ -742,6 +779,7 @@ PyCursesWindow_EchoChar(PyCursesWindowObject *self, PyObject *args)
|
|||
PyObject *temp;
|
||||
chtype ch;
|
||||
attr_t attr = A_NORMAL;
|
||||
long lattr;
|
||||
|
||||
switch (PyTuple_Size(args)) {
|
||||
case 1:
|
||||
|
@ -749,8 +787,9 @@ PyCursesWindow_EchoChar(PyCursesWindowObject *self, PyObject *args)
|
|||
return NULL;
|
||||
break;
|
||||
case 2:
|
||||
if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &attr))
|
||||
if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError, "echochar requires 1 or 2 arguments");
|
||||
|
@ -916,6 +955,7 @@ PyCursesWindow_Hline(PyCursesWindowObject *self, PyObject *args)
|
|||
chtype ch;
|
||||
int n, x, y, code = OK;
|
||||
attr_t attr = A_NORMAL;
|
||||
long lattr;
|
||||
|
||||
switch (PyTuple_Size(args)) {
|
||||
case 2:
|
||||
|
@ -923,8 +963,9 @@ PyCursesWindow_Hline(PyCursesWindowObject *self, PyObject *args)
|
|||
return NULL;
|
||||
break;
|
||||
case 3:
|
||||
if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &attr))
|
||||
if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
break;
|
||||
case 4:
|
||||
if (!PyArg_ParseTuple(args, "iiOi;y,x,ch or int,n", &y, &x, &temp, &n))
|
||||
|
@ -933,8 +974,9 @@ PyCursesWindow_Hline(PyCursesWindowObject *self, PyObject *args)
|
|||
break;
|
||||
case 5:
|
||||
if (!PyArg_ParseTuple(args, "iiOil; y,x,ch or int,n,attr",
|
||||
&y, &x, &temp, &n, &attr))
|
||||
&y, &x, &temp, &n, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
code = wmove(self->win, y, x);
|
||||
break;
|
||||
default:
|
||||
|
@ -960,6 +1002,7 @@ PyCursesWindow_InsCh(PyCursesWindowObject *self, PyObject *args)
|
|||
PyObject *temp;
|
||||
chtype ch = 0;
|
||||
attr_t attr = A_NORMAL;
|
||||
long lattr;
|
||||
|
||||
switch (PyTuple_Size(args)) {
|
||||
case 1:
|
||||
|
@ -967,8 +1010,9 @@ PyCursesWindow_InsCh(PyCursesWindowObject *self, PyObject *args)
|
|||
return NULL;
|
||||
break;
|
||||
case 2:
|
||||
if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &attr))
|
||||
if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
break;
|
||||
case 3:
|
||||
if (!PyArg_ParseTuple(args,"iiO;y,x,ch or int", &y, &x, &temp))
|
||||
|
@ -976,8 +1020,9 @@ PyCursesWindow_InsCh(PyCursesWindowObject *self, PyObject *args)
|
|||
use_xy = TRUE;
|
||||
break;
|
||||
case 4:
|
||||
if (!PyArg_ParseTuple(args,"iiOl;y,x,ch or int, attr", &y, &x, &temp, &attr))
|
||||
if (!PyArg_ParseTuple(args,"iiOl;y,x,ch or int, attr", &y, &x, &temp, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
use_xy = TRUE;
|
||||
break;
|
||||
default:
|
||||
|
@ -1062,6 +1107,7 @@ PyCursesWindow_InsStr(PyCursesWindowObject *self, PyObject *args)
|
|||
int x, y;
|
||||
char *str;
|
||||
attr_t attr = A_NORMAL , attr_old = A_NORMAL;
|
||||
long lattr;
|
||||
int use_xy = FALSE, use_attr = FALSE;
|
||||
|
||||
switch (PyTuple_Size(args)) {
|
||||
|
@ -1070,8 +1116,9 @@ PyCursesWindow_InsStr(PyCursesWindowObject *self, PyObject *args)
|
|||
return NULL;
|
||||
break;
|
||||
case 2:
|
||||
if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &attr))
|
||||
if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
use_attr = TRUE;
|
||||
break;
|
||||
case 3:
|
||||
|
@ -1080,8 +1127,9 @@ PyCursesWindow_InsStr(PyCursesWindowObject *self, PyObject *args)
|
|||
use_xy = TRUE;
|
||||
break;
|
||||
case 4:
|
||||
if (!PyArg_ParseTuple(args,"iisl;y,x,str,attr", &y, &x, &str, &attr))
|
||||
if (!PyArg_ParseTuple(args,"iisl;y,x,str,attr", &y, &x, &str, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
use_xy = use_attr = TRUE;
|
||||
break;
|
||||
default:
|
||||
|
@ -1108,6 +1156,7 @@ PyCursesWindow_InsNStr(PyCursesWindowObject *self, PyObject *args)
|
|||
int rtn, x, y, n;
|
||||
char *str;
|
||||
attr_t attr = A_NORMAL , attr_old = A_NORMAL;
|
||||
long lattr;
|
||||
int use_xy = FALSE, use_attr = FALSE;
|
||||
|
||||
switch (PyTuple_Size(args)) {
|
||||
|
@ -1116,8 +1165,9 @@ PyCursesWindow_InsNStr(PyCursesWindowObject *self, PyObject *args)
|
|||
return NULL;
|
||||
break;
|
||||
case 3:
|
||||
if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &attr))
|
||||
if (!PyArg_ParseTuple(args,"sil;str,n,attr", &str, &n, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
use_attr = TRUE;
|
||||
break;
|
||||
case 4:
|
||||
|
@ -1126,8 +1176,9 @@ PyCursesWindow_InsNStr(PyCursesWindowObject *self, PyObject *args)
|
|||
use_xy = TRUE;
|
||||
break;
|
||||
case 5:
|
||||
if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &attr))
|
||||
if (!PyArg_ParseTuple(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
use_xy = use_attr = TRUE;
|
||||
break;
|
||||
default:
|
||||
|
@ -1470,6 +1521,7 @@ PyCursesWindow_Vline(PyCursesWindowObject *self, PyObject *args)
|
|||
chtype ch;
|
||||
int n, x, y, code = OK;
|
||||
attr_t attr = A_NORMAL;
|
||||
long lattr;
|
||||
|
||||
switch (PyTuple_Size(args)) {
|
||||
case 2:
|
||||
|
@ -1477,8 +1529,9 @@ PyCursesWindow_Vline(PyCursesWindowObject *self, PyObject *args)
|
|||
return NULL;
|
||||
break;
|
||||
case 3:
|
||||
if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &attr))
|
||||
if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
break;
|
||||
case 4:
|
||||
if (!PyArg_ParseTuple(args, "iiOi;y,x,ch or int,n", &y, &x, &temp, &n))
|
||||
|
@ -1487,8 +1540,9 @@ PyCursesWindow_Vline(PyCursesWindowObject *self, PyObject *args)
|
|||
break;
|
||||
case 5:
|
||||
if (!PyArg_ParseTuple(args, "iiOil; y,x,ch or int,n,attr",
|
||||
&y, &x, &temp, &n, &attr))
|
||||
&y, &x, &temp, &n, &lattr))
|
||||
return NULL;
|
||||
attr = lattr;
|
||||
code = wmove(self->win, y, x);
|
||||
break;
|
||||
default:
|
||||
|
@ -1511,9 +1565,9 @@ static PyMethodDef PyCursesWindow_Methods[] = {
|
|||
{"addch", (PyCFunction)PyCursesWindow_AddCh, METH_VARARGS},
|
||||
{"addnstr", (PyCFunction)PyCursesWindow_AddNStr, METH_VARARGS},
|
||||
{"addstr", (PyCFunction)PyCursesWindow_AddStr, METH_VARARGS},
|
||||
{"attroff", (PyCFunction)PyCursesWindow_wattroff, METH_VARARGS},
|
||||
{"attron", (PyCFunction)PyCursesWindow_wattron, METH_VARARGS},
|
||||
{"attrset", (PyCFunction)PyCursesWindow_wattrset, METH_VARARGS},
|
||||
{"attroff", (PyCFunction)PyCursesWindow_AttrOff, METH_VARARGS},
|
||||
{"attron", (PyCFunction)PyCursesWindow_AttrOn, METH_VARARGS},
|
||||
{"attrset", (PyCFunction)PyCursesWindow_AttrSet, METH_VARARGS},
|
||||
{"bkgd", (PyCFunction)PyCursesWindow_Bkgd, METH_VARARGS},
|
||||
{"chgat", (PyCFunction)PyCursesWindow_ChgAt, METH_VARARGS},
|
||||
{"bkgdset", (PyCFunction)PyCursesWindow_BkgdSet, METH_VARARGS},
|
||||
|
|
|
@ -95,6 +95,7 @@ static char copyright[] =
|
|||
#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
|
||||
|
@ -805,6 +806,7 @@ SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern)
|
|||
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;
|
||||
|
@ -833,6 +835,9 @@ entrance:
|
|||
}
|
||||
|
||||
for (;;) {
|
||||
++sigcount;
|
||||
if ((0 == (sigcount & 0xfff)) && PyErr_CheckSignals())
|
||||
RETURN_ERROR(SRE_ERROR_INTERRUPTED);
|
||||
|
||||
switch (*ctx->pattern++) {
|
||||
|
||||
|
@ -1833,6 +1838,9 @@ pattern_error(int status)
|
|||
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(
|
||||
|
|
|
@ -1524,6 +1524,50 @@ xmlparse_setattr(xmlparseobject *self, char *name, PyObject *v)
|
|||
self->specified_attributes = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strcmp(name, "buffer_size") == 0) {
|
||||
long new_buffer_size;
|
||||
if (!PyLong_Check(v)) {
|
||||
PyErr_SetString(PyExc_TypeError, "buffer_size must be an integer");
|
||||
return -1;
|
||||
}
|
||||
|
||||
new_buffer_size=PyLong_AS_LONG(v);
|
||||
/* trivial case -- no change */
|
||||
if (new_buffer_size == self->buffer_size) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (new_buffer_size <= 0) {
|
||||
PyErr_SetString(PyExc_ValueError, "buffer_size must be greater than zero");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* check maximum */
|
||||
if (new_buffer_size > INT_MAX) {
|
||||
char errmsg[100];
|
||||
sprintf(errmsg, "buffer_size must not be greater than %i", INT_MAX);
|
||||
PyErr_SetString(PyExc_ValueError, errmsg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (self->buffer != NULL) {
|
||||
/* there is already a buffer */
|
||||
if (self->buffer_used != 0) {
|
||||
flush_character_buffer(self);
|
||||
}
|
||||
/* free existing buffer */
|
||||
free(self->buffer);
|
||||
}
|
||||
self->buffer = malloc(new_buffer_size);
|
||||
if (self->buffer == NULL) {
|
||||
PyErr_NoMemory();
|
||||
return -1;
|
||||
}
|
||||
self->buffer_size = new_buffer_size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strcmp(name, "CharacterDataHandler") == 0) {
|
||||
/* If we're changing the character data handler, flush all
|
||||
* cached data with the old handler. Not sure there's a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue