2001-09-19 07:37:50 -03:00
|
|
|
#include "Python.h"
|
2001-03-24 15:58:26 -04:00
|
|
|
#include <ctype.h>
|
|
|
|
|
2001-01-21 06:18:10 -04:00
|
|
|
#include "frameobject.h"
|
2000-09-29 16:23:29 -03:00
|
|
|
#include "expat.h"
|
2001-01-21 06:18:10 -04:00
|
|
|
|
2005-12-13 15:49:55 -04:00
|
|
|
#include "pyexpat.h"
|
|
|
|
|
2003-01-21 07:09:21 -04:00
|
|
|
#define XML_COMBINED_VERSION (10000*XML_MAJOR_VERSION+100*XML_MINOR_VERSION+XML_MICRO_VERSION)
|
|
|
|
|
2002-06-30 03:40:55 -03:00
|
|
|
#ifndef PyDoc_STRVAR
|
2003-01-21 06:58:18 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* fdrake says:
|
|
|
|
* Don't change the PyDoc_STR macro definition to (str), because
|
|
|
|
* '''the parentheses cause compile failures
|
|
|
|
* ("non-constant static initializer" or something like that)
|
|
|
|
* on some platforms (Irix?)'''
|
|
|
|
*/
|
2002-09-02 12:54:06 -03:00
|
|
|
#define PyDoc_STR(str) str
|
2002-07-01 11:02:31 -03:00
|
|
|
#define PyDoc_VAR(name) static char name[]
|
2002-06-30 03:40:55 -03:00
|
|
|
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
|
2001-01-21 06:18:10 -04:00
|
|
|
#endif
|
|
|
|
|
2002-06-30 03:40:55 -03:00
|
|
|
#if (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 2)
|
|
|
|
/* In Python 2.0 and 2.1, disabling Unicode was not possible. */
|
2001-08-17 15:39:25 -03:00
|
|
|
#define Py_USING_UNICODE
|
2003-06-27 13:13:17 -03:00
|
|
|
#else
|
|
|
|
#define FIX_TRACE
|
2001-08-17 15:39:25 -03:00
|
|
|
#endif
|
|
|
|
|
2000-07-12 01:49:00 -03:00
|
|
|
enum HandlerTypes {
|
|
|
|
StartElement,
|
|
|
|
EndElement,
|
|
|
|
ProcessingInstruction,
|
|
|
|
CharacterData,
|
|
|
|
UnparsedEntityDecl,
|
|
|
|
NotationDecl,
|
|
|
|
StartNamespaceDecl,
|
|
|
|
EndNamespaceDecl,
|
|
|
|
Comment,
|
|
|
|
StartCdataSection,
|
|
|
|
EndCdataSection,
|
|
|
|
Default,
|
|
|
|
DefaultHandlerExpand,
|
|
|
|
NotStandalone,
|
2001-01-21 06:18:10 -04:00
|
|
|
ExternalEntityRef,
|
|
|
|
StartDoctypeDecl,
|
|
|
|
EndDoctypeDecl,
|
2001-02-08 11:39:08 -04:00
|
|
|
EntityDecl,
|
|
|
|
XmlDecl,
|
|
|
|
ElementDecl,
|
|
|
|
AttlistDecl,
|
2003-01-21 07:09:21 -04:00
|
|
|
#if XML_COMBINED_VERSION >= 19504
|
2003-01-21 06:58:18 -04:00
|
|
|
SkippedEntity,
|
2003-01-21 07:09:21 -04:00
|
|
|
#endif
|
2001-02-08 11:39:08 -04:00
|
|
|
_DummyDecl
|
2000-03-31 11:43:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
static PyObject *ErrorObject;
|
|
|
|
|
|
|
|
/* ----------------------------------------------------- */
|
|
|
|
|
|
|
|
/* Declarations for objects of type xmlparser */
|
|
|
|
|
|
|
|
typedef struct {
|
2000-07-12 01:49:00 -03:00
|
|
|
PyObject_HEAD
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2000-07-12 01:49:00 -03:00
|
|
|
XML_Parser itself;
|
2001-02-08 11:39:08 -04:00
|
|
|
int returns_unicode; /* True if Unicode strings are returned;
|
|
|
|
if false, UTF-8 strings are returned */
|
|
|
|
int ordered_attributes; /* Return attributes as a list. */
|
|
|
|
int specified_attributes; /* Report only specified attributes. */
|
2001-02-14 14:29:45 -04:00
|
|
|
int in_callback; /* Is a callback active? */
|
2003-01-21 06:58:18 -04:00
|
|
|
int ns_prefixes; /* Namespace-triplets mode? */
|
2002-06-28 19:56:48 -03:00
|
|
|
XML_Char *buffer; /* Buffer used when accumulating characters */
|
|
|
|
/* NULL if not enabled */
|
|
|
|
int buffer_size; /* Size of buffer, in XML_Char units */
|
|
|
|
int buffer_used; /* Buffer units in use */
|
2002-06-27 16:40:48 -03:00
|
|
|
PyObject *intern; /* Dictionary to intern strings */
|
2000-07-12 01:49:00 -03:00
|
|
|
PyObject **handlers;
|
2000-03-31 11:43:31 -04:00
|
|
|
} xmlparseobject;
|
|
|
|
|
2002-06-28 19:56:48 -03:00
|
|
|
#define CHARACTER_DATA_BUFFER_SIZE 8192
|
|
|
|
|
2002-07-17 13:30:39 -03:00
|
|
|
static PyTypeObject Xmlparsetype;
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2002-09-24 13:24:54 -03:00
|
|
|
typedef void (*xmlhandlersetter)(XML_Parser self, void *meth);
|
2000-03-31 11:43:31 -04:00
|
|
|
typedef void* xmlhandler;
|
|
|
|
|
2000-06-26 21:33:30 -03:00
|
|
|
struct HandlerInfo {
|
2000-07-12 01:49:00 -03:00
|
|
|
const char *name;
|
|
|
|
xmlhandlersetter setter;
|
|
|
|
xmlhandler handler;
|
2001-01-21 06:18:10 -04:00
|
|
|
PyCodeObject *tb_code;
|
2002-06-28 19:29:01 -03:00
|
|
|
PyObject *nameobj;
|
2000-03-31 11:43:31 -04:00
|
|
|
};
|
|
|
|
|
2002-07-17 13:30:39 -03:00
|
|
|
static struct HandlerInfo handler_info[64];
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2001-02-14 14:29:45 -04:00
|
|
|
/* Set an integer attribute on the error object; return true on success,
|
|
|
|
* false on an exception.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
set_error_attr(PyObject *err, char *name, int value)
|
|
|
|
{
|
|
|
|
PyObject *v = PyInt_FromLong(value);
|
|
|
|
|
2006-03-08 02:36:45 -04:00
|
|
|
if (v == NULL || PyObject_SetAttrString(err, name, v) == -1) {
|
|
|
|
Py_XDECREF(v);
|
2001-02-14 14:29:45 -04:00
|
|
|
return 0;
|
|
|
|
}
|
2004-08-03 08:31:31 -03:00
|
|
|
Py_DECREF(v);
|
2001-02-14 14:29:45 -04:00
|
|
|
return 1;
|
|
|
|
}
|
2001-02-08 11:39:08 -04:00
|
|
|
|
2001-02-14 14:29:45 -04:00
|
|
|
/* Build and set an Expat exception, including positioning
|
|
|
|
* information. Always returns NULL.
|
|
|
|
*/
|
2001-02-08 11:39:08 -04:00
|
|
|
static PyObject *
|
2003-01-21 06:58:18 -04:00
|
|
|
set_error(xmlparseobject *self, enum XML_Error code)
|
2001-02-08 11:39:08 -04:00
|
|
|
{
|
|
|
|
PyObject *err;
|
|
|
|
char buffer[256];
|
|
|
|
XML_Parser parser = self->itself;
|
2001-02-14 14:29:45 -04:00
|
|
|
int lineno = XML_GetErrorLineNumber(parser);
|
|
|
|
int column = XML_GetErrorColumnNumber(parser);
|
2001-02-08 11:39:08 -04:00
|
|
|
|
2002-06-30 03:03:35 -03:00
|
|
|
/* There is no risk of overflowing this buffer, since
|
|
|
|
even for 64-bit integers, there is sufficient space. */
|
|
|
|
sprintf(buffer, "%.200s: line %i, column %i",
|
2001-02-14 14:29:45 -04:00
|
|
|
XML_ErrorString(code), lineno, column);
|
2001-02-08 11:39:08 -04:00
|
|
|
err = PyObject_CallFunction(ErrorObject, "s", buffer);
|
2001-02-14 14:29:45 -04:00
|
|
|
if ( err != NULL
|
|
|
|
&& set_error_attr(err, "code", code)
|
|
|
|
&& set_error_attr(err, "offset", column)
|
|
|
|
&& set_error_attr(err, "lineno", lineno)) {
|
|
|
|
PyErr_SetObject(ErrorObject, err);
|
2001-02-08 11:39:08 -04:00
|
|
|
}
|
2006-03-08 02:36:45 -04:00
|
|
|
Py_XDECREF(err);
|
2001-02-08 11:39:08 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2002-06-28 19:29:01 -03:00
|
|
|
static int
|
|
|
|
have_handler(xmlparseobject *self, int type)
|
|
|
|
{
|
|
|
|
PyObject *handler = self->handlers[type];
|
|
|
|
return handler != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
get_handler_name(struct HandlerInfo *hinfo)
|
|
|
|
{
|
|
|
|
PyObject *name = hinfo->nameobj;
|
|
|
|
if (name == NULL) {
|
|
|
|
name = PyString_FromString(hinfo->name);
|
|
|
|
hinfo->nameobj = name;
|
|
|
|
}
|
|
|
|
Py_XINCREF(name);
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2001-02-08 11:39:08 -04:00
|
|
|
|
2001-08-17 15:39:25 -03:00
|
|
|
#ifdef Py_USING_UNICODE
|
2000-06-26 21:33:30 -03:00
|
|
|
/* Convert a string of XML_Chars into a Unicode string.
|
|
|
|
Returns None if str is a null pointer. */
|
|
|
|
|
2000-07-12 01:49:00 -03:00
|
|
|
static PyObject *
|
2002-06-27 16:40:48 -03:00
|
|
|
conv_string_to_unicode(const XML_Char *str)
|
2000-07-12 01:49:00 -03:00
|
|
|
{
|
2002-06-28 19:29:01 -03:00
|
|
|
/* XXX currently this code assumes that XML_Char is 8-bit,
|
2000-07-12 01:49:00 -03:00
|
|
|
and hence in UTF-8. */
|
|
|
|
/* UTF-8 from Expat, Unicode desired */
|
|
|
|
if (str == NULL) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
2002-06-28 19:29:01 -03:00
|
|
|
return PyUnicode_DecodeUTF8(str, strlen(str), "strict");
|
2000-06-26 21:33:30 -03:00
|
|
|
}
|
|
|
|
|
2000-07-12 01:49:00 -03:00
|
|
|
static PyObject *
|
|
|
|
conv_string_len_to_unicode(const XML_Char *str, int len)
|
|
|
|
{
|
2002-06-28 19:29:01 -03:00
|
|
|
/* XXX currently this code assumes that XML_Char is 8-bit,
|
2000-07-12 01:49:00 -03:00
|
|
|
and hence in UTF-8. */
|
|
|
|
/* UTF-8 from Expat, Unicode desired */
|
|
|
|
if (str == NULL) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
2000-08-25 15:03:30 -03:00
|
|
|
return PyUnicode_DecodeUTF8((const char *)str, len, "strict");
|
2000-06-26 21:33:30 -03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Convert a string of XML_Chars into an 8-bit Python string.
|
|
|
|
Returns None if str is a null pointer. */
|
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
static PyObject *
|
2002-06-27 16:40:48 -03:00
|
|
|
conv_string_to_utf8(const XML_Char *str)
|
2000-08-25 15:03:30 -03:00
|
|
|
{
|
2002-06-28 19:29:01 -03:00
|
|
|
/* XXX currently this code assumes that XML_Char is 8-bit,
|
2000-08-25 15:03:30 -03:00
|
|
|
and hence in UTF-8. */
|
|
|
|
/* UTF-8 from Expat, UTF-8 desired */
|
|
|
|
if (str == NULL) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
2002-06-27 16:40:48 -03:00
|
|
|
return PyString_FromString(str);
|
2000-06-26 21:33:30 -03:00
|
|
|
}
|
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
static PyObject *
|
2002-06-28 19:29:01 -03:00
|
|
|
conv_string_len_to_utf8(const XML_Char *str, int len)
|
2000-06-26 21:33:30 -03:00
|
|
|
{
|
2002-06-28 19:29:01 -03:00
|
|
|
/* XXX currently this code assumes that XML_Char is 8-bit,
|
2000-08-25 15:03:30 -03:00
|
|
|
and hence in UTF-8. */
|
|
|
|
/* UTF-8 from Expat, UTF-8 desired */
|
|
|
|
if (str == NULL) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
return PyString_FromStringAndSize((const char *)str, len);
|
2000-06-26 21:33:30 -03:00
|
|
|
}
|
|
|
|
|
2000-03-31 11:43:31 -04:00
|
|
|
/* Callback routines */
|
|
|
|
|
2001-10-21 05:53:52 -03:00
|
|
|
static void clear_handlers(xmlparseobject *self, int initial);
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2003-01-21 06:58:18 -04:00
|
|
|
/* This handler is used when an error has been detected, in the hope
|
|
|
|
that actual parsing can be terminated early. This will only help
|
|
|
|
if an external entity reference is encountered. */
|
|
|
|
static int
|
|
|
|
error_external_entity_ref_handler(XML_Parser parser,
|
|
|
|
const XML_Char *context,
|
|
|
|
const XML_Char *base,
|
|
|
|
const XML_Char *systemId,
|
|
|
|
const XML_Char *publicId)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
static void
|
|
|
|
flag_error(xmlparseobject *self)
|
|
|
|
{
|
2001-10-21 05:53:52 -03:00
|
|
|
clear_handlers(self, 0);
|
2003-01-21 06:58:18 -04:00
|
|
|
XML_SetExternalEntityRefHandler(self->itself,
|
|
|
|
error_external_entity_ref_handler);
|
2001-01-21 06:18:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyCodeObject*
|
|
|
|
getcode(enum HandlerTypes slot, char* func_name, int lineno)
|
|
|
|
{
|
2001-02-14 14:29:45 -04:00
|
|
|
PyObject *code = NULL;
|
|
|
|
PyObject *name = NULL;
|
|
|
|
PyObject *nulltuple = NULL;
|
|
|
|
PyObject *filename = NULL;
|
|
|
|
|
|
|
|
if (handler_info[slot].tb_code == NULL) {
|
|
|
|
code = PyString_FromString("");
|
|
|
|
if (code == NULL)
|
|
|
|
goto failed;
|
|
|
|
name = PyString_FromString(func_name);
|
|
|
|
if (name == NULL)
|
|
|
|
goto failed;
|
|
|
|
nulltuple = PyTuple_New(0);
|
|
|
|
if (nulltuple == NULL)
|
|
|
|
goto failed;
|
|
|
|
filename = PyString_FromString(__FILE__);
|
|
|
|
handler_info[slot].tb_code =
|
|
|
|
PyCode_New(0, /* argcount */
|
|
|
|
0, /* nlocals */
|
|
|
|
0, /* stacksize */
|
|
|
|
0, /* flags */
|
|
|
|
code, /* code */
|
|
|
|
nulltuple, /* consts */
|
|
|
|
nulltuple, /* names */
|
|
|
|
nulltuple, /* varnames */
|
2001-02-06 05:34:40 -04:00
|
|
|
#if PYTHON_API_VERSION >= 1010
|
2001-02-14 14:29:45 -04:00
|
|
|
nulltuple, /* freevars */
|
|
|
|
nulltuple, /* cellvars */
|
2001-02-06 05:34:40 -04:00
|
|
|
#endif
|
2001-02-14 14:29:45 -04:00
|
|
|
filename, /* filename */
|
|
|
|
name, /* name */
|
|
|
|
lineno, /* firstlineno */
|
|
|
|
code /* lnotab */
|
|
|
|
);
|
|
|
|
if (handler_info[slot].tb_code == NULL)
|
|
|
|
goto failed;
|
|
|
|
Py_DECREF(code);
|
|
|
|
Py_DECREF(nulltuple);
|
|
|
|
Py_DECREF(filename);
|
|
|
|
Py_DECREF(name);
|
|
|
|
}
|
|
|
|
return handler_info[slot].tb_code;
|
|
|
|
failed:
|
|
|
|
Py_XDECREF(code);
|
|
|
|
Py_XDECREF(name);
|
|
|
|
return NULL;
|
2001-01-21 06:18:10 -04:00
|
|
|
}
|
|
|
|
|
2003-06-27 13:13:17 -03:00
|
|
|
#ifdef FIX_TRACE
|
2002-08-04 05:24:49 -03:00
|
|
|
static int
|
|
|
|
trace_frame(PyThreadState *tstate, PyFrameObject *f, int code, PyObject *val)
|
|
|
|
{
|
|
|
|
int result = 0;
|
|
|
|
if (!tstate->use_tracing || tstate->tracing)
|
|
|
|
return 0;
|
|
|
|
if (tstate->c_profilefunc != NULL) {
|
|
|
|
tstate->tracing++;
|
|
|
|
result = tstate->c_profilefunc(tstate->c_profileobj,
|
|
|
|
f, code , val);
|
|
|
|
tstate->use_tracing = ((tstate->c_tracefunc != NULL)
|
|
|
|
|| (tstate->c_profilefunc != NULL));
|
|
|
|
tstate->tracing--;
|
|
|
|
if (result)
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
if (tstate->c_tracefunc != NULL) {
|
|
|
|
tstate->tracing++;
|
|
|
|
result = tstate->c_tracefunc(tstate->c_traceobj,
|
|
|
|
f, code , val);
|
|
|
|
tstate->use_tracing = ((tstate->c_tracefunc != NULL)
|
|
|
|
|| (tstate->c_profilefunc != NULL));
|
|
|
|
tstate->tracing--;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2003-06-27 13:13:17 -03:00
|
|
|
|
|
|
|
static int
|
|
|
|
trace_frame_exc(PyThreadState *tstate, PyFrameObject *f)
|
|
|
|
{
|
|
|
|
PyObject *type, *value, *traceback, *arg;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (tstate->c_tracefunc == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
PyErr_Fetch(&type, &value, &traceback);
|
|
|
|
if (value == NULL) {
|
|
|
|
value = Py_None;
|
|
|
|
Py_INCREF(value);
|
|
|
|
}
|
2004-10-13 16:50:11 -03:00
|
|
|
#if PY_VERSION_HEX < 0x02040000
|
|
|
|
arg = Py_BuildValue("(OOO)", type, value, traceback);
|
|
|
|
#else
|
2003-10-12 16:09:37 -03:00
|
|
|
arg = PyTuple_Pack(3, type, value, traceback);
|
2004-10-13 16:50:11 -03:00
|
|
|
#endif
|
2003-06-27 13:13:17 -03:00
|
|
|
if (arg == NULL) {
|
|
|
|
PyErr_Restore(type, value, traceback);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
err = trace_frame(tstate, f, PyTrace_EXCEPTION, arg);
|
|
|
|
Py_DECREF(arg);
|
|
|
|
if (err == 0)
|
|
|
|
PyErr_Restore(type, value, traceback);
|
|
|
|
else {
|
|
|
|
Py_XDECREF(type);
|
|
|
|
Py_XDECREF(value);
|
|
|
|
Py_XDECREF(traceback);
|
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
2003-01-21 06:58:18 -04:00
|
|
|
#endif
|
2002-08-04 05:24:49 -03:00
|
|
|
|
2001-01-21 06:18:10 -04:00
|
|
|
static PyObject*
|
2004-08-13 00:12:57 -03:00
|
|
|
call_with_frame(PyCodeObject *c, PyObject* func, PyObject* args,
|
|
|
|
xmlparseobject *self)
|
2001-01-21 06:18:10 -04:00
|
|
|
{
|
2001-02-14 14:29:45 -04:00
|
|
|
PyThreadState *tstate = PyThreadState_GET();
|
|
|
|
PyFrameObject *f;
|
|
|
|
PyObject *res;
|
|
|
|
|
|
|
|
if (c == NULL)
|
|
|
|
return NULL;
|
2002-08-04 05:24:49 -03:00
|
|
|
|
2003-06-27 13:13:17 -03:00
|
|
|
f = PyFrame_New(tstate, c, PyEval_GetGlobals(), NULL);
|
2001-02-14 14:29:45 -04:00
|
|
|
if (f == NULL)
|
|
|
|
return NULL;
|
|
|
|
tstate->frame = f;
|
2003-06-27 13:13:17 -03:00
|
|
|
#ifdef FIX_TRACE
|
|
|
|
if (trace_frame(tstate, f, PyTrace_CALL, Py_None) < 0) {
|
2002-08-04 05:24:49 -03:00
|
|
|
return NULL;
|
|
|
|
}
|
2003-01-21 06:58:18 -04:00
|
|
|
#endif
|
2001-02-14 14:29:45 -04:00
|
|
|
res = PyEval_CallObject(func, args);
|
2003-06-27 13:13:17 -03:00
|
|
|
if (res == NULL) {
|
|
|
|
if (tstate->curexc_traceback == NULL)
|
|
|
|
PyTraceBack_Here(f);
|
2004-08-13 00:12:57 -03:00
|
|
|
XML_StopParser(self->itself, XML_FALSE);
|
2003-06-27 13:13:17 -03:00
|
|
|
#ifdef FIX_TRACE
|
|
|
|
if (trace_frame_exc(tstate, f) < 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2002-08-04 05:24:49 -03:00
|
|
|
else {
|
2003-06-27 13:13:17 -03:00
|
|
|
if (trace_frame(tstate, f, PyTrace_RETURN, res) < 0) {
|
2002-08-04 05:24:49 -03:00
|
|
|
Py_XDECREF(res);
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
}
|
2003-06-27 13:13:17 -03:00
|
|
|
#else
|
|
|
|
}
|
2003-01-21 06:58:18 -04:00
|
|
|
#endif
|
2001-02-14 14:29:45 -04:00
|
|
|
tstate->frame = f->f_back;
|
|
|
|
Py_DECREF(f);
|
|
|
|
return res;
|
2000-03-31 11:43:31 -04:00
|
|
|
}
|
|
|
|
|
2001-08-17 15:39:25 -03:00
|
|
|
#ifndef Py_USING_UNICODE
|
2000-06-26 21:33:30 -03:00
|
|
|
#define STRING_CONV_FUNC conv_string_to_utf8
|
|
|
|
#else
|
2003-01-21 06:58:18 -04:00
|
|
|
/* Python 2.0 and later versions, when built with Unicode support */
|
2000-06-26 21:33:30 -03:00
|
|
|
#define STRING_CONV_FUNC (self->returns_unicode \
|
|
|
|
? conv_string_to_unicode : conv_string_to_utf8)
|
|
|
|
#endif
|
2000-03-31 12:18:11 -04:00
|
|
|
|
2002-06-27 16:40:48 -03:00
|
|
|
static PyObject*
|
|
|
|
string_intern(xmlparseobject *self, const char* str)
|
|
|
|
{
|
|
|
|
PyObject *result = STRING_CONV_FUNC(str);
|
|
|
|
PyObject *value;
|
2005-09-30 01:46:49 -03:00
|
|
|
/* result can be NULL if the unicode conversion failed. */
|
|
|
|
if (!result)
|
|
|
|
return result;
|
2002-06-27 16:40:48 -03:00
|
|
|
if (!self->intern)
|
|
|
|
return result;
|
|
|
|
value = PyDict_GetItem(self->intern, result);
|
|
|
|
if (!value) {
|
|
|
|
if (PyDict_SetItem(self->intern, result, result) == 0)
|
|
|
|
return result;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
Py_INCREF(value);
|
|
|
|
Py_DECREF(result);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2002-06-28 19:56:48 -03:00
|
|
|
/* Return 0 on success, -1 on exception.
|
|
|
|
* flag_error() will be called before return if needed.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
call_character_handler(xmlparseobject *self, const XML_Char *buffer, int len)
|
|
|
|
{
|
|
|
|
PyObject *args;
|
|
|
|
PyObject *temp;
|
|
|
|
|
|
|
|
args = PyTuple_New(1);
|
|
|
|
if (args == NULL)
|
|
|
|
return -1;
|
|
|
|
#ifdef Py_USING_UNICODE
|
|
|
|
temp = (self->returns_unicode
|
|
|
|
? conv_string_len_to_unicode(buffer, len)
|
|
|
|
: conv_string_len_to_utf8(buffer, len));
|
|
|
|
#else
|
|
|
|
temp = conv_string_len_to_utf8(buffer, len);
|
|
|
|
#endif
|
|
|
|
if (temp == NULL) {
|
|
|
|
Py_DECREF(args);
|
|
|
|
flag_error(self);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
PyTuple_SET_ITEM(args, 0, temp);
|
|
|
|
/* temp is now a borrowed reference; consider it unused. */
|
|
|
|
self->in_callback = 1;
|
|
|
|
temp = call_with_frame(getcode(CharacterData, "CharacterData", __LINE__),
|
2004-08-13 00:12:57 -03:00
|
|
|
self->handlers[CharacterData], args, self);
|
2002-06-28 19:56:48 -03:00
|
|
|
/* temp is an owned reference again, or NULL */
|
|
|
|
self->in_callback = 0;
|
|
|
|
Py_DECREF(args);
|
|
|
|
if (temp == NULL) {
|
|
|
|
flag_error(self);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
Py_DECREF(temp);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
flush_character_buffer(xmlparseobject *self)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
if (self->buffer == NULL || self->buffer_used == 0)
|
|
|
|
return 0;
|
|
|
|
rc = call_character_handler(self, self->buffer, self->buffer_used);
|
|
|
|
self->buffer_used = 0;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
my_CharacterDataHandler(void *userData, const XML_Char *data, int len)
|
|
|
|
{
|
|
|
|
xmlparseobject *self = (xmlparseobject *) userData;
|
|
|
|
if (self->buffer == NULL)
|
|
|
|
call_character_handler(self, data, len);
|
|
|
|
else {
|
|
|
|
if ((self->buffer_used + len) > self->buffer_size) {
|
|
|
|
if (flush_character_buffer(self) < 0)
|
|
|
|
return;
|
|
|
|
/* handler might have changed; drop the rest on the floor
|
|
|
|
* if there isn't a handler anymore
|
|
|
|
*/
|
|
|
|
if (!have_handler(self, CharacterData))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (len > self->buffer_size) {
|
|
|
|
call_character_handler(self, data, len);
|
|
|
|
self->buffer_used = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
memcpy(self->buffer + self->buffer_used,
|
|
|
|
data, len * sizeof(XML_Char));
|
|
|
|
self->buffer_used += len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-08 11:39:08 -04:00
|
|
|
static void
|
|
|
|
my_StartElementHandler(void *userData,
|
2002-06-28 19:29:01 -03:00
|
|
|
const XML_Char *name, const XML_Char *atts[])
|
2001-02-08 11:39:08 -04:00
|
|
|
{
|
|
|
|
xmlparseobject *self = (xmlparseobject *)userData;
|
|
|
|
|
2002-06-28 19:29:01 -03:00
|
|
|
if (have_handler(self, StartElement)) {
|
2001-02-08 11:39:08 -04:00
|
|
|
PyObject *container, *rv, *args;
|
|
|
|
int i, max;
|
|
|
|
|
2002-06-28 19:56:48 -03:00
|
|
|
if (flush_character_buffer(self) < 0)
|
|
|
|
return;
|
2001-02-08 11:39:08 -04:00
|
|
|
/* Set max to the number of slots filled in atts[]; max/2 is
|
|
|
|
* the number of attributes we need to process.
|
|
|
|
*/
|
|
|
|
if (self->specified_attributes) {
|
|
|
|
max = XML_GetSpecifiedAttributeCount(self->itself);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
max = 0;
|
|
|
|
while (atts[max] != NULL)
|
|
|
|
max += 2;
|
|
|
|
}
|
|
|
|
/* Build the container. */
|
|
|
|
if (self->ordered_attributes)
|
|
|
|
container = PyList_New(max);
|
|
|
|
else
|
|
|
|
container = PyDict_New();
|
|
|
|
if (container == NULL) {
|
|
|
|
flag_error(self);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (i = 0; i < max; i += 2) {
|
2002-06-27 16:40:48 -03:00
|
|
|
PyObject *n = string_intern(self, (XML_Char *) atts[i]);
|
2001-02-08 11:39:08 -04:00
|
|
|
PyObject *v;
|
|
|
|
if (n == NULL) {
|
|
|
|
flag_error(self);
|
|
|
|
Py_DECREF(container);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
v = STRING_CONV_FUNC((XML_Char *) atts[i+1]);
|
|
|
|
if (v == NULL) {
|
|
|
|
flag_error(self);
|
|
|
|
Py_DECREF(container);
|
|
|
|
Py_DECREF(n);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (self->ordered_attributes) {
|
|
|
|
PyList_SET_ITEM(container, i, n);
|
|
|
|
PyList_SET_ITEM(container, i+1, v);
|
|
|
|
}
|
|
|
|
else if (PyDict_SetItem(container, n, v)) {
|
|
|
|
flag_error(self);
|
|
|
|
Py_DECREF(n);
|
|
|
|
Py_DECREF(v);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Py_DECREF(n);
|
|
|
|
Py_DECREF(v);
|
|
|
|
}
|
|
|
|
}
|
2005-09-30 01:46:49 -03:00
|
|
|
args = string_intern(self, name);
|
|
|
|
if (args != NULL)
|
|
|
|
args = Py_BuildValue("(NN)", args, container);
|
2001-02-08 11:39:08 -04:00
|
|
|
if (args == NULL) {
|
|
|
|
Py_DECREF(container);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Container is now a borrowed reference; ignore it. */
|
2001-02-14 14:29:45 -04:00
|
|
|
self->in_callback = 1;
|
|
|
|
rv = call_with_frame(getcode(StartElement, "StartElement", __LINE__),
|
2004-08-13 00:12:57 -03:00
|
|
|
self->handlers[StartElement], args, self);
|
2001-02-14 14:29:45 -04:00
|
|
|
self->in_callback = 0;
|
|
|
|
Py_DECREF(args);
|
2001-02-08 11:39:08 -04:00
|
|
|
if (rv == NULL) {
|
|
|
|
flag_error(self);
|
|
|
|
return;
|
2001-02-14 14:29:45 -04:00
|
|
|
}
|
2001-02-08 11:39:08 -04:00
|
|
|
Py_DECREF(rv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RC_HANDLER(RC, NAME, PARAMS, INIT, PARAM_FORMAT, CONVERSION, \
|
|
|
|
RETURN, GETUSERDATA) \
|
|
|
|
static RC \
|
|
|
|
my_##NAME##Handler PARAMS {\
|
|
|
|
xmlparseobject *self = GETUSERDATA ; \
|
|
|
|
PyObject *args = NULL; \
|
|
|
|
PyObject *rv = NULL; \
|
|
|
|
INIT \
|
|
|
|
\
|
2002-06-28 19:29:01 -03:00
|
|
|
if (have_handler(self, NAME)) { \
|
2002-06-28 19:56:48 -03:00
|
|
|
if (flush_character_buffer(self) < 0) \
|
|
|
|
return RETURN; \
|
2001-02-08 11:39:08 -04:00
|
|
|
args = Py_BuildValue PARAM_FORMAT ;\
|
2001-11-10 09:57:55 -04:00
|
|
|
if (!args) { flag_error(self); return RETURN;} \
|
2001-02-14 14:29:45 -04:00
|
|
|
self->in_callback = 1; \
|
2001-02-08 11:39:08 -04:00
|
|
|
rv = call_with_frame(getcode(NAME,#NAME,__LINE__), \
|
2004-08-13 00:12:57 -03:00
|
|
|
self->handlers[NAME], args, self); \
|
2001-02-14 14:29:45 -04:00
|
|
|
self->in_callback = 0; \
|
2001-02-08 11:39:08 -04:00
|
|
|
Py_DECREF(args); \
|
|
|
|
if (rv == NULL) { \
|
|
|
|
flag_error(self); \
|
|
|
|
return RETURN; \
|
|
|
|
} \
|
|
|
|
CONVERSION \
|
|
|
|
Py_DECREF(rv); \
|
|
|
|
} \
|
|
|
|
return RETURN; \
|
|
|
|
}
|
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
#define VOID_HANDLER(NAME, PARAMS, PARAM_FORMAT) \
|
|
|
|
RC_HANDLER(void, NAME, PARAMS, ;, PARAM_FORMAT, ;, ;,\
|
|
|
|
(xmlparseobject *)userData)
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
#define INT_HANDLER(NAME, PARAMS, PARAM_FORMAT)\
|
|
|
|
RC_HANDLER(int, NAME, PARAMS, int rc=0;, PARAM_FORMAT, \
|
|
|
|
rc = PyInt_AsLong(rv);, rc, \
|
|
|
|
(xmlparseobject *)userData)
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2002-06-28 19:29:01 -03:00
|
|
|
VOID_HANDLER(EndElement,
|
|
|
|
(void *userData, const XML_Char *name),
|
2002-06-27 16:40:48 -03:00
|
|
|
("(N)", string_intern(self, name)))
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
VOID_HANDLER(ProcessingInstruction,
|
2002-06-28 19:29:01 -03:00
|
|
|
(void *userData,
|
|
|
|
const XML_Char *target,
|
2001-02-08 11:39:08 -04:00
|
|
|
const XML_Char *data),
|
2002-06-27 16:40:48 -03:00
|
|
|
("(NO&)", string_intern(self, target), STRING_CONV_FUNC,data))
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
VOID_HANDLER(UnparsedEntityDecl,
|
2002-06-28 19:29:01 -03:00
|
|
|
(void *userData,
|
2001-02-08 11:39:08 -04:00
|
|
|
const XML_Char *entityName,
|
|
|
|
const XML_Char *base,
|
|
|
|
const XML_Char *systemId,
|
|
|
|
const XML_Char *publicId,
|
|
|
|
const XML_Char *notationName),
|
2002-06-27 16:40:48 -03:00
|
|
|
("(NNNNN)",
|
2002-06-28 19:29:01 -03:00
|
|
|
string_intern(self, entityName), string_intern(self, base),
|
|
|
|
string_intern(self, systemId), string_intern(self, publicId),
|
2002-06-27 16:40:48 -03:00
|
|
|
string_intern(self, notationName)))
|
2001-02-08 11:39:08 -04:00
|
|
|
|
2001-08-17 15:39:25 -03:00
|
|
|
#ifndef Py_USING_UNICODE
|
2001-02-08 11:39:08 -04:00
|
|
|
VOID_HANDLER(EntityDecl,
|
|
|
|
(void *userData,
|
|
|
|
const XML_Char *entityName,
|
|
|
|
int is_parameter_entity,
|
|
|
|
const XML_Char *value,
|
|
|
|
int value_length,
|
|
|
|
const XML_Char *base,
|
|
|
|
const XML_Char *systemId,
|
|
|
|
const XML_Char *publicId,
|
|
|
|
const XML_Char *notationName),
|
2002-06-27 16:40:48 -03:00
|
|
|
("NiNNNNN",
|
|
|
|
string_intern(self, entityName), is_parameter_entity,
|
2001-02-08 11:39:08 -04:00
|
|
|
conv_string_len_to_utf8(value, value_length),
|
2002-06-27 16:40:48 -03:00
|
|
|
string_intern(self, base), string_intern(self, systemId),
|
|
|
|
string_intern(self, publicId),
|
|
|
|
string_intern(self, notationName)))
|
2001-02-08 11:39:08 -04:00
|
|
|
#else
|
|
|
|
VOID_HANDLER(EntityDecl,
|
|
|
|
(void *userData,
|
|
|
|
const XML_Char *entityName,
|
|
|
|
int is_parameter_entity,
|
|
|
|
const XML_Char *value,
|
|
|
|
int value_length,
|
|
|
|
const XML_Char *base,
|
|
|
|
const XML_Char *systemId,
|
|
|
|
const XML_Char *publicId,
|
|
|
|
const XML_Char *notationName),
|
2002-06-27 16:40:48 -03:00
|
|
|
("NiNNNNN",
|
|
|
|
string_intern(self, entityName), is_parameter_entity,
|
2002-06-28 19:29:01 -03:00
|
|
|
(self->returns_unicode
|
|
|
|
? conv_string_len_to_unicode(value, value_length)
|
2001-02-08 11:39:08 -04:00
|
|
|
: conv_string_len_to_utf8(value, value_length)),
|
2002-06-27 16:40:48 -03:00
|
|
|
string_intern(self, base), string_intern(self, systemId),
|
|
|
|
string_intern(self, publicId),
|
|
|
|
string_intern(self, notationName)))
|
2001-02-08 11:39:08 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
VOID_HANDLER(XmlDecl,
|
|
|
|
(void *userData,
|
|
|
|
const XML_Char *version,
|
|
|
|
const XML_Char *encoding,
|
|
|
|
int standalone),
|
|
|
|
("(O&O&i)",
|
2002-06-28 19:29:01 -03:00
|
|
|
STRING_CONV_FUNC,version, STRING_CONV_FUNC,encoding,
|
2001-02-08 11:39:08 -04:00
|
|
|
standalone))
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
conv_content_model(XML_Content * const model,
|
2002-06-27 16:40:48 -03:00
|
|
|
PyObject *(*conv_string)(const XML_Char *))
|
2001-02-08 11:39:08 -04:00
|
|
|
{
|
|
|
|
PyObject *result = NULL;
|
|
|
|
PyObject *children = PyTuple_New(model->numchildren);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (children != NULL) {
|
2001-07-28 06:36:36 -03:00
|
|
|
assert(model->numchildren < INT_MAX);
|
|
|
|
for (i = 0; i < (int)model->numchildren; ++i) {
|
2001-02-08 11:39:08 -04:00
|
|
|
PyObject *child = conv_content_model(&model->children[i],
|
|
|
|
conv_string);
|
|
|
|
if (child == NULL) {
|
|
|
|
Py_XDECREF(children);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
PyTuple_SET_ITEM(children, i, child);
|
|
|
|
}
|
|
|
|
result = Py_BuildValue("(iiO&N)",
|
|
|
|
model->type, model->quant,
|
|
|
|
conv_string,model->name, children);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2003-02-01 23:54:17 -04:00
|
|
|
static void
|
|
|
|
my_ElementDeclHandler(void *userData,
|
|
|
|
const XML_Char *name,
|
|
|
|
XML_Content *model)
|
2001-02-08 11:39:08 -04:00
|
|
|
{
|
2003-02-01 23:54:17 -04:00
|
|
|
xmlparseobject *self = (xmlparseobject *)userData;
|
|
|
|
PyObject *args = NULL;
|
2001-02-08 11:39:08 -04:00
|
|
|
|
2003-02-01 23:54:17 -04:00
|
|
|
if (have_handler(self, ElementDecl)) {
|
|
|
|
PyObject *rv = NULL;
|
|
|
|
PyObject *modelobj, *nameobj;
|
2001-02-08 11:39:08 -04:00
|
|
|
|
2003-02-01 23:54:17 -04:00
|
|
|
if (flush_character_buffer(self) < 0)
|
|
|
|
goto finally;
|
|
|
|
#ifdef Py_USING_UNICODE
|
|
|
|
modelobj = conv_content_model(model,
|
|
|
|
(self->returns_unicode
|
|
|
|
? conv_string_to_unicode
|
|
|
|
: conv_string_to_utf8));
|
2001-02-08 11:39:08 -04:00
|
|
|
#else
|
2003-02-01 23:54:17 -04:00
|
|
|
modelobj = conv_content_model(model, conv_string_to_utf8);
|
2001-02-08 11:39:08 -04:00
|
|
|
#endif
|
2003-02-01 23:54:17 -04:00
|
|
|
if (modelobj == NULL) {
|
|
|
|
flag_error(self);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
nameobj = string_intern(self, name);
|
|
|
|
if (nameobj == NULL) {
|
|
|
|
Py_DECREF(modelobj);
|
|
|
|
flag_error(self);
|
|
|
|
goto finally;
|
|
|
|
}
|
2004-08-03 08:31:31 -03:00
|
|
|
args = Py_BuildValue("NN", nameobj, modelobj);
|
2003-02-01 23:54:17 -04:00
|
|
|
if (args == NULL) {
|
|
|
|
Py_DECREF(modelobj);
|
|
|
|
flag_error(self);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
self->in_callback = 1;
|
|
|
|
rv = call_with_frame(getcode(ElementDecl, "ElementDecl", __LINE__),
|
2004-08-13 00:12:57 -03:00
|
|
|
self->handlers[ElementDecl], args, self);
|
2003-02-01 23:54:17 -04:00
|
|
|
self->in_callback = 0;
|
|
|
|
if (rv == NULL) {
|
|
|
|
flag_error(self);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
Py_DECREF(rv);
|
|
|
|
}
|
|
|
|
finally:
|
|
|
|
Py_XDECREF(args);
|
|
|
|
XML_FreeContentModel(self->itself, model);
|
|
|
|
return;
|
|
|
|
}
|
2001-02-08 11:39:08 -04:00
|
|
|
|
|
|
|
VOID_HANDLER(AttlistDecl,
|
|
|
|
(void *userData,
|
|
|
|
const XML_Char *elname,
|
|
|
|
const XML_Char *attname,
|
|
|
|
const XML_Char *att_type,
|
|
|
|
const XML_Char *dflt,
|
|
|
|
int isrequired),
|
2002-06-27 16:40:48 -03:00
|
|
|
("(NNO&O&i)",
|
|
|
|
string_intern(self, elname), string_intern(self, attname),
|
2001-02-08 11:39:08 -04:00
|
|
|
STRING_CONV_FUNC,att_type, STRING_CONV_FUNC,dflt,
|
|
|
|
isrequired))
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2003-01-21 07:09:21 -04:00
|
|
|
#if XML_COMBINED_VERSION >= 19504
|
2003-01-21 06:58:18 -04:00
|
|
|
VOID_HANDLER(SkippedEntity,
|
|
|
|
(void *userData,
|
|
|
|
const XML_Char *entityName,
|
|
|
|
int is_parameter_entity),
|
|
|
|
("Ni",
|
|
|
|
string_intern(self, entityName), is_parameter_entity))
|
2003-01-21 07:09:21 -04:00
|
|
|
#endif
|
2003-01-21 06:58:18 -04:00
|
|
|
|
2002-06-28 19:29:01 -03:00
|
|
|
VOID_HANDLER(NotationDecl,
|
2000-06-26 21:33:30 -03:00
|
|
|
(void *userData,
|
|
|
|
const XML_Char *notationName,
|
|
|
|
const XML_Char *base,
|
|
|
|
const XML_Char *systemId,
|
|
|
|
const XML_Char *publicId),
|
2002-06-27 16:40:48 -03:00
|
|
|
("(NNNN)",
|
2002-06-28 19:29:01 -03:00
|
|
|
string_intern(self, notationName), string_intern(self, base),
|
2002-06-27 16:40:48 -03:00
|
|
|
string_intern(self, systemId), string_intern(self, publicId)))
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
VOID_HANDLER(StartNamespaceDecl,
|
2000-06-26 21:33:30 -03:00
|
|
|
(void *userData,
|
|
|
|
const XML_Char *prefix,
|
|
|
|
const XML_Char *uri),
|
2002-06-27 16:40:48 -03:00
|
|
|
("(NN)",
|
|
|
|
string_intern(self, prefix), string_intern(self, uri)))
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
VOID_HANDLER(EndNamespaceDecl,
|
2000-06-26 21:33:30 -03:00
|
|
|
(void *userData,
|
|
|
|
const XML_Char *prefix),
|
2002-06-27 16:40:48 -03:00
|
|
|
("(N)", string_intern(self, prefix)))
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
VOID_HANDLER(Comment,
|
2002-06-27 16:40:48 -03:00
|
|
|
(void *userData, const XML_Char *data),
|
|
|
|
("(O&)", STRING_CONV_FUNC,data))
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
VOID_HANDLER(StartCdataSection,
|
2000-03-31 11:43:31 -04:00
|
|
|
(void *userData),
|
2000-08-25 15:03:30 -03:00
|
|
|
("()"))
|
2002-06-28 19:29:01 -03:00
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
VOID_HANDLER(EndCdataSection,
|
2000-03-31 11:43:31 -04:00
|
|
|
(void *userData),
|
2000-08-25 15:03:30 -03:00
|
|
|
("()"))
|
2000-06-26 21:33:30 -03:00
|
|
|
|
2001-08-17 15:39:25 -03:00
|
|
|
#ifndef Py_USING_UNICODE
|
2000-08-25 15:03:30 -03:00
|
|
|
VOID_HANDLER(Default,
|
2002-06-28 19:29:01 -03:00
|
|
|
(void *userData, const XML_Char *s, int len),
|
2000-09-21 17:10:23 -03:00
|
|
|
("(N)", conv_string_len_to_utf8(s,len)))
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
VOID_HANDLER(DefaultHandlerExpand,
|
2002-06-28 19:29:01 -03:00
|
|
|
(void *userData, const XML_Char *s, int len),
|
2000-09-21 17:10:23 -03:00
|
|
|
("(N)", conv_string_len_to_utf8(s,len)))
|
2000-06-26 21:33:30 -03:00
|
|
|
#else
|
2000-08-25 15:03:30 -03:00
|
|
|
VOID_HANDLER(Default,
|
2002-06-28 19:29:01 -03:00
|
|
|
(void *userData, const XML_Char *s, int len),
|
|
|
|
("(N)", (self->returns_unicode
|
|
|
|
? conv_string_len_to_unicode(s,len)
|
2000-08-25 15:03:30 -03:00
|
|
|
: conv_string_len_to_utf8(s,len))))
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
VOID_HANDLER(DefaultHandlerExpand,
|
2002-06-28 19:29:01 -03:00
|
|
|
(void *userData, const XML_Char *s, int len),
|
|
|
|
("(N)", (self->returns_unicode
|
|
|
|
? conv_string_len_to_unicode(s,len)
|
2000-08-25 15:03:30 -03:00
|
|
|
: conv_string_len_to_utf8(s,len))))
|
2000-06-26 21:33:30 -03:00
|
|
|
#endif
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2002-06-28 19:29:01 -03:00
|
|
|
INT_HANDLER(NotStandalone,
|
|
|
|
(void *userData),
|
2000-06-26 21:33:30 -03:00
|
|
|
("()"))
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
RC_HANDLER(int, ExternalEntityRef,
|
2000-06-26 21:33:30 -03:00
|
|
|
(XML_Parser parser,
|
|
|
|
const XML_Char *context,
|
|
|
|
const XML_Char *base,
|
|
|
|
const XML_Char *systemId,
|
|
|
|
const XML_Char *publicId),
|
|
|
|
int rc=0;,
|
2002-06-27 16:40:48 -03:00
|
|
|
("(O&NNN)",
|
2002-06-28 19:29:01 -03:00
|
|
|
STRING_CONV_FUNC,context, string_intern(self, base),
|
2002-06-27 16:40:48 -03:00
|
|
|
string_intern(self, systemId), string_intern(self, publicId)),
|
2000-08-25 15:03:30 -03:00
|
|
|
rc = PyInt_AsLong(rv);, rc,
|
|
|
|
XML_GetUserData(parser))
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2001-01-21 06:18:10 -04:00
|
|
|
/* XXX UnknownEncodingHandler */
|
|
|
|
|
2001-02-08 11:39:08 -04:00
|
|
|
VOID_HANDLER(StartDoctypeDecl,
|
|
|
|
(void *userData, const XML_Char *doctypeName,
|
|
|
|
const XML_Char *sysid, const XML_Char *pubid,
|
|
|
|
int has_internal_subset),
|
2002-06-27 16:40:48 -03:00
|
|
|
("(NNNi)", string_intern(self, doctypeName),
|
|
|
|
string_intern(self, sysid), string_intern(self, pubid),
|
2001-02-08 11:39:08 -04:00
|
|
|
has_internal_subset))
|
2001-01-21 06:18:10 -04:00
|
|
|
|
|
|
|
VOID_HANDLER(EndDoctypeDecl, (void *userData), ("()"))
|
2000-03-31 11:43:31 -04:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
2002-06-28 19:29:01 -03:00
|
|
|
static PyObject *
|
|
|
|
get_parse_result(xmlparseobject *self, int rv)
|
|
|
|
{
|
|
|
|
if (PyErr_Occurred()) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (rv == 0) {
|
2003-01-21 06:58:18 -04:00
|
|
|
return set_error(self, XML_GetErrorCode(self->itself));
|
2002-06-28 19:29:01 -03:00
|
|
|
}
|
2002-06-28 19:56:48 -03:00
|
|
|
if (flush_character_buffer(self) < 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-06-28 19:29:01 -03:00
|
|
|
return PyInt_FromLong(rv);
|
|
|
|
}
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(xmlparse_Parse__doc__,
|
2000-07-22 13:34:15 -03:00
|
|
|
"Parse(data[, isfinal])\n\
|
2002-06-13 17:33:02 -03:00
|
|
|
Parse XML data. `isfinal' should be true at end of input.");
|
2000-03-31 11:43:31 -04:00
|
|
|
|
|
|
|
static PyObject *
|
2000-07-12 01:49:00 -03:00
|
|
|
xmlparse_Parse(xmlparseobject *self, PyObject *args)
|
2000-03-31 11:43:31 -04:00
|
|
|
{
|
2000-07-12 01:49:00 -03:00
|
|
|
char *s;
|
|
|
|
int slen;
|
|
|
|
int isFinal = 0;
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2000-07-12 01:49:00 -03:00
|
|
|
if (!PyArg_ParseTuple(args, "s#|i:Parse", &s, &slen, &isFinal))
|
|
|
|
return NULL;
|
2002-06-28 19:29:01 -03:00
|
|
|
|
|
|
|
return get_parse_result(self, XML_Parse(self->itself, s, slen, isFinal));
|
2000-03-31 11:43:31 -04:00
|
|
|
}
|
|
|
|
|
2000-09-21 17:10:23 -03:00
|
|
|
/* File reading copied from cPickle */
|
|
|
|
|
2000-03-31 11:43:31 -04:00
|
|
|
#define BUF_SIZE 2048
|
|
|
|
|
2000-07-12 01:49:00 -03:00
|
|
|
static int
|
|
|
|
readinst(char *buf, int buf_size, PyObject *meth)
|
|
|
|
{
|
|
|
|
PyObject *arg = NULL;
|
|
|
|
PyObject *bytes = NULL;
|
|
|
|
PyObject *str = NULL;
|
|
|
|
int len = -1;
|
2000-06-26 21:33:30 -03:00
|
|
|
|
2000-09-22 12:21:31 -03:00
|
|
|
if ((bytes = PyInt_FromLong(buf_size)) == NULL)
|
2000-07-12 01:49:00 -03:00
|
|
|
goto finally;
|
2000-09-22 12:21:31 -03:00
|
|
|
|
2003-07-21 14:05:56 -03:00
|
|
|
if ((arg = PyTuple_New(1)) == NULL) {
|
|
|
|
Py_DECREF(bytes);
|
2000-07-12 01:49:00 -03:00
|
|
|
goto finally;
|
2003-07-21 14:05:56 -03:00
|
|
|
}
|
2000-06-26 21:33:30 -03:00
|
|
|
|
2000-09-22 03:01:11 -03:00
|
|
|
PyTuple_SET_ITEM(arg, 0, bytes);
|
2000-06-26 21:33:30 -03:00
|
|
|
|
2004-10-13 16:50:11 -03:00
|
|
|
#if PY_VERSION_HEX < 0x02020000
|
|
|
|
str = PyObject_CallObject(meth, arg);
|
|
|
|
#else
|
|
|
|
str = PyObject_Call(meth, arg, NULL);
|
|
|
|
#endif
|
|
|
|
if (str == NULL)
|
2000-07-12 01:49:00 -03:00
|
|
|
goto finally;
|
2000-06-26 21:33:30 -03:00
|
|
|
|
2000-07-12 01:49:00 -03:00
|
|
|
/* XXX what to do if it returns a Unicode string? */
|
2000-09-21 17:10:23 -03:00
|
|
|
if (!PyString_Check(str)) {
|
2002-06-28 19:29:01 -03:00
|
|
|
PyErr_Format(PyExc_TypeError,
|
2000-07-12 01:49:00 -03:00
|
|
|
"read() did not return a string object (type=%.400s)",
|
|
|
|
str->ob_type->tp_name);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
len = PyString_GET_SIZE(str);
|
|
|
|
if (len > buf_size) {
|
|
|
|
PyErr_Format(PyExc_ValueError,
|
|
|
|
"read() returned too much data: "
|
|
|
|
"%i bytes requested, %i returned",
|
|
|
|
buf_size, len);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
memcpy(buf, PyString_AsString(str), len);
|
2000-03-31 11:43:31 -04:00
|
|
|
finally:
|
2000-07-12 01:49:00 -03:00
|
|
|
Py_XDECREF(arg);
|
2000-09-21 17:10:23 -03:00
|
|
|
Py_XDECREF(str);
|
2000-07-12 01:49:00 -03:00
|
|
|
return len;
|
2000-03-31 11:43:31 -04:00
|
|
|
}
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(xmlparse_ParseFile__doc__,
|
2000-07-22 13:34:15 -03:00
|
|
|
"ParseFile(file)\n\
|
2002-06-13 17:33:02 -03:00
|
|
|
Parse XML data from file-like object.");
|
2000-03-31 11:43:31 -04:00
|
|
|
|
|
|
|
static PyObject *
|
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
merge in bad ways, so I'll have to merge that extra-carefully (probably manually.)
Merged revisions 46495-46605 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r46495 | tim.peters | 2006-05-28 03:52:38 +0200 (Sun, 28 May 2006) | 2 lines
Added missing svn:eol-style property to text files.
........
r46497 | tim.peters | 2006-05-28 12:41:29 +0200 (Sun, 28 May 2006) | 3 lines
PyErr_Display(), PyErr_WriteUnraisable(): Coverity found a cut-and-paste
bug in both: `className` was referenced before being checked for NULL.
........
r46499 | fredrik.lundh | 2006-05-28 14:06:46 +0200 (Sun, 28 May 2006) | 5 lines
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
and use it for string copy operations. this gives a 20% speedup on some
string benchmarks.
........
r46501 | michael.hudson | 2006-05-28 17:51:40 +0200 (Sun, 28 May 2006) | 26 lines
Quality control, meet exceptions.c.
Fix a number of problems with the need for speed code:
One is doing this sort of thing:
Py_DECREF(self->field);
self->field = newval;
Py_INCREF(self->field);
without being very sure that self->field doesn't start with a
value that has a __del__, because that almost certainly can lead
to segfaults.
As self->args is constrained to be an exact tuple we may as well
exploit this fact consistently. This leads to quite a lot of
simplification (and, hey, probably better performance).
Add some error checking in places lacking it.
Fix some rather strange indentation in the Unicode code.
Delete some trailing whitespace.
More to come, I haven't fixed all the reference leaks yet...
........
r46502 | george.yoshida | 2006-05-28 18:39:09 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1080727: add "encoding" parameter to doctest.DocFileSuite
Contributed by Bjorn Tillenius.
........
r46503 | martin.v.loewis | 2006-05-28 18:57:38 +0200 (Sun, 28 May 2006) | 4 lines
Rest of patch #1490384: Commit icon source, remove
claim that Erik von Blokland is the author of the
installer picture.
........
r46504 | michael.hudson | 2006-05-28 19:40:29 +0200 (Sun, 28 May 2006) | 16 lines
Quality control, meet exceptions.c, round two.
Make some functions that should have been static static.
Fix a bunch of refleaks by fixing the definition of
MiddlingExtendsException.
Remove all the __new__ implementations apart from
BaseException_new. Rewrite most code that needs it to cope with
NULL fields (such code could get excercised anyway, the
__new__-removal just makes it more likely). This involved
editing the code for WindowsError, which I can't test.
This fixes all the refleaks in at least the start of a regrtest
-R :: run.
........
r46505 | marc-andre.lemburg | 2006-05-28 19:46:58 +0200 (Sun, 28 May 2006) | 10 lines
Initial version of systimes - a module to provide platform dependent
performance measurements.
The module is currently just a proof-of-concept implementation, but
will integrated into pybench once it is stable enough.
License: pybench license.
Author: Marc-Andre Lemburg.
........
r46507 | armin.rigo | 2006-05-28 21:13:17 +0200 (Sun, 28 May 2006) | 15 lines
("Forward-port" of r46506)
Remove various dependencies on dictionary order in the standard library
tests, and one (clearly an oversight, potentially critical) in the
standard library itself - base64.py.
Remaining open issues:
* test_extcall is an output test, messy to make robust
* tarfile.py has a potential bug here, but I'm not familiar
enough with this code. Filed in as SF bug #1496501.
* urllib2.HTTPPasswordMgr() returns a random result if there is more
than one matching root path. I'm asking python-dev for
clarification...
........
r46508 | georg.brandl | 2006-05-28 22:11:45 +0200 (Sun, 28 May 2006) | 4 lines
The empty string is a valid import path.
(fixes #1496539)
........
r46509 | georg.brandl | 2006-05-28 22:23:12 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1496206: urllib2 PasswordMgr ./. default ports
........
r46510 | georg.brandl | 2006-05-28 22:57:09 +0200 (Sun, 28 May 2006) | 3 lines
Fix refleaks in UnicodeError get and set methods.
........
r46511 | michael.hudson | 2006-05-28 23:19:03 +0200 (Sun, 28 May 2006) | 3 lines
use the UnicodeError traversal and clearing functions in UnicodeError
subclasses.
........
r46512 | thomas.wouters | 2006-05-28 23:32:12 +0200 (Sun, 28 May 2006) | 4 lines
Make last patch valid C89 so Windows compilers can deal with it.
........
r46513 | georg.brandl | 2006-05-28 23:42:54 +0200 (Sun, 28 May 2006) | 3 lines
Fix ref-antileak in _struct.c which eventually lead to deallocating None.
........
r46514 | georg.brandl | 2006-05-28 23:57:35 +0200 (Sun, 28 May 2006) | 4 lines
Correct None refcount issue in Mac modules. (Are they
still used?)
........
r46515 | armin.rigo | 2006-05-29 00:07:08 +0200 (Mon, 29 May 2006) | 3 lines
A clearer error message when passing -R to regrtest.py with
release builds of Python.
........
r46516 | georg.brandl | 2006-05-29 00:14:04 +0200 (Mon, 29 May 2006) | 3 lines
Fix C function calling conventions in _sre module.
........
r46517 | georg.brandl | 2006-05-29 00:34:51 +0200 (Mon, 29 May 2006) | 3 lines
Convert audioop over to METH_VARARGS.
........
r46518 | georg.brandl | 2006-05-29 00:38:57 +0200 (Mon, 29 May 2006) | 3 lines
METH_NOARGS functions do get called with two args.
........
r46519 | georg.brandl | 2006-05-29 11:46:51 +0200 (Mon, 29 May 2006) | 4 lines
Fix refleak in socketmodule. Replace bogus Py_BuildValue calls.
Fix refleak in exceptions.
........
r46520 | nick.coghlan | 2006-05-29 14:43:05 +0200 (Mon, 29 May 2006) | 7 lines
Apply modified version of Collin Winter's patch #1478788
Renames functional extension module to _functools and adds a Python
functools module so that utility functions like update_wrapper can be
added easily.
........
r46522 | georg.brandl | 2006-05-29 15:53:16 +0200 (Mon, 29 May 2006) | 3 lines
Convert fmmodule to METH_VARARGS.
........
r46523 | georg.brandl | 2006-05-29 16:13:21 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494605.
........
r46524 | georg.brandl | 2006-05-29 16:28:05 +0200 (Mon, 29 May 2006) | 3 lines
Handle PyMem_Malloc failure in pystrtod.c. Closes #1494671.
........
r46525 | georg.brandl | 2006-05-29 16:33:55 +0200 (Mon, 29 May 2006) | 3 lines
Fix compiler warning.
........
r46526 | georg.brandl | 2006-05-29 16:39:00 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494787 (pyclbr counts whitespace as superclass name)
........
r46527 | bob.ippolito | 2006-05-29 17:47:29 +0200 (Mon, 29 May 2006) | 1 line
simplify the struct code a bit (no functional changes)
........
r46528 | armin.rigo | 2006-05-29 19:59:47 +0200 (Mon, 29 May 2006) | 2 lines
Silence a warning.
........
r46529 | georg.brandl | 2006-05-29 21:39:45 +0200 (Mon, 29 May 2006) | 3 lines
Correct some value converting strangenesses.
........
r46530 | nick.coghlan | 2006-05-29 22:27:44 +0200 (Mon, 29 May 2006) | 1 line
When adding a module like functools, it helps to let SVN know about the file.
........
r46531 | georg.brandl | 2006-05-29 22:52:54 +0200 (Mon, 29 May 2006) | 4 lines
Patches #1497027 and #972322: try HTTP digest auth first,
and watch out for handler name collisions.
........
r46532 | georg.brandl | 2006-05-29 22:57:01 +0200 (Mon, 29 May 2006) | 3 lines
Add News entry for last commit.
........
r46533 | georg.brandl | 2006-05-29 23:04:52 +0200 (Mon, 29 May 2006) | 4 lines
Make use of METH_O and METH_NOARGS where possible.
Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
........
r46534 | georg.brandl | 2006-05-29 23:58:42 +0200 (Mon, 29 May 2006) | 3 lines
Convert more modules to METH_VARARGS.
........
r46535 | georg.brandl | 2006-05-30 00:00:30 +0200 (Tue, 30 May 2006) | 3 lines
Whoops.
........
r46536 | fredrik.lundh | 2006-05-30 00:42:07 +0200 (Tue, 30 May 2006) | 4 lines
fixed "abc".count("", 100) == -96 error (hopefully, nobody's relying on
the current behaviour ;-)
........
r46537 | bob.ippolito | 2006-05-30 00:55:48 +0200 (Tue, 30 May 2006) | 1 line
struct: modulo math plus warning on all endian-explicit formats for compatibility with older struct usage (ugly)
........
r46539 | bob.ippolito | 2006-05-30 02:26:01 +0200 (Tue, 30 May 2006) | 1 line
Add a length check to aifc to ensure it doesn't write a bogus file
........
r46540 | tim.peters | 2006-05-30 04:25:25 +0200 (Tue, 30 May 2006) | 10 lines
deprecated_err(): Stop bizarre warning messages when the tests
are run in the order:
test_genexps (or any other doctest-based test)
test_struct
test_doctest
The `warnings` module needs an advertised way to save/restore
its internal filter list.
........
r46541 | tim.peters | 2006-05-30 04:26:46 +0200 (Tue, 30 May 2006) | 2 lines
Whitespace normalization.
........
r46542 | tim.peters | 2006-05-30 04:30:30 +0200 (Tue, 30 May 2006) | 2 lines
Set a binary svn:mime-type property on this UTF-8 encoded file.
........
r46543 | neal.norwitz | 2006-05-30 05:18:50 +0200 (Tue, 30 May 2006) | 1 line
Simplify further by using AddStringConstant
........
r46544 | tim.peters | 2006-05-30 06:16:25 +0200 (Tue, 30 May 2006) | 6 lines
Convert relevant dict internals to Py_ssize_t.
I don't have a box with nearly enough RAM, or an OS,
that could get close to tickling this, though (requires
a dict w/ at least 2**31 entries).
........
r46545 | neal.norwitz | 2006-05-30 06:19:21 +0200 (Tue, 30 May 2006) | 1 line
Remove stray | in comment
........
r46546 | neal.norwitz | 2006-05-30 06:25:05 +0200 (Tue, 30 May 2006) | 1 line
Use Py_SAFE_DOWNCAST for safety. Fix format strings. Remove 2 more stray | in comment
........
r46547 | neal.norwitz | 2006-05-30 06:43:23 +0200 (Tue, 30 May 2006) | 1 line
No DOWNCAST is required since sizeof(Py_ssize_t) >= sizeof(int) and Py_ReprEntr returns an int
........
r46548 | tim.peters | 2006-05-30 07:04:59 +0200 (Tue, 30 May 2006) | 3 lines
dict_print(): Explicitly narrow the return value
from a (possibly) wider variable.
........
r46549 | tim.peters | 2006-05-30 07:23:59 +0200 (Tue, 30 May 2006) | 5 lines
dict_print(): So that Neal & I don't spend the rest of
our lives taking turns rewriting code that works ;-),
get rid of casting illusions by declaring a new variable
with the obvious type.
........
r46550 | georg.brandl | 2006-05-30 09:04:55 +0200 (Tue, 30 May 2006) | 3 lines
Restore exception pickle support. #1497319.
........
r46551 | georg.brandl | 2006-05-30 09:13:29 +0200 (Tue, 30 May 2006) | 3 lines
Add a test case for exception pickling. args is never NULL.
........
r46552 | neal.norwitz | 2006-05-30 09:21:10 +0200 (Tue, 30 May 2006) | 1 line
Don't fail if the (sub)pkgname already exist.
........
r46553 | georg.brandl | 2006-05-30 09:34:45 +0200 (Tue, 30 May 2006) | 3 lines
Disallow keyword args for exceptions.
........
r46554 | neal.norwitz | 2006-05-30 09:36:54 +0200 (Tue, 30 May 2006) | 5 lines
I'm impatient. I think this will fix a few more problems with the buildbots.
I'm not sure this is the best approach, but I can't think of anything better.
If this creates problems, feel free to revert, but I think it's safe and
should make things a little better.
........
r46555 | georg.brandl | 2006-05-30 10:17:00 +0200 (Tue, 30 May 2006) | 4 lines
Do the check for no keyword arguments in __init__ so that
subclasses of Exception can be supplied keyword args
........
r46556 | georg.brandl | 2006-05-30 10:47:19 +0200 (Tue, 30 May 2006) | 3 lines
Convert test_exceptions to unittest.
........
r46557 | andrew.kuchling | 2006-05-30 14:52:01 +0200 (Tue, 30 May 2006) | 1 line
Add SoC name, and reorganize this section a bit
........
r46559 | tim.peters | 2006-05-30 17:53:34 +0200 (Tue, 30 May 2006) | 11 lines
PyLong_FromString(): Continued fraction analysis (explained in
a new comment) suggests there are almost certainly large input
integers in all non-binary input bases for which one Python digit
too few is initally allocated to hold the final result. Instead
of assert-failing when that happens, allocate more space. Alas,
I estimate it would take a few days to find a specific such case,
so this isn't backed up by a new test (not to mention that such
a case may take hours to run, since conversion time is quadratic
in the number of digits, and preliminary attempts suggested that
the smallest such inputs contain at least a million digits).
........
r46560 | fredrik.lundh | 2006-05-30 19:11:48 +0200 (Tue, 30 May 2006) | 3 lines
changed find/rfind to return -1 for matches outside the source string
........
r46561 | bob.ippolito | 2006-05-30 19:37:54 +0200 (Tue, 30 May 2006) | 1 line
Change wrapping terminology to overflow masking
........
r46562 | fredrik.lundh | 2006-05-30 19:39:58 +0200 (Tue, 30 May 2006) | 3 lines
changed count to return 0 for slices outside the source string
........
r46568 | tim.peters | 2006-05-31 01:28:02 +0200 (Wed, 31 May 2006) | 2 lines
Whitespace normalization.
........
r46569 | brett.cannon | 2006-05-31 04:19:54 +0200 (Wed, 31 May 2006) | 5 lines
Clarify wording on default values for strptime(); defaults are used when better
values cannot be inferred.
Closes bug #1496315.
........
r46572 | neal.norwitz | 2006-05-31 09:43:27 +0200 (Wed, 31 May 2006) | 1 line
Calculate smallest properly (it was off by one) and use proper ssize_t types for Win64
........
r46573 | neal.norwitz | 2006-05-31 10:01:08 +0200 (Wed, 31 May 2006) | 1 line
Revert last checkin, it is better to do make distclean
........
r46574 | neal.norwitz | 2006-05-31 11:02:44 +0200 (Wed, 31 May 2006) | 3 lines
On 64-bit platforms running test_struct after test_tarfile would fail
since the deprecation warning wouldn't be raised.
........
r46575 | thomas.heller | 2006-05-31 13:37:58 +0200 (Wed, 31 May 2006) | 3 lines
PyTuple_Pack is not available in Python 2.3, but ctypes must stay
compatible with that.
........
r46576 | andrew.kuchling | 2006-05-31 15:18:56 +0200 (Wed, 31 May 2006) | 1 line
'functional' module was renamed to 'functools'
........
r46577 | kristjan.jonsson | 2006-05-31 15:35:41 +0200 (Wed, 31 May 2006) | 1 line
Fixup the PCBuild8 project directory. exceptions.c have moved to Objects, and the functionalmodule.c has been replaced with _functoolsmodule.c. Other minor changes to .vcproj files and .sln to fix compilation
........
r46578 | andrew.kuchling | 2006-05-31 16:08:48 +0200 (Wed, 31 May 2006) | 15 lines
[Bug #1473048]
SimpleXMLRPCServer and DocXMLRPCServer don't look at
the path of the HTTP request at all; you can POST or
GET from / or /RPC2 or /blahblahblah with the same results.
Security scanners that look for /cgi-bin/phf will therefore report
lots of vulnerabilities.
Fix: add a .rpc_paths attribute to the SimpleXMLRPCServer class,
and report a 404 error if the path isn't on the allowed list.
Possibly-controversial aspect of this change: the default makes only
'/' and '/RPC2' legal. Maybe this will break people's applications
(though I doubt it). We could just set the default to an empty tuple,
which would exactly match the current behaviour.
........
r46579 | andrew.kuchling | 2006-05-31 16:12:47 +0200 (Wed, 31 May 2006) | 1 line
Mention SimpleXMLRPCServer change
........
r46580 | tim.peters | 2006-05-31 16:28:07 +0200 (Wed, 31 May 2006) | 2 lines
Trimmed trailing whitespace.
........
r46581 | tim.peters | 2006-05-31 17:33:22 +0200 (Wed, 31 May 2006) | 4 lines
_range_error(): Speed and simplify (there's no real need for
loops here). Assert that size_t is actually big enough, and
that f->size is at least one. Wrap a long line.
........
r46582 | tim.peters | 2006-05-31 17:34:37 +0200 (Wed, 31 May 2006) | 2 lines
Repaired error in new comment.
........
r46584 | neal.norwitz | 2006-06-01 07:32:49 +0200 (Thu, 01 Jun 2006) | 4 lines
Remove ; at end of macro. There was a compiler recently that warned
about extra semi-colons. It may have been the HP C compiler.
This file will trigger a bunch of those warnings now.
........
r46585 | georg.brandl | 2006-06-01 08:39:19 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly unpickle 2.4 exceptions via __setstate__ (patch #1498571)
........
r46586 | georg.brandl | 2006-06-01 10:27:32 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly allocate complex types with tp_alloc. (bug #1498638)
........
r46587 | georg.brandl | 2006-06-01 14:30:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Correctly dispatch Faults in loads (patch #1498627)
........
r46588 | georg.brandl | 2006-06-01 15:00:49 +0200 (Thu, 01 Jun 2006) | 3 lines
Some code style tweaks, and remove apply.
........
r46589 | armin.rigo | 2006-06-01 15:19:12 +0200 (Thu, 01 Jun 2006) | 5 lines
[ 1497053 ] Let dicts propagate the exceptions in user __eq__().
[ 1456209 ] dictresize() vulnerability ( <- backport candidate ).
........
r46590 | tim.peters | 2006-06-01 15:41:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Whitespace normalization.
........
r46591 | tim.peters | 2006-06-01 15:49:23 +0200 (Thu, 01 Jun 2006) | 2 lines
Record bugs 1275608 and 1456209 as being fixed.
........
r46592 | tim.peters | 2006-06-01 15:56:26 +0200 (Thu, 01 Jun 2006) | 5 lines
Re-enable a new empty-string test added during the NFS sprint,
but disabled then because str and unicode strings gave different
results. The implementations were repaired later during the
sprint, but the new test remained disabled.
........
r46594 | tim.peters | 2006-06-01 17:50:44 +0200 (Thu, 01 Jun 2006) | 7 lines
Armin committed his patch while I was reviewing it (I'm sure
he didn't know this), so merged in some changes I made during
review. Nothing material apart from changing a new `mask` local
from int to Py_ssize_t. Mostly this is repairing comments that
were made incorrect, and adding new comments. Also a few
minor code rewrites for clarity or helpful succinctness.
........
r46599 | neal.norwitz | 2006-06-02 06:45:53 +0200 (Fri, 02 Jun 2006) | 1 line
Convert docstrings to comments so regrtest -v prints method names
........
r46600 | neal.norwitz | 2006-06-02 06:50:49 +0200 (Fri, 02 Jun 2006) | 2 lines
Fix memory leak found by valgrind.
........
r46601 | neal.norwitz | 2006-06-02 06:54:52 +0200 (Fri, 02 Jun 2006) | 1 line
More memory leaks from valgrind
........
r46602 | neal.norwitz | 2006-06-02 08:23:00 +0200 (Fri, 02 Jun 2006) | 11 lines
Patch #1357836:
Prevent an invalid memory read from test_coding in case the done flag is set.
In that case, the loop isn't entered. I wonder if rather than setting
the done flag in the cases before the loop, if they should just exit early.
This code looks like it should be refactored.
Backport candidate (also the early break above if decoding_fgets fails)
........
r46603 | martin.blais | 2006-06-02 15:03:43 +0200 (Fri, 02 Jun 2006) | 1 line
Fixed struct test to not use unittest.
........
r46605 | tim.peters | 2006-06-03 01:22:51 +0200 (Sat, 03 Jun 2006) | 10 lines
pprint functions used to sort a dict (by key) if and only if
the output required more than one line. "Small" dicts got
displayed in seemingly random order (the hash-induced order
produced by dict.__repr__). None of this was documented.
Now pprint functions always sort dicts by key, and the docs
promise it.
This was proposed and agreed to during the PyCon 2006 core
sprint -- I just didn't have time for it before now.
........
2006-06-08 11:42:34 -03:00
|
|
|
xmlparse_ParseFile(xmlparseobject *self, PyObject *f)
|
2000-03-31 11:43:31 -04:00
|
|
|
{
|
2000-07-12 01:49:00 -03:00
|
|
|
int rv = 1;
|
|
|
|
FILE *fp;
|
|
|
|
PyObject *readmethod = NULL;
|
2000-06-26 21:33:30 -03:00
|
|
|
|
2000-07-12 01:49:00 -03:00
|
|
|
if (PyFile_Check(f)) {
|
|
|
|
fp = PyFile_AsFile(f);
|
|
|
|
}
|
2006-03-08 02:36:45 -04:00
|
|
|
else {
|
2000-07-12 01:49:00 -03:00
|
|
|
fp = NULL;
|
2000-09-21 17:10:23 -03:00
|
|
|
readmethod = PyObject_GetAttrString(f, "read");
|
|
|
|
if (readmethod == NULL) {
|
2000-07-12 01:49:00 -03:00
|
|
|
PyErr_Clear();
|
2002-06-28 19:29:01 -03:00
|
|
|
PyErr_SetString(PyExc_TypeError,
|
2000-07-12 01:49:00 -03:00
|
|
|
"argument must have 'read' attribute");
|
2002-07-19 19:03:03 -03:00
|
|
|
return NULL;
|
2000-07-12 01:49:00 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for (;;) {
|
|
|
|
int bytes_read;
|
|
|
|
void *buf = XML_GetBuffer(self->itself, BUF_SIZE);
|
2003-07-21 14:05:56 -03:00
|
|
|
if (buf == NULL) {
|
2003-07-21 14:22:43 -03:00
|
|
|
Py_XDECREF(readmethod);
|
2000-07-12 01:49:00 -03:00
|
|
|
return PyErr_NoMemory();
|
2003-07-21 14:05:56 -03:00
|
|
|
}
|
2000-07-12 01:49:00 -03:00
|
|
|
|
|
|
|
if (fp) {
|
|
|
|
bytes_read = fread(buf, sizeof(char), BUF_SIZE, fp);
|
|
|
|
if (bytes_read < 0) {
|
|
|
|
PyErr_SetFromErrno(PyExc_IOError);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bytes_read = readinst(buf, BUF_SIZE, readmethod);
|
2003-07-21 14:05:56 -03:00
|
|
|
if (bytes_read < 0) {
|
|
|
|
Py_DECREF(readmethod);
|
2000-07-12 01:49:00 -03:00
|
|
|
return NULL;
|
2003-07-21 14:05:56 -03:00
|
|
|
}
|
2000-07-12 01:49:00 -03:00
|
|
|
}
|
|
|
|
rv = XML_ParseBuffer(self->itself, bytes_read, bytes_read == 0);
|
2003-07-21 14:05:56 -03:00
|
|
|
if (PyErr_Occurred()) {
|
|
|
|
Py_XDECREF(readmethod);
|
2000-07-12 01:49:00 -03:00
|
|
|
return NULL;
|
2003-07-21 14:05:56 -03:00
|
|
|
}
|
2000-06-26 21:33:30 -03:00
|
|
|
|
2000-07-12 01:49:00 -03:00
|
|
|
if (!rv || bytes_read == 0)
|
|
|
|
break;
|
|
|
|
}
|
2003-07-21 14:05:56 -03:00
|
|
|
Py_XDECREF(readmethod);
|
2002-06-28 19:29:01 -03:00
|
|
|
return get_parse_result(self, rv);
|
2000-03-31 11:43:31 -04:00
|
|
|
}
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(xmlparse_SetBase__doc__,
|
2000-07-22 13:34:15 -03:00
|
|
|
"SetBase(base_url)\n\
|
2002-06-13 17:33:02 -03:00
|
|
|
Set the base URL for the parser.");
|
2000-03-31 11:43:31 -04:00
|
|
|
|
|
|
|
static PyObject *
|
2000-07-12 01:49:00 -03:00
|
|
|
xmlparse_SetBase(xmlparseobject *self, PyObject *args)
|
|
|
|
{
|
2000-03-31 11:43:31 -04:00
|
|
|
char *base;
|
|
|
|
|
2000-07-12 01:49:00 -03:00
|
|
|
if (!PyArg_ParseTuple(args, "s:SetBase", &base))
|
2000-03-31 11:43:31 -04:00
|
|
|
return NULL;
|
2000-07-12 01:49:00 -03:00
|
|
|
if (!XML_SetBase(self->itself, base)) {
|
|
|
|
return PyErr_NoMemory();
|
2000-03-31 11:43:31 -04:00
|
|
|
}
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(xmlparse_GetBase__doc__,
|
2000-07-22 13:34:15 -03:00
|
|
|
"GetBase() -> url\n\
|
2002-06-13 17:33:02 -03:00
|
|
|
Return base URL string for the parser.");
|
2000-03-31 11:43:31 -04:00
|
|
|
|
|
|
|
static PyObject *
|
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
merge in bad ways, so I'll have to merge that extra-carefully (probably manually.)
Merged revisions 46495-46605 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r46495 | tim.peters | 2006-05-28 03:52:38 +0200 (Sun, 28 May 2006) | 2 lines
Added missing svn:eol-style property to text files.
........
r46497 | tim.peters | 2006-05-28 12:41:29 +0200 (Sun, 28 May 2006) | 3 lines
PyErr_Display(), PyErr_WriteUnraisable(): Coverity found a cut-and-paste
bug in both: `className` was referenced before being checked for NULL.
........
r46499 | fredrik.lundh | 2006-05-28 14:06:46 +0200 (Sun, 28 May 2006) | 5 lines
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
and use it for string copy operations. this gives a 20% speedup on some
string benchmarks.
........
r46501 | michael.hudson | 2006-05-28 17:51:40 +0200 (Sun, 28 May 2006) | 26 lines
Quality control, meet exceptions.c.
Fix a number of problems with the need for speed code:
One is doing this sort of thing:
Py_DECREF(self->field);
self->field = newval;
Py_INCREF(self->field);
without being very sure that self->field doesn't start with a
value that has a __del__, because that almost certainly can lead
to segfaults.
As self->args is constrained to be an exact tuple we may as well
exploit this fact consistently. This leads to quite a lot of
simplification (and, hey, probably better performance).
Add some error checking in places lacking it.
Fix some rather strange indentation in the Unicode code.
Delete some trailing whitespace.
More to come, I haven't fixed all the reference leaks yet...
........
r46502 | george.yoshida | 2006-05-28 18:39:09 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1080727: add "encoding" parameter to doctest.DocFileSuite
Contributed by Bjorn Tillenius.
........
r46503 | martin.v.loewis | 2006-05-28 18:57:38 +0200 (Sun, 28 May 2006) | 4 lines
Rest of patch #1490384: Commit icon source, remove
claim that Erik von Blokland is the author of the
installer picture.
........
r46504 | michael.hudson | 2006-05-28 19:40:29 +0200 (Sun, 28 May 2006) | 16 lines
Quality control, meet exceptions.c, round two.
Make some functions that should have been static static.
Fix a bunch of refleaks by fixing the definition of
MiddlingExtendsException.
Remove all the __new__ implementations apart from
BaseException_new. Rewrite most code that needs it to cope with
NULL fields (such code could get excercised anyway, the
__new__-removal just makes it more likely). This involved
editing the code for WindowsError, which I can't test.
This fixes all the refleaks in at least the start of a regrtest
-R :: run.
........
r46505 | marc-andre.lemburg | 2006-05-28 19:46:58 +0200 (Sun, 28 May 2006) | 10 lines
Initial version of systimes - a module to provide platform dependent
performance measurements.
The module is currently just a proof-of-concept implementation, but
will integrated into pybench once it is stable enough.
License: pybench license.
Author: Marc-Andre Lemburg.
........
r46507 | armin.rigo | 2006-05-28 21:13:17 +0200 (Sun, 28 May 2006) | 15 lines
("Forward-port" of r46506)
Remove various dependencies on dictionary order in the standard library
tests, and one (clearly an oversight, potentially critical) in the
standard library itself - base64.py.
Remaining open issues:
* test_extcall is an output test, messy to make robust
* tarfile.py has a potential bug here, but I'm not familiar
enough with this code. Filed in as SF bug #1496501.
* urllib2.HTTPPasswordMgr() returns a random result if there is more
than one matching root path. I'm asking python-dev for
clarification...
........
r46508 | georg.brandl | 2006-05-28 22:11:45 +0200 (Sun, 28 May 2006) | 4 lines
The empty string is a valid import path.
(fixes #1496539)
........
r46509 | georg.brandl | 2006-05-28 22:23:12 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1496206: urllib2 PasswordMgr ./. default ports
........
r46510 | georg.brandl | 2006-05-28 22:57:09 +0200 (Sun, 28 May 2006) | 3 lines
Fix refleaks in UnicodeError get and set methods.
........
r46511 | michael.hudson | 2006-05-28 23:19:03 +0200 (Sun, 28 May 2006) | 3 lines
use the UnicodeError traversal and clearing functions in UnicodeError
subclasses.
........
r46512 | thomas.wouters | 2006-05-28 23:32:12 +0200 (Sun, 28 May 2006) | 4 lines
Make last patch valid C89 so Windows compilers can deal with it.
........
r46513 | georg.brandl | 2006-05-28 23:42:54 +0200 (Sun, 28 May 2006) | 3 lines
Fix ref-antileak in _struct.c which eventually lead to deallocating None.
........
r46514 | georg.brandl | 2006-05-28 23:57:35 +0200 (Sun, 28 May 2006) | 4 lines
Correct None refcount issue in Mac modules. (Are they
still used?)
........
r46515 | armin.rigo | 2006-05-29 00:07:08 +0200 (Mon, 29 May 2006) | 3 lines
A clearer error message when passing -R to regrtest.py with
release builds of Python.
........
r46516 | georg.brandl | 2006-05-29 00:14:04 +0200 (Mon, 29 May 2006) | 3 lines
Fix C function calling conventions in _sre module.
........
r46517 | georg.brandl | 2006-05-29 00:34:51 +0200 (Mon, 29 May 2006) | 3 lines
Convert audioop over to METH_VARARGS.
........
r46518 | georg.brandl | 2006-05-29 00:38:57 +0200 (Mon, 29 May 2006) | 3 lines
METH_NOARGS functions do get called with two args.
........
r46519 | georg.brandl | 2006-05-29 11:46:51 +0200 (Mon, 29 May 2006) | 4 lines
Fix refleak in socketmodule. Replace bogus Py_BuildValue calls.
Fix refleak in exceptions.
........
r46520 | nick.coghlan | 2006-05-29 14:43:05 +0200 (Mon, 29 May 2006) | 7 lines
Apply modified version of Collin Winter's patch #1478788
Renames functional extension module to _functools and adds a Python
functools module so that utility functions like update_wrapper can be
added easily.
........
r46522 | georg.brandl | 2006-05-29 15:53:16 +0200 (Mon, 29 May 2006) | 3 lines
Convert fmmodule to METH_VARARGS.
........
r46523 | georg.brandl | 2006-05-29 16:13:21 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494605.
........
r46524 | georg.brandl | 2006-05-29 16:28:05 +0200 (Mon, 29 May 2006) | 3 lines
Handle PyMem_Malloc failure in pystrtod.c. Closes #1494671.
........
r46525 | georg.brandl | 2006-05-29 16:33:55 +0200 (Mon, 29 May 2006) | 3 lines
Fix compiler warning.
........
r46526 | georg.brandl | 2006-05-29 16:39:00 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494787 (pyclbr counts whitespace as superclass name)
........
r46527 | bob.ippolito | 2006-05-29 17:47:29 +0200 (Mon, 29 May 2006) | 1 line
simplify the struct code a bit (no functional changes)
........
r46528 | armin.rigo | 2006-05-29 19:59:47 +0200 (Mon, 29 May 2006) | 2 lines
Silence a warning.
........
r46529 | georg.brandl | 2006-05-29 21:39:45 +0200 (Mon, 29 May 2006) | 3 lines
Correct some value converting strangenesses.
........
r46530 | nick.coghlan | 2006-05-29 22:27:44 +0200 (Mon, 29 May 2006) | 1 line
When adding a module like functools, it helps to let SVN know about the file.
........
r46531 | georg.brandl | 2006-05-29 22:52:54 +0200 (Mon, 29 May 2006) | 4 lines
Patches #1497027 and #972322: try HTTP digest auth first,
and watch out for handler name collisions.
........
r46532 | georg.brandl | 2006-05-29 22:57:01 +0200 (Mon, 29 May 2006) | 3 lines
Add News entry for last commit.
........
r46533 | georg.brandl | 2006-05-29 23:04:52 +0200 (Mon, 29 May 2006) | 4 lines
Make use of METH_O and METH_NOARGS where possible.
Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
........
r46534 | georg.brandl | 2006-05-29 23:58:42 +0200 (Mon, 29 May 2006) | 3 lines
Convert more modules to METH_VARARGS.
........
r46535 | georg.brandl | 2006-05-30 00:00:30 +0200 (Tue, 30 May 2006) | 3 lines
Whoops.
........
r46536 | fredrik.lundh | 2006-05-30 00:42:07 +0200 (Tue, 30 May 2006) | 4 lines
fixed "abc".count("", 100) == -96 error (hopefully, nobody's relying on
the current behaviour ;-)
........
r46537 | bob.ippolito | 2006-05-30 00:55:48 +0200 (Tue, 30 May 2006) | 1 line
struct: modulo math plus warning on all endian-explicit formats for compatibility with older struct usage (ugly)
........
r46539 | bob.ippolito | 2006-05-30 02:26:01 +0200 (Tue, 30 May 2006) | 1 line
Add a length check to aifc to ensure it doesn't write a bogus file
........
r46540 | tim.peters | 2006-05-30 04:25:25 +0200 (Tue, 30 May 2006) | 10 lines
deprecated_err(): Stop bizarre warning messages when the tests
are run in the order:
test_genexps (or any other doctest-based test)
test_struct
test_doctest
The `warnings` module needs an advertised way to save/restore
its internal filter list.
........
r46541 | tim.peters | 2006-05-30 04:26:46 +0200 (Tue, 30 May 2006) | 2 lines
Whitespace normalization.
........
r46542 | tim.peters | 2006-05-30 04:30:30 +0200 (Tue, 30 May 2006) | 2 lines
Set a binary svn:mime-type property on this UTF-8 encoded file.
........
r46543 | neal.norwitz | 2006-05-30 05:18:50 +0200 (Tue, 30 May 2006) | 1 line
Simplify further by using AddStringConstant
........
r46544 | tim.peters | 2006-05-30 06:16:25 +0200 (Tue, 30 May 2006) | 6 lines
Convert relevant dict internals to Py_ssize_t.
I don't have a box with nearly enough RAM, or an OS,
that could get close to tickling this, though (requires
a dict w/ at least 2**31 entries).
........
r46545 | neal.norwitz | 2006-05-30 06:19:21 +0200 (Tue, 30 May 2006) | 1 line
Remove stray | in comment
........
r46546 | neal.norwitz | 2006-05-30 06:25:05 +0200 (Tue, 30 May 2006) | 1 line
Use Py_SAFE_DOWNCAST for safety. Fix format strings. Remove 2 more stray | in comment
........
r46547 | neal.norwitz | 2006-05-30 06:43:23 +0200 (Tue, 30 May 2006) | 1 line
No DOWNCAST is required since sizeof(Py_ssize_t) >= sizeof(int) and Py_ReprEntr returns an int
........
r46548 | tim.peters | 2006-05-30 07:04:59 +0200 (Tue, 30 May 2006) | 3 lines
dict_print(): Explicitly narrow the return value
from a (possibly) wider variable.
........
r46549 | tim.peters | 2006-05-30 07:23:59 +0200 (Tue, 30 May 2006) | 5 lines
dict_print(): So that Neal & I don't spend the rest of
our lives taking turns rewriting code that works ;-),
get rid of casting illusions by declaring a new variable
with the obvious type.
........
r46550 | georg.brandl | 2006-05-30 09:04:55 +0200 (Tue, 30 May 2006) | 3 lines
Restore exception pickle support. #1497319.
........
r46551 | georg.brandl | 2006-05-30 09:13:29 +0200 (Tue, 30 May 2006) | 3 lines
Add a test case for exception pickling. args is never NULL.
........
r46552 | neal.norwitz | 2006-05-30 09:21:10 +0200 (Tue, 30 May 2006) | 1 line
Don't fail if the (sub)pkgname already exist.
........
r46553 | georg.brandl | 2006-05-30 09:34:45 +0200 (Tue, 30 May 2006) | 3 lines
Disallow keyword args for exceptions.
........
r46554 | neal.norwitz | 2006-05-30 09:36:54 +0200 (Tue, 30 May 2006) | 5 lines
I'm impatient. I think this will fix a few more problems with the buildbots.
I'm not sure this is the best approach, but I can't think of anything better.
If this creates problems, feel free to revert, but I think it's safe and
should make things a little better.
........
r46555 | georg.brandl | 2006-05-30 10:17:00 +0200 (Tue, 30 May 2006) | 4 lines
Do the check for no keyword arguments in __init__ so that
subclasses of Exception can be supplied keyword args
........
r46556 | georg.brandl | 2006-05-30 10:47:19 +0200 (Tue, 30 May 2006) | 3 lines
Convert test_exceptions to unittest.
........
r46557 | andrew.kuchling | 2006-05-30 14:52:01 +0200 (Tue, 30 May 2006) | 1 line
Add SoC name, and reorganize this section a bit
........
r46559 | tim.peters | 2006-05-30 17:53:34 +0200 (Tue, 30 May 2006) | 11 lines
PyLong_FromString(): Continued fraction analysis (explained in
a new comment) suggests there are almost certainly large input
integers in all non-binary input bases for which one Python digit
too few is initally allocated to hold the final result. Instead
of assert-failing when that happens, allocate more space. Alas,
I estimate it would take a few days to find a specific such case,
so this isn't backed up by a new test (not to mention that such
a case may take hours to run, since conversion time is quadratic
in the number of digits, and preliminary attempts suggested that
the smallest such inputs contain at least a million digits).
........
r46560 | fredrik.lundh | 2006-05-30 19:11:48 +0200 (Tue, 30 May 2006) | 3 lines
changed find/rfind to return -1 for matches outside the source string
........
r46561 | bob.ippolito | 2006-05-30 19:37:54 +0200 (Tue, 30 May 2006) | 1 line
Change wrapping terminology to overflow masking
........
r46562 | fredrik.lundh | 2006-05-30 19:39:58 +0200 (Tue, 30 May 2006) | 3 lines
changed count to return 0 for slices outside the source string
........
r46568 | tim.peters | 2006-05-31 01:28:02 +0200 (Wed, 31 May 2006) | 2 lines
Whitespace normalization.
........
r46569 | brett.cannon | 2006-05-31 04:19:54 +0200 (Wed, 31 May 2006) | 5 lines
Clarify wording on default values for strptime(); defaults are used when better
values cannot be inferred.
Closes bug #1496315.
........
r46572 | neal.norwitz | 2006-05-31 09:43:27 +0200 (Wed, 31 May 2006) | 1 line
Calculate smallest properly (it was off by one) and use proper ssize_t types for Win64
........
r46573 | neal.norwitz | 2006-05-31 10:01:08 +0200 (Wed, 31 May 2006) | 1 line
Revert last checkin, it is better to do make distclean
........
r46574 | neal.norwitz | 2006-05-31 11:02:44 +0200 (Wed, 31 May 2006) | 3 lines
On 64-bit platforms running test_struct after test_tarfile would fail
since the deprecation warning wouldn't be raised.
........
r46575 | thomas.heller | 2006-05-31 13:37:58 +0200 (Wed, 31 May 2006) | 3 lines
PyTuple_Pack is not available in Python 2.3, but ctypes must stay
compatible with that.
........
r46576 | andrew.kuchling | 2006-05-31 15:18:56 +0200 (Wed, 31 May 2006) | 1 line
'functional' module was renamed to 'functools'
........
r46577 | kristjan.jonsson | 2006-05-31 15:35:41 +0200 (Wed, 31 May 2006) | 1 line
Fixup the PCBuild8 project directory. exceptions.c have moved to Objects, and the functionalmodule.c has been replaced with _functoolsmodule.c. Other minor changes to .vcproj files and .sln to fix compilation
........
r46578 | andrew.kuchling | 2006-05-31 16:08:48 +0200 (Wed, 31 May 2006) | 15 lines
[Bug #1473048]
SimpleXMLRPCServer and DocXMLRPCServer don't look at
the path of the HTTP request at all; you can POST or
GET from / or /RPC2 or /blahblahblah with the same results.
Security scanners that look for /cgi-bin/phf will therefore report
lots of vulnerabilities.
Fix: add a .rpc_paths attribute to the SimpleXMLRPCServer class,
and report a 404 error if the path isn't on the allowed list.
Possibly-controversial aspect of this change: the default makes only
'/' and '/RPC2' legal. Maybe this will break people's applications
(though I doubt it). We could just set the default to an empty tuple,
which would exactly match the current behaviour.
........
r46579 | andrew.kuchling | 2006-05-31 16:12:47 +0200 (Wed, 31 May 2006) | 1 line
Mention SimpleXMLRPCServer change
........
r46580 | tim.peters | 2006-05-31 16:28:07 +0200 (Wed, 31 May 2006) | 2 lines
Trimmed trailing whitespace.
........
r46581 | tim.peters | 2006-05-31 17:33:22 +0200 (Wed, 31 May 2006) | 4 lines
_range_error(): Speed and simplify (there's no real need for
loops here). Assert that size_t is actually big enough, and
that f->size is at least one. Wrap a long line.
........
r46582 | tim.peters | 2006-05-31 17:34:37 +0200 (Wed, 31 May 2006) | 2 lines
Repaired error in new comment.
........
r46584 | neal.norwitz | 2006-06-01 07:32:49 +0200 (Thu, 01 Jun 2006) | 4 lines
Remove ; at end of macro. There was a compiler recently that warned
about extra semi-colons. It may have been the HP C compiler.
This file will trigger a bunch of those warnings now.
........
r46585 | georg.brandl | 2006-06-01 08:39:19 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly unpickle 2.4 exceptions via __setstate__ (patch #1498571)
........
r46586 | georg.brandl | 2006-06-01 10:27:32 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly allocate complex types with tp_alloc. (bug #1498638)
........
r46587 | georg.brandl | 2006-06-01 14:30:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Correctly dispatch Faults in loads (patch #1498627)
........
r46588 | georg.brandl | 2006-06-01 15:00:49 +0200 (Thu, 01 Jun 2006) | 3 lines
Some code style tweaks, and remove apply.
........
r46589 | armin.rigo | 2006-06-01 15:19:12 +0200 (Thu, 01 Jun 2006) | 5 lines
[ 1497053 ] Let dicts propagate the exceptions in user __eq__().
[ 1456209 ] dictresize() vulnerability ( <- backport candidate ).
........
r46590 | tim.peters | 2006-06-01 15:41:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Whitespace normalization.
........
r46591 | tim.peters | 2006-06-01 15:49:23 +0200 (Thu, 01 Jun 2006) | 2 lines
Record bugs 1275608 and 1456209 as being fixed.
........
r46592 | tim.peters | 2006-06-01 15:56:26 +0200 (Thu, 01 Jun 2006) | 5 lines
Re-enable a new empty-string test added during the NFS sprint,
but disabled then because str and unicode strings gave different
results. The implementations were repaired later during the
sprint, but the new test remained disabled.
........
r46594 | tim.peters | 2006-06-01 17:50:44 +0200 (Thu, 01 Jun 2006) | 7 lines
Armin committed his patch while I was reviewing it (I'm sure
he didn't know this), so merged in some changes I made during
review. Nothing material apart from changing a new `mask` local
from int to Py_ssize_t. Mostly this is repairing comments that
were made incorrect, and adding new comments. Also a few
minor code rewrites for clarity or helpful succinctness.
........
r46599 | neal.norwitz | 2006-06-02 06:45:53 +0200 (Fri, 02 Jun 2006) | 1 line
Convert docstrings to comments so regrtest -v prints method names
........
r46600 | neal.norwitz | 2006-06-02 06:50:49 +0200 (Fri, 02 Jun 2006) | 2 lines
Fix memory leak found by valgrind.
........
r46601 | neal.norwitz | 2006-06-02 06:54:52 +0200 (Fri, 02 Jun 2006) | 1 line
More memory leaks from valgrind
........
r46602 | neal.norwitz | 2006-06-02 08:23:00 +0200 (Fri, 02 Jun 2006) | 11 lines
Patch #1357836:
Prevent an invalid memory read from test_coding in case the done flag is set.
In that case, the loop isn't entered. I wonder if rather than setting
the done flag in the cases before the loop, if they should just exit early.
This code looks like it should be refactored.
Backport candidate (also the early break above if decoding_fgets fails)
........
r46603 | martin.blais | 2006-06-02 15:03:43 +0200 (Fri, 02 Jun 2006) | 1 line
Fixed struct test to not use unittest.
........
r46605 | tim.peters | 2006-06-03 01:22:51 +0200 (Sat, 03 Jun 2006) | 10 lines
pprint functions used to sort a dict (by key) if and only if
the output required more than one line. "Small" dicts got
displayed in seemingly random order (the hash-induced order
produced by dict.__repr__). None of this was documented.
Now pprint functions always sort dicts by key, and the docs
promise it.
This was proposed and agreed to during the PyCon 2006 core
sprint -- I just didn't have time for it before now.
........
2006-06-08 11:42:34 -03:00
|
|
|
xmlparse_GetBase(xmlparseobject *self, PyObject *unused)
|
2000-07-12 01:49:00 -03:00
|
|
|
{
|
|
|
|
return Py_BuildValue("z", XML_GetBase(self->itself));
|
2000-03-31 11:43:31 -04:00
|
|
|
}
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(xmlparse_GetInputContext__doc__,
|
2001-02-14 14:29:45 -04:00
|
|
|
"GetInputContext() -> string\n\
|
|
|
|
Return the untranslated text of the input that caused the current event.\n\
|
|
|
|
If the event was generated by a large amount of text (such as a start tag\n\
|
2002-06-13 17:33:02 -03:00
|
|
|
for an element with many attributes), not all of the text may be available.");
|
2001-02-14 14:29:45 -04:00
|
|
|
|
|
|
|
static PyObject *
|
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
merge in bad ways, so I'll have to merge that extra-carefully (probably manually.)
Merged revisions 46495-46605 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r46495 | tim.peters | 2006-05-28 03:52:38 +0200 (Sun, 28 May 2006) | 2 lines
Added missing svn:eol-style property to text files.
........
r46497 | tim.peters | 2006-05-28 12:41:29 +0200 (Sun, 28 May 2006) | 3 lines
PyErr_Display(), PyErr_WriteUnraisable(): Coverity found a cut-and-paste
bug in both: `className` was referenced before being checked for NULL.
........
r46499 | fredrik.lundh | 2006-05-28 14:06:46 +0200 (Sun, 28 May 2006) | 5 lines
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
and use it for string copy operations. this gives a 20% speedup on some
string benchmarks.
........
r46501 | michael.hudson | 2006-05-28 17:51:40 +0200 (Sun, 28 May 2006) | 26 lines
Quality control, meet exceptions.c.
Fix a number of problems with the need for speed code:
One is doing this sort of thing:
Py_DECREF(self->field);
self->field = newval;
Py_INCREF(self->field);
without being very sure that self->field doesn't start with a
value that has a __del__, because that almost certainly can lead
to segfaults.
As self->args is constrained to be an exact tuple we may as well
exploit this fact consistently. This leads to quite a lot of
simplification (and, hey, probably better performance).
Add some error checking in places lacking it.
Fix some rather strange indentation in the Unicode code.
Delete some trailing whitespace.
More to come, I haven't fixed all the reference leaks yet...
........
r46502 | george.yoshida | 2006-05-28 18:39:09 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1080727: add "encoding" parameter to doctest.DocFileSuite
Contributed by Bjorn Tillenius.
........
r46503 | martin.v.loewis | 2006-05-28 18:57:38 +0200 (Sun, 28 May 2006) | 4 lines
Rest of patch #1490384: Commit icon source, remove
claim that Erik von Blokland is the author of the
installer picture.
........
r46504 | michael.hudson | 2006-05-28 19:40:29 +0200 (Sun, 28 May 2006) | 16 lines
Quality control, meet exceptions.c, round two.
Make some functions that should have been static static.
Fix a bunch of refleaks by fixing the definition of
MiddlingExtendsException.
Remove all the __new__ implementations apart from
BaseException_new. Rewrite most code that needs it to cope with
NULL fields (such code could get excercised anyway, the
__new__-removal just makes it more likely). This involved
editing the code for WindowsError, which I can't test.
This fixes all the refleaks in at least the start of a regrtest
-R :: run.
........
r46505 | marc-andre.lemburg | 2006-05-28 19:46:58 +0200 (Sun, 28 May 2006) | 10 lines
Initial version of systimes - a module to provide platform dependent
performance measurements.
The module is currently just a proof-of-concept implementation, but
will integrated into pybench once it is stable enough.
License: pybench license.
Author: Marc-Andre Lemburg.
........
r46507 | armin.rigo | 2006-05-28 21:13:17 +0200 (Sun, 28 May 2006) | 15 lines
("Forward-port" of r46506)
Remove various dependencies on dictionary order in the standard library
tests, and one (clearly an oversight, potentially critical) in the
standard library itself - base64.py.
Remaining open issues:
* test_extcall is an output test, messy to make robust
* tarfile.py has a potential bug here, but I'm not familiar
enough with this code. Filed in as SF bug #1496501.
* urllib2.HTTPPasswordMgr() returns a random result if there is more
than one matching root path. I'm asking python-dev for
clarification...
........
r46508 | georg.brandl | 2006-05-28 22:11:45 +0200 (Sun, 28 May 2006) | 4 lines
The empty string is a valid import path.
(fixes #1496539)
........
r46509 | georg.brandl | 2006-05-28 22:23:12 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1496206: urllib2 PasswordMgr ./. default ports
........
r46510 | georg.brandl | 2006-05-28 22:57:09 +0200 (Sun, 28 May 2006) | 3 lines
Fix refleaks in UnicodeError get and set methods.
........
r46511 | michael.hudson | 2006-05-28 23:19:03 +0200 (Sun, 28 May 2006) | 3 lines
use the UnicodeError traversal and clearing functions in UnicodeError
subclasses.
........
r46512 | thomas.wouters | 2006-05-28 23:32:12 +0200 (Sun, 28 May 2006) | 4 lines
Make last patch valid C89 so Windows compilers can deal with it.
........
r46513 | georg.brandl | 2006-05-28 23:42:54 +0200 (Sun, 28 May 2006) | 3 lines
Fix ref-antileak in _struct.c which eventually lead to deallocating None.
........
r46514 | georg.brandl | 2006-05-28 23:57:35 +0200 (Sun, 28 May 2006) | 4 lines
Correct None refcount issue in Mac modules. (Are they
still used?)
........
r46515 | armin.rigo | 2006-05-29 00:07:08 +0200 (Mon, 29 May 2006) | 3 lines
A clearer error message when passing -R to regrtest.py with
release builds of Python.
........
r46516 | georg.brandl | 2006-05-29 00:14:04 +0200 (Mon, 29 May 2006) | 3 lines
Fix C function calling conventions in _sre module.
........
r46517 | georg.brandl | 2006-05-29 00:34:51 +0200 (Mon, 29 May 2006) | 3 lines
Convert audioop over to METH_VARARGS.
........
r46518 | georg.brandl | 2006-05-29 00:38:57 +0200 (Mon, 29 May 2006) | 3 lines
METH_NOARGS functions do get called with two args.
........
r46519 | georg.brandl | 2006-05-29 11:46:51 +0200 (Mon, 29 May 2006) | 4 lines
Fix refleak in socketmodule. Replace bogus Py_BuildValue calls.
Fix refleak in exceptions.
........
r46520 | nick.coghlan | 2006-05-29 14:43:05 +0200 (Mon, 29 May 2006) | 7 lines
Apply modified version of Collin Winter's patch #1478788
Renames functional extension module to _functools and adds a Python
functools module so that utility functions like update_wrapper can be
added easily.
........
r46522 | georg.brandl | 2006-05-29 15:53:16 +0200 (Mon, 29 May 2006) | 3 lines
Convert fmmodule to METH_VARARGS.
........
r46523 | georg.brandl | 2006-05-29 16:13:21 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494605.
........
r46524 | georg.brandl | 2006-05-29 16:28:05 +0200 (Mon, 29 May 2006) | 3 lines
Handle PyMem_Malloc failure in pystrtod.c. Closes #1494671.
........
r46525 | georg.brandl | 2006-05-29 16:33:55 +0200 (Mon, 29 May 2006) | 3 lines
Fix compiler warning.
........
r46526 | georg.brandl | 2006-05-29 16:39:00 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494787 (pyclbr counts whitespace as superclass name)
........
r46527 | bob.ippolito | 2006-05-29 17:47:29 +0200 (Mon, 29 May 2006) | 1 line
simplify the struct code a bit (no functional changes)
........
r46528 | armin.rigo | 2006-05-29 19:59:47 +0200 (Mon, 29 May 2006) | 2 lines
Silence a warning.
........
r46529 | georg.brandl | 2006-05-29 21:39:45 +0200 (Mon, 29 May 2006) | 3 lines
Correct some value converting strangenesses.
........
r46530 | nick.coghlan | 2006-05-29 22:27:44 +0200 (Mon, 29 May 2006) | 1 line
When adding a module like functools, it helps to let SVN know about the file.
........
r46531 | georg.brandl | 2006-05-29 22:52:54 +0200 (Mon, 29 May 2006) | 4 lines
Patches #1497027 and #972322: try HTTP digest auth first,
and watch out for handler name collisions.
........
r46532 | georg.brandl | 2006-05-29 22:57:01 +0200 (Mon, 29 May 2006) | 3 lines
Add News entry for last commit.
........
r46533 | georg.brandl | 2006-05-29 23:04:52 +0200 (Mon, 29 May 2006) | 4 lines
Make use of METH_O and METH_NOARGS where possible.
Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
........
r46534 | georg.brandl | 2006-05-29 23:58:42 +0200 (Mon, 29 May 2006) | 3 lines
Convert more modules to METH_VARARGS.
........
r46535 | georg.brandl | 2006-05-30 00:00:30 +0200 (Tue, 30 May 2006) | 3 lines
Whoops.
........
r46536 | fredrik.lundh | 2006-05-30 00:42:07 +0200 (Tue, 30 May 2006) | 4 lines
fixed "abc".count("", 100) == -96 error (hopefully, nobody's relying on
the current behaviour ;-)
........
r46537 | bob.ippolito | 2006-05-30 00:55:48 +0200 (Tue, 30 May 2006) | 1 line
struct: modulo math plus warning on all endian-explicit formats for compatibility with older struct usage (ugly)
........
r46539 | bob.ippolito | 2006-05-30 02:26:01 +0200 (Tue, 30 May 2006) | 1 line
Add a length check to aifc to ensure it doesn't write a bogus file
........
r46540 | tim.peters | 2006-05-30 04:25:25 +0200 (Tue, 30 May 2006) | 10 lines
deprecated_err(): Stop bizarre warning messages when the tests
are run in the order:
test_genexps (or any other doctest-based test)
test_struct
test_doctest
The `warnings` module needs an advertised way to save/restore
its internal filter list.
........
r46541 | tim.peters | 2006-05-30 04:26:46 +0200 (Tue, 30 May 2006) | 2 lines
Whitespace normalization.
........
r46542 | tim.peters | 2006-05-30 04:30:30 +0200 (Tue, 30 May 2006) | 2 lines
Set a binary svn:mime-type property on this UTF-8 encoded file.
........
r46543 | neal.norwitz | 2006-05-30 05:18:50 +0200 (Tue, 30 May 2006) | 1 line
Simplify further by using AddStringConstant
........
r46544 | tim.peters | 2006-05-30 06:16:25 +0200 (Tue, 30 May 2006) | 6 lines
Convert relevant dict internals to Py_ssize_t.
I don't have a box with nearly enough RAM, or an OS,
that could get close to tickling this, though (requires
a dict w/ at least 2**31 entries).
........
r46545 | neal.norwitz | 2006-05-30 06:19:21 +0200 (Tue, 30 May 2006) | 1 line
Remove stray | in comment
........
r46546 | neal.norwitz | 2006-05-30 06:25:05 +0200 (Tue, 30 May 2006) | 1 line
Use Py_SAFE_DOWNCAST for safety. Fix format strings. Remove 2 more stray | in comment
........
r46547 | neal.norwitz | 2006-05-30 06:43:23 +0200 (Tue, 30 May 2006) | 1 line
No DOWNCAST is required since sizeof(Py_ssize_t) >= sizeof(int) and Py_ReprEntr returns an int
........
r46548 | tim.peters | 2006-05-30 07:04:59 +0200 (Tue, 30 May 2006) | 3 lines
dict_print(): Explicitly narrow the return value
from a (possibly) wider variable.
........
r46549 | tim.peters | 2006-05-30 07:23:59 +0200 (Tue, 30 May 2006) | 5 lines
dict_print(): So that Neal & I don't spend the rest of
our lives taking turns rewriting code that works ;-),
get rid of casting illusions by declaring a new variable
with the obvious type.
........
r46550 | georg.brandl | 2006-05-30 09:04:55 +0200 (Tue, 30 May 2006) | 3 lines
Restore exception pickle support. #1497319.
........
r46551 | georg.brandl | 2006-05-30 09:13:29 +0200 (Tue, 30 May 2006) | 3 lines
Add a test case for exception pickling. args is never NULL.
........
r46552 | neal.norwitz | 2006-05-30 09:21:10 +0200 (Tue, 30 May 2006) | 1 line
Don't fail if the (sub)pkgname already exist.
........
r46553 | georg.brandl | 2006-05-30 09:34:45 +0200 (Tue, 30 May 2006) | 3 lines
Disallow keyword args for exceptions.
........
r46554 | neal.norwitz | 2006-05-30 09:36:54 +0200 (Tue, 30 May 2006) | 5 lines
I'm impatient. I think this will fix a few more problems with the buildbots.
I'm not sure this is the best approach, but I can't think of anything better.
If this creates problems, feel free to revert, but I think it's safe and
should make things a little better.
........
r46555 | georg.brandl | 2006-05-30 10:17:00 +0200 (Tue, 30 May 2006) | 4 lines
Do the check for no keyword arguments in __init__ so that
subclasses of Exception can be supplied keyword args
........
r46556 | georg.brandl | 2006-05-30 10:47:19 +0200 (Tue, 30 May 2006) | 3 lines
Convert test_exceptions to unittest.
........
r46557 | andrew.kuchling | 2006-05-30 14:52:01 +0200 (Tue, 30 May 2006) | 1 line
Add SoC name, and reorganize this section a bit
........
r46559 | tim.peters | 2006-05-30 17:53:34 +0200 (Tue, 30 May 2006) | 11 lines
PyLong_FromString(): Continued fraction analysis (explained in
a new comment) suggests there are almost certainly large input
integers in all non-binary input bases for which one Python digit
too few is initally allocated to hold the final result. Instead
of assert-failing when that happens, allocate more space. Alas,
I estimate it would take a few days to find a specific such case,
so this isn't backed up by a new test (not to mention that such
a case may take hours to run, since conversion time is quadratic
in the number of digits, and preliminary attempts suggested that
the smallest such inputs contain at least a million digits).
........
r46560 | fredrik.lundh | 2006-05-30 19:11:48 +0200 (Tue, 30 May 2006) | 3 lines
changed find/rfind to return -1 for matches outside the source string
........
r46561 | bob.ippolito | 2006-05-30 19:37:54 +0200 (Tue, 30 May 2006) | 1 line
Change wrapping terminology to overflow masking
........
r46562 | fredrik.lundh | 2006-05-30 19:39:58 +0200 (Tue, 30 May 2006) | 3 lines
changed count to return 0 for slices outside the source string
........
r46568 | tim.peters | 2006-05-31 01:28:02 +0200 (Wed, 31 May 2006) | 2 lines
Whitespace normalization.
........
r46569 | brett.cannon | 2006-05-31 04:19:54 +0200 (Wed, 31 May 2006) | 5 lines
Clarify wording on default values for strptime(); defaults are used when better
values cannot be inferred.
Closes bug #1496315.
........
r46572 | neal.norwitz | 2006-05-31 09:43:27 +0200 (Wed, 31 May 2006) | 1 line
Calculate smallest properly (it was off by one) and use proper ssize_t types for Win64
........
r46573 | neal.norwitz | 2006-05-31 10:01:08 +0200 (Wed, 31 May 2006) | 1 line
Revert last checkin, it is better to do make distclean
........
r46574 | neal.norwitz | 2006-05-31 11:02:44 +0200 (Wed, 31 May 2006) | 3 lines
On 64-bit platforms running test_struct after test_tarfile would fail
since the deprecation warning wouldn't be raised.
........
r46575 | thomas.heller | 2006-05-31 13:37:58 +0200 (Wed, 31 May 2006) | 3 lines
PyTuple_Pack is not available in Python 2.3, but ctypes must stay
compatible with that.
........
r46576 | andrew.kuchling | 2006-05-31 15:18:56 +0200 (Wed, 31 May 2006) | 1 line
'functional' module was renamed to 'functools'
........
r46577 | kristjan.jonsson | 2006-05-31 15:35:41 +0200 (Wed, 31 May 2006) | 1 line
Fixup the PCBuild8 project directory. exceptions.c have moved to Objects, and the functionalmodule.c has been replaced with _functoolsmodule.c. Other minor changes to .vcproj files and .sln to fix compilation
........
r46578 | andrew.kuchling | 2006-05-31 16:08:48 +0200 (Wed, 31 May 2006) | 15 lines
[Bug #1473048]
SimpleXMLRPCServer and DocXMLRPCServer don't look at
the path of the HTTP request at all; you can POST or
GET from / or /RPC2 or /blahblahblah with the same results.
Security scanners that look for /cgi-bin/phf will therefore report
lots of vulnerabilities.
Fix: add a .rpc_paths attribute to the SimpleXMLRPCServer class,
and report a 404 error if the path isn't on the allowed list.
Possibly-controversial aspect of this change: the default makes only
'/' and '/RPC2' legal. Maybe this will break people's applications
(though I doubt it). We could just set the default to an empty tuple,
which would exactly match the current behaviour.
........
r46579 | andrew.kuchling | 2006-05-31 16:12:47 +0200 (Wed, 31 May 2006) | 1 line
Mention SimpleXMLRPCServer change
........
r46580 | tim.peters | 2006-05-31 16:28:07 +0200 (Wed, 31 May 2006) | 2 lines
Trimmed trailing whitespace.
........
r46581 | tim.peters | 2006-05-31 17:33:22 +0200 (Wed, 31 May 2006) | 4 lines
_range_error(): Speed and simplify (there's no real need for
loops here). Assert that size_t is actually big enough, and
that f->size is at least one. Wrap a long line.
........
r46582 | tim.peters | 2006-05-31 17:34:37 +0200 (Wed, 31 May 2006) | 2 lines
Repaired error in new comment.
........
r46584 | neal.norwitz | 2006-06-01 07:32:49 +0200 (Thu, 01 Jun 2006) | 4 lines
Remove ; at end of macro. There was a compiler recently that warned
about extra semi-colons. It may have been the HP C compiler.
This file will trigger a bunch of those warnings now.
........
r46585 | georg.brandl | 2006-06-01 08:39:19 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly unpickle 2.4 exceptions via __setstate__ (patch #1498571)
........
r46586 | georg.brandl | 2006-06-01 10:27:32 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly allocate complex types with tp_alloc. (bug #1498638)
........
r46587 | georg.brandl | 2006-06-01 14:30:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Correctly dispatch Faults in loads (patch #1498627)
........
r46588 | georg.brandl | 2006-06-01 15:00:49 +0200 (Thu, 01 Jun 2006) | 3 lines
Some code style tweaks, and remove apply.
........
r46589 | armin.rigo | 2006-06-01 15:19:12 +0200 (Thu, 01 Jun 2006) | 5 lines
[ 1497053 ] Let dicts propagate the exceptions in user __eq__().
[ 1456209 ] dictresize() vulnerability ( <- backport candidate ).
........
r46590 | tim.peters | 2006-06-01 15:41:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Whitespace normalization.
........
r46591 | tim.peters | 2006-06-01 15:49:23 +0200 (Thu, 01 Jun 2006) | 2 lines
Record bugs 1275608 and 1456209 as being fixed.
........
r46592 | tim.peters | 2006-06-01 15:56:26 +0200 (Thu, 01 Jun 2006) | 5 lines
Re-enable a new empty-string test added during the NFS sprint,
but disabled then because str and unicode strings gave different
results. The implementations were repaired later during the
sprint, but the new test remained disabled.
........
r46594 | tim.peters | 2006-06-01 17:50:44 +0200 (Thu, 01 Jun 2006) | 7 lines
Armin committed his patch while I was reviewing it (I'm sure
he didn't know this), so merged in some changes I made during
review. Nothing material apart from changing a new `mask` local
from int to Py_ssize_t. Mostly this is repairing comments that
were made incorrect, and adding new comments. Also a few
minor code rewrites for clarity or helpful succinctness.
........
r46599 | neal.norwitz | 2006-06-02 06:45:53 +0200 (Fri, 02 Jun 2006) | 1 line
Convert docstrings to comments so regrtest -v prints method names
........
r46600 | neal.norwitz | 2006-06-02 06:50:49 +0200 (Fri, 02 Jun 2006) | 2 lines
Fix memory leak found by valgrind.
........
r46601 | neal.norwitz | 2006-06-02 06:54:52 +0200 (Fri, 02 Jun 2006) | 1 line
More memory leaks from valgrind
........
r46602 | neal.norwitz | 2006-06-02 08:23:00 +0200 (Fri, 02 Jun 2006) | 11 lines
Patch #1357836:
Prevent an invalid memory read from test_coding in case the done flag is set.
In that case, the loop isn't entered. I wonder if rather than setting
the done flag in the cases before the loop, if they should just exit early.
This code looks like it should be refactored.
Backport candidate (also the early break above if decoding_fgets fails)
........
r46603 | martin.blais | 2006-06-02 15:03:43 +0200 (Fri, 02 Jun 2006) | 1 line
Fixed struct test to not use unittest.
........
r46605 | tim.peters | 2006-06-03 01:22:51 +0200 (Sat, 03 Jun 2006) | 10 lines
pprint functions used to sort a dict (by key) if and only if
the output required more than one line. "Small" dicts got
displayed in seemingly random order (the hash-induced order
produced by dict.__repr__). None of this was documented.
Now pprint functions always sort dicts by key, and the docs
promise it.
This was proposed and agreed to during the PyCon 2006 core
sprint -- I just didn't have time for it before now.
........
2006-06-08 11:42:34 -03:00
|
|
|
xmlparse_GetInputContext(xmlparseobject *self, PyObject *unused)
|
2001-02-14 14:29:45 -04:00
|
|
|
{
|
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
merge in bad ways, so I'll have to merge that extra-carefully (probably manually.)
Merged revisions 46495-46605 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r46495 | tim.peters | 2006-05-28 03:52:38 +0200 (Sun, 28 May 2006) | 2 lines
Added missing svn:eol-style property to text files.
........
r46497 | tim.peters | 2006-05-28 12:41:29 +0200 (Sun, 28 May 2006) | 3 lines
PyErr_Display(), PyErr_WriteUnraisable(): Coverity found a cut-and-paste
bug in both: `className` was referenced before being checked for NULL.
........
r46499 | fredrik.lundh | 2006-05-28 14:06:46 +0200 (Sun, 28 May 2006) | 5 lines
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
and use it for string copy operations. this gives a 20% speedup on some
string benchmarks.
........
r46501 | michael.hudson | 2006-05-28 17:51:40 +0200 (Sun, 28 May 2006) | 26 lines
Quality control, meet exceptions.c.
Fix a number of problems with the need for speed code:
One is doing this sort of thing:
Py_DECREF(self->field);
self->field = newval;
Py_INCREF(self->field);
without being very sure that self->field doesn't start with a
value that has a __del__, because that almost certainly can lead
to segfaults.
As self->args is constrained to be an exact tuple we may as well
exploit this fact consistently. This leads to quite a lot of
simplification (and, hey, probably better performance).
Add some error checking in places lacking it.
Fix some rather strange indentation in the Unicode code.
Delete some trailing whitespace.
More to come, I haven't fixed all the reference leaks yet...
........
r46502 | george.yoshida | 2006-05-28 18:39:09 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1080727: add "encoding" parameter to doctest.DocFileSuite
Contributed by Bjorn Tillenius.
........
r46503 | martin.v.loewis | 2006-05-28 18:57:38 +0200 (Sun, 28 May 2006) | 4 lines
Rest of patch #1490384: Commit icon source, remove
claim that Erik von Blokland is the author of the
installer picture.
........
r46504 | michael.hudson | 2006-05-28 19:40:29 +0200 (Sun, 28 May 2006) | 16 lines
Quality control, meet exceptions.c, round two.
Make some functions that should have been static static.
Fix a bunch of refleaks by fixing the definition of
MiddlingExtendsException.
Remove all the __new__ implementations apart from
BaseException_new. Rewrite most code that needs it to cope with
NULL fields (such code could get excercised anyway, the
__new__-removal just makes it more likely). This involved
editing the code for WindowsError, which I can't test.
This fixes all the refleaks in at least the start of a regrtest
-R :: run.
........
r46505 | marc-andre.lemburg | 2006-05-28 19:46:58 +0200 (Sun, 28 May 2006) | 10 lines
Initial version of systimes - a module to provide platform dependent
performance measurements.
The module is currently just a proof-of-concept implementation, but
will integrated into pybench once it is stable enough.
License: pybench license.
Author: Marc-Andre Lemburg.
........
r46507 | armin.rigo | 2006-05-28 21:13:17 +0200 (Sun, 28 May 2006) | 15 lines
("Forward-port" of r46506)
Remove various dependencies on dictionary order in the standard library
tests, and one (clearly an oversight, potentially critical) in the
standard library itself - base64.py.
Remaining open issues:
* test_extcall is an output test, messy to make robust
* tarfile.py has a potential bug here, but I'm not familiar
enough with this code. Filed in as SF bug #1496501.
* urllib2.HTTPPasswordMgr() returns a random result if there is more
than one matching root path. I'm asking python-dev for
clarification...
........
r46508 | georg.brandl | 2006-05-28 22:11:45 +0200 (Sun, 28 May 2006) | 4 lines
The empty string is a valid import path.
(fixes #1496539)
........
r46509 | georg.brandl | 2006-05-28 22:23:12 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1496206: urllib2 PasswordMgr ./. default ports
........
r46510 | georg.brandl | 2006-05-28 22:57:09 +0200 (Sun, 28 May 2006) | 3 lines
Fix refleaks in UnicodeError get and set methods.
........
r46511 | michael.hudson | 2006-05-28 23:19:03 +0200 (Sun, 28 May 2006) | 3 lines
use the UnicodeError traversal and clearing functions in UnicodeError
subclasses.
........
r46512 | thomas.wouters | 2006-05-28 23:32:12 +0200 (Sun, 28 May 2006) | 4 lines
Make last patch valid C89 so Windows compilers can deal with it.
........
r46513 | georg.brandl | 2006-05-28 23:42:54 +0200 (Sun, 28 May 2006) | 3 lines
Fix ref-antileak in _struct.c which eventually lead to deallocating None.
........
r46514 | georg.brandl | 2006-05-28 23:57:35 +0200 (Sun, 28 May 2006) | 4 lines
Correct None refcount issue in Mac modules. (Are they
still used?)
........
r46515 | armin.rigo | 2006-05-29 00:07:08 +0200 (Mon, 29 May 2006) | 3 lines
A clearer error message when passing -R to regrtest.py with
release builds of Python.
........
r46516 | georg.brandl | 2006-05-29 00:14:04 +0200 (Mon, 29 May 2006) | 3 lines
Fix C function calling conventions in _sre module.
........
r46517 | georg.brandl | 2006-05-29 00:34:51 +0200 (Mon, 29 May 2006) | 3 lines
Convert audioop over to METH_VARARGS.
........
r46518 | georg.brandl | 2006-05-29 00:38:57 +0200 (Mon, 29 May 2006) | 3 lines
METH_NOARGS functions do get called with two args.
........
r46519 | georg.brandl | 2006-05-29 11:46:51 +0200 (Mon, 29 May 2006) | 4 lines
Fix refleak in socketmodule. Replace bogus Py_BuildValue calls.
Fix refleak in exceptions.
........
r46520 | nick.coghlan | 2006-05-29 14:43:05 +0200 (Mon, 29 May 2006) | 7 lines
Apply modified version of Collin Winter's patch #1478788
Renames functional extension module to _functools and adds a Python
functools module so that utility functions like update_wrapper can be
added easily.
........
r46522 | georg.brandl | 2006-05-29 15:53:16 +0200 (Mon, 29 May 2006) | 3 lines
Convert fmmodule to METH_VARARGS.
........
r46523 | georg.brandl | 2006-05-29 16:13:21 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494605.
........
r46524 | georg.brandl | 2006-05-29 16:28:05 +0200 (Mon, 29 May 2006) | 3 lines
Handle PyMem_Malloc failure in pystrtod.c. Closes #1494671.
........
r46525 | georg.brandl | 2006-05-29 16:33:55 +0200 (Mon, 29 May 2006) | 3 lines
Fix compiler warning.
........
r46526 | georg.brandl | 2006-05-29 16:39:00 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494787 (pyclbr counts whitespace as superclass name)
........
r46527 | bob.ippolito | 2006-05-29 17:47:29 +0200 (Mon, 29 May 2006) | 1 line
simplify the struct code a bit (no functional changes)
........
r46528 | armin.rigo | 2006-05-29 19:59:47 +0200 (Mon, 29 May 2006) | 2 lines
Silence a warning.
........
r46529 | georg.brandl | 2006-05-29 21:39:45 +0200 (Mon, 29 May 2006) | 3 lines
Correct some value converting strangenesses.
........
r46530 | nick.coghlan | 2006-05-29 22:27:44 +0200 (Mon, 29 May 2006) | 1 line
When adding a module like functools, it helps to let SVN know about the file.
........
r46531 | georg.brandl | 2006-05-29 22:52:54 +0200 (Mon, 29 May 2006) | 4 lines
Patches #1497027 and #972322: try HTTP digest auth first,
and watch out for handler name collisions.
........
r46532 | georg.brandl | 2006-05-29 22:57:01 +0200 (Mon, 29 May 2006) | 3 lines
Add News entry for last commit.
........
r46533 | georg.brandl | 2006-05-29 23:04:52 +0200 (Mon, 29 May 2006) | 4 lines
Make use of METH_O and METH_NOARGS where possible.
Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
........
r46534 | georg.brandl | 2006-05-29 23:58:42 +0200 (Mon, 29 May 2006) | 3 lines
Convert more modules to METH_VARARGS.
........
r46535 | georg.brandl | 2006-05-30 00:00:30 +0200 (Tue, 30 May 2006) | 3 lines
Whoops.
........
r46536 | fredrik.lundh | 2006-05-30 00:42:07 +0200 (Tue, 30 May 2006) | 4 lines
fixed "abc".count("", 100) == -96 error (hopefully, nobody's relying on
the current behaviour ;-)
........
r46537 | bob.ippolito | 2006-05-30 00:55:48 +0200 (Tue, 30 May 2006) | 1 line
struct: modulo math plus warning on all endian-explicit formats for compatibility with older struct usage (ugly)
........
r46539 | bob.ippolito | 2006-05-30 02:26:01 +0200 (Tue, 30 May 2006) | 1 line
Add a length check to aifc to ensure it doesn't write a bogus file
........
r46540 | tim.peters | 2006-05-30 04:25:25 +0200 (Tue, 30 May 2006) | 10 lines
deprecated_err(): Stop bizarre warning messages when the tests
are run in the order:
test_genexps (or any other doctest-based test)
test_struct
test_doctest
The `warnings` module needs an advertised way to save/restore
its internal filter list.
........
r46541 | tim.peters | 2006-05-30 04:26:46 +0200 (Tue, 30 May 2006) | 2 lines
Whitespace normalization.
........
r46542 | tim.peters | 2006-05-30 04:30:30 +0200 (Tue, 30 May 2006) | 2 lines
Set a binary svn:mime-type property on this UTF-8 encoded file.
........
r46543 | neal.norwitz | 2006-05-30 05:18:50 +0200 (Tue, 30 May 2006) | 1 line
Simplify further by using AddStringConstant
........
r46544 | tim.peters | 2006-05-30 06:16:25 +0200 (Tue, 30 May 2006) | 6 lines
Convert relevant dict internals to Py_ssize_t.
I don't have a box with nearly enough RAM, or an OS,
that could get close to tickling this, though (requires
a dict w/ at least 2**31 entries).
........
r46545 | neal.norwitz | 2006-05-30 06:19:21 +0200 (Tue, 30 May 2006) | 1 line
Remove stray | in comment
........
r46546 | neal.norwitz | 2006-05-30 06:25:05 +0200 (Tue, 30 May 2006) | 1 line
Use Py_SAFE_DOWNCAST for safety. Fix format strings. Remove 2 more stray | in comment
........
r46547 | neal.norwitz | 2006-05-30 06:43:23 +0200 (Tue, 30 May 2006) | 1 line
No DOWNCAST is required since sizeof(Py_ssize_t) >= sizeof(int) and Py_ReprEntr returns an int
........
r46548 | tim.peters | 2006-05-30 07:04:59 +0200 (Tue, 30 May 2006) | 3 lines
dict_print(): Explicitly narrow the return value
from a (possibly) wider variable.
........
r46549 | tim.peters | 2006-05-30 07:23:59 +0200 (Tue, 30 May 2006) | 5 lines
dict_print(): So that Neal & I don't spend the rest of
our lives taking turns rewriting code that works ;-),
get rid of casting illusions by declaring a new variable
with the obvious type.
........
r46550 | georg.brandl | 2006-05-30 09:04:55 +0200 (Tue, 30 May 2006) | 3 lines
Restore exception pickle support. #1497319.
........
r46551 | georg.brandl | 2006-05-30 09:13:29 +0200 (Tue, 30 May 2006) | 3 lines
Add a test case for exception pickling. args is never NULL.
........
r46552 | neal.norwitz | 2006-05-30 09:21:10 +0200 (Tue, 30 May 2006) | 1 line
Don't fail if the (sub)pkgname already exist.
........
r46553 | georg.brandl | 2006-05-30 09:34:45 +0200 (Tue, 30 May 2006) | 3 lines
Disallow keyword args for exceptions.
........
r46554 | neal.norwitz | 2006-05-30 09:36:54 +0200 (Tue, 30 May 2006) | 5 lines
I'm impatient. I think this will fix a few more problems with the buildbots.
I'm not sure this is the best approach, but I can't think of anything better.
If this creates problems, feel free to revert, but I think it's safe and
should make things a little better.
........
r46555 | georg.brandl | 2006-05-30 10:17:00 +0200 (Tue, 30 May 2006) | 4 lines
Do the check for no keyword arguments in __init__ so that
subclasses of Exception can be supplied keyword args
........
r46556 | georg.brandl | 2006-05-30 10:47:19 +0200 (Tue, 30 May 2006) | 3 lines
Convert test_exceptions to unittest.
........
r46557 | andrew.kuchling | 2006-05-30 14:52:01 +0200 (Tue, 30 May 2006) | 1 line
Add SoC name, and reorganize this section a bit
........
r46559 | tim.peters | 2006-05-30 17:53:34 +0200 (Tue, 30 May 2006) | 11 lines
PyLong_FromString(): Continued fraction analysis (explained in
a new comment) suggests there are almost certainly large input
integers in all non-binary input bases for which one Python digit
too few is initally allocated to hold the final result. Instead
of assert-failing when that happens, allocate more space. Alas,
I estimate it would take a few days to find a specific such case,
so this isn't backed up by a new test (not to mention that such
a case may take hours to run, since conversion time is quadratic
in the number of digits, and preliminary attempts suggested that
the smallest such inputs contain at least a million digits).
........
r46560 | fredrik.lundh | 2006-05-30 19:11:48 +0200 (Tue, 30 May 2006) | 3 lines
changed find/rfind to return -1 for matches outside the source string
........
r46561 | bob.ippolito | 2006-05-30 19:37:54 +0200 (Tue, 30 May 2006) | 1 line
Change wrapping terminology to overflow masking
........
r46562 | fredrik.lundh | 2006-05-30 19:39:58 +0200 (Tue, 30 May 2006) | 3 lines
changed count to return 0 for slices outside the source string
........
r46568 | tim.peters | 2006-05-31 01:28:02 +0200 (Wed, 31 May 2006) | 2 lines
Whitespace normalization.
........
r46569 | brett.cannon | 2006-05-31 04:19:54 +0200 (Wed, 31 May 2006) | 5 lines
Clarify wording on default values for strptime(); defaults are used when better
values cannot be inferred.
Closes bug #1496315.
........
r46572 | neal.norwitz | 2006-05-31 09:43:27 +0200 (Wed, 31 May 2006) | 1 line
Calculate smallest properly (it was off by one) and use proper ssize_t types for Win64
........
r46573 | neal.norwitz | 2006-05-31 10:01:08 +0200 (Wed, 31 May 2006) | 1 line
Revert last checkin, it is better to do make distclean
........
r46574 | neal.norwitz | 2006-05-31 11:02:44 +0200 (Wed, 31 May 2006) | 3 lines
On 64-bit platforms running test_struct after test_tarfile would fail
since the deprecation warning wouldn't be raised.
........
r46575 | thomas.heller | 2006-05-31 13:37:58 +0200 (Wed, 31 May 2006) | 3 lines
PyTuple_Pack is not available in Python 2.3, but ctypes must stay
compatible with that.
........
r46576 | andrew.kuchling | 2006-05-31 15:18:56 +0200 (Wed, 31 May 2006) | 1 line
'functional' module was renamed to 'functools'
........
r46577 | kristjan.jonsson | 2006-05-31 15:35:41 +0200 (Wed, 31 May 2006) | 1 line
Fixup the PCBuild8 project directory. exceptions.c have moved to Objects, and the functionalmodule.c has been replaced with _functoolsmodule.c. Other minor changes to .vcproj files and .sln to fix compilation
........
r46578 | andrew.kuchling | 2006-05-31 16:08:48 +0200 (Wed, 31 May 2006) | 15 lines
[Bug #1473048]
SimpleXMLRPCServer and DocXMLRPCServer don't look at
the path of the HTTP request at all; you can POST or
GET from / or /RPC2 or /blahblahblah with the same results.
Security scanners that look for /cgi-bin/phf will therefore report
lots of vulnerabilities.
Fix: add a .rpc_paths attribute to the SimpleXMLRPCServer class,
and report a 404 error if the path isn't on the allowed list.
Possibly-controversial aspect of this change: the default makes only
'/' and '/RPC2' legal. Maybe this will break people's applications
(though I doubt it). We could just set the default to an empty tuple,
which would exactly match the current behaviour.
........
r46579 | andrew.kuchling | 2006-05-31 16:12:47 +0200 (Wed, 31 May 2006) | 1 line
Mention SimpleXMLRPCServer change
........
r46580 | tim.peters | 2006-05-31 16:28:07 +0200 (Wed, 31 May 2006) | 2 lines
Trimmed trailing whitespace.
........
r46581 | tim.peters | 2006-05-31 17:33:22 +0200 (Wed, 31 May 2006) | 4 lines
_range_error(): Speed and simplify (there's no real need for
loops here). Assert that size_t is actually big enough, and
that f->size is at least one. Wrap a long line.
........
r46582 | tim.peters | 2006-05-31 17:34:37 +0200 (Wed, 31 May 2006) | 2 lines
Repaired error in new comment.
........
r46584 | neal.norwitz | 2006-06-01 07:32:49 +0200 (Thu, 01 Jun 2006) | 4 lines
Remove ; at end of macro. There was a compiler recently that warned
about extra semi-colons. It may have been the HP C compiler.
This file will trigger a bunch of those warnings now.
........
r46585 | georg.brandl | 2006-06-01 08:39:19 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly unpickle 2.4 exceptions via __setstate__ (patch #1498571)
........
r46586 | georg.brandl | 2006-06-01 10:27:32 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly allocate complex types with tp_alloc. (bug #1498638)
........
r46587 | georg.brandl | 2006-06-01 14:30:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Correctly dispatch Faults in loads (patch #1498627)
........
r46588 | georg.brandl | 2006-06-01 15:00:49 +0200 (Thu, 01 Jun 2006) | 3 lines
Some code style tweaks, and remove apply.
........
r46589 | armin.rigo | 2006-06-01 15:19:12 +0200 (Thu, 01 Jun 2006) | 5 lines
[ 1497053 ] Let dicts propagate the exceptions in user __eq__().
[ 1456209 ] dictresize() vulnerability ( <- backport candidate ).
........
r46590 | tim.peters | 2006-06-01 15:41:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Whitespace normalization.
........
r46591 | tim.peters | 2006-06-01 15:49:23 +0200 (Thu, 01 Jun 2006) | 2 lines
Record bugs 1275608 and 1456209 as being fixed.
........
r46592 | tim.peters | 2006-06-01 15:56:26 +0200 (Thu, 01 Jun 2006) | 5 lines
Re-enable a new empty-string test added during the NFS sprint,
but disabled then because str and unicode strings gave different
results. The implementations were repaired later during the
sprint, but the new test remained disabled.
........
r46594 | tim.peters | 2006-06-01 17:50:44 +0200 (Thu, 01 Jun 2006) | 7 lines
Armin committed his patch while I was reviewing it (I'm sure
he didn't know this), so merged in some changes I made during
review. Nothing material apart from changing a new `mask` local
from int to Py_ssize_t. Mostly this is repairing comments that
were made incorrect, and adding new comments. Also a few
minor code rewrites for clarity or helpful succinctness.
........
r46599 | neal.norwitz | 2006-06-02 06:45:53 +0200 (Fri, 02 Jun 2006) | 1 line
Convert docstrings to comments so regrtest -v prints method names
........
r46600 | neal.norwitz | 2006-06-02 06:50:49 +0200 (Fri, 02 Jun 2006) | 2 lines
Fix memory leak found by valgrind.
........
r46601 | neal.norwitz | 2006-06-02 06:54:52 +0200 (Fri, 02 Jun 2006) | 1 line
More memory leaks from valgrind
........
r46602 | neal.norwitz | 2006-06-02 08:23:00 +0200 (Fri, 02 Jun 2006) | 11 lines
Patch #1357836:
Prevent an invalid memory read from test_coding in case the done flag is set.
In that case, the loop isn't entered. I wonder if rather than setting
the done flag in the cases before the loop, if they should just exit early.
This code looks like it should be refactored.
Backport candidate (also the early break above if decoding_fgets fails)
........
r46603 | martin.blais | 2006-06-02 15:03:43 +0200 (Fri, 02 Jun 2006) | 1 line
Fixed struct test to not use unittest.
........
r46605 | tim.peters | 2006-06-03 01:22:51 +0200 (Sat, 03 Jun 2006) | 10 lines
pprint functions used to sort a dict (by key) if and only if
the output required more than one line. "Small" dicts got
displayed in seemingly random order (the hash-induced order
produced by dict.__repr__). None of this was documented.
Now pprint functions always sort dicts by key, and the docs
promise it.
This was proposed and agreed to during the PyCon 2006 core
sprint -- I just didn't have time for it before now.
........
2006-06-08 11:42:34 -03:00
|
|
|
if (self->in_callback) {
|
|
|
|
int offset, size;
|
|
|
|
const char *buffer
|
|
|
|
= XML_GetInputContext(self->itself, &offset, &size);
|
|
|
|
|
|
|
|
if (buffer != NULL)
|
|
|
|
return PyString_FromStringAndSize(buffer + offset,
|
|
|
|
size - offset);
|
|
|
|
else
|
|
|
|
Py_RETURN_NONE;
|
2001-02-14 14:29:45 -04:00
|
|
|
}
|
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
merge in bad ways, so I'll have to merge that extra-carefully (probably manually.)
Merged revisions 46495-46605 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r46495 | tim.peters | 2006-05-28 03:52:38 +0200 (Sun, 28 May 2006) | 2 lines
Added missing svn:eol-style property to text files.
........
r46497 | tim.peters | 2006-05-28 12:41:29 +0200 (Sun, 28 May 2006) | 3 lines
PyErr_Display(), PyErr_WriteUnraisable(): Coverity found a cut-and-paste
bug in both: `className` was referenced before being checked for NULL.
........
r46499 | fredrik.lundh | 2006-05-28 14:06:46 +0200 (Sun, 28 May 2006) | 5 lines
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
and use it for string copy operations. this gives a 20% speedup on some
string benchmarks.
........
r46501 | michael.hudson | 2006-05-28 17:51:40 +0200 (Sun, 28 May 2006) | 26 lines
Quality control, meet exceptions.c.
Fix a number of problems with the need for speed code:
One is doing this sort of thing:
Py_DECREF(self->field);
self->field = newval;
Py_INCREF(self->field);
without being very sure that self->field doesn't start with a
value that has a __del__, because that almost certainly can lead
to segfaults.
As self->args is constrained to be an exact tuple we may as well
exploit this fact consistently. This leads to quite a lot of
simplification (and, hey, probably better performance).
Add some error checking in places lacking it.
Fix some rather strange indentation in the Unicode code.
Delete some trailing whitespace.
More to come, I haven't fixed all the reference leaks yet...
........
r46502 | george.yoshida | 2006-05-28 18:39:09 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1080727: add "encoding" parameter to doctest.DocFileSuite
Contributed by Bjorn Tillenius.
........
r46503 | martin.v.loewis | 2006-05-28 18:57:38 +0200 (Sun, 28 May 2006) | 4 lines
Rest of patch #1490384: Commit icon source, remove
claim that Erik von Blokland is the author of the
installer picture.
........
r46504 | michael.hudson | 2006-05-28 19:40:29 +0200 (Sun, 28 May 2006) | 16 lines
Quality control, meet exceptions.c, round two.
Make some functions that should have been static static.
Fix a bunch of refleaks by fixing the definition of
MiddlingExtendsException.
Remove all the __new__ implementations apart from
BaseException_new. Rewrite most code that needs it to cope with
NULL fields (such code could get excercised anyway, the
__new__-removal just makes it more likely). This involved
editing the code for WindowsError, which I can't test.
This fixes all the refleaks in at least the start of a regrtest
-R :: run.
........
r46505 | marc-andre.lemburg | 2006-05-28 19:46:58 +0200 (Sun, 28 May 2006) | 10 lines
Initial version of systimes - a module to provide platform dependent
performance measurements.
The module is currently just a proof-of-concept implementation, but
will integrated into pybench once it is stable enough.
License: pybench license.
Author: Marc-Andre Lemburg.
........
r46507 | armin.rigo | 2006-05-28 21:13:17 +0200 (Sun, 28 May 2006) | 15 lines
("Forward-port" of r46506)
Remove various dependencies on dictionary order in the standard library
tests, and one (clearly an oversight, potentially critical) in the
standard library itself - base64.py.
Remaining open issues:
* test_extcall is an output test, messy to make robust
* tarfile.py has a potential bug here, but I'm not familiar
enough with this code. Filed in as SF bug #1496501.
* urllib2.HTTPPasswordMgr() returns a random result if there is more
than one matching root path. I'm asking python-dev for
clarification...
........
r46508 | georg.brandl | 2006-05-28 22:11:45 +0200 (Sun, 28 May 2006) | 4 lines
The empty string is a valid import path.
(fixes #1496539)
........
r46509 | georg.brandl | 2006-05-28 22:23:12 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1496206: urllib2 PasswordMgr ./. default ports
........
r46510 | georg.brandl | 2006-05-28 22:57:09 +0200 (Sun, 28 May 2006) | 3 lines
Fix refleaks in UnicodeError get and set methods.
........
r46511 | michael.hudson | 2006-05-28 23:19:03 +0200 (Sun, 28 May 2006) | 3 lines
use the UnicodeError traversal and clearing functions in UnicodeError
subclasses.
........
r46512 | thomas.wouters | 2006-05-28 23:32:12 +0200 (Sun, 28 May 2006) | 4 lines
Make last patch valid C89 so Windows compilers can deal with it.
........
r46513 | georg.brandl | 2006-05-28 23:42:54 +0200 (Sun, 28 May 2006) | 3 lines
Fix ref-antileak in _struct.c which eventually lead to deallocating None.
........
r46514 | georg.brandl | 2006-05-28 23:57:35 +0200 (Sun, 28 May 2006) | 4 lines
Correct None refcount issue in Mac modules. (Are they
still used?)
........
r46515 | armin.rigo | 2006-05-29 00:07:08 +0200 (Mon, 29 May 2006) | 3 lines
A clearer error message when passing -R to regrtest.py with
release builds of Python.
........
r46516 | georg.brandl | 2006-05-29 00:14:04 +0200 (Mon, 29 May 2006) | 3 lines
Fix C function calling conventions in _sre module.
........
r46517 | georg.brandl | 2006-05-29 00:34:51 +0200 (Mon, 29 May 2006) | 3 lines
Convert audioop over to METH_VARARGS.
........
r46518 | georg.brandl | 2006-05-29 00:38:57 +0200 (Mon, 29 May 2006) | 3 lines
METH_NOARGS functions do get called with two args.
........
r46519 | georg.brandl | 2006-05-29 11:46:51 +0200 (Mon, 29 May 2006) | 4 lines
Fix refleak in socketmodule. Replace bogus Py_BuildValue calls.
Fix refleak in exceptions.
........
r46520 | nick.coghlan | 2006-05-29 14:43:05 +0200 (Mon, 29 May 2006) | 7 lines
Apply modified version of Collin Winter's patch #1478788
Renames functional extension module to _functools and adds a Python
functools module so that utility functions like update_wrapper can be
added easily.
........
r46522 | georg.brandl | 2006-05-29 15:53:16 +0200 (Mon, 29 May 2006) | 3 lines
Convert fmmodule to METH_VARARGS.
........
r46523 | georg.brandl | 2006-05-29 16:13:21 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494605.
........
r46524 | georg.brandl | 2006-05-29 16:28:05 +0200 (Mon, 29 May 2006) | 3 lines
Handle PyMem_Malloc failure in pystrtod.c. Closes #1494671.
........
r46525 | georg.brandl | 2006-05-29 16:33:55 +0200 (Mon, 29 May 2006) | 3 lines
Fix compiler warning.
........
r46526 | georg.brandl | 2006-05-29 16:39:00 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494787 (pyclbr counts whitespace as superclass name)
........
r46527 | bob.ippolito | 2006-05-29 17:47:29 +0200 (Mon, 29 May 2006) | 1 line
simplify the struct code a bit (no functional changes)
........
r46528 | armin.rigo | 2006-05-29 19:59:47 +0200 (Mon, 29 May 2006) | 2 lines
Silence a warning.
........
r46529 | georg.brandl | 2006-05-29 21:39:45 +0200 (Mon, 29 May 2006) | 3 lines
Correct some value converting strangenesses.
........
r46530 | nick.coghlan | 2006-05-29 22:27:44 +0200 (Mon, 29 May 2006) | 1 line
When adding a module like functools, it helps to let SVN know about the file.
........
r46531 | georg.brandl | 2006-05-29 22:52:54 +0200 (Mon, 29 May 2006) | 4 lines
Patches #1497027 and #972322: try HTTP digest auth first,
and watch out for handler name collisions.
........
r46532 | georg.brandl | 2006-05-29 22:57:01 +0200 (Mon, 29 May 2006) | 3 lines
Add News entry for last commit.
........
r46533 | georg.brandl | 2006-05-29 23:04:52 +0200 (Mon, 29 May 2006) | 4 lines
Make use of METH_O and METH_NOARGS where possible.
Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
........
r46534 | georg.brandl | 2006-05-29 23:58:42 +0200 (Mon, 29 May 2006) | 3 lines
Convert more modules to METH_VARARGS.
........
r46535 | georg.brandl | 2006-05-30 00:00:30 +0200 (Tue, 30 May 2006) | 3 lines
Whoops.
........
r46536 | fredrik.lundh | 2006-05-30 00:42:07 +0200 (Tue, 30 May 2006) | 4 lines
fixed "abc".count("", 100) == -96 error (hopefully, nobody's relying on
the current behaviour ;-)
........
r46537 | bob.ippolito | 2006-05-30 00:55:48 +0200 (Tue, 30 May 2006) | 1 line
struct: modulo math plus warning on all endian-explicit formats for compatibility with older struct usage (ugly)
........
r46539 | bob.ippolito | 2006-05-30 02:26:01 +0200 (Tue, 30 May 2006) | 1 line
Add a length check to aifc to ensure it doesn't write a bogus file
........
r46540 | tim.peters | 2006-05-30 04:25:25 +0200 (Tue, 30 May 2006) | 10 lines
deprecated_err(): Stop bizarre warning messages when the tests
are run in the order:
test_genexps (or any other doctest-based test)
test_struct
test_doctest
The `warnings` module needs an advertised way to save/restore
its internal filter list.
........
r46541 | tim.peters | 2006-05-30 04:26:46 +0200 (Tue, 30 May 2006) | 2 lines
Whitespace normalization.
........
r46542 | tim.peters | 2006-05-30 04:30:30 +0200 (Tue, 30 May 2006) | 2 lines
Set a binary svn:mime-type property on this UTF-8 encoded file.
........
r46543 | neal.norwitz | 2006-05-30 05:18:50 +0200 (Tue, 30 May 2006) | 1 line
Simplify further by using AddStringConstant
........
r46544 | tim.peters | 2006-05-30 06:16:25 +0200 (Tue, 30 May 2006) | 6 lines
Convert relevant dict internals to Py_ssize_t.
I don't have a box with nearly enough RAM, or an OS,
that could get close to tickling this, though (requires
a dict w/ at least 2**31 entries).
........
r46545 | neal.norwitz | 2006-05-30 06:19:21 +0200 (Tue, 30 May 2006) | 1 line
Remove stray | in comment
........
r46546 | neal.norwitz | 2006-05-30 06:25:05 +0200 (Tue, 30 May 2006) | 1 line
Use Py_SAFE_DOWNCAST for safety. Fix format strings. Remove 2 more stray | in comment
........
r46547 | neal.norwitz | 2006-05-30 06:43:23 +0200 (Tue, 30 May 2006) | 1 line
No DOWNCAST is required since sizeof(Py_ssize_t) >= sizeof(int) and Py_ReprEntr returns an int
........
r46548 | tim.peters | 2006-05-30 07:04:59 +0200 (Tue, 30 May 2006) | 3 lines
dict_print(): Explicitly narrow the return value
from a (possibly) wider variable.
........
r46549 | tim.peters | 2006-05-30 07:23:59 +0200 (Tue, 30 May 2006) | 5 lines
dict_print(): So that Neal & I don't spend the rest of
our lives taking turns rewriting code that works ;-),
get rid of casting illusions by declaring a new variable
with the obvious type.
........
r46550 | georg.brandl | 2006-05-30 09:04:55 +0200 (Tue, 30 May 2006) | 3 lines
Restore exception pickle support. #1497319.
........
r46551 | georg.brandl | 2006-05-30 09:13:29 +0200 (Tue, 30 May 2006) | 3 lines
Add a test case for exception pickling. args is never NULL.
........
r46552 | neal.norwitz | 2006-05-30 09:21:10 +0200 (Tue, 30 May 2006) | 1 line
Don't fail if the (sub)pkgname already exist.
........
r46553 | georg.brandl | 2006-05-30 09:34:45 +0200 (Tue, 30 May 2006) | 3 lines
Disallow keyword args for exceptions.
........
r46554 | neal.norwitz | 2006-05-30 09:36:54 +0200 (Tue, 30 May 2006) | 5 lines
I'm impatient. I think this will fix a few more problems with the buildbots.
I'm not sure this is the best approach, but I can't think of anything better.
If this creates problems, feel free to revert, but I think it's safe and
should make things a little better.
........
r46555 | georg.brandl | 2006-05-30 10:17:00 +0200 (Tue, 30 May 2006) | 4 lines
Do the check for no keyword arguments in __init__ so that
subclasses of Exception can be supplied keyword args
........
r46556 | georg.brandl | 2006-05-30 10:47:19 +0200 (Tue, 30 May 2006) | 3 lines
Convert test_exceptions to unittest.
........
r46557 | andrew.kuchling | 2006-05-30 14:52:01 +0200 (Tue, 30 May 2006) | 1 line
Add SoC name, and reorganize this section a bit
........
r46559 | tim.peters | 2006-05-30 17:53:34 +0200 (Tue, 30 May 2006) | 11 lines
PyLong_FromString(): Continued fraction analysis (explained in
a new comment) suggests there are almost certainly large input
integers in all non-binary input bases for which one Python digit
too few is initally allocated to hold the final result. Instead
of assert-failing when that happens, allocate more space. Alas,
I estimate it would take a few days to find a specific such case,
so this isn't backed up by a new test (not to mention that such
a case may take hours to run, since conversion time is quadratic
in the number of digits, and preliminary attempts suggested that
the smallest such inputs contain at least a million digits).
........
r46560 | fredrik.lundh | 2006-05-30 19:11:48 +0200 (Tue, 30 May 2006) | 3 lines
changed find/rfind to return -1 for matches outside the source string
........
r46561 | bob.ippolito | 2006-05-30 19:37:54 +0200 (Tue, 30 May 2006) | 1 line
Change wrapping terminology to overflow masking
........
r46562 | fredrik.lundh | 2006-05-30 19:39:58 +0200 (Tue, 30 May 2006) | 3 lines
changed count to return 0 for slices outside the source string
........
r46568 | tim.peters | 2006-05-31 01:28:02 +0200 (Wed, 31 May 2006) | 2 lines
Whitespace normalization.
........
r46569 | brett.cannon | 2006-05-31 04:19:54 +0200 (Wed, 31 May 2006) | 5 lines
Clarify wording on default values for strptime(); defaults are used when better
values cannot be inferred.
Closes bug #1496315.
........
r46572 | neal.norwitz | 2006-05-31 09:43:27 +0200 (Wed, 31 May 2006) | 1 line
Calculate smallest properly (it was off by one) and use proper ssize_t types for Win64
........
r46573 | neal.norwitz | 2006-05-31 10:01:08 +0200 (Wed, 31 May 2006) | 1 line
Revert last checkin, it is better to do make distclean
........
r46574 | neal.norwitz | 2006-05-31 11:02:44 +0200 (Wed, 31 May 2006) | 3 lines
On 64-bit platforms running test_struct after test_tarfile would fail
since the deprecation warning wouldn't be raised.
........
r46575 | thomas.heller | 2006-05-31 13:37:58 +0200 (Wed, 31 May 2006) | 3 lines
PyTuple_Pack is not available in Python 2.3, but ctypes must stay
compatible with that.
........
r46576 | andrew.kuchling | 2006-05-31 15:18:56 +0200 (Wed, 31 May 2006) | 1 line
'functional' module was renamed to 'functools'
........
r46577 | kristjan.jonsson | 2006-05-31 15:35:41 +0200 (Wed, 31 May 2006) | 1 line
Fixup the PCBuild8 project directory. exceptions.c have moved to Objects, and the functionalmodule.c has been replaced with _functoolsmodule.c. Other minor changes to .vcproj files and .sln to fix compilation
........
r46578 | andrew.kuchling | 2006-05-31 16:08:48 +0200 (Wed, 31 May 2006) | 15 lines
[Bug #1473048]
SimpleXMLRPCServer and DocXMLRPCServer don't look at
the path of the HTTP request at all; you can POST or
GET from / or /RPC2 or /blahblahblah with the same results.
Security scanners that look for /cgi-bin/phf will therefore report
lots of vulnerabilities.
Fix: add a .rpc_paths attribute to the SimpleXMLRPCServer class,
and report a 404 error if the path isn't on the allowed list.
Possibly-controversial aspect of this change: the default makes only
'/' and '/RPC2' legal. Maybe this will break people's applications
(though I doubt it). We could just set the default to an empty tuple,
which would exactly match the current behaviour.
........
r46579 | andrew.kuchling | 2006-05-31 16:12:47 +0200 (Wed, 31 May 2006) | 1 line
Mention SimpleXMLRPCServer change
........
r46580 | tim.peters | 2006-05-31 16:28:07 +0200 (Wed, 31 May 2006) | 2 lines
Trimmed trailing whitespace.
........
r46581 | tim.peters | 2006-05-31 17:33:22 +0200 (Wed, 31 May 2006) | 4 lines
_range_error(): Speed and simplify (there's no real need for
loops here). Assert that size_t is actually big enough, and
that f->size is at least one. Wrap a long line.
........
r46582 | tim.peters | 2006-05-31 17:34:37 +0200 (Wed, 31 May 2006) | 2 lines
Repaired error in new comment.
........
r46584 | neal.norwitz | 2006-06-01 07:32:49 +0200 (Thu, 01 Jun 2006) | 4 lines
Remove ; at end of macro. There was a compiler recently that warned
about extra semi-colons. It may have been the HP C compiler.
This file will trigger a bunch of those warnings now.
........
r46585 | georg.brandl | 2006-06-01 08:39:19 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly unpickle 2.4 exceptions via __setstate__ (patch #1498571)
........
r46586 | georg.brandl | 2006-06-01 10:27:32 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly allocate complex types with tp_alloc. (bug #1498638)
........
r46587 | georg.brandl | 2006-06-01 14:30:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Correctly dispatch Faults in loads (patch #1498627)
........
r46588 | georg.brandl | 2006-06-01 15:00:49 +0200 (Thu, 01 Jun 2006) | 3 lines
Some code style tweaks, and remove apply.
........
r46589 | armin.rigo | 2006-06-01 15:19:12 +0200 (Thu, 01 Jun 2006) | 5 lines
[ 1497053 ] Let dicts propagate the exceptions in user __eq__().
[ 1456209 ] dictresize() vulnerability ( <- backport candidate ).
........
r46590 | tim.peters | 2006-06-01 15:41:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Whitespace normalization.
........
r46591 | tim.peters | 2006-06-01 15:49:23 +0200 (Thu, 01 Jun 2006) | 2 lines
Record bugs 1275608 and 1456209 as being fixed.
........
r46592 | tim.peters | 2006-06-01 15:56:26 +0200 (Thu, 01 Jun 2006) | 5 lines
Re-enable a new empty-string test added during the NFS sprint,
but disabled then because str and unicode strings gave different
results. The implementations were repaired later during the
sprint, but the new test remained disabled.
........
r46594 | tim.peters | 2006-06-01 17:50:44 +0200 (Thu, 01 Jun 2006) | 7 lines
Armin committed his patch while I was reviewing it (I'm sure
he didn't know this), so merged in some changes I made during
review. Nothing material apart from changing a new `mask` local
from int to Py_ssize_t. Mostly this is repairing comments that
were made incorrect, and adding new comments. Also a few
minor code rewrites for clarity or helpful succinctness.
........
r46599 | neal.norwitz | 2006-06-02 06:45:53 +0200 (Fri, 02 Jun 2006) | 1 line
Convert docstrings to comments so regrtest -v prints method names
........
r46600 | neal.norwitz | 2006-06-02 06:50:49 +0200 (Fri, 02 Jun 2006) | 2 lines
Fix memory leak found by valgrind.
........
r46601 | neal.norwitz | 2006-06-02 06:54:52 +0200 (Fri, 02 Jun 2006) | 1 line
More memory leaks from valgrind
........
r46602 | neal.norwitz | 2006-06-02 08:23:00 +0200 (Fri, 02 Jun 2006) | 11 lines
Patch #1357836:
Prevent an invalid memory read from test_coding in case the done flag is set.
In that case, the loop isn't entered. I wonder if rather than setting
the done flag in the cases before the loop, if they should just exit early.
This code looks like it should be refactored.
Backport candidate (also the early break above if decoding_fgets fails)
........
r46603 | martin.blais | 2006-06-02 15:03:43 +0200 (Fri, 02 Jun 2006) | 1 line
Fixed struct test to not use unittest.
........
r46605 | tim.peters | 2006-06-03 01:22:51 +0200 (Sat, 03 Jun 2006) | 10 lines
pprint functions used to sort a dict (by key) if and only if
the output required more than one line. "Small" dicts got
displayed in seemingly random order (the hash-induced order
produced by dict.__repr__). None of this was documented.
Now pprint functions always sort dicts by key, and the docs
promise it.
This was proposed and agreed to during the PyCon 2006 core
sprint -- I just didn't have time for it before now.
........
2006-06-08 11:42:34 -03:00
|
|
|
else
|
|
|
|
Py_RETURN_NONE;
|
2001-02-14 14:29:45 -04:00
|
|
|
}
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(xmlparse_ExternalEntityParserCreate__doc__,
|
2001-01-03 11:36:25 -04:00
|
|
|
"ExternalEntityParserCreate(context[, encoding])\n\
|
2000-09-24 19:12:45 -03:00
|
|
|
Create a parser for parsing an external entity based on the\n\
|
2002-06-13 17:33:02 -03:00
|
|
|
information passed to the ExternalEntityRefHandler.");
|
2000-09-24 17:50:52 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
xmlparse_ExternalEntityParserCreate(xmlparseobject *self, PyObject *args)
|
|
|
|
{
|
|
|
|
char *context;
|
|
|
|
char *encoding = NULL;
|
|
|
|
xmlparseobject *new_parser;
|
|
|
|
int i;
|
|
|
|
|
2001-09-19 06:55:09 -03:00
|
|
|
if (!PyArg_ParseTuple(args, "z|s:ExternalEntityParserCreate",
|
2001-04-25 13:01:30 -03:00
|
|
|
&context, &encoding)) {
|
|
|
|
return NULL;
|
2000-09-24 17:50:52 -03:00
|
|
|
}
|
|
|
|
|
2001-09-23 07:20:10 -03:00
|
|
|
#ifndef Py_TPFLAGS_HAVE_GC
|
2002-06-30 03:40:55 -03:00
|
|
|
/* Python versions 2.0 and 2.1 */
|
2000-09-24 17:50:52 -03:00
|
|
|
new_parser = PyObject_New(xmlparseobject, &Xmlparsetype);
|
2001-09-23 07:20:10 -03:00
|
|
|
#else
|
|
|
|
/* Python versions 2.2 and later */
|
|
|
|
new_parser = PyObject_GC_New(xmlparseobject, &Xmlparsetype);
|
2000-09-24 17:50:52 -03:00
|
|
|
#endif
|
2001-02-08 11:39:08 -04:00
|
|
|
|
|
|
|
if (new_parser == NULL)
|
|
|
|
return NULL;
|
2002-06-28 19:56:48 -03:00
|
|
|
new_parser->buffer_size = self->buffer_size;
|
|
|
|
new_parser->buffer_used = 0;
|
|
|
|
if (self->buffer != NULL) {
|
|
|
|
new_parser->buffer = malloc(new_parser->buffer_size);
|
|
|
|
if (new_parser->buffer == NULL) {
|
2002-07-02 12:44:36 -03:00
|
|
|
#ifndef Py_TPFLAGS_HAVE_GC
|
|
|
|
/* Code for versions 2.0 and 2.1 */
|
|
|
|
PyObject_Del(new_parser);
|
|
|
|
#else
|
|
|
|
/* Code for versions 2.2 and later. */
|
2002-06-28 19:56:48 -03:00
|
|
|
PyObject_GC_Del(new_parser);
|
2002-07-02 12:44:36 -03:00
|
|
|
#endif
|
2002-06-28 19:56:48 -03:00
|
|
|
return PyErr_NoMemory();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
new_parser->buffer = NULL;
|
2001-02-08 11:39:08 -04:00
|
|
|
new_parser->returns_unicode = self->returns_unicode;
|
|
|
|
new_parser->ordered_attributes = self->ordered_attributes;
|
|
|
|
new_parser->specified_attributes = self->specified_attributes;
|
2001-02-14 14:29:45 -04:00
|
|
|
new_parser->in_callback = 0;
|
2003-01-21 06:58:18 -04:00
|
|
|
new_parser->ns_prefixes = self->ns_prefixes;
|
2000-09-24 17:50:52 -03:00
|
|
|
new_parser->itself = XML_ExternalEntityParserCreate(self->itself, context,
|
2001-01-21 06:18:10 -04:00
|
|
|
encoding);
|
|
|
|
new_parser->handlers = 0;
|
2002-06-27 16:40:48 -03:00
|
|
|
new_parser->intern = self->intern;
|
|
|
|
Py_XINCREF(new_parser->intern);
|
2001-09-23 07:20:10 -03:00
|
|
|
#ifdef Py_TPFLAGS_HAVE_GC
|
|
|
|
PyObject_GC_Track(new_parser);
|
|
|
|
#else
|
2001-01-21 06:18:10 -04:00
|
|
|
PyObject_GC_Init(new_parser);
|
2001-09-23 07:20:10 -03:00
|
|
|
#endif
|
2001-01-21 06:18:10 -04:00
|
|
|
|
|
|
|
if (!new_parser->itself) {
|
2001-02-08 11:39:08 -04:00
|
|
|
Py_DECREF(new_parser);
|
|
|
|
return PyErr_NoMemory();
|
2000-09-24 17:50:52 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
XML_SetUserData(new_parser->itself, (void *)new_parser);
|
|
|
|
|
|
|
|
/* allocate and clear handlers first */
|
2002-06-28 19:56:48 -03:00
|
|
|
for (i = 0; handler_info[i].name != NULL; i++)
|
2001-02-08 11:39:08 -04:00
|
|
|
/* do nothing */;
|
2000-09-24 17:50:52 -03:00
|
|
|
|
2002-06-28 19:56:48 -03:00
|
|
|
new_parser->handlers = malloc(sizeof(PyObject *) * i);
|
2001-01-21 06:18:10 -04:00
|
|
|
if (!new_parser->handlers) {
|
2001-02-08 11:39:08 -04:00
|
|
|
Py_DECREF(new_parser);
|
|
|
|
return PyErr_NoMemory();
|
2001-01-21 06:18:10 -04:00
|
|
|
}
|
2001-10-21 05:53:52 -03:00
|
|
|
clear_handlers(new_parser, 1);
|
2000-09-24 17:50:52 -03:00
|
|
|
|
|
|
|
/* then copy handlers from self */
|
|
|
|
for (i = 0; handler_info[i].name != NULL; i++) {
|
2002-06-28 19:29:01 -03:00
|
|
|
PyObject *handler = self->handlers[i];
|
|
|
|
if (handler != NULL) {
|
|
|
|
Py_INCREF(handler);
|
|
|
|
new_parser->handlers[i] = handler;
|
|
|
|
handler_info[i].setter(new_parser->itself,
|
2001-02-08 11:39:08 -04:00
|
|
|
handler_info[i].handler);
|
|
|
|
}
|
2000-09-24 17:50:52 -03:00
|
|
|
}
|
2002-06-28 19:29:01 -03:00
|
|
|
return (PyObject *)new_parser;
|
2000-09-24 17:50:52 -03:00
|
|
|
}
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(xmlparse_SetParamEntityParsing__doc__,
|
2001-01-21 06:18:10 -04:00
|
|
|
"SetParamEntityParsing(flag) -> success\n\
|
|
|
|
Controls parsing of parameter entities (including the external DTD\n\
|
|
|
|
subset). Possible flag values are XML_PARAM_ENTITY_PARSING_NEVER,\n\
|
|
|
|
XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE and\n\
|
|
|
|
XML_PARAM_ENTITY_PARSING_ALWAYS. Returns true if setting the flag\n\
|
2002-06-13 17:33:02 -03:00
|
|
|
was successful.");
|
2001-01-21 06:18:10 -04:00
|
|
|
|
|
|
|
static PyObject*
|
2001-02-14 14:29:45 -04:00
|
|
|
xmlparse_SetParamEntityParsing(xmlparseobject *p, PyObject* args)
|
2001-01-21 06:18:10 -04:00
|
|
|
{
|
2001-02-08 11:39:08 -04:00
|
|
|
int flag;
|
|
|
|
if (!PyArg_ParseTuple(args, "i", &flag))
|
|
|
|
return NULL;
|
2001-02-14 14:29:45 -04:00
|
|
|
flag = XML_SetParamEntityParsing(p->itself, flag);
|
2001-02-08 11:39:08 -04:00
|
|
|
return PyInt_FromLong(flag);
|
2001-01-21 06:18:10 -04:00
|
|
|
}
|
|
|
|
|
2003-01-21 07:09:21 -04:00
|
|
|
|
|
|
|
#if XML_COMBINED_VERSION >= 19505
|
2003-01-21 06:58:18 -04:00
|
|
|
PyDoc_STRVAR(xmlparse_UseForeignDTD__doc__,
|
|
|
|
"UseForeignDTD([flag])\n\
|
|
|
|
Allows the application to provide an artificial external subset if one is\n\
|
|
|
|
not specified as part of the document instance. This readily allows the\n\
|
|
|
|
use of a 'default' document type controlled by the application, while still\n\
|
|
|
|
getting the advantage of providing document type information to the parser.\n\
|
|
|
|
'flag' defaults to True if not provided.");
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
xmlparse_UseForeignDTD(xmlparseobject *self, PyObject *args)
|
|
|
|
{
|
|
|
|
PyObject *flagobj = NULL;
|
|
|
|
XML_Bool flag = XML_TRUE;
|
|
|
|
enum XML_Error rc;
|
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
merge in bad ways, so I'll have to merge that extra-carefully (probably manually.)
Merged revisions 46495-46605 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r46495 | tim.peters | 2006-05-28 03:52:38 +0200 (Sun, 28 May 2006) | 2 lines
Added missing svn:eol-style property to text files.
........
r46497 | tim.peters | 2006-05-28 12:41:29 +0200 (Sun, 28 May 2006) | 3 lines
PyErr_Display(), PyErr_WriteUnraisable(): Coverity found a cut-and-paste
bug in both: `className` was referenced before being checked for NULL.
........
r46499 | fredrik.lundh | 2006-05-28 14:06:46 +0200 (Sun, 28 May 2006) | 5 lines
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
and use it for string copy operations. this gives a 20% speedup on some
string benchmarks.
........
r46501 | michael.hudson | 2006-05-28 17:51:40 +0200 (Sun, 28 May 2006) | 26 lines
Quality control, meet exceptions.c.
Fix a number of problems with the need for speed code:
One is doing this sort of thing:
Py_DECREF(self->field);
self->field = newval;
Py_INCREF(self->field);
without being very sure that self->field doesn't start with a
value that has a __del__, because that almost certainly can lead
to segfaults.
As self->args is constrained to be an exact tuple we may as well
exploit this fact consistently. This leads to quite a lot of
simplification (and, hey, probably better performance).
Add some error checking in places lacking it.
Fix some rather strange indentation in the Unicode code.
Delete some trailing whitespace.
More to come, I haven't fixed all the reference leaks yet...
........
r46502 | george.yoshida | 2006-05-28 18:39:09 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1080727: add "encoding" parameter to doctest.DocFileSuite
Contributed by Bjorn Tillenius.
........
r46503 | martin.v.loewis | 2006-05-28 18:57:38 +0200 (Sun, 28 May 2006) | 4 lines
Rest of patch #1490384: Commit icon source, remove
claim that Erik von Blokland is the author of the
installer picture.
........
r46504 | michael.hudson | 2006-05-28 19:40:29 +0200 (Sun, 28 May 2006) | 16 lines
Quality control, meet exceptions.c, round two.
Make some functions that should have been static static.
Fix a bunch of refleaks by fixing the definition of
MiddlingExtendsException.
Remove all the __new__ implementations apart from
BaseException_new. Rewrite most code that needs it to cope with
NULL fields (such code could get excercised anyway, the
__new__-removal just makes it more likely). This involved
editing the code for WindowsError, which I can't test.
This fixes all the refleaks in at least the start of a regrtest
-R :: run.
........
r46505 | marc-andre.lemburg | 2006-05-28 19:46:58 +0200 (Sun, 28 May 2006) | 10 lines
Initial version of systimes - a module to provide platform dependent
performance measurements.
The module is currently just a proof-of-concept implementation, but
will integrated into pybench once it is stable enough.
License: pybench license.
Author: Marc-Andre Lemburg.
........
r46507 | armin.rigo | 2006-05-28 21:13:17 +0200 (Sun, 28 May 2006) | 15 lines
("Forward-port" of r46506)
Remove various dependencies on dictionary order in the standard library
tests, and one (clearly an oversight, potentially critical) in the
standard library itself - base64.py.
Remaining open issues:
* test_extcall is an output test, messy to make robust
* tarfile.py has a potential bug here, but I'm not familiar
enough with this code. Filed in as SF bug #1496501.
* urllib2.HTTPPasswordMgr() returns a random result if there is more
than one matching root path. I'm asking python-dev for
clarification...
........
r46508 | georg.brandl | 2006-05-28 22:11:45 +0200 (Sun, 28 May 2006) | 4 lines
The empty string is a valid import path.
(fixes #1496539)
........
r46509 | georg.brandl | 2006-05-28 22:23:12 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1496206: urllib2 PasswordMgr ./. default ports
........
r46510 | georg.brandl | 2006-05-28 22:57:09 +0200 (Sun, 28 May 2006) | 3 lines
Fix refleaks in UnicodeError get and set methods.
........
r46511 | michael.hudson | 2006-05-28 23:19:03 +0200 (Sun, 28 May 2006) | 3 lines
use the UnicodeError traversal and clearing functions in UnicodeError
subclasses.
........
r46512 | thomas.wouters | 2006-05-28 23:32:12 +0200 (Sun, 28 May 2006) | 4 lines
Make last patch valid C89 so Windows compilers can deal with it.
........
r46513 | georg.brandl | 2006-05-28 23:42:54 +0200 (Sun, 28 May 2006) | 3 lines
Fix ref-antileak in _struct.c which eventually lead to deallocating None.
........
r46514 | georg.brandl | 2006-05-28 23:57:35 +0200 (Sun, 28 May 2006) | 4 lines
Correct None refcount issue in Mac modules. (Are they
still used?)
........
r46515 | armin.rigo | 2006-05-29 00:07:08 +0200 (Mon, 29 May 2006) | 3 lines
A clearer error message when passing -R to regrtest.py with
release builds of Python.
........
r46516 | georg.brandl | 2006-05-29 00:14:04 +0200 (Mon, 29 May 2006) | 3 lines
Fix C function calling conventions in _sre module.
........
r46517 | georg.brandl | 2006-05-29 00:34:51 +0200 (Mon, 29 May 2006) | 3 lines
Convert audioop over to METH_VARARGS.
........
r46518 | georg.brandl | 2006-05-29 00:38:57 +0200 (Mon, 29 May 2006) | 3 lines
METH_NOARGS functions do get called with two args.
........
r46519 | georg.brandl | 2006-05-29 11:46:51 +0200 (Mon, 29 May 2006) | 4 lines
Fix refleak in socketmodule. Replace bogus Py_BuildValue calls.
Fix refleak in exceptions.
........
r46520 | nick.coghlan | 2006-05-29 14:43:05 +0200 (Mon, 29 May 2006) | 7 lines
Apply modified version of Collin Winter's patch #1478788
Renames functional extension module to _functools and adds a Python
functools module so that utility functions like update_wrapper can be
added easily.
........
r46522 | georg.brandl | 2006-05-29 15:53:16 +0200 (Mon, 29 May 2006) | 3 lines
Convert fmmodule to METH_VARARGS.
........
r46523 | georg.brandl | 2006-05-29 16:13:21 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494605.
........
r46524 | georg.brandl | 2006-05-29 16:28:05 +0200 (Mon, 29 May 2006) | 3 lines
Handle PyMem_Malloc failure in pystrtod.c. Closes #1494671.
........
r46525 | georg.brandl | 2006-05-29 16:33:55 +0200 (Mon, 29 May 2006) | 3 lines
Fix compiler warning.
........
r46526 | georg.brandl | 2006-05-29 16:39:00 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494787 (pyclbr counts whitespace as superclass name)
........
r46527 | bob.ippolito | 2006-05-29 17:47:29 +0200 (Mon, 29 May 2006) | 1 line
simplify the struct code a bit (no functional changes)
........
r46528 | armin.rigo | 2006-05-29 19:59:47 +0200 (Mon, 29 May 2006) | 2 lines
Silence a warning.
........
r46529 | georg.brandl | 2006-05-29 21:39:45 +0200 (Mon, 29 May 2006) | 3 lines
Correct some value converting strangenesses.
........
r46530 | nick.coghlan | 2006-05-29 22:27:44 +0200 (Mon, 29 May 2006) | 1 line
When adding a module like functools, it helps to let SVN know about the file.
........
r46531 | georg.brandl | 2006-05-29 22:52:54 +0200 (Mon, 29 May 2006) | 4 lines
Patches #1497027 and #972322: try HTTP digest auth first,
and watch out for handler name collisions.
........
r46532 | georg.brandl | 2006-05-29 22:57:01 +0200 (Mon, 29 May 2006) | 3 lines
Add News entry for last commit.
........
r46533 | georg.brandl | 2006-05-29 23:04:52 +0200 (Mon, 29 May 2006) | 4 lines
Make use of METH_O and METH_NOARGS where possible.
Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
........
r46534 | georg.brandl | 2006-05-29 23:58:42 +0200 (Mon, 29 May 2006) | 3 lines
Convert more modules to METH_VARARGS.
........
r46535 | georg.brandl | 2006-05-30 00:00:30 +0200 (Tue, 30 May 2006) | 3 lines
Whoops.
........
r46536 | fredrik.lundh | 2006-05-30 00:42:07 +0200 (Tue, 30 May 2006) | 4 lines
fixed "abc".count("", 100) == -96 error (hopefully, nobody's relying on
the current behaviour ;-)
........
r46537 | bob.ippolito | 2006-05-30 00:55:48 +0200 (Tue, 30 May 2006) | 1 line
struct: modulo math plus warning on all endian-explicit formats for compatibility with older struct usage (ugly)
........
r46539 | bob.ippolito | 2006-05-30 02:26:01 +0200 (Tue, 30 May 2006) | 1 line
Add a length check to aifc to ensure it doesn't write a bogus file
........
r46540 | tim.peters | 2006-05-30 04:25:25 +0200 (Tue, 30 May 2006) | 10 lines
deprecated_err(): Stop bizarre warning messages when the tests
are run in the order:
test_genexps (or any other doctest-based test)
test_struct
test_doctest
The `warnings` module needs an advertised way to save/restore
its internal filter list.
........
r46541 | tim.peters | 2006-05-30 04:26:46 +0200 (Tue, 30 May 2006) | 2 lines
Whitespace normalization.
........
r46542 | tim.peters | 2006-05-30 04:30:30 +0200 (Tue, 30 May 2006) | 2 lines
Set a binary svn:mime-type property on this UTF-8 encoded file.
........
r46543 | neal.norwitz | 2006-05-30 05:18:50 +0200 (Tue, 30 May 2006) | 1 line
Simplify further by using AddStringConstant
........
r46544 | tim.peters | 2006-05-30 06:16:25 +0200 (Tue, 30 May 2006) | 6 lines
Convert relevant dict internals to Py_ssize_t.
I don't have a box with nearly enough RAM, or an OS,
that could get close to tickling this, though (requires
a dict w/ at least 2**31 entries).
........
r46545 | neal.norwitz | 2006-05-30 06:19:21 +0200 (Tue, 30 May 2006) | 1 line
Remove stray | in comment
........
r46546 | neal.norwitz | 2006-05-30 06:25:05 +0200 (Tue, 30 May 2006) | 1 line
Use Py_SAFE_DOWNCAST for safety. Fix format strings. Remove 2 more stray | in comment
........
r46547 | neal.norwitz | 2006-05-30 06:43:23 +0200 (Tue, 30 May 2006) | 1 line
No DOWNCAST is required since sizeof(Py_ssize_t) >= sizeof(int) and Py_ReprEntr returns an int
........
r46548 | tim.peters | 2006-05-30 07:04:59 +0200 (Tue, 30 May 2006) | 3 lines
dict_print(): Explicitly narrow the return value
from a (possibly) wider variable.
........
r46549 | tim.peters | 2006-05-30 07:23:59 +0200 (Tue, 30 May 2006) | 5 lines
dict_print(): So that Neal & I don't spend the rest of
our lives taking turns rewriting code that works ;-),
get rid of casting illusions by declaring a new variable
with the obvious type.
........
r46550 | georg.brandl | 2006-05-30 09:04:55 +0200 (Tue, 30 May 2006) | 3 lines
Restore exception pickle support. #1497319.
........
r46551 | georg.brandl | 2006-05-30 09:13:29 +0200 (Tue, 30 May 2006) | 3 lines
Add a test case for exception pickling. args is never NULL.
........
r46552 | neal.norwitz | 2006-05-30 09:21:10 +0200 (Tue, 30 May 2006) | 1 line
Don't fail if the (sub)pkgname already exist.
........
r46553 | georg.brandl | 2006-05-30 09:34:45 +0200 (Tue, 30 May 2006) | 3 lines
Disallow keyword args for exceptions.
........
r46554 | neal.norwitz | 2006-05-30 09:36:54 +0200 (Tue, 30 May 2006) | 5 lines
I'm impatient. I think this will fix a few more problems with the buildbots.
I'm not sure this is the best approach, but I can't think of anything better.
If this creates problems, feel free to revert, but I think it's safe and
should make things a little better.
........
r46555 | georg.brandl | 2006-05-30 10:17:00 +0200 (Tue, 30 May 2006) | 4 lines
Do the check for no keyword arguments in __init__ so that
subclasses of Exception can be supplied keyword args
........
r46556 | georg.brandl | 2006-05-30 10:47:19 +0200 (Tue, 30 May 2006) | 3 lines
Convert test_exceptions to unittest.
........
r46557 | andrew.kuchling | 2006-05-30 14:52:01 +0200 (Tue, 30 May 2006) | 1 line
Add SoC name, and reorganize this section a bit
........
r46559 | tim.peters | 2006-05-30 17:53:34 +0200 (Tue, 30 May 2006) | 11 lines
PyLong_FromString(): Continued fraction analysis (explained in
a new comment) suggests there are almost certainly large input
integers in all non-binary input bases for which one Python digit
too few is initally allocated to hold the final result. Instead
of assert-failing when that happens, allocate more space. Alas,
I estimate it would take a few days to find a specific such case,
so this isn't backed up by a new test (not to mention that such
a case may take hours to run, since conversion time is quadratic
in the number of digits, and preliminary attempts suggested that
the smallest such inputs contain at least a million digits).
........
r46560 | fredrik.lundh | 2006-05-30 19:11:48 +0200 (Tue, 30 May 2006) | 3 lines
changed find/rfind to return -1 for matches outside the source string
........
r46561 | bob.ippolito | 2006-05-30 19:37:54 +0200 (Tue, 30 May 2006) | 1 line
Change wrapping terminology to overflow masking
........
r46562 | fredrik.lundh | 2006-05-30 19:39:58 +0200 (Tue, 30 May 2006) | 3 lines
changed count to return 0 for slices outside the source string
........
r46568 | tim.peters | 2006-05-31 01:28:02 +0200 (Wed, 31 May 2006) | 2 lines
Whitespace normalization.
........
r46569 | brett.cannon | 2006-05-31 04:19:54 +0200 (Wed, 31 May 2006) | 5 lines
Clarify wording on default values for strptime(); defaults are used when better
values cannot be inferred.
Closes bug #1496315.
........
r46572 | neal.norwitz | 2006-05-31 09:43:27 +0200 (Wed, 31 May 2006) | 1 line
Calculate smallest properly (it was off by one) and use proper ssize_t types for Win64
........
r46573 | neal.norwitz | 2006-05-31 10:01:08 +0200 (Wed, 31 May 2006) | 1 line
Revert last checkin, it is better to do make distclean
........
r46574 | neal.norwitz | 2006-05-31 11:02:44 +0200 (Wed, 31 May 2006) | 3 lines
On 64-bit platforms running test_struct after test_tarfile would fail
since the deprecation warning wouldn't be raised.
........
r46575 | thomas.heller | 2006-05-31 13:37:58 +0200 (Wed, 31 May 2006) | 3 lines
PyTuple_Pack is not available in Python 2.3, but ctypes must stay
compatible with that.
........
r46576 | andrew.kuchling | 2006-05-31 15:18:56 +0200 (Wed, 31 May 2006) | 1 line
'functional' module was renamed to 'functools'
........
r46577 | kristjan.jonsson | 2006-05-31 15:35:41 +0200 (Wed, 31 May 2006) | 1 line
Fixup the PCBuild8 project directory. exceptions.c have moved to Objects, and the functionalmodule.c has been replaced with _functoolsmodule.c. Other minor changes to .vcproj files and .sln to fix compilation
........
r46578 | andrew.kuchling | 2006-05-31 16:08:48 +0200 (Wed, 31 May 2006) | 15 lines
[Bug #1473048]
SimpleXMLRPCServer and DocXMLRPCServer don't look at
the path of the HTTP request at all; you can POST or
GET from / or /RPC2 or /blahblahblah with the same results.
Security scanners that look for /cgi-bin/phf will therefore report
lots of vulnerabilities.
Fix: add a .rpc_paths attribute to the SimpleXMLRPCServer class,
and report a 404 error if the path isn't on the allowed list.
Possibly-controversial aspect of this change: the default makes only
'/' and '/RPC2' legal. Maybe this will break people's applications
(though I doubt it). We could just set the default to an empty tuple,
which would exactly match the current behaviour.
........
r46579 | andrew.kuchling | 2006-05-31 16:12:47 +0200 (Wed, 31 May 2006) | 1 line
Mention SimpleXMLRPCServer change
........
r46580 | tim.peters | 2006-05-31 16:28:07 +0200 (Wed, 31 May 2006) | 2 lines
Trimmed trailing whitespace.
........
r46581 | tim.peters | 2006-05-31 17:33:22 +0200 (Wed, 31 May 2006) | 4 lines
_range_error(): Speed and simplify (there's no real need for
loops here). Assert that size_t is actually big enough, and
that f->size is at least one. Wrap a long line.
........
r46582 | tim.peters | 2006-05-31 17:34:37 +0200 (Wed, 31 May 2006) | 2 lines
Repaired error in new comment.
........
r46584 | neal.norwitz | 2006-06-01 07:32:49 +0200 (Thu, 01 Jun 2006) | 4 lines
Remove ; at end of macro. There was a compiler recently that warned
about extra semi-colons. It may have been the HP C compiler.
This file will trigger a bunch of those warnings now.
........
r46585 | georg.brandl | 2006-06-01 08:39:19 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly unpickle 2.4 exceptions via __setstate__ (patch #1498571)
........
r46586 | georg.brandl | 2006-06-01 10:27:32 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly allocate complex types with tp_alloc. (bug #1498638)
........
r46587 | georg.brandl | 2006-06-01 14:30:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Correctly dispatch Faults in loads (patch #1498627)
........
r46588 | georg.brandl | 2006-06-01 15:00:49 +0200 (Thu, 01 Jun 2006) | 3 lines
Some code style tweaks, and remove apply.
........
r46589 | armin.rigo | 2006-06-01 15:19:12 +0200 (Thu, 01 Jun 2006) | 5 lines
[ 1497053 ] Let dicts propagate the exceptions in user __eq__().
[ 1456209 ] dictresize() vulnerability ( <- backport candidate ).
........
r46590 | tim.peters | 2006-06-01 15:41:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Whitespace normalization.
........
r46591 | tim.peters | 2006-06-01 15:49:23 +0200 (Thu, 01 Jun 2006) | 2 lines
Record bugs 1275608 and 1456209 as being fixed.
........
r46592 | tim.peters | 2006-06-01 15:56:26 +0200 (Thu, 01 Jun 2006) | 5 lines
Re-enable a new empty-string test added during the NFS sprint,
but disabled then because str and unicode strings gave different
results. The implementations were repaired later during the
sprint, but the new test remained disabled.
........
r46594 | tim.peters | 2006-06-01 17:50:44 +0200 (Thu, 01 Jun 2006) | 7 lines
Armin committed his patch while I was reviewing it (I'm sure
he didn't know this), so merged in some changes I made during
review. Nothing material apart from changing a new `mask` local
from int to Py_ssize_t. Mostly this is repairing comments that
were made incorrect, and adding new comments. Also a few
minor code rewrites for clarity or helpful succinctness.
........
r46599 | neal.norwitz | 2006-06-02 06:45:53 +0200 (Fri, 02 Jun 2006) | 1 line
Convert docstrings to comments so regrtest -v prints method names
........
r46600 | neal.norwitz | 2006-06-02 06:50:49 +0200 (Fri, 02 Jun 2006) | 2 lines
Fix memory leak found by valgrind.
........
r46601 | neal.norwitz | 2006-06-02 06:54:52 +0200 (Fri, 02 Jun 2006) | 1 line
More memory leaks from valgrind
........
r46602 | neal.norwitz | 2006-06-02 08:23:00 +0200 (Fri, 02 Jun 2006) | 11 lines
Patch #1357836:
Prevent an invalid memory read from test_coding in case the done flag is set.
In that case, the loop isn't entered. I wonder if rather than setting
the done flag in the cases before the loop, if they should just exit early.
This code looks like it should be refactored.
Backport candidate (also the early break above if decoding_fgets fails)
........
r46603 | martin.blais | 2006-06-02 15:03:43 +0200 (Fri, 02 Jun 2006) | 1 line
Fixed struct test to not use unittest.
........
r46605 | tim.peters | 2006-06-03 01:22:51 +0200 (Sat, 03 Jun 2006) | 10 lines
pprint functions used to sort a dict (by key) if and only if
the output required more than one line. "Small" dicts got
displayed in seemingly random order (the hash-induced order
produced by dict.__repr__). None of this was documented.
Now pprint functions always sort dicts by key, and the docs
promise it.
This was proposed and agreed to during the PyCon 2006 core
sprint -- I just didn't have time for it before now.
........
2006-06-08 11:42:34 -03:00
|
|
|
if (!PyArg_UnpackTuple(args, "UseForeignDTD", 0, 1, &flagobj))
|
2003-01-21 06:58:18 -04:00
|
|
|
return NULL;
|
|
|
|
if (flagobj != NULL)
|
|
|
|
flag = PyObject_IsTrue(flagobj) ? XML_TRUE : XML_FALSE;
|
|
|
|
rc = XML_UseForeignDTD(self->itself, flag);
|
|
|
|
if (rc != XML_ERROR_NONE) {
|
|
|
|
return set_error(self, rc);
|
|
|
|
}
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
2003-01-21 07:09:21 -04:00
|
|
|
#endif
|
2003-01-21 06:58:18 -04:00
|
|
|
|
2000-03-31 11:43:31 -04:00
|
|
|
static struct PyMethodDef xmlparse_methods[] = {
|
2000-07-12 01:49:00 -03:00
|
|
|
{"Parse", (PyCFunction)xmlparse_Parse,
|
2001-02-14 14:29:45 -04:00
|
|
|
METH_VARARGS, xmlparse_Parse__doc__},
|
2000-07-12 01:49:00 -03:00
|
|
|
{"ParseFile", (PyCFunction)xmlparse_ParseFile,
|
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
merge in bad ways, so I'll have to merge that extra-carefully (probably manually.)
Merged revisions 46495-46605 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r46495 | tim.peters | 2006-05-28 03:52:38 +0200 (Sun, 28 May 2006) | 2 lines
Added missing svn:eol-style property to text files.
........
r46497 | tim.peters | 2006-05-28 12:41:29 +0200 (Sun, 28 May 2006) | 3 lines
PyErr_Display(), PyErr_WriteUnraisable(): Coverity found a cut-and-paste
bug in both: `className` was referenced before being checked for NULL.
........
r46499 | fredrik.lundh | 2006-05-28 14:06:46 +0200 (Sun, 28 May 2006) | 5 lines
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
and use it for string copy operations. this gives a 20% speedup on some
string benchmarks.
........
r46501 | michael.hudson | 2006-05-28 17:51:40 +0200 (Sun, 28 May 2006) | 26 lines
Quality control, meet exceptions.c.
Fix a number of problems with the need for speed code:
One is doing this sort of thing:
Py_DECREF(self->field);
self->field = newval;
Py_INCREF(self->field);
without being very sure that self->field doesn't start with a
value that has a __del__, because that almost certainly can lead
to segfaults.
As self->args is constrained to be an exact tuple we may as well
exploit this fact consistently. This leads to quite a lot of
simplification (and, hey, probably better performance).
Add some error checking in places lacking it.
Fix some rather strange indentation in the Unicode code.
Delete some trailing whitespace.
More to come, I haven't fixed all the reference leaks yet...
........
r46502 | george.yoshida | 2006-05-28 18:39:09 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1080727: add "encoding" parameter to doctest.DocFileSuite
Contributed by Bjorn Tillenius.
........
r46503 | martin.v.loewis | 2006-05-28 18:57:38 +0200 (Sun, 28 May 2006) | 4 lines
Rest of patch #1490384: Commit icon source, remove
claim that Erik von Blokland is the author of the
installer picture.
........
r46504 | michael.hudson | 2006-05-28 19:40:29 +0200 (Sun, 28 May 2006) | 16 lines
Quality control, meet exceptions.c, round two.
Make some functions that should have been static static.
Fix a bunch of refleaks by fixing the definition of
MiddlingExtendsException.
Remove all the __new__ implementations apart from
BaseException_new. Rewrite most code that needs it to cope with
NULL fields (such code could get excercised anyway, the
__new__-removal just makes it more likely). This involved
editing the code for WindowsError, which I can't test.
This fixes all the refleaks in at least the start of a regrtest
-R :: run.
........
r46505 | marc-andre.lemburg | 2006-05-28 19:46:58 +0200 (Sun, 28 May 2006) | 10 lines
Initial version of systimes - a module to provide platform dependent
performance measurements.
The module is currently just a proof-of-concept implementation, but
will integrated into pybench once it is stable enough.
License: pybench license.
Author: Marc-Andre Lemburg.
........
r46507 | armin.rigo | 2006-05-28 21:13:17 +0200 (Sun, 28 May 2006) | 15 lines
("Forward-port" of r46506)
Remove various dependencies on dictionary order in the standard library
tests, and one (clearly an oversight, potentially critical) in the
standard library itself - base64.py.
Remaining open issues:
* test_extcall is an output test, messy to make robust
* tarfile.py has a potential bug here, but I'm not familiar
enough with this code. Filed in as SF bug #1496501.
* urllib2.HTTPPasswordMgr() returns a random result if there is more
than one matching root path. I'm asking python-dev for
clarification...
........
r46508 | georg.brandl | 2006-05-28 22:11:45 +0200 (Sun, 28 May 2006) | 4 lines
The empty string is a valid import path.
(fixes #1496539)
........
r46509 | georg.brandl | 2006-05-28 22:23:12 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1496206: urllib2 PasswordMgr ./. default ports
........
r46510 | georg.brandl | 2006-05-28 22:57:09 +0200 (Sun, 28 May 2006) | 3 lines
Fix refleaks in UnicodeError get and set methods.
........
r46511 | michael.hudson | 2006-05-28 23:19:03 +0200 (Sun, 28 May 2006) | 3 lines
use the UnicodeError traversal and clearing functions in UnicodeError
subclasses.
........
r46512 | thomas.wouters | 2006-05-28 23:32:12 +0200 (Sun, 28 May 2006) | 4 lines
Make last patch valid C89 so Windows compilers can deal with it.
........
r46513 | georg.brandl | 2006-05-28 23:42:54 +0200 (Sun, 28 May 2006) | 3 lines
Fix ref-antileak in _struct.c which eventually lead to deallocating None.
........
r46514 | georg.brandl | 2006-05-28 23:57:35 +0200 (Sun, 28 May 2006) | 4 lines
Correct None refcount issue in Mac modules. (Are they
still used?)
........
r46515 | armin.rigo | 2006-05-29 00:07:08 +0200 (Mon, 29 May 2006) | 3 lines
A clearer error message when passing -R to regrtest.py with
release builds of Python.
........
r46516 | georg.brandl | 2006-05-29 00:14:04 +0200 (Mon, 29 May 2006) | 3 lines
Fix C function calling conventions in _sre module.
........
r46517 | georg.brandl | 2006-05-29 00:34:51 +0200 (Mon, 29 May 2006) | 3 lines
Convert audioop over to METH_VARARGS.
........
r46518 | georg.brandl | 2006-05-29 00:38:57 +0200 (Mon, 29 May 2006) | 3 lines
METH_NOARGS functions do get called with two args.
........
r46519 | georg.brandl | 2006-05-29 11:46:51 +0200 (Mon, 29 May 2006) | 4 lines
Fix refleak in socketmodule. Replace bogus Py_BuildValue calls.
Fix refleak in exceptions.
........
r46520 | nick.coghlan | 2006-05-29 14:43:05 +0200 (Mon, 29 May 2006) | 7 lines
Apply modified version of Collin Winter's patch #1478788
Renames functional extension module to _functools and adds a Python
functools module so that utility functions like update_wrapper can be
added easily.
........
r46522 | georg.brandl | 2006-05-29 15:53:16 +0200 (Mon, 29 May 2006) | 3 lines
Convert fmmodule to METH_VARARGS.
........
r46523 | georg.brandl | 2006-05-29 16:13:21 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494605.
........
r46524 | georg.brandl | 2006-05-29 16:28:05 +0200 (Mon, 29 May 2006) | 3 lines
Handle PyMem_Malloc failure in pystrtod.c. Closes #1494671.
........
r46525 | georg.brandl | 2006-05-29 16:33:55 +0200 (Mon, 29 May 2006) | 3 lines
Fix compiler warning.
........
r46526 | georg.brandl | 2006-05-29 16:39:00 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494787 (pyclbr counts whitespace as superclass name)
........
r46527 | bob.ippolito | 2006-05-29 17:47:29 +0200 (Mon, 29 May 2006) | 1 line
simplify the struct code a bit (no functional changes)
........
r46528 | armin.rigo | 2006-05-29 19:59:47 +0200 (Mon, 29 May 2006) | 2 lines
Silence a warning.
........
r46529 | georg.brandl | 2006-05-29 21:39:45 +0200 (Mon, 29 May 2006) | 3 lines
Correct some value converting strangenesses.
........
r46530 | nick.coghlan | 2006-05-29 22:27:44 +0200 (Mon, 29 May 2006) | 1 line
When adding a module like functools, it helps to let SVN know about the file.
........
r46531 | georg.brandl | 2006-05-29 22:52:54 +0200 (Mon, 29 May 2006) | 4 lines
Patches #1497027 and #972322: try HTTP digest auth first,
and watch out for handler name collisions.
........
r46532 | georg.brandl | 2006-05-29 22:57:01 +0200 (Mon, 29 May 2006) | 3 lines
Add News entry for last commit.
........
r46533 | georg.brandl | 2006-05-29 23:04:52 +0200 (Mon, 29 May 2006) | 4 lines
Make use of METH_O and METH_NOARGS where possible.
Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
........
r46534 | georg.brandl | 2006-05-29 23:58:42 +0200 (Mon, 29 May 2006) | 3 lines
Convert more modules to METH_VARARGS.
........
r46535 | georg.brandl | 2006-05-30 00:00:30 +0200 (Tue, 30 May 2006) | 3 lines
Whoops.
........
r46536 | fredrik.lundh | 2006-05-30 00:42:07 +0200 (Tue, 30 May 2006) | 4 lines
fixed "abc".count("", 100) == -96 error (hopefully, nobody's relying on
the current behaviour ;-)
........
r46537 | bob.ippolito | 2006-05-30 00:55:48 +0200 (Tue, 30 May 2006) | 1 line
struct: modulo math plus warning on all endian-explicit formats for compatibility with older struct usage (ugly)
........
r46539 | bob.ippolito | 2006-05-30 02:26:01 +0200 (Tue, 30 May 2006) | 1 line
Add a length check to aifc to ensure it doesn't write a bogus file
........
r46540 | tim.peters | 2006-05-30 04:25:25 +0200 (Tue, 30 May 2006) | 10 lines
deprecated_err(): Stop bizarre warning messages when the tests
are run in the order:
test_genexps (or any other doctest-based test)
test_struct
test_doctest
The `warnings` module needs an advertised way to save/restore
its internal filter list.
........
r46541 | tim.peters | 2006-05-30 04:26:46 +0200 (Tue, 30 May 2006) | 2 lines
Whitespace normalization.
........
r46542 | tim.peters | 2006-05-30 04:30:30 +0200 (Tue, 30 May 2006) | 2 lines
Set a binary svn:mime-type property on this UTF-8 encoded file.
........
r46543 | neal.norwitz | 2006-05-30 05:18:50 +0200 (Tue, 30 May 2006) | 1 line
Simplify further by using AddStringConstant
........
r46544 | tim.peters | 2006-05-30 06:16:25 +0200 (Tue, 30 May 2006) | 6 lines
Convert relevant dict internals to Py_ssize_t.
I don't have a box with nearly enough RAM, or an OS,
that could get close to tickling this, though (requires
a dict w/ at least 2**31 entries).
........
r46545 | neal.norwitz | 2006-05-30 06:19:21 +0200 (Tue, 30 May 2006) | 1 line
Remove stray | in comment
........
r46546 | neal.norwitz | 2006-05-30 06:25:05 +0200 (Tue, 30 May 2006) | 1 line
Use Py_SAFE_DOWNCAST for safety. Fix format strings. Remove 2 more stray | in comment
........
r46547 | neal.norwitz | 2006-05-30 06:43:23 +0200 (Tue, 30 May 2006) | 1 line
No DOWNCAST is required since sizeof(Py_ssize_t) >= sizeof(int) and Py_ReprEntr returns an int
........
r46548 | tim.peters | 2006-05-30 07:04:59 +0200 (Tue, 30 May 2006) | 3 lines
dict_print(): Explicitly narrow the return value
from a (possibly) wider variable.
........
r46549 | tim.peters | 2006-05-30 07:23:59 +0200 (Tue, 30 May 2006) | 5 lines
dict_print(): So that Neal & I don't spend the rest of
our lives taking turns rewriting code that works ;-),
get rid of casting illusions by declaring a new variable
with the obvious type.
........
r46550 | georg.brandl | 2006-05-30 09:04:55 +0200 (Tue, 30 May 2006) | 3 lines
Restore exception pickle support. #1497319.
........
r46551 | georg.brandl | 2006-05-30 09:13:29 +0200 (Tue, 30 May 2006) | 3 lines
Add a test case for exception pickling. args is never NULL.
........
r46552 | neal.norwitz | 2006-05-30 09:21:10 +0200 (Tue, 30 May 2006) | 1 line
Don't fail if the (sub)pkgname already exist.
........
r46553 | georg.brandl | 2006-05-30 09:34:45 +0200 (Tue, 30 May 2006) | 3 lines
Disallow keyword args for exceptions.
........
r46554 | neal.norwitz | 2006-05-30 09:36:54 +0200 (Tue, 30 May 2006) | 5 lines
I'm impatient. I think this will fix a few more problems with the buildbots.
I'm not sure this is the best approach, but I can't think of anything better.
If this creates problems, feel free to revert, but I think it's safe and
should make things a little better.
........
r46555 | georg.brandl | 2006-05-30 10:17:00 +0200 (Tue, 30 May 2006) | 4 lines
Do the check for no keyword arguments in __init__ so that
subclasses of Exception can be supplied keyword args
........
r46556 | georg.brandl | 2006-05-30 10:47:19 +0200 (Tue, 30 May 2006) | 3 lines
Convert test_exceptions to unittest.
........
r46557 | andrew.kuchling | 2006-05-30 14:52:01 +0200 (Tue, 30 May 2006) | 1 line
Add SoC name, and reorganize this section a bit
........
r46559 | tim.peters | 2006-05-30 17:53:34 +0200 (Tue, 30 May 2006) | 11 lines
PyLong_FromString(): Continued fraction analysis (explained in
a new comment) suggests there are almost certainly large input
integers in all non-binary input bases for which one Python digit
too few is initally allocated to hold the final result. Instead
of assert-failing when that happens, allocate more space. Alas,
I estimate it would take a few days to find a specific such case,
so this isn't backed up by a new test (not to mention that such
a case may take hours to run, since conversion time is quadratic
in the number of digits, and preliminary attempts suggested that
the smallest such inputs contain at least a million digits).
........
r46560 | fredrik.lundh | 2006-05-30 19:11:48 +0200 (Tue, 30 May 2006) | 3 lines
changed find/rfind to return -1 for matches outside the source string
........
r46561 | bob.ippolito | 2006-05-30 19:37:54 +0200 (Tue, 30 May 2006) | 1 line
Change wrapping terminology to overflow masking
........
r46562 | fredrik.lundh | 2006-05-30 19:39:58 +0200 (Tue, 30 May 2006) | 3 lines
changed count to return 0 for slices outside the source string
........
r46568 | tim.peters | 2006-05-31 01:28:02 +0200 (Wed, 31 May 2006) | 2 lines
Whitespace normalization.
........
r46569 | brett.cannon | 2006-05-31 04:19:54 +0200 (Wed, 31 May 2006) | 5 lines
Clarify wording on default values for strptime(); defaults are used when better
values cannot be inferred.
Closes bug #1496315.
........
r46572 | neal.norwitz | 2006-05-31 09:43:27 +0200 (Wed, 31 May 2006) | 1 line
Calculate smallest properly (it was off by one) and use proper ssize_t types for Win64
........
r46573 | neal.norwitz | 2006-05-31 10:01:08 +0200 (Wed, 31 May 2006) | 1 line
Revert last checkin, it is better to do make distclean
........
r46574 | neal.norwitz | 2006-05-31 11:02:44 +0200 (Wed, 31 May 2006) | 3 lines
On 64-bit platforms running test_struct after test_tarfile would fail
since the deprecation warning wouldn't be raised.
........
r46575 | thomas.heller | 2006-05-31 13:37:58 +0200 (Wed, 31 May 2006) | 3 lines
PyTuple_Pack is not available in Python 2.3, but ctypes must stay
compatible with that.
........
r46576 | andrew.kuchling | 2006-05-31 15:18:56 +0200 (Wed, 31 May 2006) | 1 line
'functional' module was renamed to 'functools'
........
r46577 | kristjan.jonsson | 2006-05-31 15:35:41 +0200 (Wed, 31 May 2006) | 1 line
Fixup the PCBuild8 project directory. exceptions.c have moved to Objects, and the functionalmodule.c has been replaced with _functoolsmodule.c. Other minor changes to .vcproj files and .sln to fix compilation
........
r46578 | andrew.kuchling | 2006-05-31 16:08:48 +0200 (Wed, 31 May 2006) | 15 lines
[Bug #1473048]
SimpleXMLRPCServer and DocXMLRPCServer don't look at
the path of the HTTP request at all; you can POST or
GET from / or /RPC2 or /blahblahblah with the same results.
Security scanners that look for /cgi-bin/phf will therefore report
lots of vulnerabilities.
Fix: add a .rpc_paths attribute to the SimpleXMLRPCServer class,
and report a 404 error if the path isn't on the allowed list.
Possibly-controversial aspect of this change: the default makes only
'/' and '/RPC2' legal. Maybe this will break people's applications
(though I doubt it). We could just set the default to an empty tuple,
which would exactly match the current behaviour.
........
r46579 | andrew.kuchling | 2006-05-31 16:12:47 +0200 (Wed, 31 May 2006) | 1 line
Mention SimpleXMLRPCServer change
........
r46580 | tim.peters | 2006-05-31 16:28:07 +0200 (Wed, 31 May 2006) | 2 lines
Trimmed trailing whitespace.
........
r46581 | tim.peters | 2006-05-31 17:33:22 +0200 (Wed, 31 May 2006) | 4 lines
_range_error(): Speed and simplify (there's no real need for
loops here). Assert that size_t is actually big enough, and
that f->size is at least one. Wrap a long line.
........
r46582 | tim.peters | 2006-05-31 17:34:37 +0200 (Wed, 31 May 2006) | 2 lines
Repaired error in new comment.
........
r46584 | neal.norwitz | 2006-06-01 07:32:49 +0200 (Thu, 01 Jun 2006) | 4 lines
Remove ; at end of macro. There was a compiler recently that warned
about extra semi-colons. It may have been the HP C compiler.
This file will trigger a bunch of those warnings now.
........
r46585 | georg.brandl | 2006-06-01 08:39:19 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly unpickle 2.4 exceptions via __setstate__ (patch #1498571)
........
r46586 | georg.brandl | 2006-06-01 10:27:32 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly allocate complex types with tp_alloc. (bug #1498638)
........
r46587 | georg.brandl | 2006-06-01 14:30:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Correctly dispatch Faults in loads (patch #1498627)
........
r46588 | georg.brandl | 2006-06-01 15:00:49 +0200 (Thu, 01 Jun 2006) | 3 lines
Some code style tweaks, and remove apply.
........
r46589 | armin.rigo | 2006-06-01 15:19:12 +0200 (Thu, 01 Jun 2006) | 5 lines
[ 1497053 ] Let dicts propagate the exceptions in user __eq__().
[ 1456209 ] dictresize() vulnerability ( <- backport candidate ).
........
r46590 | tim.peters | 2006-06-01 15:41:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Whitespace normalization.
........
r46591 | tim.peters | 2006-06-01 15:49:23 +0200 (Thu, 01 Jun 2006) | 2 lines
Record bugs 1275608 and 1456209 as being fixed.
........
r46592 | tim.peters | 2006-06-01 15:56:26 +0200 (Thu, 01 Jun 2006) | 5 lines
Re-enable a new empty-string test added during the NFS sprint,
but disabled then because str and unicode strings gave different
results. The implementations were repaired later during the
sprint, but the new test remained disabled.
........
r46594 | tim.peters | 2006-06-01 17:50:44 +0200 (Thu, 01 Jun 2006) | 7 lines
Armin committed his patch while I was reviewing it (I'm sure
he didn't know this), so merged in some changes I made during
review. Nothing material apart from changing a new `mask` local
from int to Py_ssize_t. Mostly this is repairing comments that
were made incorrect, and adding new comments. Also a few
minor code rewrites for clarity or helpful succinctness.
........
r46599 | neal.norwitz | 2006-06-02 06:45:53 +0200 (Fri, 02 Jun 2006) | 1 line
Convert docstrings to comments so regrtest -v prints method names
........
r46600 | neal.norwitz | 2006-06-02 06:50:49 +0200 (Fri, 02 Jun 2006) | 2 lines
Fix memory leak found by valgrind.
........
r46601 | neal.norwitz | 2006-06-02 06:54:52 +0200 (Fri, 02 Jun 2006) | 1 line
More memory leaks from valgrind
........
r46602 | neal.norwitz | 2006-06-02 08:23:00 +0200 (Fri, 02 Jun 2006) | 11 lines
Patch #1357836:
Prevent an invalid memory read from test_coding in case the done flag is set.
In that case, the loop isn't entered. I wonder if rather than setting
the done flag in the cases before the loop, if they should just exit early.
This code looks like it should be refactored.
Backport candidate (also the early break above if decoding_fgets fails)
........
r46603 | martin.blais | 2006-06-02 15:03:43 +0200 (Fri, 02 Jun 2006) | 1 line
Fixed struct test to not use unittest.
........
r46605 | tim.peters | 2006-06-03 01:22:51 +0200 (Sat, 03 Jun 2006) | 10 lines
pprint functions used to sort a dict (by key) if and only if
the output required more than one line. "Small" dicts got
displayed in seemingly random order (the hash-induced order
produced by dict.__repr__). None of this was documented.
Now pprint functions always sort dicts by key, and the docs
promise it.
This was proposed and agreed to during the PyCon 2006 core
sprint -- I just didn't have time for it before now.
........
2006-06-08 11:42:34 -03:00
|
|
|
METH_O, xmlparse_ParseFile__doc__},
|
2000-07-12 01:49:00 -03:00
|
|
|
{"SetBase", (PyCFunction)xmlparse_SetBase,
|
2003-01-21 06:58:18 -04:00
|
|
|
METH_VARARGS, xmlparse_SetBase__doc__},
|
2000-07-12 01:49:00 -03:00
|
|
|
{"GetBase", (PyCFunction)xmlparse_GetBase,
|
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
merge in bad ways, so I'll have to merge that extra-carefully (probably manually.)
Merged revisions 46495-46605 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r46495 | tim.peters | 2006-05-28 03:52:38 +0200 (Sun, 28 May 2006) | 2 lines
Added missing svn:eol-style property to text files.
........
r46497 | tim.peters | 2006-05-28 12:41:29 +0200 (Sun, 28 May 2006) | 3 lines
PyErr_Display(), PyErr_WriteUnraisable(): Coverity found a cut-and-paste
bug in both: `className` was referenced before being checked for NULL.
........
r46499 | fredrik.lundh | 2006-05-28 14:06:46 +0200 (Sun, 28 May 2006) | 5 lines
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
and use it for string copy operations. this gives a 20% speedup on some
string benchmarks.
........
r46501 | michael.hudson | 2006-05-28 17:51:40 +0200 (Sun, 28 May 2006) | 26 lines
Quality control, meet exceptions.c.
Fix a number of problems with the need for speed code:
One is doing this sort of thing:
Py_DECREF(self->field);
self->field = newval;
Py_INCREF(self->field);
without being very sure that self->field doesn't start with a
value that has a __del__, because that almost certainly can lead
to segfaults.
As self->args is constrained to be an exact tuple we may as well
exploit this fact consistently. This leads to quite a lot of
simplification (and, hey, probably better performance).
Add some error checking in places lacking it.
Fix some rather strange indentation in the Unicode code.
Delete some trailing whitespace.
More to come, I haven't fixed all the reference leaks yet...
........
r46502 | george.yoshida | 2006-05-28 18:39:09 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1080727: add "encoding" parameter to doctest.DocFileSuite
Contributed by Bjorn Tillenius.
........
r46503 | martin.v.loewis | 2006-05-28 18:57:38 +0200 (Sun, 28 May 2006) | 4 lines
Rest of patch #1490384: Commit icon source, remove
claim that Erik von Blokland is the author of the
installer picture.
........
r46504 | michael.hudson | 2006-05-28 19:40:29 +0200 (Sun, 28 May 2006) | 16 lines
Quality control, meet exceptions.c, round two.
Make some functions that should have been static static.
Fix a bunch of refleaks by fixing the definition of
MiddlingExtendsException.
Remove all the __new__ implementations apart from
BaseException_new. Rewrite most code that needs it to cope with
NULL fields (such code could get excercised anyway, the
__new__-removal just makes it more likely). This involved
editing the code for WindowsError, which I can't test.
This fixes all the refleaks in at least the start of a regrtest
-R :: run.
........
r46505 | marc-andre.lemburg | 2006-05-28 19:46:58 +0200 (Sun, 28 May 2006) | 10 lines
Initial version of systimes - a module to provide platform dependent
performance measurements.
The module is currently just a proof-of-concept implementation, but
will integrated into pybench once it is stable enough.
License: pybench license.
Author: Marc-Andre Lemburg.
........
r46507 | armin.rigo | 2006-05-28 21:13:17 +0200 (Sun, 28 May 2006) | 15 lines
("Forward-port" of r46506)
Remove various dependencies on dictionary order in the standard library
tests, and one (clearly an oversight, potentially critical) in the
standard library itself - base64.py.
Remaining open issues:
* test_extcall is an output test, messy to make robust
* tarfile.py has a potential bug here, but I'm not familiar
enough with this code. Filed in as SF bug #1496501.
* urllib2.HTTPPasswordMgr() returns a random result if there is more
than one matching root path. I'm asking python-dev for
clarification...
........
r46508 | georg.brandl | 2006-05-28 22:11:45 +0200 (Sun, 28 May 2006) | 4 lines
The empty string is a valid import path.
(fixes #1496539)
........
r46509 | georg.brandl | 2006-05-28 22:23:12 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1496206: urllib2 PasswordMgr ./. default ports
........
r46510 | georg.brandl | 2006-05-28 22:57:09 +0200 (Sun, 28 May 2006) | 3 lines
Fix refleaks in UnicodeError get and set methods.
........
r46511 | michael.hudson | 2006-05-28 23:19:03 +0200 (Sun, 28 May 2006) | 3 lines
use the UnicodeError traversal and clearing functions in UnicodeError
subclasses.
........
r46512 | thomas.wouters | 2006-05-28 23:32:12 +0200 (Sun, 28 May 2006) | 4 lines
Make last patch valid C89 so Windows compilers can deal with it.
........
r46513 | georg.brandl | 2006-05-28 23:42:54 +0200 (Sun, 28 May 2006) | 3 lines
Fix ref-antileak in _struct.c which eventually lead to deallocating None.
........
r46514 | georg.brandl | 2006-05-28 23:57:35 +0200 (Sun, 28 May 2006) | 4 lines
Correct None refcount issue in Mac modules. (Are they
still used?)
........
r46515 | armin.rigo | 2006-05-29 00:07:08 +0200 (Mon, 29 May 2006) | 3 lines
A clearer error message when passing -R to regrtest.py with
release builds of Python.
........
r46516 | georg.brandl | 2006-05-29 00:14:04 +0200 (Mon, 29 May 2006) | 3 lines
Fix C function calling conventions in _sre module.
........
r46517 | georg.brandl | 2006-05-29 00:34:51 +0200 (Mon, 29 May 2006) | 3 lines
Convert audioop over to METH_VARARGS.
........
r46518 | georg.brandl | 2006-05-29 00:38:57 +0200 (Mon, 29 May 2006) | 3 lines
METH_NOARGS functions do get called with two args.
........
r46519 | georg.brandl | 2006-05-29 11:46:51 +0200 (Mon, 29 May 2006) | 4 lines
Fix refleak in socketmodule. Replace bogus Py_BuildValue calls.
Fix refleak in exceptions.
........
r46520 | nick.coghlan | 2006-05-29 14:43:05 +0200 (Mon, 29 May 2006) | 7 lines
Apply modified version of Collin Winter's patch #1478788
Renames functional extension module to _functools and adds a Python
functools module so that utility functions like update_wrapper can be
added easily.
........
r46522 | georg.brandl | 2006-05-29 15:53:16 +0200 (Mon, 29 May 2006) | 3 lines
Convert fmmodule to METH_VARARGS.
........
r46523 | georg.brandl | 2006-05-29 16:13:21 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494605.
........
r46524 | georg.brandl | 2006-05-29 16:28:05 +0200 (Mon, 29 May 2006) | 3 lines
Handle PyMem_Malloc failure in pystrtod.c. Closes #1494671.
........
r46525 | georg.brandl | 2006-05-29 16:33:55 +0200 (Mon, 29 May 2006) | 3 lines
Fix compiler warning.
........
r46526 | georg.brandl | 2006-05-29 16:39:00 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494787 (pyclbr counts whitespace as superclass name)
........
r46527 | bob.ippolito | 2006-05-29 17:47:29 +0200 (Mon, 29 May 2006) | 1 line
simplify the struct code a bit (no functional changes)
........
r46528 | armin.rigo | 2006-05-29 19:59:47 +0200 (Mon, 29 May 2006) | 2 lines
Silence a warning.
........
r46529 | georg.brandl | 2006-05-29 21:39:45 +0200 (Mon, 29 May 2006) | 3 lines
Correct some value converting strangenesses.
........
r46530 | nick.coghlan | 2006-05-29 22:27:44 +0200 (Mon, 29 May 2006) | 1 line
When adding a module like functools, it helps to let SVN know about the file.
........
r46531 | georg.brandl | 2006-05-29 22:52:54 +0200 (Mon, 29 May 2006) | 4 lines
Patches #1497027 and #972322: try HTTP digest auth first,
and watch out for handler name collisions.
........
r46532 | georg.brandl | 2006-05-29 22:57:01 +0200 (Mon, 29 May 2006) | 3 lines
Add News entry for last commit.
........
r46533 | georg.brandl | 2006-05-29 23:04:52 +0200 (Mon, 29 May 2006) | 4 lines
Make use of METH_O and METH_NOARGS where possible.
Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
........
r46534 | georg.brandl | 2006-05-29 23:58:42 +0200 (Mon, 29 May 2006) | 3 lines
Convert more modules to METH_VARARGS.
........
r46535 | georg.brandl | 2006-05-30 00:00:30 +0200 (Tue, 30 May 2006) | 3 lines
Whoops.
........
r46536 | fredrik.lundh | 2006-05-30 00:42:07 +0200 (Tue, 30 May 2006) | 4 lines
fixed "abc".count("", 100) == -96 error (hopefully, nobody's relying on
the current behaviour ;-)
........
r46537 | bob.ippolito | 2006-05-30 00:55:48 +0200 (Tue, 30 May 2006) | 1 line
struct: modulo math plus warning on all endian-explicit formats for compatibility with older struct usage (ugly)
........
r46539 | bob.ippolito | 2006-05-30 02:26:01 +0200 (Tue, 30 May 2006) | 1 line
Add a length check to aifc to ensure it doesn't write a bogus file
........
r46540 | tim.peters | 2006-05-30 04:25:25 +0200 (Tue, 30 May 2006) | 10 lines
deprecated_err(): Stop bizarre warning messages when the tests
are run in the order:
test_genexps (or any other doctest-based test)
test_struct
test_doctest
The `warnings` module needs an advertised way to save/restore
its internal filter list.
........
r46541 | tim.peters | 2006-05-30 04:26:46 +0200 (Tue, 30 May 2006) | 2 lines
Whitespace normalization.
........
r46542 | tim.peters | 2006-05-30 04:30:30 +0200 (Tue, 30 May 2006) | 2 lines
Set a binary svn:mime-type property on this UTF-8 encoded file.
........
r46543 | neal.norwitz | 2006-05-30 05:18:50 +0200 (Tue, 30 May 2006) | 1 line
Simplify further by using AddStringConstant
........
r46544 | tim.peters | 2006-05-30 06:16:25 +0200 (Tue, 30 May 2006) | 6 lines
Convert relevant dict internals to Py_ssize_t.
I don't have a box with nearly enough RAM, or an OS,
that could get close to tickling this, though (requires
a dict w/ at least 2**31 entries).
........
r46545 | neal.norwitz | 2006-05-30 06:19:21 +0200 (Tue, 30 May 2006) | 1 line
Remove stray | in comment
........
r46546 | neal.norwitz | 2006-05-30 06:25:05 +0200 (Tue, 30 May 2006) | 1 line
Use Py_SAFE_DOWNCAST for safety. Fix format strings. Remove 2 more stray | in comment
........
r46547 | neal.norwitz | 2006-05-30 06:43:23 +0200 (Tue, 30 May 2006) | 1 line
No DOWNCAST is required since sizeof(Py_ssize_t) >= sizeof(int) and Py_ReprEntr returns an int
........
r46548 | tim.peters | 2006-05-30 07:04:59 +0200 (Tue, 30 May 2006) | 3 lines
dict_print(): Explicitly narrow the return value
from a (possibly) wider variable.
........
r46549 | tim.peters | 2006-05-30 07:23:59 +0200 (Tue, 30 May 2006) | 5 lines
dict_print(): So that Neal & I don't spend the rest of
our lives taking turns rewriting code that works ;-),
get rid of casting illusions by declaring a new variable
with the obvious type.
........
r46550 | georg.brandl | 2006-05-30 09:04:55 +0200 (Tue, 30 May 2006) | 3 lines
Restore exception pickle support. #1497319.
........
r46551 | georg.brandl | 2006-05-30 09:13:29 +0200 (Tue, 30 May 2006) | 3 lines
Add a test case for exception pickling. args is never NULL.
........
r46552 | neal.norwitz | 2006-05-30 09:21:10 +0200 (Tue, 30 May 2006) | 1 line
Don't fail if the (sub)pkgname already exist.
........
r46553 | georg.brandl | 2006-05-30 09:34:45 +0200 (Tue, 30 May 2006) | 3 lines
Disallow keyword args for exceptions.
........
r46554 | neal.norwitz | 2006-05-30 09:36:54 +0200 (Tue, 30 May 2006) | 5 lines
I'm impatient. I think this will fix a few more problems with the buildbots.
I'm not sure this is the best approach, but I can't think of anything better.
If this creates problems, feel free to revert, but I think it's safe and
should make things a little better.
........
r46555 | georg.brandl | 2006-05-30 10:17:00 +0200 (Tue, 30 May 2006) | 4 lines
Do the check for no keyword arguments in __init__ so that
subclasses of Exception can be supplied keyword args
........
r46556 | georg.brandl | 2006-05-30 10:47:19 +0200 (Tue, 30 May 2006) | 3 lines
Convert test_exceptions to unittest.
........
r46557 | andrew.kuchling | 2006-05-30 14:52:01 +0200 (Tue, 30 May 2006) | 1 line
Add SoC name, and reorganize this section a bit
........
r46559 | tim.peters | 2006-05-30 17:53:34 +0200 (Tue, 30 May 2006) | 11 lines
PyLong_FromString(): Continued fraction analysis (explained in
a new comment) suggests there are almost certainly large input
integers in all non-binary input bases for which one Python digit
too few is initally allocated to hold the final result. Instead
of assert-failing when that happens, allocate more space. Alas,
I estimate it would take a few days to find a specific such case,
so this isn't backed up by a new test (not to mention that such
a case may take hours to run, since conversion time is quadratic
in the number of digits, and preliminary attempts suggested that
the smallest such inputs contain at least a million digits).
........
r46560 | fredrik.lundh | 2006-05-30 19:11:48 +0200 (Tue, 30 May 2006) | 3 lines
changed find/rfind to return -1 for matches outside the source string
........
r46561 | bob.ippolito | 2006-05-30 19:37:54 +0200 (Tue, 30 May 2006) | 1 line
Change wrapping terminology to overflow masking
........
r46562 | fredrik.lundh | 2006-05-30 19:39:58 +0200 (Tue, 30 May 2006) | 3 lines
changed count to return 0 for slices outside the source string
........
r46568 | tim.peters | 2006-05-31 01:28:02 +0200 (Wed, 31 May 2006) | 2 lines
Whitespace normalization.
........
r46569 | brett.cannon | 2006-05-31 04:19:54 +0200 (Wed, 31 May 2006) | 5 lines
Clarify wording on default values for strptime(); defaults are used when better
values cannot be inferred.
Closes bug #1496315.
........
r46572 | neal.norwitz | 2006-05-31 09:43:27 +0200 (Wed, 31 May 2006) | 1 line
Calculate smallest properly (it was off by one) and use proper ssize_t types for Win64
........
r46573 | neal.norwitz | 2006-05-31 10:01:08 +0200 (Wed, 31 May 2006) | 1 line
Revert last checkin, it is better to do make distclean
........
r46574 | neal.norwitz | 2006-05-31 11:02:44 +0200 (Wed, 31 May 2006) | 3 lines
On 64-bit platforms running test_struct after test_tarfile would fail
since the deprecation warning wouldn't be raised.
........
r46575 | thomas.heller | 2006-05-31 13:37:58 +0200 (Wed, 31 May 2006) | 3 lines
PyTuple_Pack is not available in Python 2.3, but ctypes must stay
compatible with that.
........
r46576 | andrew.kuchling | 2006-05-31 15:18:56 +0200 (Wed, 31 May 2006) | 1 line
'functional' module was renamed to 'functools'
........
r46577 | kristjan.jonsson | 2006-05-31 15:35:41 +0200 (Wed, 31 May 2006) | 1 line
Fixup the PCBuild8 project directory. exceptions.c have moved to Objects, and the functionalmodule.c has been replaced with _functoolsmodule.c. Other minor changes to .vcproj files and .sln to fix compilation
........
r46578 | andrew.kuchling | 2006-05-31 16:08:48 +0200 (Wed, 31 May 2006) | 15 lines
[Bug #1473048]
SimpleXMLRPCServer and DocXMLRPCServer don't look at
the path of the HTTP request at all; you can POST or
GET from / or /RPC2 or /blahblahblah with the same results.
Security scanners that look for /cgi-bin/phf will therefore report
lots of vulnerabilities.
Fix: add a .rpc_paths attribute to the SimpleXMLRPCServer class,
and report a 404 error if the path isn't on the allowed list.
Possibly-controversial aspect of this change: the default makes only
'/' and '/RPC2' legal. Maybe this will break people's applications
(though I doubt it). We could just set the default to an empty tuple,
which would exactly match the current behaviour.
........
r46579 | andrew.kuchling | 2006-05-31 16:12:47 +0200 (Wed, 31 May 2006) | 1 line
Mention SimpleXMLRPCServer change
........
r46580 | tim.peters | 2006-05-31 16:28:07 +0200 (Wed, 31 May 2006) | 2 lines
Trimmed trailing whitespace.
........
r46581 | tim.peters | 2006-05-31 17:33:22 +0200 (Wed, 31 May 2006) | 4 lines
_range_error(): Speed and simplify (there's no real need for
loops here). Assert that size_t is actually big enough, and
that f->size is at least one. Wrap a long line.
........
r46582 | tim.peters | 2006-05-31 17:34:37 +0200 (Wed, 31 May 2006) | 2 lines
Repaired error in new comment.
........
r46584 | neal.norwitz | 2006-06-01 07:32:49 +0200 (Thu, 01 Jun 2006) | 4 lines
Remove ; at end of macro. There was a compiler recently that warned
about extra semi-colons. It may have been the HP C compiler.
This file will trigger a bunch of those warnings now.
........
r46585 | georg.brandl | 2006-06-01 08:39:19 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly unpickle 2.4 exceptions via __setstate__ (patch #1498571)
........
r46586 | georg.brandl | 2006-06-01 10:27:32 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly allocate complex types with tp_alloc. (bug #1498638)
........
r46587 | georg.brandl | 2006-06-01 14:30:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Correctly dispatch Faults in loads (patch #1498627)
........
r46588 | georg.brandl | 2006-06-01 15:00:49 +0200 (Thu, 01 Jun 2006) | 3 lines
Some code style tweaks, and remove apply.
........
r46589 | armin.rigo | 2006-06-01 15:19:12 +0200 (Thu, 01 Jun 2006) | 5 lines
[ 1497053 ] Let dicts propagate the exceptions in user __eq__().
[ 1456209 ] dictresize() vulnerability ( <- backport candidate ).
........
r46590 | tim.peters | 2006-06-01 15:41:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Whitespace normalization.
........
r46591 | tim.peters | 2006-06-01 15:49:23 +0200 (Thu, 01 Jun 2006) | 2 lines
Record bugs 1275608 and 1456209 as being fixed.
........
r46592 | tim.peters | 2006-06-01 15:56:26 +0200 (Thu, 01 Jun 2006) | 5 lines
Re-enable a new empty-string test added during the NFS sprint,
but disabled then because str and unicode strings gave different
results. The implementations were repaired later during the
sprint, but the new test remained disabled.
........
r46594 | tim.peters | 2006-06-01 17:50:44 +0200 (Thu, 01 Jun 2006) | 7 lines
Armin committed his patch while I was reviewing it (I'm sure
he didn't know this), so merged in some changes I made during
review. Nothing material apart from changing a new `mask` local
from int to Py_ssize_t. Mostly this is repairing comments that
were made incorrect, and adding new comments. Also a few
minor code rewrites for clarity or helpful succinctness.
........
r46599 | neal.norwitz | 2006-06-02 06:45:53 +0200 (Fri, 02 Jun 2006) | 1 line
Convert docstrings to comments so regrtest -v prints method names
........
r46600 | neal.norwitz | 2006-06-02 06:50:49 +0200 (Fri, 02 Jun 2006) | 2 lines
Fix memory leak found by valgrind.
........
r46601 | neal.norwitz | 2006-06-02 06:54:52 +0200 (Fri, 02 Jun 2006) | 1 line
More memory leaks from valgrind
........
r46602 | neal.norwitz | 2006-06-02 08:23:00 +0200 (Fri, 02 Jun 2006) | 11 lines
Patch #1357836:
Prevent an invalid memory read from test_coding in case the done flag is set.
In that case, the loop isn't entered. I wonder if rather than setting
the done flag in the cases before the loop, if they should just exit early.
This code looks like it should be refactored.
Backport candidate (also the early break above if decoding_fgets fails)
........
r46603 | martin.blais | 2006-06-02 15:03:43 +0200 (Fri, 02 Jun 2006) | 1 line
Fixed struct test to not use unittest.
........
r46605 | tim.peters | 2006-06-03 01:22:51 +0200 (Sat, 03 Jun 2006) | 10 lines
pprint functions used to sort a dict (by key) if and only if
the output required more than one line. "Small" dicts got
displayed in seemingly random order (the hash-induced order
produced by dict.__repr__). None of this was documented.
Now pprint functions always sort dicts by key, and the docs
promise it.
This was proposed and agreed to during the PyCon 2006 core
sprint -- I just didn't have time for it before now.
........
2006-06-08 11:42:34 -03:00
|
|
|
METH_NOARGS, xmlparse_GetBase__doc__},
|
2000-09-24 17:50:52 -03:00
|
|
|
{"ExternalEntityParserCreate", (PyCFunction)xmlparse_ExternalEntityParserCreate,
|
2003-01-21 06:58:18 -04:00
|
|
|
METH_VARARGS, xmlparse_ExternalEntityParserCreate__doc__},
|
2001-02-14 14:29:45 -04:00
|
|
|
{"SetParamEntityParsing", (PyCFunction)xmlparse_SetParamEntityParsing,
|
|
|
|
METH_VARARGS, xmlparse_SetParamEntityParsing__doc__},
|
|
|
|
{"GetInputContext", (PyCFunction)xmlparse_GetInputContext,
|
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
merge in bad ways, so I'll have to merge that extra-carefully (probably manually.)
Merged revisions 46495-46605 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r46495 | tim.peters | 2006-05-28 03:52:38 +0200 (Sun, 28 May 2006) | 2 lines
Added missing svn:eol-style property to text files.
........
r46497 | tim.peters | 2006-05-28 12:41:29 +0200 (Sun, 28 May 2006) | 3 lines
PyErr_Display(), PyErr_WriteUnraisable(): Coverity found a cut-and-paste
bug in both: `className` was referenced before being checked for NULL.
........
r46499 | fredrik.lundh | 2006-05-28 14:06:46 +0200 (Sun, 28 May 2006) | 5 lines
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
and use it for string copy operations. this gives a 20% speedup on some
string benchmarks.
........
r46501 | michael.hudson | 2006-05-28 17:51:40 +0200 (Sun, 28 May 2006) | 26 lines
Quality control, meet exceptions.c.
Fix a number of problems with the need for speed code:
One is doing this sort of thing:
Py_DECREF(self->field);
self->field = newval;
Py_INCREF(self->field);
without being very sure that self->field doesn't start with a
value that has a __del__, because that almost certainly can lead
to segfaults.
As self->args is constrained to be an exact tuple we may as well
exploit this fact consistently. This leads to quite a lot of
simplification (and, hey, probably better performance).
Add some error checking in places lacking it.
Fix some rather strange indentation in the Unicode code.
Delete some trailing whitespace.
More to come, I haven't fixed all the reference leaks yet...
........
r46502 | george.yoshida | 2006-05-28 18:39:09 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1080727: add "encoding" parameter to doctest.DocFileSuite
Contributed by Bjorn Tillenius.
........
r46503 | martin.v.loewis | 2006-05-28 18:57:38 +0200 (Sun, 28 May 2006) | 4 lines
Rest of patch #1490384: Commit icon source, remove
claim that Erik von Blokland is the author of the
installer picture.
........
r46504 | michael.hudson | 2006-05-28 19:40:29 +0200 (Sun, 28 May 2006) | 16 lines
Quality control, meet exceptions.c, round two.
Make some functions that should have been static static.
Fix a bunch of refleaks by fixing the definition of
MiddlingExtendsException.
Remove all the __new__ implementations apart from
BaseException_new. Rewrite most code that needs it to cope with
NULL fields (such code could get excercised anyway, the
__new__-removal just makes it more likely). This involved
editing the code for WindowsError, which I can't test.
This fixes all the refleaks in at least the start of a regrtest
-R :: run.
........
r46505 | marc-andre.lemburg | 2006-05-28 19:46:58 +0200 (Sun, 28 May 2006) | 10 lines
Initial version of systimes - a module to provide platform dependent
performance measurements.
The module is currently just a proof-of-concept implementation, but
will integrated into pybench once it is stable enough.
License: pybench license.
Author: Marc-Andre Lemburg.
........
r46507 | armin.rigo | 2006-05-28 21:13:17 +0200 (Sun, 28 May 2006) | 15 lines
("Forward-port" of r46506)
Remove various dependencies on dictionary order in the standard library
tests, and one (clearly an oversight, potentially critical) in the
standard library itself - base64.py.
Remaining open issues:
* test_extcall is an output test, messy to make robust
* tarfile.py has a potential bug here, but I'm not familiar
enough with this code. Filed in as SF bug #1496501.
* urllib2.HTTPPasswordMgr() returns a random result if there is more
than one matching root path. I'm asking python-dev for
clarification...
........
r46508 | georg.brandl | 2006-05-28 22:11:45 +0200 (Sun, 28 May 2006) | 4 lines
The empty string is a valid import path.
(fixes #1496539)
........
r46509 | georg.brandl | 2006-05-28 22:23:12 +0200 (Sun, 28 May 2006) | 3 lines
Patch #1496206: urllib2 PasswordMgr ./. default ports
........
r46510 | georg.brandl | 2006-05-28 22:57:09 +0200 (Sun, 28 May 2006) | 3 lines
Fix refleaks in UnicodeError get and set methods.
........
r46511 | michael.hudson | 2006-05-28 23:19:03 +0200 (Sun, 28 May 2006) | 3 lines
use the UnicodeError traversal and clearing functions in UnicodeError
subclasses.
........
r46512 | thomas.wouters | 2006-05-28 23:32:12 +0200 (Sun, 28 May 2006) | 4 lines
Make last patch valid C89 so Windows compilers can deal with it.
........
r46513 | georg.brandl | 2006-05-28 23:42:54 +0200 (Sun, 28 May 2006) | 3 lines
Fix ref-antileak in _struct.c which eventually lead to deallocating None.
........
r46514 | georg.brandl | 2006-05-28 23:57:35 +0200 (Sun, 28 May 2006) | 4 lines
Correct None refcount issue in Mac modules. (Are they
still used?)
........
r46515 | armin.rigo | 2006-05-29 00:07:08 +0200 (Mon, 29 May 2006) | 3 lines
A clearer error message when passing -R to regrtest.py with
release builds of Python.
........
r46516 | georg.brandl | 2006-05-29 00:14:04 +0200 (Mon, 29 May 2006) | 3 lines
Fix C function calling conventions in _sre module.
........
r46517 | georg.brandl | 2006-05-29 00:34:51 +0200 (Mon, 29 May 2006) | 3 lines
Convert audioop over to METH_VARARGS.
........
r46518 | georg.brandl | 2006-05-29 00:38:57 +0200 (Mon, 29 May 2006) | 3 lines
METH_NOARGS functions do get called with two args.
........
r46519 | georg.brandl | 2006-05-29 11:46:51 +0200 (Mon, 29 May 2006) | 4 lines
Fix refleak in socketmodule. Replace bogus Py_BuildValue calls.
Fix refleak in exceptions.
........
r46520 | nick.coghlan | 2006-05-29 14:43:05 +0200 (Mon, 29 May 2006) | 7 lines
Apply modified version of Collin Winter's patch #1478788
Renames functional extension module to _functools and adds a Python
functools module so that utility functions like update_wrapper can be
added easily.
........
r46522 | georg.brandl | 2006-05-29 15:53:16 +0200 (Mon, 29 May 2006) | 3 lines
Convert fmmodule to METH_VARARGS.
........
r46523 | georg.brandl | 2006-05-29 16:13:21 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494605.
........
r46524 | georg.brandl | 2006-05-29 16:28:05 +0200 (Mon, 29 May 2006) | 3 lines
Handle PyMem_Malloc failure in pystrtod.c. Closes #1494671.
........
r46525 | georg.brandl | 2006-05-29 16:33:55 +0200 (Mon, 29 May 2006) | 3 lines
Fix compiler warning.
........
r46526 | georg.brandl | 2006-05-29 16:39:00 +0200 (Mon, 29 May 2006) | 3 lines
Fix #1494787 (pyclbr counts whitespace as superclass name)
........
r46527 | bob.ippolito | 2006-05-29 17:47:29 +0200 (Mon, 29 May 2006) | 1 line
simplify the struct code a bit (no functional changes)
........
r46528 | armin.rigo | 2006-05-29 19:59:47 +0200 (Mon, 29 May 2006) | 2 lines
Silence a warning.
........
r46529 | georg.brandl | 2006-05-29 21:39:45 +0200 (Mon, 29 May 2006) | 3 lines
Correct some value converting strangenesses.
........
r46530 | nick.coghlan | 2006-05-29 22:27:44 +0200 (Mon, 29 May 2006) | 1 line
When adding a module like functools, it helps to let SVN know about the file.
........
r46531 | georg.brandl | 2006-05-29 22:52:54 +0200 (Mon, 29 May 2006) | 4 lines
Patches #1497027 and #972322: try HTTP digest auth first,
and watch out for handler name collisions.
........
r46532 | georg.brandl | 2006-05-29 22:57:01 +0200 (Mon, 29 May 2006) | 3 lines
Add News entry for last commit.
........
r46533 | georg.brandl | 2006-05-29 23:04:52 +0200 (Mon, 29 May 2006) | 4 lines
Make use of METH_O and METH_NOARGS where possible.
Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
........
r46534 | georg.brandl | 2006-05-29 23:58:42 +0200 (Mon, 29 May 2006) | 3 lines
Convert more modules to METH_VARARGS.
........
r46535 | georg.brandl | 2006-05-30 00:00:30 +0200 (Tue, 30 May 2006) | 3 lines
Whoops.
........
r46536 | fredrik.lundh | 2006-05-30 00:42:07 +0200 (Tue, 30 May 2006) | 4 lines
fixed "abc".count("", 100) == -96 error (hopefully, nobody's relying on
the current behaviour ;-)
........
r46537 | bob.ippolito | 2006-05-30 00:55:48 +0200 (Tue, 30 May 2006) | 1 line
struct: modulo math plus warning on all endian-explicit formats for compatibility with older struct usage (ugly)
........
r46539 | bob.ippolito | 2006-05-30 02:26:01 +0200 (Tue, 30 May 2006) | 1 line
Add a length check to aifc to ensure it doesn't write a bogus file
........
r46540 | tim.peters | 2006-05-30 04:25:25 +0200 (Tue, 30 May 2006) | 10 lines
deprecated_err(): Stop bizarre warning messages when the tests
are run in the order:
test_genexps (or any other doctest-based test)
test_struct
test_doctest
The `warnings` module needs an advertised way to save/restore
its internal filter list.
........
r46541 | tim.peters | 2006-05-30 04:26:46 +0200 (Tue, 30 May 2006) | 2 lines
Whitespace normalization.
........
r46542 | tim.peters | 2006-05-30 04:30:30 +0200 (Tue, 30 May 2006) | 2 lines
Set a binary svn:mime-type property on this UTF-8 encoded file.
........
r46543 | neal.norwitz | 2006-05-30 05:18:50 +0200 (Tue, 30 May 2006) | 1 line
Simplify further by using AddStringConstant
........
r46544 | tim.peters | 2006-05-30 06:16:25 +0200 (Tue, 30 May 2006) | 6 lines
Convert relevant dict internals to Py_ssize_t.
I don't have a box with nearly enough RAM, or an OS,
that could get close to tickling this, though (requires
a dict w/ at least 2**31 entries).
........
r46545 | neal.norwitz | 2006-05-30 06:19:21 +0200 (Tue, 30 May 2006) | 1 line
Remove stray | in comment
........
r46546 | neal.norwitz | 2006-05-30 06:25:05 +0200 (Tue, 30 May 2006) | 1 line
Use Py_SAFE_DOWNCAST for safety. Fix format strings. Remove 2 more stray | in comment
........
r46547 | neal.norwitz | 2006-05-30 06:43:23 +0200 (Tue, 30 May 2006) | 1 line
No DOWNCAST is required since sizeof(Py_ssize_t) >= sizeof(int) and Py_ReprEntr returns an int
........
r46548 | tim.peters | 2006-05-30 07:04:59 +0200 (Tue, 30 May 2006) | 3 lines
dict_print(): Explicitly narrow the return value
from a (possibly) wider variable.
........
r46549 | tim.peters | 2006-05-30 07:23:59 +0200 (Tue, 30 May 2006) | 5 lines
dict_print(): So that Neal & I don't spend the rest of
our lives taking turns rewriting code that works ;-),
get rid of casting illusions by declaring a new variable
with the obvious type.
........
r46550 | georg.brandl | 2006-05-30 09:04:55 +0200 (Tue, 30 May 2006) | 3 lines
Restore exception pickle support. #1497319.
........
r46551 | georg.brandl | 2006-05-30 09:13:29 +0200 (Tue, 30 May 2006) | 3 lines
Add a test case for exception pickling. args is never NULL.
........
r46552 | neal.norwitz | 2006-05-30 09:21:10 +0200 (Tue, 30 May 2006) | 1 line
Don't fail if the (sub)pkgname already exist.
........
r46553 | georg.brandl | 2006-05-30 09:34:45 +0200 (Tue, 30 May 2006) | 3 lines
Disallow keyword args for exceptions.
........
r46554 | neal.norwitz | 2006-05-30 09:36:54 +0200 (Tue, 30 May 2006) | 5 lines
I'm impatient. I think this will fix a few more problems with the buildbots.
I'm not sure this is the best approach, but I can't think of anything better.
If this creates problems, feel free to revert, but I think it's safe and
should make things a little better.
........
r46555 | georg.brandl | 2006-05-30 10:17:00 +0200 (Tue, 30 May 2006) | 4 lines
Do the check for no keyword arguments in __init__ so that
subclasses of Exception can be supplied keyword args
........
r46556 | georg.brandl | 2006-05-30 10:47:19 +0200 (Tue, 30 May 2006) | 3 lines
Convert test_exceptions to unittest.
........
r46557 | andrew.kuchling | 2006-05-30 14:52:01 +0200 (Tue, 30 May 2006) | 1 line
Add SoC name, and reorganize this section a bit
........
r46559 | tim.peters | 2006-05-30 17:53:34 +0200 (Tue, 30 May 2006) | 11 lines
PyLong_FromString(): Continued fraction analysis (explained in
a new comment) suggests there are almost certainly large input
integers in all non-binary input bases for which one Python digit
too few is initally allocated to hold the final result. Instead
of assert-failing when that happens, allocate more space. Alas,
I estimate it would take a few days to find a specific such case,
so this isn't backed up by a new test (not to mention that such
a case may take hours to run, since conversion time is quadratic
in the number of digits, and preliminary attempts suggested that
the smallest such inputs contain at least a million digits).
........
r46560 | fredrik.lundh | 2006-05-30 19:11:48 +0200 (Tue, 30 May 2006) | 3 lines
changed find/rfind to return -1 for matches outside the source string
........
r46561 | bob.ippolito | 2006-05-30 19:37:54 +0200 (Tue, 30 May 2006) | 1 line
Change wrapping terminology to overflow masking
........
r46562 | fredrik.lundh | 2006-05-30 19:39:58 +0200 (Tue, 30 May 2006) | 3 lines
changed count to return 0 for slices outside the source string
........
r46568 | tim.peters | 2006-05-31 01:28:02 +0200 (Wed, 31 May 2006) | 2 lines
Whitespace normalization.
........
r46569 | brett.cannon | 2006-05-31 04:19:54 +0200 (Wed, 31 May 2006) | 5 lines
Clarify wording on default values for strptime(); defaults are used when better
values cannot be inferred.
Closes bug #1496315.
........
r46572 | neal.norwitz | 2006-05-31 09:43:27 +0200 (Wed, 31 May 2006) | 1 line
Calculate smallest properly (it was off by one) and use proper ssize_t types for Win64
........
r46573 | neal.norwitz | 2006-05-31 10:01:08 +0200 (Wed, 31 May 2006) | 1 line
Revert last checkin, it is better to do make distclean
........
r46574 | neal.norwitz | 2006-05-31 11:02:44 +0200 (Wed, 31 May 2006) | 3 lines
On 64-bit platforms running test_struct after test_tarfile would fail
since the deprecation warning wouldn't be raised.
........
r46575 | thomas.heller | 2006-05-31 13:37:58 +0200 (Wed, 31 May 2006) | 3 lines
PyTuple_Pack is not available in Python 2.3, but ctypes must stay
compatible with that.
........
r46576 | andrew.kuchling | 2006-05-31 15:18:56 +0200 (Wed, 31 May 2006) | 1 line
'functional' module was renamed to 'functools'
........
r46577 | kristjan.jonsson | 2006-05-31 15:35:41 +0200 (Wed, 31 May 2006) | 1 line
Fixup the PCBuild8 project directory. exceptions.c have moved to Objects, and the functionalmodule.c has been replaced with _functoolsmodule.c. Other minor changes to .vcproj files and .sln to fix compilation
........
r46578 | andrew.kuchling | 2006-05-31 16:08:48 +0200 (Wed, 31 May 2006) | 15 lines
[Bug #1473048]
SimpleXMLRPCServer and DocXMLRPCServer don't look at
the path of the HTTP request at all; you can POST or
GET from / or /RPC2 or /blahblahblah with the same results.
Security scanners that look for /cgi-bin/phf will therefore report
lots of vulnerabilities.
Fix: add a .rpc_paths attribute to the SimpleXMLRPCServer class,
and report a 404 error if the path isn't on the allowed list.
Possibly-controversial aspect of this change: the default makes only
'/' and '/RPC2' legal. Maybe this will break people's applications
(though I doubt it). We could just set the default to an empty tuple,
which would exactly match the current behaviour.
........
r46579 | andrew.kuchling | 2006-05-31 16:12:47 +0200 (Wed, 31 May 2006) | 1 line
Mention SimpleXMLRPCServer change
........
r46580 | tim.peters | 2006-05-31 16:28:07 +0200 (Wed, 31 May 2006) | 2 lines
Trimmed trailing whitespace.
........
r46581 | tim.peters | 2006-05-31 17:33:22 +0200 (Wed, 31 May 2006) | 4 lines
_range_error(): Speed and simplify (there's no real need for
loops here). Assert that size_t is actually big enough, and
that f->size is at least one. Wrap a long line.
........
r46582 | tim.peters | 2006-05-31 17:34:37 +0200 (Wed, 31 May 2006) | 2 lines
Repaired error in new comment.
........
r46584 | neal.norwitz | 2006-06-01 07:32:49 +0200 (Thu, 01 Jun 2006) | 4 lines
Remove ; at end of macro. There was a compiler recently that warned
about extra semi-colons. It may have been the HP C compiler.
This file will trigger a bunch of those warnings now.
........
r46585 | georg.brandl | 2006-06-01 08:39:19 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly unpickle 2.4 exceptions via __setstate__ (patch #1498571)
........
r46586 | georg.brandl | 2006-06-01 10:27:32 +0200 (Thu, 01 Jun 2006) | 3 lines
Correctly allocate complex types with tp_alloc. (bug #1498638)
........
r46587 | georg.brandl | 2006-06-01 14:30:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Correctly dispatch Faults in loads (patch #1498627)
........
r46588 | georg.brandl | 2006-06-01 15:00:49 +0200 (Thu, 01 Jun 2006) | 3 lines
Some code style tweaks, and remove apply.
........
r46589 | armin.rigo | 2006-06-01 15:19:12 +0200 (Thu, 01 Jun 2006) | 5 lines
[ 1497053 ] Let dicts propagate the exceptions in user __eq__().
[ 1456209 ] dictresize() vulnerability ( <- backport candidate ).
........
r46590 | tim.peters | 2006-06-01 15:41:46 +0200 (Thu, 01 Jun 2006) | 2 lines
Whitespace normalization.
........
r46591 | tim.peters | 2006-06-01 15:49:23 +0200 (Thu, 01 Jun 2006) | 2 lines
Record bugs 1275608 and 1456209 as being fixed.
........
r46592 | tim.peters | 2006-06-01 15:56:26 +0200 (Thu, 01 Jun 2006) | 5 lines
Re-enable a new empty-string test added during the NFS sprint,
but disabled then because str and unicode strings gave different
results. The implementations were repaired later during the
sprint, but the new test remained disabled.
........
r46594 | tim.peters | 2006-06-01 17:50:44 +0200 (Thu, 01 Jun 2006) | 7 lines
Armin committed his patch while I was reviewing it (I'm sure
he didn't know this), so merged in some changes I made during
review. Nothing material apart from changing a new `mask` local
from int to Py_ssize_t. Mostly this is repairing comments that
were made incorrect, and adding new comments. Also a few
minor code rewrites for clarity or helpful succinctness.
........
r46599 | neal.norwitz | 2006-06-02 06:45:53 +0200 (Fri, 02 Jun 2006) | 1 line
Convert docstrings to comments so regrtest -v prints method names
........
r46600 | neal.norwitz | 2006-06-02 06:50:49 +0200 (Fri, 02 Jun 2006) | 2 lines
Fix memory leak found by valgrind.
........
r46601 | neal.norwitz | 2006-06-02 06:54:52 +0200 (Fri, 02 Jun 2006) | 1 line
More memory leaks from valgrind
........
r46602 | neal.norwitz | 2006-06-02 08:23:00 +0200 (Fri, 02 Jun 2006) | 11 lines
Patch #1357836:
Prevent an invalid memory read from test_coding in case the done flag is set.
In that case, the loop isn't entered. I wonder if rather than setting
the done flag in the cases before the loop, if they should just exit early.
This code looks like it should be refactored.
Backport candidate (also the early break above if decoding_fgets fails)
........
r46603 | martin.blais | 2006-06-02 15:03:43 +0200 (Fri, 02 Jun 2006) | 1 line
Fixed struct test to not use unittest.
........
r46605 | tim.peters | 2006-06-03 01:22:51 +0200 (Sat, 03 Jun 2006) | 10 lines
pprint functions used to sort a dict (by key) if and only if
the output required more than one line. "Small" dicts got
displayed in seemingly random order (the hash-induced order
produced by dict.__repr__). None of this was documented.
Now pprint functions always sort dicts by key, and the docs
promise it.
This was proposed and agreed to during the PyCon 2006 core
sprint -- I just didn't have time for it before now.
........
2006-06-08 11:42:34 -03:00
|
|
|
METH_NOARGS, xmlparse_GetInputContext__doc__},
|
2003-01-21 07:09:21 -04:00
|
|
|
#if XML_COMBINED_VERSION >= 19505
|
2003-01-21 06:58:18 -04:00
|
|
|
{"UseForeignDTD", (PyCFunction)xmlparse_UseForeignDTD,
|
|
|
|
METH_VARARGS, xmlparse_UseForeignDTD__doc__},
|
2003-01-21 07:09:21 -04:00
|
|
|
#endif
|
2003-01-21 06:58:18 -04:00
|
|
|
{NULL, NULL} /* sentinel */
|
2000-03-31 11:43:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ---------- */
|
|
|
|
|
|
|
|
|
2001-08-17 15:39:25 -03:00
|
|
|
#ifdef Py_USING_UNICODE
|
2001-01-21 06:18:10 -04:00
|
|
|
|
2002-06-28 19:29:01 -03:00
|
|
|
/* pyexpat international encoding support.
|
|
|
|
Make it as simple as possible.
|
2001-01-21 06:18:10 -04:00
|
|
|
*/
|
|
|
|
|
2001-01-22 04:19:10 -04:00
|
|
|
static char template_buffer[257];
|
2001-03-01 16:48:17 -04:00
|
|
|
PyObject *template_string = NULL;
|
2001-01-21 06:18:10 -04:00
|
|
|
|
2002-06-28 19:29:01 -03:00
|
|
|
static void
|
2001-01-21 06:18:10 -04:00
|
|
|
init_template_buffer(void)
|
|
|
|
{
|
|
|
|
int i;
|
2001-03-01 16:48:17 -04:00
|
|
|
for (i = 0; i < 256; i++) {
|
|
|
|
template_buffer[i] = i;
|
2001-02-17 14:12:50 -04:00
|
|
|
}
|
2001-03-01 16:48:17 -04:00
|
|
|
template_buffer[256] = 0;
|
2001-02-17 14:12:50 -04:00
|
|
|
}
|
2001-01-21 06:18:10 -04:00
|
|
|
|
2002-06-28 19:29:01 -03:00
|
|
|
static int
|
|
|
|
PyUnknownEncodingHandler(void *encodingHandlerData,
|
|
|
|
const XML_Char *name,
|
|
|
|
XML_Encoding *info)
|
2001-01-21 06:18:10 -04:00
|
|
|
{
|
2001-03-01 16:48:17 -04:00
|
|
|
PyUnicodeObject *_u_string = NULL;
|
|
|
|
int result = 0;
|
2001-01-21 06:18:10 -04:00
|
|
|
int i;
|
2002-06-28 19:29:01 -03:00
|
|
|
|
2001-03-01 16:48:17 -04:00
|
|
|
/* Yes, supports only 8bit encodings */
|
|
|
|
_u_string = (PyUnicodeObject *)
|
|
|
|
PyUnicode_Decode(template_buffer, 256, name, "replace");
|
2002-06-28 19:29:01 -03:00
|
|
|
|
2001-03-01 16:48:17 -04:00
|
|
|
if (_u_string == NULL)
|
2001-01-21 06:18:10 -04:00
|
|
|
return result;
|
2002-06-28 19:29:01 -03:00
|
|
|
|
2001-03-01 16:48:17 -04:00
|
|
|
for (i = 0; i < 256; i++) {
|
|
|
|
/* Stupid to access directly, but fast */
|
|
|
|
Py_UNICODE c = _u_string->str[i];
|
|
|
|
if (c == Py_UNICODE_REPLACEMENT_CHARACTER)
|
2001-01-21 06:18:10 -04:00
|
|
|
info->map[i] = -1;
|
2001-03-01 16:48:17 -04:00
|
|
|
else
|
2001-01-21 06:18:10 -04:00
|
|
|
info->map[i] = c;
|
2001-02-17 14:12:50 -04:00
|
|
|
}
|
2001-01-21 06:18:10 -04:00
|
|
|
info->data = NULL;
|
|
|
|
info->convert = NULL;
|
|
|
|
info->release = NULL;
|
2002-06-28 19:29:01 -03:00
|
|
|
result = 1;
|
2001-01-21 06:18:10 -04:00
|
|
|
Py_DECREF(_u_string);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static PyObject *
|
2002-06-27 16:40:48 -03:00
|
|
|
newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern)
|
2000-07-12 01:49:00 -03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
xmlparseobject *self;
|
2002-06-28 19:29:01 -03:00
|
|
|
|
2001-09-23 07:20:10 -03:00
|
|
|
#ifdef Py_TPFLAGS_HAVE_GC
|
|
|
|
/* Code for versions 2.2 and later */
|
|
|
|
self = PyObject_GC_New(xmlparseobject, &Xmlparsetype);
|
|
|
|
#else
|
2000-07-12 01:49:00 -03:00
|
|
|
self = PyObject_New(xmlparseobject, &Xmlparsetype);
|
2001-09-23 07:20:10 -03:00
|
|
|
#endif
|
2000-07-12 01:49:00 -03:00
|
|
|
if (self == NULL)
|
|
|
|
return NULL;
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2002-06-30 03:40:55 -03:00
|
|
|
#ifdef Py_USING_UNICODE
|
2000-07-12 01:49:00 -03:00
|
|
|
self->returns_unicode = 1;
|
2002-06-30 03:40:55 -03:00
|
|
|
#else
|
|
|
|
self->returns_unicode = 0;
|
2000-06-26 21:33:30 -03:00
|
|
|
#endif
|
2002-06-30 03:40:55 -03:00
|
|
|
|
2002-06-28 19:56:48 -03:00
|
|
|
self->buffer = NULL;
|
|
|
|
self->buffer_size = CHARACTER_DATA_BUFFER_SIZE;
|
|
|
|
self->buffer_used = 0;
|
2001-02-08 11:39:08 -04:00
|
|
|
self->ordered_attributes = 0;
|
|
|
|
self->specified_attributes = 0;
|
2001-02-14 14:29:45 -04:00
|
|
|
self->in_callback = 0;
|
2003-01-21 06:58:18 -04:00
|
|
|
self->ns_prefixes = 0;
|
2001-01-21 06:18:10 -04:00
|
|
|
self->handlers = NULL;
|
2001-04-25 13:01:30 -03:00
|
|
|
if (namespace_separator != NULL) {
|
2000-07-12 01:49:00 -03:00
|
|
|
self->itself = XML_ParserCreateNS(encoding, *namespace_separator);
|
|
|
|
}
|
2001-02-08 11:39:08 -04:00
|
|
|
else {
|
2000-07-12 01:49:00 -03:00
|
|
|
self->itself = XML_ParserCreate(encoding);
|
|
|
|
}
|
2002-06-27 16:40:48 -03:00
|
|
|
self->intern = intern;
|
|
|
|
Py_XINCREF(self->intern);
|
2001-09-23 07:20:10 -03:00
|
|
|
#ifdef Py_TPFLAGS_HAVE_GC
|
|
|
|
PyObject_GC_Track(self);
|
|
|
|
#else
|
2001-01-21 06:18:10 -04:00
|
|
|
PyObject_GC_Init(self);
|
2001-09-23 07:20:10 -03:00
|
|
|
#endif
|
2000-07-12 01:49:00 -03:00
|
|
|
if (self->itself == NULL) {
|
2002-06-28 19:29:01 -03:00
|
|
|
PyErr_SetString(PyExc_RuntimeError,
|
2000-07-12 01:49:00 -03:00
|
|
|
"XML_ParserCreate failed");
|
|
|
|
Py_DECREF(self);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
XML_SetUserData(self->itself, (void *)self);
|
2001-08-17 15:39:25 -03:00
|
|
|
#ifdef Py_USING_UNICODE
|
2002-07-01 11:02:31 -03:00
|
|
|
XML_SetUnknownEncodingHandler(self->itself,
|
|
|
|
(XML_UnknownEncodingHandler) PyUnknownEncodingHandler, NULL);
|
2001-01-21 06:18:10 -04:00
|
|
|
#endif
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2002-06-28 19:56:48 -03:00
|
|
|
for (i = 0; handler_info[i].name != NULL; i++)
|
2000-07-12 01:49:00 -03:00
|
|
|
/* do nothing */;
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2002-07-01 11:02:31 -03:00
|
|
|
self->handlers = malloc(sizeof(PyObject *) * i);
|
|
|
|
if (!self->handlers) {
|
2002-06-28 19:29:01 -03:00
|
|
|
Py_DECREF(self);
|
|
|
|
return PyErr_NoMemory();
|
2001-01-21 06:18:10 -04:00
|
|
|
}
|
2001-10-21 05:53:52 -03:00
|
|
|
clear_handlers(self, 1);
|
2000-06-26 21:33:30 -03:00
|
|
|
|
2001-01-21 06:18:10 -04:00
|
|
|
return (PyObject*)self;
|
2000-03-31 11:43:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2000-07-12 01:49:00 -03:00
|
|
|
xmlparse_dealloc(xmlparseobject *self)
|
2000-03-31 11:43:31 -04:00
|
|
|
{
|
2000-07-12 01:49:00 -03:00
|
|
|
int i;
|
2001-09-23 07:20:10 -03:00
|
|
|
#ifdef Py_TPFLAGS_HAVE_GC
|
|
|
|
PyObject_GC_UnTrack(self);
|
|
|
|
#else
|
2001-01-21 06:18:10 -04:00
|
|
|
PyObject_GC_Fini(self);
|
2001-09-23 07:20:10 -03:00
|
|
|
#endif
|
2001-02-08 11:39:08 -04:00
|
|
|
if (self->itself != NULL)
|
2000-07-12 01:49:00 -03:00
|
|
|
XML_ParserFree(self->itself);
|
|
|
|
self->itself = NULL;
|
2000-06-26 21:33:30 -03:00
|
|
|
|
2001-02-08 11:39:08 -04:00
|
|
|
if (self->handlers != NULL) {
|
2001-04-25 13:01:30 -03:00
|
|
|
PyObject *temp;
|
2001-02-08 11:39:08 -04:00
|
|
|
for (i = 0; handler_info[i].name != NULL; i++) {
|
2001-04-25 13:01:30 -03:00
|
|
|
temp = self->handlers[i];
|
|
|
|
self->handlers[i] = NULL;
|
|
|
|
Py_XDECREF(temp);
|
2001-02-08 11:39:08 -04:00
|
|
|
}
|
|
|
|
free(self->handlers);
|
2002-06-28 19:29:01 -03:00
|
|
|
self->handlers = NULL;
|
2000-07-12 01:49:00 -03:00
|
|
|
}
|
2002-06-28 19:56:48 -03:00
|
|
|
if (self->buffer != NULL) {
|
|
|
|
free(self->buffer);
|
|
|
|
self->buffer = NULL;
|
|
|
|
}
|
2002-06-27 16:40:48 -03:00
|
|
|
Py_XDECREF(self->intern);
|
2001-09-23 07:20:10 -03:00
|
|
|
#ifndef Py_TPFLAGS_HAVE_GC
|
2002-06-30 03:40:55 -03:00
|
|
|
/* Code for versions 2.0 and 2.1 */
|
2000-07-12 01:49:00 -03:00
|
|
|
PyObject_Del(self);
|
2001-09-23 07:20:10 -03:00
|
|
|
#else
|
|
|
|
/* Code for versions 2.2 and later. */
|
|
|
|
PyObject_GC_Del(self);
|
|
|
|
#endif
|
2000-03-31 11:43:31 -04:00
|
|
|
}
|
|
|
|
|
2000-07-12 01:49:00 -03:00
|
|
|
static int
|
|
|
|
handlername2int(const char *name)
|
|
|
|
{
|
|
|
|
int i;
|
2002-06-28 19:29:01 -03:00
|
|
|
for (i = 0; handler_info[i].name != NULL; i++) {
|
2000-07-12 01:49:00 -03:00
|
|
|
if (strcmp(name, handler_info[i].name) == 0) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
2000-03-31 11:43:31 -04:00
|
|
|
}
|
|
|
|
|
2002-06-28 19:29:01 -03:00
|
|
|
static PyObject *
|
|
|
|
get_pybool(int istrue)
|
|
|
|
{
|
|
|
|
PyObject *result = istrue ? Py_True : Py_False;
|
|
|
|
Py_INCREF(result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-03-31 11:43:31 -04:00
|
|
|
static PyObject *
|
|
|
|
xmlparse_getattr(xmlparseobject *self, char *name)
|
|
|
|
{
|
2002-06-28 19:29:01 -03:00
|
|
|
int handlernum = handlername2int(name);
|
|
|
|
|
|
|
|
if (handlernum != -1) {
|
|
|
|
PyObject *result = self->handlers[handlernum];
|
|
|
|
if (result == NULL)
|
|
|
|
result = Py_None;
|
|
|
|
Py_INCREF(result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
if (name[0] == 'E') {
|
|
|
|
if (strcmp(name, "ErrorCode") == 0)
|
|
|
|
return PyInt_FromLong((long)
|
|
|
|
XML_GetErrorCode(self->itself));
|
|
|
|
if (strcmp(name, "ErrorLineNumber") == 0)
|
|
|
|
return PyInt_FromLong((long)
|
|
|
|
XML_GetErrorLineNumber(self->itself));
|
|
|
|
if (strcmp(name, "ErrorColumnNumber") == 0)
|
|
|
|
return PyInt_FromLong((long)
|
|
|
|
XML_GetErrorColumnNumber(self->itself));
|
|
|
|
if (strcmp(name, "ErrorByteIndex") == 0)
|
|
|
|
return PyInt_FromLong((long)
|
|
|
|
XML_GetErrorByteIndex(self->itself));
|
|
|
|
}
|
2004-08-25 21:37:31 -03:00
|
|
|
if (name[0] == 'C') {
|
|
|
|
if (strcmp(name, "CurrentLineNumber") == 0)
|
|
|
|
return PyInt_FromLong((long)
|
|
|
|
XML_GetCurrentLineNumber(self->itself));
|
|
|
|
if (strcmp(name, "CurrentColumnNumber") == 0)
|
|
|
|
return PyInt_FromLong((long)
|
|
|
|
XML_GetCurrentColumnNumber(self->itself));
|
|
|
|
if (strcmp(name, "CurrentByteIndex") == 0)
|
|
|
|
return PyInt_FromLong((long)
|
|
|
|
XML_GetCurrentByteIndex(self->itself));
|
|
|
|
}
|
2002-06-28 19:56:48 -03:00
|
|
|
if (name[0] == 'b') {
|
|
|
|
if (strcmp(name, "buffer_size") == 0)
|
|
|
|
return PyInt_FromLong((long) self->buffer_size);
|
|
|
|
if (strcmp(name, "buffer_text") == 0)
|
|
|
|
return get_pybool(self->buffer != NULL);
|
|
|
|
if (strcmp(name, "buffer_used") == 0)
|
|
|
|
return PyInt_FromLong((long) self->buffer_used);
|
|
|
|
}
|
2003-01-21 06:58:18 -04:00
|
|
|
if (strcmp(name, "namespace_prefixes") == 0)
|
|
|
|
return get_pybool(self->ns_prefixes);
|
2001-02-08 11:39:08 -04:00
|
|
|
if (strcmp(name, "ordered_attributes") == 0)
|
2002-06-28 19:29:01 -03:00
|
|
|
return get_pybool(self->ordered_attributes);
|
2000-07-12 01:49:00 -03:00
|
|
|
if (strcmp(name, "returns_unicode") == 0)
|
2002-06-28 19:29:01 -03:00
|
|
|
return get_pybool((long) self->returns_unicode);
|
2001-02-08 11:39:08 -04:00
|
|
|
if (strcmp(name, "specified_attributes") == 0)
|
2002-06-28 19:29:01 -03:00
|
|
|
return get_pybool((long) self->specified_attributes);
|
2002-06-27 16:40:48 -03:00
|
|
|
if (strcmp(name, "intern") == 0) {
|
|
|
|
if (self->intern == NULL) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Py_INCREF(self->intern);
|
|
|
|
return self->intern;
|
|
|
|
}
|
|
|
|
}
|
2000-07-12 01:49:00 -03:00
|
|
|
|
2003-01-19 11:40:09 -04:00
|
|
|
#define APPEND(list, str) \
|
2003-01-21 06:58:18 -04:00
|
|
|
do { \
|
|
|
|
PyObject *o = PyString_FromString(str); \
|
|
|
|
if (o != NULL) \
|
|
|
|
PyList_Append(list, o); \
|
|
|
|
Py_XDECREF(o); \
|
|
|
|
} while (0)
|
2003-01-19 11:40:09 -04:00
|
|
|
|
2000-07-12 01:49:00 -03:00
|
|
|
if (strcmp(name, "__members__") == 0) {
|
|
|
|
int i;
|
|
|
|
PyObject *rc = PyList_New(0);
|
2006-04-21 07:40:58 -03:00
|
|
|
if (!rc)
|
|
|
|
return NULL;
|
2002-06-28 19:29:01 -03:00
|
|
|
for (i = 0; handler_info[i].name != NULL; i++) {
|
2003-01-19 11:40:09 -04:00
|
|
|
PyObject *o = get_handler_name(&handler_info[i]);
|
|
|
|
if (o != NULL)
|
|
|
|
PyList_Append(rc, o);
|
|
|
|
Py_XDECREF(o);
|
2000-07-12 01:49:00 -03:00
|
|
|
}
|
2003-01-19 11:40:09 -04:00
|
|
|
APPEND(rc, "ErrorCode");
|
|
|
|
APPEND(rc, "ErrorLineNumber");
|
|
|
|
APPEND(rc, "ErrorColumnNumber");
|
|
|
|
APPEND(rc, "ErrorByteIndex");
|
2004-08-25 21:37:31 -03:00
|
|
|
APPEND(rc, "CurrentLineNumber");
|
|
|
|
APPEND(rc, "CurrentColumnNumber");
|
|
|
|
APPEND(rc, "CurrentByteIndex");
|
2003-01-19 11:40:09 -04:00
|
|
|
APPEND(rc, "buffer_size");
|
|
|
|
APPEND(rc, "buffer_text");
|
|
|
|
APPEND(rc, "buffer_used");
|
2003-01-21 06:58:18 -04:00
|
|
|
APPEND(rc, "namespace_prefixes");
|
2003-01-19 11:40:09 -04:00
|
|
|
APPEND(rc, "ordered_attributes");
|
|
|
|
APPEND(rc, "returns_unicode");
|
|
|
|
APPEND(rc, "specified_attributes");
|
|
|
|
APPEND(rc, "intern");
|
|
|
|
|
|
|
|
#undef APPEND
|
2000-07-12 01:49:00 -03:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
return Py_FindMethod(xmlparse_methods, (PyObject *)self, name);
|
2000-03-31 11:43:31 -04:00
|
|
|
}
|
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
static int
|
|
|
|
sethandler(xmlparseobject *self, const char *name, PyObject* v)
|
2000-07-12 01:49:00 -03:00
|
|
|
{
|
|
|
|
int handlernum = handlername2int(name);
|
2002-06-28 19:29:01 -03:00
|
|
|
if (handlernum >= 0) {
|
|
|
|
xmlhandler c_handler = NULL;
|
|
|
|
PyObject *temp = self->handlers[handlernum];
|
|
|
|
|
|
|
|
if (v == Py_None)
|
|
|
|
v = NULL;
|
|
|
|
else if (v != NULL) {
|
|
|
|
Py_INCREF(v);
|
|
|
|
c_handler = handler_info[handlernum].handler;
|
|
|
|
}
|
2000-07-12 01:49:00 -03:00
|
|
|
self->handlers[handlernum] = v;
|
2002-06-28 19:29:01 -03:00
|
|
|
Py_XDECREF(temp);
|
|
|
|
handler_info[handlernum].setter(self->itself, c_handler);
|
2000-07-12 01:49:00 -03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2000-03-31 11:43:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-08-25 15:03:30 -03:00
|
|
|
xmlparse_setattr(xmlparseobject *self, char *name, PyObject *v)
|
2000-03-31 11:43:31 -04:00
|
|
|
{
|
2000-08-25 15:03:30 -03:00
|
|
|
/* Set attribute 'name' to value 'v'. v==NULL means delete */
|
2001-02-08 11:39:08 -04:00
|
|
|
if (v == NULL) {
|
2000-08-25 15:03:30 -03:00
|
|
|
PyErr_SetString(PyExc_RuntimeError, "Cannot delete attribute");
|
|
|
|
return -1;
|
|
|
|
}
|
2002-06-28 19:56:48 -03:00
|
|
|
if (strcmp(name, "buffer_text") == 0) {
|
|
|
|
if (PyObject_IsTrue(v)) {
|
|
|
|
if (self->buffer == NULL) {
|
|
|
|
self->buffer = malloc(self->buffer_size);
|
|
|
|
if (self->buffer == NULL) {
|
|
|
|
PyErr_NoMemory();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
self->buffer_used = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (self->buffer != NULL) {
|
|
|
|
if (flush_character_buffer(self) < 0)
|
|
|
|
return -1;
|
|
|
|
free(self->buffer);
|
|
|
|
self->buffer = NULL;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2003-01-21 06:58:18 -04:00
|
|
|
if (strcmp(name, "namespace_prefixes") == 0) {
|
|
|
|
if (PyObject_IsTrue(v))
|
|
|
|
self->ns_prefixes = 1;
|
|
|
|
else
|
|
|
|
self->ns_prefixes = 0;
|
|
|
|
XML_SetReturnNSTriplet(self->itself, self->ns_prefixes);
|
|
|
|
return 0;
|
|
|
|
}
|
2001-02-08 11:39:08 -04:00
|
|
|
if (strcmp(name, "ordered_attributes") == 0) {
|
|
|
|
if (PyObject_IsTrue(v))
|
|
|
|
self->ordered_attributes = 1;
|
|
|
|
else
|
|
|
|
self->ordered_attributes = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
2000-08-25 15:03:30 -03:00
|
|
|
if (strcmp(name, "returns_unicode") == 0) {
|
2001-02-08 11:39:08 -04:00
|
|
|
if (PyObject_IsTrue(v)) {
|
2001-08-17 15:39:25 -03:00
|
|
|
#ifndef Py_USING_UNICODE
|
2002-06-28 19:29:01 -03:00
|
|
|
PyErr_SetString(PyExc_ValueError,
|
|
|
|
"Unicode support not available");
|
2000-08-25 15:03:30 -03:00
|
|
|
return -1;
|
2000-06-26 21:33:30 -03:00
|
|
|
#else
|
2000-08-25 15:03:30 -03:00
|
|
|
self->returns_unicode = 1;
|
2000-06-26 21:33:30 -03:00
|
|
|
#endif
|
2000-08-25 15:03:30 -03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
self->returns_unicode = 0;
|
2001-02-08 11:39:08 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (strcmp(name, "specified_attributes") == 0) {
|
|
|
|
if (PyObject_IsTrue(v))
|
|
|
|
self->specified_attributes = 1;
|
|
|
|
else
|
|
|
|
self->specified_attributes = 0;
|
2000-08-25 15:03:30 -03:00
|
|
|
return 0;
|
|
|
|
}
|
2002-06-28 19:56:48 -03:00
|
|
|
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
|
|
|
|
* "right" thing to do, though, but this probably won't
|
|
|
|
* happen.
|
|
|
|
*/
|
|
|
|
if (flush_character_buffer(self) < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
2000-08-25 15:03:30 -03:00
|
|
|
if (sethandler(self, name, v)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
PyErr_SetString(PyExc_AttributeError, name);
|
|
|
|
return -1;
|
2000-03-31 11:43:31 -04:00
|
|
|
}
|
|
|
|
|
2001-01-21 06:18:10 -04:00
|
|
|
#ifdef WITH_CYCLE_GC
|
|
|
|
static int
|
|
|
|
xmlparse_traverse(xmlparseobject *op, visitproc visit, void *arg)
|
|
|
|
{
|
2006-04-21 07:40:58 -03:00
|
|
|
int i;
|
|
|
|
for (i = 0; handler_info[i].name != NULL; i++)
|
|
|
|
Py_VISIT(op->handlers[i]);
|
2001-04-25 13:01:30 -03:00
|
|
|
return 0;
|
2001-01-21 06:18:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
xmlparse_clear(xmlparseobject *op)
|
|
|
|
{
|
2001-10-21 05:53:52 -03:00
|
|
|
clear_handlers(op, 0);
|
2006-04-21 07:40:58 -03:00
|
|
|
Py_CLEAR(op->intern);
|
2001-04-25 13:01:30 -03:00
|
|
|
return 0;
|
2001-01-21 06:18:10 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(Xmlparsetype__doc__, "XML parser");
|
2000-03-31 11:43:31 -04:00
|
|
|
|
|
|
|
static PyTypeObject Xmlparsetype = {
|
2000-06-26 21:33:30 -03:00
|
|
|
PyObject_HEAD_INIT(NULL)
|
|
|
|
0, /*ob_size*/
|
2001-12-08 14:02:58 -04:00
|
|
|
"pyexpat.xmlparser", /*tp_name*/
|
2001-01-21 06:18:10 -04:00
|
|
|
sizeof(xmlparseobject) + PyGC_HEAD_SIZE,/*tp_basicsize*/
|
2000-06-26 21:33:30 -03:00
|
|
|
0, /*tp_itemsize*/
|
|
|
|
/* methods */
|
|
|
|
(destructor)xmlparse_dealloc, /*tp_dealloc*/
|
|
|
|
(printfunc)0, /*tp_print*/
|
|
|
|
(getattrfunc)xmlparse_getattr, /*tp_getattr*/
|
|
|
|
(setattrfunc)xmlparse_setattr, /*tp_setattr*/
|
|
|
|
(cmpfunc)0, /*tp_compare*/
|
|
|
|
(reprfunc)0, /*tp_repr*/
|
|
|
|
0, /*tp_as_number*/
|
|
|
|
0, /*tp_as_sequence*/
|
|
|
|
0, /*tp_as_mapping*/
|
|
|
|
(hashfunc)0, /*tp_hash*/
|
|
|
|
(ternaryfunc)0, /*tp_call*/
|
|
|
|
(reprfunc)0, /*tp_str*/
|
2001-01-21 06:18:10 -04:00
|
|
|
0, /* tp_getattro */
|
|
|
|
0, /* tp_setattro */
|
|
|
|
0, /* tp_as_buffer */
|
2001-09-23 07:20:10 -03:00
|
|
|
#ifdef Py_TPFLAGS_HAVE_GC
|
2002-06-28 19:29:01 -03:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
|
2001-09-23 07:20:10 -03:00
|
|
|
#else
|
2002-06-28 19:29:01 -03:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/
|
2001-09-23 07:20:10 -03:00
|
|
|
#endif
|
2003-01-21 06:58:18 -04:00
|
|
|
Xmlparsetype__doc__, /* tp_doc - Documentation string */
|
2001-01-21 06:18:10 -04:00
|
|
|
#ifdef WITH_CYCLE_GC
|
|
|
|
(traverseproc)xmlparse_traverse, /* tp_traverse */
|
|
|
|
(inquiry)xmlparse_clear /* tp_clear */
|
|
|
|
#else
|
|
|
|
0, 0
|
|
|
|
#endif
|
2000-03-31 11:43:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* End of code for xmlparser objects */
|
|
|
|
/* -------------------------------------------------------- */
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(pyexpat_ParserCreate__doc__,
|
2000-07-12 01:49:00 -03:00
|
|
|
"ParserCreate([encoding[, namespace_separator]]) -> parser\n\
|
2002-06-13 17:33:02 -03:00
|
|
|
Return a new XML parser object.");
|
2000-03-31 11:43:31 -04:00
|
|
|
|
|
|
|
static PyObject *
|
2000-07-12 01:49:00 -03:00
|
|
|
pyexpat_ParserCreate(PyObject *notused, PyObject *args, PyObject *kw)
|
|
|
|
{
|
2001-04-25 13:01:30 -03:00
|
|
|
char *encoding = NULL;
|
|
|
|
char *namespace_separator = NULL;
|
2002-06-27 16:40:48 -03:00
|
|
|
PyObject *intern = NULL;
|
|
|
|
PyObject *result;
|
|
|
|
int intern_decref = 0;
|
2006-02-27 12:46:16 -04:00
|
|
|
static char *kwlist[] = {"encoding", "namespace_separator",
|
2005-12-10 14:50:16 -04:00
|
|
|
"intern", NULL};
|
2002-06-27 16:40:48 -03:00
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kw, "|zzO:ParserCreate", kwlist,
|
|
|
|
&encoding, &namespace_separator, &intern))
|
2001-04-25 13:01:30 -03:00
|
|
|
return NULL;
|
|
|
|
if (namespace_separator != NULL
|
|
|
|
&& strlen(namespace_separator) > 1) {
|
|
|
|
PyErr_SetString(PyExc_ValueError,
|
|
|
|
"namespace_separator must be at most one"
|
|
|
|
" character, omitted, or None");
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-06-27 16:40:48 -03:00
|
|
|
/* Explicitly passing None means no interning is desired.
|
|
|
|
Not passing anything means that a new dictionary is used. */
|
|
|
|
if (intern == Py_None)
|
|
|
|
intern = NULL;
|
|
|
|
else if (intern == NULL) {
|
|
|
|
intern = PyDict_New();
|
|
|
|
if (!intern)
|
|
|
|
return NULL;
|
|
|
|
intern_decref = 1;
|
2002-06-28 19:29:01 -03:00
|
|
|
}
|
2002-06-27 16:40:48 -03:00
|
|
|
else if (!PyDict_Check(intern)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "intern must be a dictionary");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = newxmlparseobject(encoding, namespace_separator, intern);
|
|
|
|
if (intern_decref) {
|
|
|
|
Py_DECREF(intern);
|
|
|
|
}
|
|
|
|
return result;
|
2000-03-31 11:43:31 -04:00
|
|
|
}
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(pyexpat_ErrorString__doc__,
|
2000-07-12 01:49:00 -03:00
|
|
|
"ErrorString(errno) -> string\n\
|
2002-06-13 17:33:02 -03:00
|
|
|
Returns string error for given number.");
|
2000-03-31 11:43:31 -04:00
|
|
|
|
|
|
|
static PyObject *
|
2000-07-12 01:49:00 -03:00
|
|
|
pyexpat_ErrorString(PyObject *self, PyObject *args)
|
2000-03-31 11:43:31 -04:00
|
|
|
{
|
2000-07-12 01:49:00 -03:00
|
|
|
long code = 0;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "l:ErrorString", &code))
|
|
|
|
return NULL;
|
|
|
|
return Py_BuildValue("z", XML_ErrorString((int)code));
|
2000-03-31 11:43:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* List of methods defined in the module */
|
|
|
|
|
|
|
|
static struct PyMethodDef pyexpat_methods[] = {
|
2000-07-12 01:49:00 -03:00
|
|
|
{"ParserCreate", (PyCFunction)pyexpat_ParserCreate,
|
|
|
|
METH_VARARGS|METH_KEYWORDS, pyexpat_ParserCreate__doc__},
|
|
|
|
{"ErrorString", (PyCFunction)pyexpat_ErrorString,
|
|
|
|
METH_VARARGS, pyexpat_ErrorString__doc__},
|
2002-06-28 19:29:01 -03:00
|
|
|
|
2000-07-12 01:49:00 -03:00
|
|
|
{NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
|
2000-03-31 11:43:31 -04:00
|
|
|
};
|
|
|
|
|
2000-06-26 21:33:30 -03:00
|
|
|
/* Module docstring */
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(pyexpat_module_documentation,
|
|
|
|
"Python wrapper for Expat parser.");
|
2000-03-31 11:43:31 -04:00
|
|
|
|
2001-03-24 15:58:26 -04:00
|
|
|
/* Return a Python string that represents the version number without the
|
|
|
|
* extra cruft added by revision control, even if the right options were
|
|
|
|
* given to the "cvs export" command to make it not include the extra
|
|
|
|
* cruft.
|
|
|
|
*/
|
|
|
|
static PyObject *
|
|
|
|
get_version_string(void)
|
|
|
|
{
|
|
|
|
static char *rcsid = "$Revision$";
|
|
|
|
char *rev = rcsid;
|
|
|
|
int i = 0;
|
|
|
|
|
2005-12-19 02:05:18 -04:00
|
|
|
while (!isdigit(Py_CHARMASK(*rev)))
|
2001-03-24 15:58:26 -04:00
|
|
|
++rev;
|
|
|
|
while (rev[i] != ' ' && rev[i] != '\0')
|
|
|
|
++i;
|
|
|
|
|
|
|
|
return PyString_FromStringAndSize(rev, i);
|
|
|
|
}
|
|
|
|
|
2001-04-25 13:01:30 -03:00
|
|
|
/* Initialization function for the module */
|
|
|
|
|
|
|
|
#ifndef MODULE_NAME
|
|
|
|
#define MODULE_NAME "pyexpat"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef MODULE_INITFUNC
|
|
|
|
#define MODULE_INITFUNC initpyexpat
|
|
|
|
#endif
|
|
|
|
|
2003-01-21 06:58:18 -04:00
|
|
|
#ifndef PyMODINIT_FUNC
|
|
|
|
# ifdef MS_WINDOWS
|
|
|
|
# define PyMODINIT_FUNC __declspec(dllexport) void
|
|
|
|
# else
|
|
|
|
# define PyMODINIT_FUNC void
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2002-07-19 03:55:41 -03:00
|
|
|
PyMODINIT_FUNC MODULE_INITFUNC(void); /* avoid compiler warnings */
|
2001-04-25 13:01:30 -03:00
|
|
|
|
2003-01-21 06:58:18 -04:00
|
|
|
PyMODINIT_FUNC
|
|
|
|
MODULE_INITFUNC(void)
|
2000-07-12 01:49:00 -03:00
|
|
|
{
|
|
|
|
PyObject *m, *d;
|
2001-04-25 13:01:30 -03:00
|
|
|
PyObject *errmod_name = PyString_FromString(MODULE_NAME ".errors");
|
2001-02-08 11:39:08 -04:00
|
|
|
PyObject *errors_module;
|
|
|
|
PyObject *modelmod_name;
|
|
|
|
PyObject *model_module;
|
2000-07-12 01:49:00 -03:00
|
|
|
PyObject *sys_modules;
|
2005-12-13 16:43:04 -04:00
|
|
|
static struct PyExpat_CAPI capi;
|
|
|
|
PyObject* capi_object;
|
2000-07-12 01:49:00 -03:00
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
if (errmod_name == NULL)
|
|
|
|
return;
|
2001-04-25 13:01:30 -03:00
|
|
|
modelmod_name = PyString_FromString(MODULE_NAME ".model");
|
2001-02-08 11:39:08 -04:00
|
|
|
if (modelmod_name == NULL)
|
|
|
|
return;
|
2000-08-25 15:03:30 -03:00
|
|
|
|
2000-07-12 01:49:00 -03:00
|
|
|
Xmlparsetype.ob_type = &PyType_Type;
|
|
|
|
|
|
|
|
/* Create the module and add the functions */
|
2001-04-25 13:01:30 -03:00
|
|
|
m = Py_InitModule3(MODULE_NAME, pyexpat_methods,
|
2001-02-08 11:39:08 -04:00
|
|
|
pyexpat_module_documentation);
|
2006-01-19 02:09:39 -04:00
|
|
|
if (m == NULL)
|
|
|
|
return;
|
2000-07-12 01:49:00 -03:00
|
|
|
|
|
|
|
/* Add some symbolic constants to the module */
|
2001-02-14 14:29:45 -04:00
|
|
|
if (ErrorObject == NULL) {
|
|
|
|
ErrorObject = PyErr_NewException("xml.parsers.expat.ExpatError",
|
2000-09-23 01:55:48 -03:00
|
|
|
NULL, NULL);
|
2001-02-14 14:29:45 -04:00
|
|
|
if (ErrorObject == NULL)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Py_INCREF(ErrorObject);
|
2000-09-23 01:55:48 -03:00
|
|
|
PyModule_AddObject(m, "error", ErrorObject);
|
2001-02-14 14:29:45 -04:00
|
|
|
Py_INCREF(ErrorObject);
|
|
|
|
PyModule_AddObject(m, "ExpatError", ErrorObject);
|
2000-10-29 01:57:53 -03:00
|
|
|
Py_INCREF(&Xmlparsetype);
|
|
|
|
PyModule_AddObject(m, "XMLParserType", (PyObject *) &Xmlparsetype);
|
2000-07-12 01:49:00 -03:00
|
|
|
|
2001-03-24 15:58:26 -04:00
|
|
|
PyModule_AddObject(m, "__version__", get_version_string());
|
2000-12-21 13:25:07 -04:00
|
|
|
PyModule_AddStringConstant(m, "EXPAT_VERSION",
|
|
|
|
(char *) XML_ExpatVersion());
|
2001-02-08 11:39:08 -04:00
|
|
|
{
|
|
|
|
XML_Expat_Version info = XML_ExpatVersionInfo();
|
|
|
|
PyModule_AddObject(m, "version_info",
|
|
|
|
Py_BuildValue("(iii)", info.major,
|
|
|
|
info.minor, info.micro));
|
|
|
|
}
|
2001-08-17 15:39:25 -03:00
|
|
|
#ifdef Py_USING_UNICODE
|
2001-01-21 06:18:10 -04:00
|
|
|
init_template_buffer();
|
|
|
|
#endif
|
2000-07-12 01:49:00 -03:00
|
|
|
/* XXX When Expat supports some way of figuring out how it was
|
2002-06-28 19:29:01 -03:00
|
|
|
compiled, this should check and set native_encoding
|
|
|
|
appropriately.
|
2000-07-12 01:49:00 -03:00
|
|
|
*/
|
2000-09-23 01:55:48 -03:00
|
|
|
PyModule_AddStringConstant(m, "native_encoding", "UTF-8");
|
2000-08-24 18:57:43 -03:00
|
|
|
|
2001-02-08 11:39:08 -04:00
|
|
|
sys_modules = PySys_GetObject("modules");
|
2000-09-23 01:55:48 -03:00
|
|
|
d = PyModule_GetDict(m);
|
2000-08-25 15:03:30 -03:00
|
|
|
errors_module = PyDict_GetItem(d, errmod_name);
|
|
|
|
if (errors_module == NULL) {
|
2001-04-25 13:01:30 -03:00
|
|
|
errors_module = PyModule_New(MODULE_NAME ".errors");
|
2000-08-25 15:03:30 -03:00
|
|
|
if (errors_module != NULL) {
|
|
|
|
PyDict_SetItem(sys_modules, errmod_name, errors_module);
|
2000-09-23 01:55:48 -03:00
|
|
|
/* gives away the reference to errors_module */
|
|
|
|
PyModule_AddObject(m, "errors", errors_module);
|
2000-08-24 18:57:43 -03:00
|
|
|
}
|
|
|
|
}
|
2000-08-25 15:03:30 -03:00
|
|
|
Py_DECREF(errmod_name);
|
2001-02-08 11:39:08 -04:00
|
|
|
model_module = PyDict_GetItem(d, modelmod_name);
|
|
|
|
if (model_module == NULL) {
|
2001-04-25 13:01:30 -03:00
|
|
|
model_module = PyModule_New(MODULE_NAME ".model");
|
2001-02-08 11:39:08 -04:00
|
|
|
if (model_module != NULL) {
|
|
|
|
PyDict_SetItem(sys_modules, modelmod_name, model_module);
|
|
|
|
/* gives away the reference to model_module */
|
|
|
|
PyModule_AddObject(m, "model", model_module);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Py_DECREF(modelmod_name);
|
|
|
|
if (errors_module == NULL || model_module == NULL)
|
|
|
|
/* Don't core dump later! */
|
2000-08-25 15:03:30 -03:00
|
|
|
return;
|
2003-01-21 06:58:18 -04:00
|
|
|
|
2003-01-21 07:09:21 -04:00
|
|
|
#if XML_COMBINED_VERSION > 19505
|
2003-01-21 06:58:18 -04:00
|
|
|
{
|
|
|
|
const XML_Feature *features = XML_GetFeatureList();
|
|
|
|
PyObject *list = PyList_New(0);
|
|
|
|
if (list == NULL)
|
|
|
|
/* just ignore it */
|
|
|
|
PyErr_Clear();
|
|
|
|
else {
|
|
|
|
int i = 0;
|
|
|
|
for (; features[i].feature != XML_FEATURE_END; ++i) {
|
|
|
|
int ok;
|
|
|
|
PyObject *item = Py_BuildValue("si", features[i].name,
|
|
|
|
features[i].value);
|
|
|
|
if (item == NULL) {
|
|
|
|
Py_DECREF(list);
|
|
|
|
list = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ok = PyList_Append(list, item);
|
|
|
|
Py_DECREF(item);
|
|
|
|
if (ok < 0) {
|
|
|
|
PyErr_Clear();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (list != NULL)
|
|
|
|
PyModule_AddObject(m, "features", list);
|
|
|
|
}
|
|
|
|
}
|
2003-01-21 07:09:21 -04:00
|
|
|
#endif
|
2000-08-25 15:03:30 -03:00
|
|
|
|
2000-03-31 11:43:31 -04:00
|
|
|
#define MYCONST(name) \
|
2000-09-23 01:55:48 -03:00
|
|
|
PyModule_AddStringConstant(errors_module, #name, \
|
|
|
|
(char*)XML_ErrorString(name))
|
2000-07-12 01:49:00 -03:00
|
|
|
|
|
|
|
MYCONST(XML_ERROR_NO_MEMORY);
|
|
|
|
MYCONST(XML_ERROR_SYNTAX);
|
|
|
|
MYCONST(XML_ERROR_NO_ELEMENTS);
|
|
|
|
MYCONST(XML_ERROR_INVALID_TOKEN);
|
|
|
|
MYCONST(XML_ERROR_UNCLOSED_TOKEN);
|
|
|
|
MYCONST(XML_ERROR_PARTIAL_CHAR);
|
|
|
|
MYCONST(XML_ERROR_TAG_MISMATCH);
|
|
|
|
MYCONST(XML_ERROR_DUPLICATE_ATTRIBUTE);
|
|
|
|
MYCONST(XML_ERROR_JUNK_AFTER_DOC_ELEMENT);
|
|
|
|
MYCONST(XML_ERROR_PARAM_ENTITY_REF);
|
|
|
|
MYCONST(XML_ERROR_UNDEFINED_ENTITY);
|
|
|
|
MYCONST(XML_ERROR_RECURSIVE_ENTITY_REF);
|
|
|
|
MYCONST(XML_ERROR_ASYNC_ENTITY);
|
|
|
|
MYCONST(XML_ERROR_BAD_CHAR_REF);
|
|
|
|
MYCONST(XML_ERROR_BINARY_ENTITY_REF);
|
|
|
|
MYCONST(XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF);
|
|
|
|
MYCONST(XML_ERROR_MISPLACED_XML_PI);
|
|
|
|
MYCONST(XML_ERROR_UNKNOWN_ENCODING);
|
|
|
|
MYCONST(XML_ERROR_INCORRECT_ENCODING);
|
2001-01-21 06:18:10 -04:00
|
|
|
MYCONST(XML_ERROR_UNCLOSED_CDATA_SECTION);
|
|
|
|
MYCONST(XML_ERROR_EXTERNAL_ENTITY_HANDLING);
|
|
|
|
MYCONST(XML_ERROR_NOT_STANDALONE);
|
2004-08-04 19:28:16 -03:00
|
|
|
MYCONST(XML_ERROR_UNEXPECTED_STATE);
|
|
|
|
MYCONST(XML_ERROR_ENTITY_DECLARED_IN_PE);
|
|
|
|
MYCONST(XML_ERROR_FEATURE_REQUIRES_XML_DTD);
|
|
|
|
MYCONST(XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING);
|
|
|
|
/* Added in Expat 1.95.7. */
|
|
|
|
MYCONST(XML_ERROR_UNBOUND_PREFIX);
|
|
|
|
/* Added in Expat 1.95.8. */
|
|
|
|
MYCONST(XML_ERROR_UNDECLARING_PREFIX);
|
|
|
|
MYCONST(XML_ERROR_INCOMPLETE_PE);
|
|
|
|
MYCONST(XML_ERROR_XML_DECL);
|
|
|
|
MYCONST(XML_ERROR_TEXT_DECL);
|
|
|
|
MYCONST(XML_ERROR_PUBLICID);
|
|
|
|
MYCONST(XML_ERROR_SUSPENDED);
|
|
|
|
MYCONST(XML_ERROR_NOT_SUSPENDED);
|
|
|
|
MYCONST(XML_ERROR_ABORTED);
|
|
|
|
MYCONST(XML_ERROR_FINISHED);
|
|
|
|
MYCONST(XML_ERROR_SUSPEND_PE);
|
2001-01-21 06:18:10 -04:00
|
|
|
|
2001-02-08 11:39:08 -04:00
|
|
|
PyModule_AddStringConstant(errors_module, "__doc__",
|
|
|
|
"Constants used to describe error conditions.");
|
|
|
|
|
2000-09-23 01:55:48 -03:00
|
|
|
#undef MYCONST
|
2001-01-21 06:18:10 -04:00
|
|
|
|
2001-02-08 11:39:08 -04:00
|
|
|
#define MYCONST(c) PyModule_AddIntConstant(m, #c, c)
|
2001-01-21 06:18:10 -04:00
|
|
|
MYCONST(XML_PARAM_ENTITY_PARSING_NEVER);
|
|
|
|
MYCONST(XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE);
|
|
|
|
MYCONST(XML_PARAM_ENTITY_PARSING_ALWAYS);
|
2001-02-08 11:39:08 -04:00
|
|
|
#undef MYCONST
|
2001-01-21 06:18:10 -04:00
|
|
|
|
2001-02-08 11:39:08 -04:00
|
|
|
#define MYCONST(c) PyModule_AddIntConstant(model_module, #c, c)
|
|
|
|
PyModule_AddStringConstant(model_module, "__doc__",
|
|
|
|
"Constants used to interpret content model information.");
|
|
|
|
|
|
|
|
MYCONST(XML_CTYPE_EMPTY);
|
|
|
|
MYCONST(XML_CTYPE_ANY);
|
|
|
|
MYCONST(XML_CTYPE_MIXED);
|
|
|
|
MYCONST(XML_CTYPE_NAME);
|
|
|
|
MYCONST(XML_CTYPE_CHOICE);
|
|
|
|
MYCONST(XML_CTYPE_SEQ);
|
|
|
|
|
|
|
|
MYCONST(XML_CQUANT_NONE);
|
|
|
|
MYCONST(XML_CQUANT_OPT);
|
|
|
|
MYCONST(XML_CQUANT_REP);
|
|
|
|
MYCONST(XML_CQUANT_PLUS);
|
2001-01-21 06:18:10 -04:00
|
|
|
#undef MYCONST
|
2005-12-13 15:49:55 -04:00
|
|
|
|
|
|
|
/* initialize pyexpat dispatch table */
|
2005-12-13 16:43:04 -04:00
|
|
|
capi.size = sizeof(capi);
|
2005-12-13 17:55:36 -04:00
|
|
|
capi.magic = PyExpat_CAPI_MAGIC;
|
2005-12-13 16:43:04 -04:00
|
|
|
capi.MAJOR_VERSION = XML_MAJOR_VERSION;
|
|
|
|
capi.MINOR_VERSION = XML_MINOR_VERSION;
|
|
|
|
capi.MICRO_VERSION = XML_MICRO_VERSION;
|
|
|
|
capi.ErrorString = XML_ErrorString;
|
2005-12-13 17:55:36 -04:00
|
|
|
capi.GetErrorCode = XML_GetErrorCode;
|
|
|
|
capi.GetErrorColumnNumber = XML_GetErrorColumnNumber;
|
|
|
|
capi.GetErrorLineNumber = XML_GetErrorLineNumber;
|
2005-12-13 16:43:04 -04:00
|
|
|
capi.Parse = XML_Parse;
|
|
|
|
capi.ParserCreate_MM = XML_ParserCreate_MM;
|
|
|
|
capi.ParserFree = XML_ParserFree;
|
|
|
|
capi.SetCharacterDataHandler = XML_SetCharacterDataHandler;
|
|
|
|
capi.SetCommentHandler = XML_SetCommentHandler;
|
|
|
|
capi.SetDefaultHandlerExpand = XML_SetDefaultHandlerExpand;
|
|
|
|
capi.SetElementHandler = XML_SetElementHandler;
|
|
|
|
capi.SetNamespaceDeclHandler = XML_SetNamespaceDeclHandler;
|
|
|
|
capi.SetProcessingInstructionHandler = XML_SetProcessingInstructionHandler;
|
|
|
|
capi.SetUnknownEncodingHandler = XML_SetUnknownEncodingHandler;
|
|
|
|
capi.SetUserData = XML_SetUserData;
|
2005-12-13 15:49:55 -04:00
|
|
|
|
|
|
|
/* export as cobject */
|
2005-12-13 17:55:36 -04:00
|
|
|
capi_object = PyCObject_FromVoidPtr(&capi, NULL);
|
2005-12-13 16:43:04 -04:00
|
|
|
if (capi_object)
|
|
|
|
PyModule_AddObject(m, "expat_CAPI", capi_object);
|
2000-03-31 11:43:31 -04:00
|
|
|
}
|
|
|
|
|
2000-08-25 15:03:30 -03:00
|
|
|
static void
|
2001-10-21 05:53:52 -03:00
|
|
|
clear_handlers(xmlparseobject *self, int initial)
|
2000-07-12 01:49:00 -03:00
|
|
|
{
|
2001-04-25 13:01:30 -03:00
|
|
|
int i = 0;
|
|
|
|
PyObject *temp;
|
|
|
|
|
2002-06-28 19:29:01 -03:00
|
|
|
for (; handler_info[i].name != NULL; i++) {
|
2001-10-21 05:53:52 -03:00
|
|
|
if (initial)
|
2002-06-28 19:29:01 -03:00
|
|
|
self->handlers[i] = NULL;
|
2001-10-21 05:53:52 -03:00
|
|
|
else {
|
2001-04-25 13:01:30 -03:00
|
|
|
temp = self->handlers[i];
|
|
|
|
self->handlers[i] = NULL;
|
|
|
|
Py_XDECREF(temp);
|
2001-10-21 05:53:52 -03:00
|
|
|
handler_info[i].setter(self->itself, NULL);
|
2001-04-25 13:01:30 -03:00
|
|
|
}
|
|
|
|
}
|
2000-03-31 11:43:31 -04:00
|
|
|
}
|
|
|
|
|
2002-07-17 13:49:03 -03:00
|
|
|
static struct HandlerInfo handler_info[] = {
|
2002-06-28 19:29:01 -03:00
|
|
|
{"StartElementHandler",
|
|
|
|
(xmlhandlersetter)XML_SetStartElementHandler,
|
2000-07-12 01:49:00 -03:00
|
|
|
(xmlhandler)my_StartElementHandler},
|
2002-06-28 19:29:01 -03:00
|
|
|
{"EndElementHandler",
|
|
|
|
(xmlhandlersetter)XML_SetEndElementHandler,
|
2000-07-12 01:49:00 -03:00
|
|
|
(xmlhandler)my_EndElementHandler},
|
2002-06-28 19:29:01 -03:00
|
|
|
{"ProcessingInstructionHandler",
|
2000-07-12 01:49:00 -03:00
|
|
|
(xmlhandlersetter)XML_SetProcessingInstructionHandler,
|
|
|
|
(xmlhandler)my_ProcessingInstructionHandler},
|
2002-06-28 19:29:01 -03:00
|
|
|
{"CharacterDataHandler",
|
2000-07-12 01:49:00 -03:00
|
|
|
(xmlhandlersetter)XML_SetCharacterDataHandler,
|
|
|
|
(xmlhandler)my_CharacterDataHandler},
|
2002-06-28 19:29:01 -03:00
|
|
|
{"UnparsedEntityDeclHandler",
|
2000-07-12 01:49:00 -03:00
|
|
|
(xmlhandlersetter)XML_SetUnparsedEntityDeclHandler,
|
2002-06-28 19:56:48 -03:00
|
|
|
(xmlhandler)my_UnparsedEntityDeclHandler},
|
2002-06-28 19:29:01 -03:00
|
|
|
{"NotationDeclHandler",
|
2000-07-12 01:49:00 -03:00
|
|
|
(xmlhandlersetter)XML_SetNotationDeclHandler,
|
2002-06-28 19:56:48 -03:00
|
|
|
(xmlhandler)my_NotationDeclHandler},
|
2002-06-28 19:29:01 -03:00
|
|
|
{"StartNamespaceDeclHandler",
|
|
|
|
(xmlhandlersetter)XML_SetStartNamespaceDeclHandler,
|
2002-06-28 19:56:48 -03:00
|
|
|
(xmlhandler)my_StartNamespaceDeclHandler},
|
2002-06-28 19:29:01 -03:00
|
|
|
{"EndNamespaceDeclHandler",
|
|
|
|
(xmlhandlersetter)XML_SetEndNamespaceDeclHandler,
|
2002-06-28 19:56:48 -03:00
|
|
|
(xmlhandler)my_EndNamespaceDeclHandler},
|
2000-07-12 01:49:00 -03:00
|
|
|
{"CommentHandler",
|
|
|
|
(xmlhandlersetter)XML_SetCommentHandler,
|
|
|
|
(xmlhandler)my_CommentHandler},
|
|
|
|
{"StartCdataSectionHandler",
|
2002-06-28 19:29:01 -03:00
|
|
|
(xmlhandlersetter)XML_SetStartCdataSectionHandler,
|
2000-07-12 01:49:00 -03:00
|
|
|
(xmlhandler)my_StartCdataSectionHandler},
|
|
|
|
{"EndCdataSectionHandler",
|
2002-06-28 19:29:01 -03:00
|
|
|
(xmlhandlersetter)XML_SetEndCdataSectionHandler,
|
2000-07-12 01:49:00 -03:00
|
|
|
(xmlhandler)my_EndCdataSectionHandler},
|
|
|
|
{"DefaultHandler",
|
|
|
|
(xmlhandlersetter)XML_SetDefaultHandler,
|
|
|
|
(xmlhandler)my_DefaultHandler},
|
|
|
|
{"DefaultHandlerExpand",
|
|
|
|
(xmlhandlersetter)XML_SetDefaultHandlerExpand,
|
|
|
|
(xmlhandler)my_DefaultHandlerExpandHandler},
|
|
|
|
{"NotStandaloneHandler",
|
|
|
|
(xmlhandlersetter)XML_SetNotStandaloneHandler,
|
|
|
|
(xmlhandler)my_NotStandaloneHandler},
|
|
|
|
{"ExternalEntityRefHandler",
|
|
|
|
(xmlhandlersetter)XML_SetExternalEntityRefHandler,
|
2002-06-28 19:56:48 -03:00
|
|
|
(xmlhandler)my_ExternalEntityRefHandler},
|
2001-01-21 06:18:10 -04:00
|
|
|
{"StartDoctypeDeclHandler",
|
2002-06-28 19:29:01 -03:00
|
|
|
(xmlhandlersetter)XML_SetStartDoctypeDeclHandler,
|
2001-01-21 06:18:10 -04:00
|
|
|
(xmlhandler)my_StartDoctypeDeclHandler},
|
|
|
|
{"EndDoctypeDeclHandler",
|
2002-06-28 19:29:01 -03:00
|
|
|
(xmlhandlersetter)XML_SetEndDoctypeDeclHandler,
|
2001-01-21 06:18:10 -04:00
|
|
|
(xmlhandler)my_EndDoctypeDeclHandler},
|
2001-02-08 11:39:08 -04:00
|
|
|
{"EntityDeclHandler",
|
|
|
|
(xmlhandlersetter)XML_SetEntityDeclHandler,
|
|
|
|
(xmlhandler)my_EntityDeclHandler},
|
|
|
|
{"XmlDeclHandler",
|
|
|
|
(xmlhandlersetter)XML_SetXmlDeclHandler,
|
|
|
|
(xmlhandler)my_XmlDeclHandler},
|
|
|
|
{"ElementDeclHandler",
|
|
|
|
(xmlhandlersetter)XML_SetElementDeclHandler,
|
|
|
|
(xmlhandler)my_ElementDeclHandler},
|
|
|
|
{"AttlistDeclHandler",
|
|
|
|
(xmlhandlersetter)XML_SetAttlistDeclHandler,
|
|
|
|
(xmlhandler)my_AttlistDeclHandler},
|
2003-01-21 07:09:21 -04:00
|
|
|
#if XML_COMBINED_VERSION >= 19504
|
2003-01-21 06:58:18 -04:00
|
|
|
{"SkippedEntityHandler",
|
|
|
|
(xmlhandlersetter)XML_SetSkippedEntityHandler,
|
|
|
|
(xmlhandler)my_SkippedEntityHandler},
|
2003-01-21 07:09:21 -04:00
|
|
|
#endif
|
2000-07-12 01:49:00 -03:00
|
|
|
|
|
|
|
{NULL, NULL, NULL} /* sentinel */
|
2000-03-31 11:43:31 -04:00
|
|
|
};
|