1997-01-06 18:59:08 -04:00
|
|
|
#include "Python.h"
|
|
|
|
#include "cStringIO.h"
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
#include "structmember.h"
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(cPickle_module_documentation,
|
2003-02-01 02:27:59 -04:00
|
|
|
"C implementation and optimization of the Python pickle module.");
|
2002-06-13 17:33:02 -03:00
|
|
|
|
1997-08-13 00:14:41 -03:00
|
|
|
#ifndef Py_eval_input
|
|
|
|
#include <graminit.h>
|
|
|
|
#define Py_eval_input eval_input
|
1997-08-20 23:30:45 -03:00
|
|
|
#endif /* Py_eval_input */
|
1997-08-13 00:14:41 -03:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
#define DEL_LIST_SLICE(list, from, to) (PyList_SetSlice(list, from, to, NULL))
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
#define WRITE_BUF_SIZE 256
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-01 12:45:06 -04:00
|
|
|
/* Bump this when new opcodes are added to the pickle protocol. */
|
2003-02-13 11:44:41 -04:00
|
|
|
#define HIGHEST_PROTOCOL 2
|
2003-02-01 12:45:06 -04:00
|
|
|
|
2003-02-01 02:22:36 -04:00
|
|
|
/*
|
|
|
|
* Pickle opcodes. These must be kept in synch with pickle.py. Extensive
|
|
|
|
* docs are in pickletools.py.
|
|
|
|
*/
|
1997-04-09 14:36:32 -03:00
|
|
|
#define MARK '('
|
|
|
|
#define STOP '.'
|
|
|
|
#define POP '0'
|
|
|
|
#define POP_MARK '1'
|
|
|
|
#define DUP '2'
|
|
|
|
#define FLOAT 'F'
|
|
|
|
#define BINFLOAT 'G'
|
|
|
|
#define INT 'I'
|
|
|
|
#define BININT 'J'
|
|
|
|
#define BININT1 'K'
|
|
|
|
#define LONG 'L'
|
|
|
|
#define BININT2 'M'
|
|
|
|
#define NONE 'N'
|
|
|
|
#define PERSID 'P'
|
|
|
|
#define BINPERSID 'Q'
|
|
|
|
#define REDUCE 'R'
|
|
|
|
#define STRING 'S'
|
|
|
|
#define BINSTRING 'T'
|
|
|
|
#define SHORT_BINSTRING 'U'
|
2000-03-10 19:11:40 -04:00
|
|
|
#define UNICODE 'V'
|
|
|
|
#define BINUNICODE 'X'
|
1997-04-09 14:36:32 -03:00
|
|
|
#define APPEND 'a'
|
|
|
|
#define BUILD 'b'
|
|
|
|
#define GLOBAL 'c'
|
|
|
|
#define DICT 'd'
|
|
|
|
#define EMPTY_DICT '}'
|
|
|
|
#define APPENDS 'e'
|
|
|
|
#define GET 'g'
|
|
|
|
#define BINGET 'h'
|
|
|
|
#define INST 'i'
|
|
|
|
#define LONG_BINGET 'j'
|
|
|
|
#define LIST 'l'
|
|
|
|
#define EMPTY_LIST ']'
|
|
|
|
#define OBJ 'o'
|
|
|
|
#define PUT 'p'
|
|
|
|
#define BINPUT 'q'
|
|
|
|
#define LONG_BINPUT 'r'
|
|
|
|
#define SETITEM 's'
|
|
|
|
#define TUPLE 't'
|
|
|
|
#define EMPTY_TUPLE ')'
|
|
|
|
#define SETITEMS 'u'
|
2003-02-01 02:22:36 -04:00
|
|
|
|
|
|
|
/* Protocol 2. */
|
|
|
|
#define PROTO '\x80' /* identify pickle protocol */
|
|
|
|
#define NEWOBJ '\x81' /* build object by applying cls.__new__ to argtuple */
|
|
|
|
#define EXT1 '\x82' /* push object from extension registry; 1-byte index */
|
|
|
|
#define EXT2 '\x83' /* ditto, but 2-byte index */
|
|
|
|
#define EXT4 '\x84' /* ditto, but 4-byte index */
|
|
|
|
#define TUPLE1 '\x85' /* build 1-tuple from stack top */
|
|
|
|
#define TUPLE2 '\x86' /* build 2-tuple from two topmost stack items */
|
|
|
|
#define TUPLE3 '\x87' /* build 3-tuple from three topmost stack items */
|
|
|
|
#define NEWTRUE '\x88' /* push True */
|
|
|
|
#define NEWFALSE '\x89' /* push False */
|
|
|
|
#define LONG1 '\x8a' /* push long from < 256 bytes */
|
|
|
|
#define LONG4 '\x8b' /* push really big long */
|
|
|
|
|
|
|
|
/* There aren't opcodes -- they're ways to pickle bools before protocol 2,
|
|
|
|
* so that unpicklers written before bools were introduced unpickle them
|
|
|
|
* as ints, but unpicklers after can recognize that bools were intended.
|
|
|
|
* Note that protocol 2 added direct ways to pickle bools.
|
|
|
|
*/
|
2002-06-26 17:40:42 -03:00
|
|
|
#undef TRUE
|
2002-04-05 15:30:08 -04:00
|
|
|
#define TRUE "I01\n"
|
2002-06-26 17:40:42 -03:00
|
|
|
#undef FALSE
|
2002-04-05 15:30:08 -04:00
|
|
|
#define FALSE "I00\n"
|
2002-04-03 18:41:51 -04:00
|
|
|
|
2003-02-11 17:06:20 -04:00
|
|
|
/* Keep in synch with pickle.Pickler._BATCHSIZE. This is how many elements
|
2003-02-11 18:43:24 -04:00
|
|
|
* batch_list/dict() pumps out before doing APPENDS/SETITEMS. Nothing will
|
|
|
|
* break if this gets out of synch with pickle.py, but it's unclear that
|
|
|
|
* would help anything either.
|
2003-02-11 17:06:20 -04:00
|
|
|
*/
|
|
|
|
#define BATCHSIZE 1000
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static char MARKv = MARK;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1999-06-09 12:23:31 -03:00
|
|
|
static PyObject *PickleError;
|
1997-01-06 18:59:08 -04:00
|
|
|
static PyObject *PicklingError;
|
1999-06-09 12:23:31 -03:00
|
|
|
static PyObject *UnpickleableError;
|
1997-01-06 18:59:08 -04:00
|
|
|
static PyObject *UnpicklingError;
|
1998-11-25 12:18:00 -04:00
|
|
|
static PyObject *BadPickleGet;
|
|
|
|
|
2003-02-03 20:21:07 -04:00
|
|
|
/* As the name says, an empty tuple. */
|
|
|
|
static PyObject *empty_tuple;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-03 20:21:07 -04:00
|
|
|
/* copy_reg.dispatch_table, {type_object: pickling_function} */
|
1997-04-09 14:36:32 -03:00
|
|
|
static PyObject *dispatch_table;
|
2003-02-03 20:21:07 -04:00
|
|
|
|
|
|
|
/* For EXT[124] opcodes. */
|
2003-02-03 21:54:49 -04:00
|
|
|
/* copy_reg._extension_registry, {(module_name, function_name): code} */
|
2003-02-03 20:21:07 -04:00
|
|
|
static PyObject *extension_registry;
|
2003-02-03 21:54:49 -04:00
|
|
|
/* copy_reg._inverted_registry, {code: (module_name, function_name)} */
|
2003-02-03 20:21:07 -04:00
|
|
|
static PyObject *inverted_registry;
|
2003-02-03 21:54:49 -04:00
|
|
|
/* copy_reg._extension_cache, {code: object} */
|
2003-02-03 20:21:07 -04:00
|
|
|
static PyObject *extension_cache;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2003-02-04 16:56:09 -04:00
|
|
|
/* For looking up name pairs in copy_reg._extension_registry. */
|
|
|
|
static PyObject *two_tuple;
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static PyObject *__class___str, *__getinitargs___str, *__dict___str,
|
|
|
|
*__getstate___str, *__setstate___str, *__name___str, *__reduce___str,
|
2003-02-18 21:45:13 -04:00
|
|
|
*__reduce_ex___str,
|
2003-01-31 22:16:37 -04:00
|
|
|
*write_str, *append_str,
|
2006-04-21 07:40:58 -03:00
|
|
|
*read_str, *readline_str, *__main___str,
|
2003-01-31 22:16:37 -04:00
|
|
|
*copy_reg_str, *dispatch_table_str;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
1998-11-25 12:18:00 -04:00
|
|
|
/*************************************************************************
|
|
|
|
Internal Data type for pickle data. */
|
|
|
|
|
|
|
|
typedef struct {
|
2002-04-01 13:40:08 -04:00
|
|
|
PyObject_HEAD
|
2003-02-02 16:29:39 -04:00
|
|
|
int length; /* number of initial slots in data currently used */
|
|
|
|
int size; /* number of slots in data allocated */
|
2002-04-01 13:40:08 -04:00
|
|
|
PyObject **data;
|
1998-11-25 12:18:00 -04:00
|
|
|
} Pdata;
|
|
|
|
|
2001-03-17 00:50:51 -04:00
|
|
|
static void
|
2003-02-01 02:24:36 -04:00
|
|
|
Pdata_dealloc(Pdata *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
PyObject **p;
|
2003-02-01 02:24:36 -04:00
|
|
|
|
2003-02-02 16:29:39 -04:00
|
|
|
for (i = self->length, p = self->data; --i >= 0; p++) {
|
|
|
|
Py_DECREF(*p);
|
|
|
|
}
|
|
|
|
if (self->data)
|
|
|
|
free(self->data);
|
2002-04-01 13:40:08 -04:00
|
|
|
PyObject_Del(self);
|
1998-11-25 12:18:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyTypeObject PdataType = {
|
2002-04-01 13:40:08 -04:00
|
|
|
PyObject_HEAD_INIT(NULL) 0, "cPickle.Pdata", sizeof(Pdata), 0,
|
|
|
|
(destructor)Pdata_dealloc,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0L,0L,0L,0L, ""
|
1998-11-25 12:18:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define Pdata_Check(O) ((O)->ob_type == &PdataType)
|
|
|
|
|
|
|
|
static PyObject *
|
2003-02-01 02:24:36 -04:00
|
|
|
Pdata_New(void)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
Pdata *self;
|
1998-11-25 12:18:00 -04:00
|
|
|
|
2003-02-02 16:29:39 -04:00
|
|
|
if (!(self = PyObject_New(Pdata, &PdataType)))
|
|
|
|
return NULL;
|
|
|
|
self->size = 8;
|
|
|
|
self->length = 0;
|
|
|
|
self->data = malloc(self->size * sizeof(PyObject*));
|
|
|
|
if (self->data)
|
|
|
|
return (PyObject*)self;
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_DECREF(self);
|
|
|
|
return PyErr_NoMemory();
|
1998-11-25 12:18:00 -04:00
|
|
|
}
|
|
|
|
|
2001-03-17 00:50:51 -04:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
stackUnderflow(void)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyErr_SetString(UnpicklingError, "unpickling stack underflow");
|
|
|
|
return -1;
|
1998-11-25 12:18:00 -04:00
|
|
|
}
|
|
|
|
|
2003-02-02 16:29:39 -04:00
|
|
|
/* Retain only the initial clearto items. If clearto >= the current
|
|
|
|
* number of items, this is a (non-erroneous) NOP.
|
|
|
|
*/
|
1998-11-25 12:18:00 -04:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
Pdata_clear(Pdata *self, int clearto)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
PyObject **p;
|
1998-11-25 12:18:00 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (clearto < 0) return stackUnderflow();
|
|
|
|
if (clearto >= self->length) return 0;
|
1998-11-25 12:18:00 -04:00
|
|
|
|
2003-02-02 16:29:39 -04:00
|
|
|
for (i = self->length, p = self->data + clearto;
|
|
|
|
--i >= clearto;
|
|
|
|
p++) {
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_DECREF(*p);
|
2003-02-02 16:29:39 -04:00
|
|
|
}
|
|
|
|
self->length = clearto;
|
1998-11-25 12:18:00 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return 0;
|
1998-11-25 12:18:00 -04:00
|
|
|
}
|
|
|
|
|
2001-03-17 00:50:51 -04:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
Pdata_grow(Pdata *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2003-02-02 16:29:39 -04:00
|
|
|
int bigger;
|
|
|
|
size_t nbytes;
|
|
|
|
|
|
|
|
bigger = self->size << 1;
|
2003-02-03 11:45:56 -04:00
|
|
|
if (bigger <= 0) /* was 0, or new value overflows */
|
2003-02-02 16:29:39 -04:00
|
|
|
goto nomemory;
|
|
|
|
if ((int)(size_t)bigger != bigger)
|
|
|
|
goto nomemory;
|
|
|
|
nbytes = (size_t)bigger * sizeof(PyObject *);
|
|
|
|
if (nbytes / sizeof(PyObject *) != (size_t)bigger)
|
|
|
|
goto nomemory;
|
|
|
|
self->data = realloc(self->data, nbytes);
|
|
|
|
if (self->data == NULL)
|
|
|
|
goto nomemory;
|
|
|
|
self->size = bigger;
|
2002-04-01 13:40:08 -04:00
|
|
|
return 0;
|
1998-11-25 12:18:00 -04:00
|
|
|
|
2003-02-02 16:29:39 -04:00
|
|
|
nomemory:
|
|
|
|
self->size = 0;
|
|
|
|
PyErr_NoMemory();
|
|
|
|
return -1;
|
1998-11-25 12:18:00 -04:00
|
|
|
}
|
|
|
|
|
2003-02-03 11:45:56 -04:00
|
|
|
/* D is a Pdata*. Pop the topmost element and store it into V, which
|
|
|
|
* must be an lvalue holding PyObject*. On stack underflow, UnpicklingError
|
2003-02-02 16:29:39 -04:00
|
|
|
* is raised and V is set to NULL. D and V may be evaluated several times.
|
|
|
|
*/
|
|
|
|
#define PDATA_POP(D, V) { \
|
2003-02-03 11:45:56 -04:00
|
|
|
if ((D)->length) \
|
|
|
|
(V) = (D)->data[--((D)->length)]; \
|
|
|
|
else { \
|
|
|
|
PyErr_SetString(UnpicklingError, "bad pickle data"); \
|
|
|
|
(V) = NULL; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PDATA_PUSH and PDATA_APPEND both push rvalue PyObject* O on to Pdata*
|
|
|
|
* D. If the Pdata stack can't be grown to hold the new value, both
|
|
|
|
* raise MemoryError and execute "return ER". The difference is in ownership
|
|
|
|
* of O after: _PUSH transfers ownership of O from the caller to the stack
|
|
|
|
* (no incref of O is done, and in case of error O is decrefed), while
|
|
|
|
* _APPEND pushes a new reference.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Push O on stack D, giving ownership of O to the stack. */
|
|
|
|
#define PDATA_PUSH(D, O, ER) { \
|
|
|
|
if (((Pdata*)(D))->length == ((Pdata*)(D))->size && \
|
|
|
|
Pdata_grow((Pdata*)(D)) < 0) { \
|
|
|
|
Py_DECREF(O); \
|
|
|
|
return ER; \
|
|
|
|
} \
|
|
|
|
((Pdata*)(D))->data[((Pdata*)(D))->length++] = (O); \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Push O on stack D, pushing a new reference. */
|
|
|
|
#define PDATA_APPEND(D, O, ER) { \
|
|
|
|
if (((Pdata*)(D))->length == ((Pdata*)(D))->size && \
|
|
|
|
Pdata_grow((Pdata*)(D)) < 0) \
|
|
|
|
return ER; \
|
|
|
|
Py_INCREF(O); \
|
|
|
|
((Pdata*)(D))->data[((Pdata*)(D))->length++] = (O); \
|
2003-02-02 16:29:39 -04:00
|
|
|
}
|
1998-11-25 12:18:00 -04:00
|
|
|
|
2003-02-03 11:45:56 -04:00
|
|
|
|
1998-11-25 12:18:00 -04:00
|
|
|
static PyObject *
|
2003-02-01 02:24:36 -04:00
|
|
|
Pdata_popTuple(Pdata *self, int start)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *r;
|
|
|
|
int i, j, l;
|
2003-02-01 02:24:36 -04:00
|
|
|
|
2003-02-02 16:29:39 -04:00
|
|
|
l = self->length-start;
|
|
|
|
r = PyTuple_New(l);
|
|
|
|
if (r == NULL)
|
|
|
|
return NULL;
|
|
|
|
for (i = start, j = 0 ; j < l; i++, j++)
|
2002-04-01 13:40:08 -04:00
|
|
|
PyTuple_SET_ITEM(r, j, self->data[i]);
|
2003-02-01 02:24:36 -04:00
|
|
|
|
2003-02-02 16:29:39 -04:00
|
|
|
self->length = start;
|
2002-04-01 13:40:08 -04:00
|
|
|
return r;
|
1998-11-25 12:18:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2003-02-01 02:24:36 -04:00
|
|
|
Pdata_popList(Pdata *self, int start)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *r;
|
|
|
|
int i, j, l;
|
1998-11-25 12:18:00 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
l=self->length-start;
|
|
|
|
if (!( r=PyList_New(l))) return NULL;
|
|
|
|
for (i=start, j=0 ; j < l; i++, j++)
|
|
|
|
PyList_SET_ITEM(r, j, self->data[i]);
|
1998-11-25 12:18:00 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
self->length=start;
|
|
|
|
return r;
|
1998-11-25 12:18:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
#define ARG_TUP(self, o) { \
|
|
|
|
if (self->arg || (self->arg=PyTuple_New(1))) { \
|
|
|
|
Py_XDECREF(PyTuple_GET_ITEM(self->arg,0)); \
|
|
|
|
PyTuple_SET_ITEM(self->arg,0,o); \
|
|
|
|
} \
|
|
|
|
else { \
|
|
|
|
Py_DECREF(o); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define FREE_ARG_TUP(self) { \
|
|
|
|
if (self->arg->ob_refcnt > 1) { \
|
|
|
|
Py_DECREF(self->arg); \
|
|
|
|
self->arg=NULL; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2000-07-22 20:56:07 -03:00
|
|
|
typedef struct Picklerobject {
|
2002-04-01 13:40:08 -04:00
|
|
|
PyObject_HEAD
|
|
|
|
FILE *fp;
|
|
|
|
PyObject *write;
|
|
|
|
PyObject *file;
|
|
|
|
PyObject *memo;
|
|
|
|
PyObject *arg;
|
|
|
|
PyObject *pers_func;
|
|
|
|
PyObject *inst_pers_func;
|
2003-02-01 02:22:36 -04:00
|
|
|
|
|
|
|
/* pickle protocol number, >= 0 */
|
|
|
|
int proto;
|
|
|
|
|
|
|
|
/* bool, true if proto > 0 */
|
2002-04-01 13:40:08 -04:00
|
|
|
int bin;
|
2003-02-01 02:22:36 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
int fast; /* Fast mode doesn't save in memo, don't use if circ ref */
|
2002-08-04 05:20:23 -03:00
|
|
|
int nesting;
|
2006-02-15 13:27:45 -04:00
|
|
|
int (*write_func)(struct Picklerobject *, const char *, Py_ssize_t);
|
2002-04-01 13:40:08 -04:00
|
|
|
char *write_buf;
|
|
|
|
int buf_size;
|
|
|
|
PyObject *dispatch_table;
|
|
|
|
int fast_container; /* count nested container dumps */
|
|
|
|
PyObject *fast_memo;
|
1997-04-09 14:36:32 -03:00
|
|
|
} Picklerobject;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2001-12-21 16:04:22 -04:00
|
|
|
#ifndef PY_CPICKLE_FAST_LIMIT
|
|
|
|
#define PY_CPICKLE_FAST_LIMIT 50
|
|
|
|
#endif
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
|
2002-07-17 13:30:39 -03:00
|
|
|
static PyTypeObject Picklertype;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2000-07-22 20:56:07 -03:00
|
|
|
typedef struct Unpicklerobject {
|
2002-04-01 13:40:08 -04:00
|
|
|
PyObject_HEAD
|
|
|
|
FILE *fp;
|
|
|
|
PyObject *file;
|
|
|
|
PyObject *readline;
|
|
|
|
PyObject *read;
|
|
|
|
PyObject *memo;
|
|
|
|
PyObject *arg;
|
|
|
|
Pdata *stack;
|
|
|
|
PyObject *mark;
|
|
|
|
PyObject *pers_func;
|
|
|
|
PyObject *last_string;
|
|
|
|
int *marks;
|
|
|
|
int num_marks;
|
|
|
|
int marks_size;
|
2006-02-15 13:27:45 -04:00
|
|
|
Py_ssize_t (*read_func)(struct Unpicklerobject *, char **, Py_ssize_t);
|
|
|
|
Py_ssize_t (*readline_func)(struct Unpicklerobject *, char **);
|
2002-04-01 13:40:08 -04:00
|
|
|
int buf_size;
|
|
|
|
char *buf;
|
|
|
|
PyObject *find_class;
|
1997-04-09 14:36:32 -03:00
|
|
|
} Unpicklerobject;
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2002-07-17 13:30:39 -03:00
|
|
|
static PyTypeObject Unpicklertype;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2000-07-24 08:36:47 -03:00
|
|
|
/* Forward decls that need the above structs */
|
|
|
|
static int save(Picklerobject *, PyObject *, int);
|
|
|
|
static int put2(Picklerobject *, PyObject *);
|
|
|
|
|
1997-04-09 14:47:47 -03:00
|
|
|
static
|
1997-04-09 14:36:32 -03:00
|
|
|
PyObject *
|
2000-07-22 20:56:07 -03:00
|
|
|
cPickle_ErrFormat(PyObject *ErrType, char *stringformat, char *format, ...)
|
|
|
|
{
|
2002-04-01 13:40:08 -04:00
|
|
|
va_list va;
|
|
|
|
PyObject *args=0, *retval=0;
|
|
|
|
va_start(va, format);
|
2003-02-01 02:24:36 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (format) args = Py_VaBuildValue(format, va);
|
|
|
|
va_end(va);
|
|
|
|
if (format && ! args) return NULL;
|
2003-02-01 02:24:36 -04:00
|
|
|
if (stringformat && !(retval=PyString_FromString(stringformat)))
|
2002-04-01 13:40:08 -04:00
|
|
|
return NULL;
|
2003-02-01 02:24:36 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (retval) {
|
|
|
|
if (args) {
|
|
|
|
PyObject *v;
|
|
|
|
v=PyString_Format(retval, args);
|
|
|
|
Py_DECREF(retval);
|
|
|
|
Py_DECREF(args);
|
|
|
|
if (! v) return NULL;
|
|
|
|
retval=v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (args) retval=args;
|
|
|
|
else {
|
|
|
|
PyErr_SetObject(ErrType,Py_None);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
PyErr_SetObject(ErrType,retval);
|
|
|
|
Py_DECREF(retval);
|
|
|
|
return NULL;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2001-03-17 00:50:51 -04:00
|
|
|
static int
|
2006-02-15 13:27:45 -04:00
|
|
|
write_file(Picklerobject *self, const char *s, Py_ssize_t n)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
size_t nbyteswritten;
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (s == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2006-02-15 13:27:45 -04:00
|
|
|
if (n > INT_MAX) {
|
|
|
|
/* String too large */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_BEGIN_ALLOW_THREADS
|
2002-07-18 17:58:57 -03:00
|
|
|
nbyteswritten = fwrite(s, sizeof(char), n, self->fp);
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_END_ALLOW_THREADS
|
2002-07-18 17:58:57 -03:00
|
|
|
if (nbyteswritten != (size_t)n) {
|
|
|
|
PyErr_SetFromErrno(PyExc_IOError);
|
|
|
|
return -1;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2006-02-15 13:27:45 -04:00
|
|
|
return (int)n;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
2001-03-17 00:50:51 -04:00
|
|
|
static int
|
2006-02-15 13:27:45 -04:00
|
|
|
write_cStringIO(Picklerobject *self, const char *s, Py_ssize_t n)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
if (s == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
2003-02-01 02:24:36 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (PycStringIO->cwrite((PyObject *)self->file, s, n) != n) {
|
|
|
|
return -1;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2006-02-15 13:27:45 -04:00
|
|
|
return (int)n;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
2001-03-17 00:50:51 -04:00
|
|
|
static int
|
2006-02-15 13:27:45 -04:00
|
|
|
write_none(Picklerobject *self, const char *s, Py_ssize_t n)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
if (s == NULL) return 0;
|
2006-02-15 13:27:45 -04:00
|
|
|
if (n > INT_MAX) return -1;
|
|
|
|
return (int)n;
|
1997-08-13 00:14:41 -03:00
|
|
|
}
|
|
|
|
|
2001-03-17 00:50:51 -04:00
|
|
|
static int
|
2006-02-15 13:27:45 -04:00
|
|
|
write_other(Picklerobject *self, const char *s, Py_ssize_t _n)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *py_str = 0, *junk = 0;
|
2006-02-15 13:27:45 -04:00
|
|
|
int n;
|
2003-02-01 02:24:36 -04:00
|
|
|
|
2006-02-15 13:27:45 -04:00
|
|
|
if (_n > INT_MAX)
|
|
|
|
return -1;
|
|
|
|
n = (int)_n;
|
2002-04-01 13:40:08 -04:00
|
|
|
if (s == NULL) {
|
|
|
|
if (!( self->buf_size )) return 0;
|
2003-02-01 02:24:36 -04:00
|
|
|
py_str = PyString_FromStringAndSize(self->write_buf,
|
2002-04-01 13:40:08 -04:00
|
|
|
self->buf_size);
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!py_str)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (self->buf_size && (n + self->buf_size) > WRITE_BUF_SIZE) {
|
|
|
|
if (write_other(self, NULL, 0) < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
2003-02-01 02:24:36 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (n > WRITE_BUF_SIZE) {
|
|
|
|
if (!( py_str =
|
2003-02-01 02:24:36 -04:00
|
|
|
PyString_FromStringAndSize(s, n)))
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
memcpy(self->write_buf + self->buf_size, s, n);
|
|
|
|
self->buf_size += n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (self->write) {
|
|
|
|
/* object with write method */
|
|
|
|
ARG_TUP(self, py_str);
|
|
|
|
if (self->arg) {
|
|
|
|
junk = PyObject_Call(self->write, self->arg, NULL);
|
|
|
|
FREE_ARG_TUP(self);
|
|
|
|
}
|
|
|
|
if (junk) Py_DECREF(junk);
|
|
|
|
else return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
PDATA_PUSH(self->file, py_str, -1);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
self->buf_size = 0;
|
|
|
|
return n;
|
|
|
|
}
|
1997-04-09 14:36:32 -03:00
|
|
|
|
|
|
|
|
2006-02-15 13:27:45 -04:00
|
|
|
static Py_ssize_t
|
|
|
|
read_file(Unpicklerobject *self, char **s, Py_ssize_t n)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
size_t nbytesread;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (self->buf_size == 0) {
|
|
|
|
int size;
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
size = ((n < 32) ? 32 : n);
|
cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments. Fixed an undetected-overflow bug in readline_file().
longobject.c: Fixed a really stupid bug in the new _PyLong_NumBits.
pickle.py: Fixed stupid bug in save_long(): When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4(): they *returned* the unpickled long instead of pushing
it on the stack. The return values were ignored. Tests passed
before only because save_long() pickled the long twice.
Fixed bugs in encode_long().
Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time. I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that. It would be more valuable to make long(string, 16) linear time.
pickletester.py: Added a global "protocols" vector so tests can try
all the protocols in a sane way. Changed test_ints() and test_unicode()
to do so. Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle: cPickle proto 2 for longs is linear-time).
2003-02-01 22:57:53 -04:00
|
|
|
if (!( self->buf = (char *)malloc(size))) {
|
2002-04-01 13:40:08 -04:00
|
|
|
PyErr_NoMemory();
|
|
|
|
return -1;
|
|
|
|
}
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
self->buf_size = size;
|
|
|
|
}
|
|
|
|
else if (n > self->buf_size) {
|
cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments. Fixed an undetected-overflow bug in readline_file().
longobject.c: Fixed a really stupid bug in the new _PyLong_NumBits.
pickle.py: Fixed stupid bug in save_long(): When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4(): they *returned* the unpickled long instead of pushing
it on the stack. The return values were ignored. Tests passed
before only because save_long() pickled the long twice.
Fixed bugs in encode_long().
Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time. I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that. It would be more valuable to make long(string, 16) linear time.
pickletester.py: Added a global "protocols" vector so tests can try
all the protocols in a sane way. Changed test_ints() and test_unicode()
to do so. Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle: cPickle proto 2 for longs is linear-time).
2003-02-01 22:57:53 -04:00
|
|
|
self->buf = (char *)realloc(self->buf, n);
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!self->buf) {
|
|
|
|
PyErr_NoMemory();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
self->buf_size = n;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
nbytesread = fread(self->buf, sizeof(char), n, self->fp);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
if (nbytesread != (size_t)n) {
|
|
|
|
if (feof(self->fp)) {
|
|
|
|
PyErr_SetNone(PyExc_EOFError);
|
|
|
|
return -1;
|
|
|
|
}
|
2003-02-01 02:24:36 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
PyErr_SetFromErrno(PyExc_IOError);
|
|
|
|
return -1;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
*s = self->buf;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return n;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-15 13:27:45 -04:00
|
|
|
static Py_ssize_t
|
2003-02-01 02:24:36 -04:00
|
|
|
readline_file(Unpicklerobject *self, char **s)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
int i;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (self->buf_size == 0) {
|
cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments. Fixed an undetected-overflow bug in readline_file().
longobject.c: Fixed a really stupid bug in the new _PyLong_NumBits.
pickle.py: Fixed stupid bug in save_long(): When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4(): they *returned* the unpickled long instead of pushing
it on the stack. The return values were ignored. Tests passed
before only because save_long() pickled the long twice.
Fixed bugs in encode_long().
Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time. I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that. It would be more valuable to make long(string, 16) linear time.
pickletester.py: Added a global "protocols" vector so tests can try
all the protocols in a sane way. Changed test_ints() and test_unicode()
to do so. Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle: cPickle proto 2 for longs is linear-time).
2003-02-01 22:57:53 -04:00
|
|
|
if (!( self->buf = (char *)malloc(40))) {
|
2002-04-01 13:40:08 -04:00
|
|
|
PyErr_NoMemory();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
self->buf_size = 40;
|
|
|
|
}
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
i = 0;
|
|
|
|
while (1) {
|
cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments. Fixed an undetected-overflow bug in readline_file().
longobject.c: Fixed a really stupid bug in the new _PyLong_NumBits.
pickle.py: Fixed stupid bug in save_long(): When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4(): they *returned* the unpickled long instead of pushing
it on the stack. The return values were ignored. Tests passed
before only because save_long() pickled the long twice.
Fixed bugs in encode_long().
Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time. I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that. It would be more valuable to make long(string, 16) linear time.
pickletester.py: Added a global "protocols" vector so tests can try
all the protocols in a sane way. Changed test_ints() and test_unicode()
to do so. Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle: cPickle proto 2 for longs is linear-time).
2003-02-01 22:57:53 -04:00
|
|
|
int bigger;
|
2002-04-01 13:40:08 -04:00
|
|
|
for (; i < (self->buf_size - 1); i++) {
|
2003-02-01 02:24:36 -04:00
|
|
|
if (feof(self->fp) ||
|
2002-04-01 13:40:08 -04:00
|
|
|
(self->buf[i] = getc(self->fp)) == '\n') {
|
|
|
|
self->buf[i + 1] = '\0';
|
|
|
|
*s = self->buf;
|
|
|
|
return i + 1;
|
|
|
|
}
|
|
|
|
}
|
cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments. Fixed an undetected-overflow bug in readline_file().
longobject.c: Fixed a really stupid bug in the new _PyLong_NumBits.
pickle.py: Fixed stupid bug in save_long(): When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4(): they *returned* the unpickled long instead of pushing
it on the stack. The return values were ignored. Tests passed
before only because save_long() pickled the long twice.
Fixed bugs in encode_long().
Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time. I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that. It would be more valuable to make long(string, 16) linear time.
pickletester.py: Added a global "protocols" vector so tests can try
all the protocols in a sane way. Changed test_ints() and test_unicode()
to do so. Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle: cPickle proto 2 for longs is linear-time).
2003-02-01 22:57:53 -04:00
|
|
|
bigger = self->buf_size << 1;
|
|
|
|
if (bigger <= 0) { /* overflow */
|
|
|
|
PyErr_NoMemory();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
self->buf = (char *)realloc(self->buf, bigger);
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!self->buf) {
|
|
|
|
PyErr_NoMemory();
|
|
|
|
return -1;
|
|
|
|
}
|
cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments. Fixed an undetected-overflow bug in readline_file().
longobject.c: Fixed a really stupid bug in the new _PyLong_NumBits.
pickle.py: Fixed stupid bug in save_long(): When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4(): they *returned* the unpickled long instead of pushing
it on the stack. The return values were ignored. Tests passed
before only because save_long() pickled the long twice.
Fixed bugs in encode_long().
Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time. I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that. It would be more valuable to make long(string, 16) linear time.
pickletester.py: Added a global "protocols" vector so tests can try
all the protocols in a sane way. Changed test_ints() and test_unicode()
to do so. Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle: cPickle proto 2 for longs is linear-time).
2003-02-01 22:57:53 -04:00
|
|
|
self->buf_size = bigger;
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
2006-02-15 13:27:45 -04:00
|
|
|
static Py_ssize_t
|
|
|
|
read_cStringIO(Unpicklerobject *self, char **s, Py_ssize_t n)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
char *ptr;
|
2003-02-01 02:24:36 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (PycStringIO->cread((PyObject *)self->file, &ptr, n) != n) {
|
|
|
|
PyErr_SetNone(PyExc_EOFError);
|
|
|
|
return -1;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
*s = ptr;
|
2003-02-01 02:24:36 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return n;
|
2001-03-17 00:50:51 -04:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
2006-02-15 13:27:45 -04:00
|
|
|
static Py_ssize_t
|
2003-02-01 02:24:36 -04:00
|
|
|
readline_cStringIO(Unpicklerobject *self, char **s)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2006-02-15 13:27:45 -04:00
|
|
|
Py_ssize_t n;
|
2002-04-01 13:40:08 -04:00
|
|
|
char *ptr;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((n = PycStringIO->creadline((PyObject *)self->file, &ptr)) < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
*s = ptr;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return n;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-15 13:27:45 -04:00
|
|
|
static Py_ssize_t
|
|
|
|
read_other(Unpicklerobject *self, char **s, Py_ssize_t n)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *bytes, *str=0;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2006-02-15 13:27:45 -04:00
|
|
|
if (!( bytes = PyInt_FromSsize_t(n))) return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
ARG_TUP(self, bytes);
|
|
|
|
if (self->arg) {
|
|
|
|
str = PyObject_Call(self->read, self->arg, NULL);
|
|
|
|
FREE_ARG_TUP(self);
|
|
|
|
}
|
|
|
|
if (! str) return -1;
|
2003-02-01 02:24:36 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_XDECREF(self->last_string);
|
|
|
|
self->last_string = str;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (! (*s = PyString_AsString(str))) return -1;
|
|
|
|
return n;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-15 13:27:45 -04:00
|
|
|
static Py_ssize_t
|
2003-02-01 02:24:36 -04:00
|
|
|
readline_other(Unpicklerobject *self, char **s)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *str;
|
2006-02-15 13:27:45 -04:00
|
|
|
Py_ssize_t str_size;
|
2003-02-01 02:24:36 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!( str = PyObject_CallObject(self->readline, empty_tuple))) {
|
|
|
|
return -1;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((str_size = PyString_Size(str)) < 0)
|
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_XDECREF(self->last_string);
|
|
|
|
self->last_string = str;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (! (*s = PyString_AsString(str)))
|
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return str_size;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments. Fixed an undetected-overflow bug in readline_file().
longobject.c: Fixed a really stupid bug in the new _PyLong_NumBits.
pickle.py: Fixed stupid bug in save_long(): When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4(): they *returned* the unpickled long instead of pushing
it on the stack. The return values were ignored. Tests passed
before only because save_long() pickled the long twice.
Fixed bugs in encode_long().
Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time. I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that. It would be more valuable to make long(string, 16) linear time.
pickletester.py: Added a global "protocols" vector so tests can try
all the protocols in a sane way. Changed test_ints() and test_unicode()
to do so. Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle: cPickle proto 2 for longs is linear-time).
2003-02-01 22:57:53 -04:00
|
|
|
/* Copy the first n bytes from s into newly malloc'ed memory, plus a
|
|
|
|
* trailing 0 byte. Return a pointer to that, or NULL if out of memory.
|
|
|
|
* The caller is responsible for free()'ing the return value.
|
|
|
|
*/
|
2002-04-01 13:40:08 -04:00
|
|
|
static char *
|
2005-12-10 14:50:16 -04:00
|
|
|
pystrndup(const char *s, int n)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments. Fixed an undetected-overflow bug in readline_file().
longobject.c: Fixed a really stupid bug in the new _PyLong_NumBits.
pickle.py: Fixed stupid bug in save_long(): When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4(): they *returned* the unpickled long instead of pushing
it on the stack. The return values were ignored. Tests passed
before only because save_long() pickled the long twice.
Fixed bugs in encode_long().
Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time. I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that. It would be more valuable to make long(string, 16) linear time.
pickletester.py: Added a global "protocols" vector so tests can try
all the protocols in a sane way. Changed test_ints() and test_unicode()
to do so. Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle: cPickle proto 2 for longs is linear-time).
2003-02-01 22:57:53 -04:00
|
|
|
char *r = (char *)malloc(n+1);
|
|
|
|
if (r == NULL)
|
|
|
|
return (char*)PyErr_NoMemory();
|
|
|
|
memcpy(r, s, n);
|
|
|
|
r[n] = 0;
|
2002-04-01 13:40:08 -04:00
|
|
|
return r;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
get(Picklerobject *self, PyObject *id)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *value, *mv;
|
|
|
|
long c_value;
|
|
|
|
char s[30];
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
if (!( mv = PyDict_GetItem(self->memo, id))) {
|
|
|
|
PyErr_SetObject(PyExc_KeyError, id);
|
|
|
|
return -1;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( value = PyTuple_GetItem(mv, 0)))
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!( PyInt_Check(value))) {
|
|
|
|
PyErr_SetString(PicklingError, "no int where int expected in memo");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
c_value = PyInt_AS_LONG((PyIntObject*)value);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!self->bin) {
|
|
|
|
s[0] = GET;
|
|
|
|
PyOS_snprintf(s + 1, sizeof(s) - 1, "%ld\n", c_value);
|
|
|
|
len = strlen(s);
|
|
|
|
}
|
|
|
|
else if (Pdata_Check(self->file)) {
|
|
|
|
if (write_other(self, NULL, 0) < 0) return -1;
|
|
|
|
PDATA_APPEND(self->file, mv, -1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (c_value < 256) {
|
|
|
|
s[0] = BINGET;
|
|
|
|
s[1] = (int)(c_value & 0xff);
|
|
|
|
len = 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
s[0] = LONG_BINGET;
|
|
|
|
s[1] = (int)(c_value & 0xff);
|
|
|
|
s[2] = (int)((c_value >> 8) & 0xff);
|
|
|
|
s[3] = (int)((c_value >> 16) & 0xff);
|
|
|
|
s[4] = (int)((c_value >> 24) & 0xff);
|
|
|
|
len = 5;
|
|
|
|
}
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, s, len) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
2003-02-01 02:24:36 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
put(Picklerobject *self, PyObject *ob)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2003-02-01 02:24:36 -04:00
|
|
|
if (ob->ob_refcnt < 2 || self->fast)
|
2002-04-01 13:40:08 -04:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return put2(self, ob);
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
2001-03-17 00:50:51 -04:00
|
|
|
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
put2(Picklerobject *self, PyObject *ob)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
char c_str[30];
|
|
|
|
int p;
|
|
|
|
size_t len;
|
|
|
|
int res = -1;
|
|
|
|
PyObject *py_ob_id = 0, *memo_len = 0, *t = 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (self->fast)
|
|
|
|
return 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((p = PyDict_Size(self->memo)) < 0)
|
|
|
|
goto finally;
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
/* Make sure memo keys are positive! */
|
2003-02-02 13:26:40 -04:00
|
|
|
/* XXX Why?
|
|
|
|
* XXX And does "positive" really mean non-negative?
|
|
|
|
* XXX pickle.py starts with PUT index 0, not 1. This makes for
|
|
|
|
* XXX gratuitous differences between the pickling modules.
|
|
|
|
*/
|
2003-02-01 02:24:36 -04:00
|
|
|
p++;
|
2002-04-01 13:40:08 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( py_ob_id = PyLong_FromVoidPtr(ob)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( memo_len = PyInt_FromLong(p)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( t = PyTuple_New(2)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
|
|
|
|
|
|
|
PyTuple_SET_ITEM(t, 0, memo_len);
|
|
|
|
Py_INCREF(memo_len);
|
|
|
|
PyTuple_SET_ITEM(t, 1, ob);
|
|
|
|
Py_INCREF(ob);
|
|
|
|
|
|
|
|
if (PyDict_SetItem(self->memo, py_ob_id, t) < 0)
|
|
|
|
goto finally;
|
|
|
|
|
|
|
|
if (!self->bin) {
|
|
|
|
c_str[0] = PUT;
|
|
|
|
PyOS_snprintf(c_str + 1, sizeof(c_str) - 1, "%d\n", p);
|
|
|
|
len = strlen(c_str);
|
|
|
|
}
|
|
|
|
else if (Pdata_Check(self->file)) {
|
|
|
|
if (write_other(self, NULL, 0) < 0) return -1;
|
|
|
|
PDATA_APPEND(self->file, memo_len, -1);
|
|
|
|
res=0; /* Job well done ;) */
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (p >= 256) {
|
|
|
|
c_str[0] = LONG_BINPUT;
|
|
|
|
c_str[1] = (int)(p & 0xff);
|
|
|
|
c_str[2] = (int)((p >> 8) & 0xff);
|
|
|
|
c_str[3] = (int)((p >> 16) & 0xff);
|
|
|
|
c_str[4] = (int)((p >> 24) & 0xff);
|
|
|
|
len = 5;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
c_str[0] = BINPUT;
|
|
|
|
c_str[1] = p;
|
|
|
|
len = 2;
|
|
|
|
}
|
|
|
|
}
|
1998-08-13 20:13:52 -03:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, c_str, len) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
|
|
|
|
|
|
|
res = 0;
|
|
|
|
|
|
|
|
finally:
|
|
|
|
Py_XDECREF(py_ob_id);
|
|
|
|
Py_XDECREF(memo_len);
|
|
|
|
Py_XDECREF(t);
|
|
|
|
|
|
|
|
return res;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
1997-12-03 21:13:01 -04:00
|
|
|
static PyObject *
|
2003-02-01 02:24:36 -04:00
|
|
|
whichmodule(PyObject *global, PyObject *global_name)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2006-02-15 13:27:45 -04:00
|
|
|
Py_ssize_t i, j;
|
2002-04-01 13:40:08 -04:00
|
|
|
PyObject *module = 0, *modules_dict = 0,
|
|
|
|
*global_name_attr = 0, *name = 0;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
module = PyObject_GetAttrString(global, "__module__");
|
2003-06-16 17:19:49 -03:00
|
|
|
if (module)
|
|
|
|
return module;
|
|
|
|
if (PyErr_ExceptionMatches(PyExc_AttributeError))
|
|
|
|
PyErr_Clear();
|
|
|
|
else
|
|
|
|
return NULL;
|
1997-09-28 02:38:51 -03:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( modules_dict = PySys_GetObject("modules")))
|
2002-04-01 13:40:08 -04:00
|
|
|
return NULL;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
i = 0;
|
|
|
|
while ((j = PyDict_Next(modules_dict, &i, &name, &module))) {
|
1997-08-13 00:14:41 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (PyObject_Compare(name, __main___str)==0) continue;
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
global_name_attr = PyObject_GetAttr(module, global_name);
|
|
|
|
if (!global_name_attr) {
|
2003-06-16 17:19:49 -03:00
|
|
|
if (PyErr_ExceptionMatches(PyExc_AttributeError))
|
|
|
|
PyErr_Clear();
|
|
|
|
else
|
|
|
|
return NULL;
|
2002-04-01 13:40:08 -04:00
|
|
|
continue;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (global_name_attr != global) {
|
|
|
|
Py_DECREF(global_name_attr);
|
|
|
|
continue;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_DECREF(global_name_attr);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
break;
|
|
|
|
}
|
1997-08-13 00:14:41 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
/* The following implements the rule in pickle.py added in 1.5
|
|
|
|
that used __main__ if no module is found. I don't actually
|
|
|
|
like this rule. jlf
|
|
|
|
*/
|
|
|
|
if (!j) {
|
|
|
|
j=1;
|
|
|
|
name=__main___str;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_INCREF(name);
|
|
|
|
return name;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
2001-10-15 18:37:58 -03:00
|
|
|
static int
|
|
|
|
fast_save_enter(Picklerobject *self, PyObject *obj)
|
|
|
|
{
|
2002-04-01 13:40:08 -04:00
|
|
|
/* if fast_container < 0, we're doing an error exit. */
|
|
|
|
if (++self->fast_container >= PY_CPICKLE_FAST_LIMIT) {
|
|
|
|
PyObject *key = NULL;
|
|
|
|
if (self->fast_memo == NULL) {
|
|
|
|
self->fast_memo = PyDict_New();
|
|
|
|
if (self->fast_memo == NULL) {
|
|
|
|
self->fast_container = -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
key = PyLong_FromVoidPtr(obj);
|
|
|
|
if (key == NULL)
|
|
|
|
return 0;
|
|
|
|
if (PyDict_GetItem(self->fast_memo, key)) {
|
2002-12-06 22:43:28 -04:00
|
|
|
Py_DECREF(key);
|
2002-04-01 13:40:08 -04:00
|
|
|
PyErr_Format(PyExc_ValueError,
|
2003-02-13 19:00:26 -04:00
|
|
|
"fast mode: can't pickle cyclic objects "
|
|
|
|
"including object type %s at %p",
|
2002-04-01 13:40:08 -04:00
|
|
|
obj->ob_type->tp_name, obj);
|
|
|
|
self->fast_container = -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (PyDict_SetItem(self->fast_memo, key, Py_None) < 0) {
|
2002-12-06 22:43:28 -04:00
|
|
|
Py_DECREF(key);
|
2002-04-01 13:40:08 -04:00
|
|
|
self->fast_container = -1;
|
|
|
|
return 0;
|
|
|
|
}
|
2002-12-06 22:43:28 -04:00
|
|
|
Py_DECREF(key);
|
2001-10-15 18:37:58 -03:00
|
|
|
}
|
2002-04-01 13:40:08 -04:00
|
|
|
return 1;
|
2001-10-15 18:37:58 -03:00
|
|
|
}
|
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
int
|
2001-10-15 18:37:58 -03:00
|
|
|
fast_save_leave(Picklerobject *self, PyObject *obj)
|
|
|
|
{
|
2002-04-01 13:40:08 -04:00
|
|
|
if (self->fast_container-- >= PY_CPICKLE_FAST_LIMIT) {
|
|
|
|
PyObject *key = PyLong_FromVoidPtr(obj);
|
|
|
|
if (key == NULL)
|
|
|
|
return 0;
|
|
|
|
if (PyDict_DelItem(self->fast_memo, key) < 0) {
|
2002-12-06 22:43:28 -04:00
|
|
|
Py_DECREF(key);
|
2002-04-01 13:40:08 -04:00
|
|
|
return 0;
|
|
|
|
}
|
2002-12-06 22:43:28 -04:00
|
|
|
Py_DECREF(key);
|
2001-10-15 18:37:58 -03:00
|
|
|
}
|
2002-04-01 13:40:08 -04:00
|
|
|
return 1;
|
2001-10-15 18:37:58 -03:00
|
|
|
}
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
save_none(Picklerobject *self, PyObject *args)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
static char none = NONE;
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, &none, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return 0;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
|
|
|
|
2002-04-03 18:41:51 -04:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
save_bool(Picklerobject *self, PyObject *args)
|
2002-04-03 18:41:51 -04:00
|
|
|
{
|
2005-12-10 14:50:16 -04:00
|
|
|
static const char *buf[2] = {FALSE, TRUE};
|
2002-04-05 15:30:08 -04:00
|
|
|
static char len[2] = {sizeof(FALSE)-1, sizeof(TRUE)-1};
|
2002-04-03 18:41:51 -04:00
|
|
|
long l = PyInt_AS_LONG((PyIntObject *)args);
|
|
|
|
|
2003-02-02 13:59:11 -04:00
|
|
|
if (self->proto >= 2) {
|
|
|
|
char opcode = l ? NEWTRUE : NEWFALSE;
|
|
|
|
if (self->write_func(self, &opcode, 1) < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else if (self->write_func(self, buf[l], len[l]) < 0)
|
2002-04-03 18:41:51 -04:00
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
2001-03-17 00:50:51 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
save_int(Picklerobject *self, PyObject *args)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
char c_str[32];
|
|
|
|
long l = PyInt_AS_LONG((PyIntObject *)args);
|
|
|
|
int len = 0;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!self->bin
|
1997-05-13 15:00:44 -03:00
|
|
|
#if SIZEOF_LONG > 4
|
2002-04-01 13:40:08 -04:00
|
|
|
|| l > 0x7fffffffL
|
|
|
|
|| l < -0x80000000L
|
1997-05-13 15:00:44 -03:00
|
|
|
#endif
|
2002-04-01 13:40:08 -04:00
|
|
|
) {
|
|
|
|
/* Text-mode pickle, or long too big to fit in the 4-byte
|
|
|
|
* signed BININT format: store as a string.
|
|
|
|
*/
|
|
|
|
c_str[0] = INT;
|
|
|
|
PyOS_snprintf(c_str + 1, sizeof(c_str) - 1, "%ld\n", l);
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, c_str, strlen(c_str)) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Binary pickle and l fits in a signed 4-byte int. */
|
|
|
|
c_str[1] = (int)( l & 0xff);
|
|
|
|
c_str[2] = (int)((l >> 8) & 0xff);
|
|
|
|
c_str[3] = (int)((l >> 16) & 0xff);
|
|
|
|
c_str[4] = (int)((l >> 24) & 0xff);
|
|
|
|
|
|
|
|
if ((c_str[4] == 0) && (c_str[3] == 0)) {
|
|
|
|
if (c_str[2] == 0) {
|
|
|
|
c_str[0] = BININT1;
|
|
|
|
len = 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
c_str[0] = BININT2;
|
|
|
|
len = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
c_str[0] = BININT;
|
|
|
|
len = 5;
|
|
|
|
}
|
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, c_str, len) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
save_long(Picklerobject *self, PyObject *args)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments. Fixed an undetected-overflow bug in readline_file().
longobject.c: Fixed a really stupid bug in the new _PyLong_NumBits.
pickle.py: Fixed stupid bug in save_long(): When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4(): they *returned* the unpickled long instead of pushing
it on the stack. The return values were ignored. Tests passed
before only because save_long() pickled the long twice.
Fixed bugs in encode_long().
Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time. I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that. It would be more valuable to make long(string, 16) linear time.
pickletester.py: Added a global "protocols" vector so tests can try
all the protocols in a sane way. Changed test_ints() and test_unicode()
to do so. Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle: cPickle proto 2 for longs is linear-time).
2003-02-01 22:57:53 -04:00
|
|
|
int size;
|
|
|
|
int res = -1;
|
|
|
|
PyObject *repr = NULL;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
static char l = LONG;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments. Fixed an undetected-overflow bug in readline_file().
longobject.c: Fixed a really stupid bug in the new _PyLong_NumBits.
pickle.py: Fixed stupid bug in save_long(): When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4(): they *returned* the unpickled long instead of pushing
it on the stack. The return values were ignored. Tests passed
before only because save_long() pickled the long twice.
Fixed bugs in encode_long().
Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time. I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that. It would be more valuable to make long(string, 16) linear time.
pickletester.py: Added a global "protocols" vector so tests can try
all the protocols in a sane way. Changed test_ints() and test_unicode()
to do so. Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle: cPickle proto 2 for longs is linear-time).
2003-02-01 22:57:53 -04:00
|
|
|
if (self->proto >= 2) {
|
|
|
|
/* Linear-time pickling. */
|
|
|
|
size_t nbits;
|
|
|
|
size_t nbytes;
|
|
|
|
unsigned char *pdata;
|
|
|
|
char c_str[5];
|
|
|
|
int i;
|
|
|
|
int sign = _PyLong_Sign(args);
|
|
|
|
|
|
|
|
if (sign == 0) {
|
|
|
|
/* It's 0 -- an empty bytestring. */
|
|
|
|
c_str[0] = LONG1;
|
|
|
|
c_str[1] = 0;
|
|
|
|
i = self->write_func(self, c_str, 2);
|
|
|
|
if (i < 0) goto finally;
|
|
|
|
res = 0;
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
nbits = _PyLong_NumBits(args);
|
|
|
|
if (nbits == (size_t)-1 && PyErr_Occurred())
|
|
|
|
goto finally;
|
|
|
|
/* How many bytes do we need? There are nbits >> 3 full
|
|
|
|
* bytes of data, and nbits & 7 leftover bits. If there
|
|
|
|
* are any leftover bits, then we clearly need another
|
|
|
|
* byte. Wnat's not so obvious is that we *probably*
|
|
|
|
* need another byte even if there aren't any leftovers:
|
|
|
|
* the most-significant bit of the most-significant byte
|
|
|
|
* acts like a sign bit, and it's usually got a sense
|
|
|
|
* opposite of the one we need. The exception is longs
|
|
|
|
* of the form -(2**(8*j-1)) for j > 0. Such a long is
|
|
|
|
* its own 256's-complement, so has the right sign bit
|
|
|
|
* even without the extra byte. That's a pain to check
|
|
|
|
* for in advance, though, so we always grab an extra
|
|
|
|
* byte at the start, and cut it back later if possible.
|
|
|
|
*/
|
|
|
|
nbytes = (nbits >> 3) + 1;
|
|
|
|
if ((int)nbytes < 0 || (size_t)(int)nbytes != nbytes) {
|
|
|
|
PyErr_SetString(PyExc_OverflowError, "long too large "
|
|
|
|
"to pickle");
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
repr = PyString_FromStringAndSize(NULL, (int)nbytes);
|
|
|
|
if (repr == NULL) goto finally;
|
|
|
|
pdata = (unsigned char *)PyString_AS_STRING(repr);
|
|
|
|
i = _PyLong_AsByteArray((PyLongObject *)args,
|
|
|
|
pdata, nbytes,
|
|
|
|
1 /* little endian */, 1 /* signed */);
|
|
|
|
if (i < 0) goto finally;
|
|
|
|
/* If the long is negative, this may be a byte more than
|
|
|
|
* needed. This is so iff the MSB is all redundant sign
|
|
|
|
* bits.
|
|
|
|
*/
|
|
|
|
if (sign < 0 && nbytes > 1 && pdata[nbytes - 1] == 0xff &&
|
|
|
|
(pdata[nbytes - 2] & 0x80) != 0)
|
|
|
|
--nbytes;
|
|
|
|
|
|
|
|
if (nbytes < 256) {
|
|
|
|
c_str[0] = LONG1;
|
|
|
|
c_str[1] = (char)nbytes;
|
|
|
|
size = 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
c_str[0] = LONG4;
|
|
|
|
size = (int)nbytes;
|
|
|
|
for (i = 1; i < 5; i++) {
|
|
|
|
c_str[i] = (char)(size & 0xff);
|
|
|
|
size >>= 8;
|
|
|
|
}
|
|
|
|
size = 5;
|
|
|
|
}
|
|
|
|
i = self->write_func(self, c_str, size);
|
|
|
|
if (i < 0) goto finally;
|
|
|
|
i = self->write_func(self, (char *)pdata, (int)nbytes);
|
|
|
|
if (i < 0) goto finally;
|
|
|
|
res = 0;
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* proto < 2: write the repr and newline. This is quadratic-time
|
|
|
|
* (in the number of digits), in both directions.
|
|
|
|
*/
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( repr = PyObject_Repr(args)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((size = PyString_Size(repr)) < 0)
|
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, &l, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self,
|
|
|
|
PyString_AS_STRING((PyStringObject *)repr),
|
|
|
|
size) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, "\n", 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
res = 0;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
finally:
|
|
|
|
Py_XDECREF(repr);
|
|
|
|
return res;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
save_float(Picklerobject *self, PyObject *args)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
double x = PyFloat_AS_DOUBLE((PyFloatObject *)args);
|
|
|
|
|
|
|
|
if (self->bin) {
|
|
|
|
char str[9];
|
2003-03-20 16:53:32 -04:00
|
|
|
str[0] = BINFLOAT;
|
|
|
|
if (_PyFloat_Pack8(x, (unsigned char *)&str[1], 0) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, str, 9) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
char c_str[250];
|
|
|
|
c_str[0] = FLOAT;
|
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Inherits test_gzip/test_tarfile failures on 64-bit platforms from the trunk,
but I don't want the merge to hang around too long (even though the regular
p3yk-contributors are/have been busy with other things.)
Merged revisions 45621-46490 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r45621 | george.yoshida | 2006-04-21 18:34:17 +0200 (Fri, 21 Apr 2006) | 2 lines
Correct the grammar
........
r45622 | tim.peters | 2006-04-21 18:34:54 +0200 (Fri, 21 Apr 2006) | 2 lines
Whitespace normalization.
........
r45624 | thomas.heller | 2006-04-21 18:48:56 +0200 (Fri, 21 Apr 2006) | 1 line
Merge in changes from ctypes 0.9.9.6 upstream version.
........
r45625 | thomas.heller | 2006-04-21 18:51:04 +0200 (Fri, 21 Apr 2006) | 1 line
Merge in changes from ctypes 0.9.9.6 upstream version.
........
r45630 | thomas.heller | 2006-04-21 20:29:17 +0200 (Fri, 21 Apr 2006) | 8 lines
Documentation for ctypes.
I think that 'generic operating system services' is the best category.
Note that the Doc/lib/libctypes.latex file is generated from reST sources.
You are welcome to make typo fixes, and I'll try to keep the reST sources
in sync, but markup changes would be lost - they should be fixed in the tool
that creates the latex file.
The conversion script is external/ctypes/docs/manual/mkpydoc.py.
........
r45631 | tim.peters | 2006-04-21 23:18:10 +0200 (Fri, 21 Apr 2006) | 24 lines
SF bug #1473760 TempFile can hang on Windows.
Python 2.4 changed ntpath.abspath to do an import
inside the function. As a result, due to Python's
import lock, anything calling abspath on Windows
(directly, or indirectly like tempfile.TemporaryFile)
hung when it was called from a thread spawned as a
side effect of importing a module.
This is a depressingly frequent problem, and
deserves a more general fix. I'm settling for
a micro-fix here because this specific one accounts
for a report of Zope Corp's ZEO hanging on Windows,
and it was an odd way to change abspath to begin
with (ntpath needs a different implementation
depending on whether we're actually running on
Windows, and the _obvious_ way to arrange for that
is not to bury a possibly-failing import _inside_
the function).
Note that if/when other micro-fixes of this kind
get made, the new Lib/test/threaded_import_hangers.py
is a convenient place to add tests for them.
........
r45634 | phillip.eby | 2006-04-21 23:53:37 +0200 (Fri, 21 Apr 2006) | 2 lines
Guido wrote contextlib, not me, but thanks anyway. ;)
........
r45636 | andrew.kuchling | 2006-04-22 03:51:41 +0200 (Sat, 22 Apr 2006) | 1 line
Typo fixes
........
r45638 | andrew.kuchling | 2006-04-22 03:58:40 +0200 (Sat, 22 Apr 2006) | 1 line
Fix comment typo
........
r45639 | andrew.kuchling | 2006-04-22 04:06:03 +0200 (Sat, 22 Apr 2006) | 8 lines
Make copy of test_mailbox.py. We'll still want to check the backward
compatibility classes in the new mailbox.py that I'll be committing in
a few minutes.
One change has been made: the tests use len(mbox) instead of len(mbox.boxes).
The 'boxes' attribute was never documented and contains some internal state
that seems unlikely to have been useful.
........
r45640 | andrew.kuchling | 2006-04-22 04:32:43 +0200 (Sat, 22 Apr 2006) | 16 lines
Add Gregory K. Johnson's revised version of mailbox.py (funded by
the 2005 Summer of Code).
The revision adds a number of new mailbox classes that support adding
and removing messages; these classes also support mailbox locking and
default to using email.Message instead of rfc822.Message.
The old mailbox classes are largely left alone for backward compatibility.
The exception is the Maildir class, which was present in the old module
and now inherits from the new classes. The Maildir class's interface
is pretty simple, though, so I think it'll be compatible with existing
code.
(The change to the NEWS file also adds a missing word to a different
news item, which unfortunately required rewrapping the line.)
........
r45641 | tim.peters | 2006-04-22 07:52:59 +0200 (Sat, 22 Apr 2006) | 2 lines
Whitespace normalization.
........
r45642 | neal.norwitz | 2006-04-22 08:07:46 +0200 (Sat, 22 Apr 2006) | 1 line
Add libctypes as a dep
........
r45643 | martin.v.loewis | 2006-04-22 13:15:41 +0200 (Sat, 22 Apr 2006) | 1 line
Fix more ssize_t problems.
........
r45644 | martin.v.loewis | 2006-04-22 13:40:03 +0200 (Sat, 22 Apr 2006) | 1 line
Fix more ssize_t issues.
........
r45645 | george.yoshida | 2006-04-22 17:10:49 +0200 (Sat, 22 Apr 2006) | 2 lines
Typo fixes
........
r45647 | martin.v.loewis | 2006-04-22 17:19:54 +0200 (Sat, 22 Apr 2006) | 1 line
Port to Python 2.5. Drop .DEF file. Change output file names to .pyd.
........
r45648 | george.yoshida | 2006-04-22 17:27:14 +0200 (Sat, 22 Apr 2006) | 3 lines
- add versionadded tag
- make arbitrary arguments come last
........
r45649 | hyeshik.chang | 2006-04-22 17:48:15 +0200 (Sat, 22 Apr 2006) | 3 lines
Remove $CJKCodecs$ RCS tags. The CJKCodecs isn't maintained outside
anymore.
........
r45654 | greg.ward | 2006-04-23 05:47:58 +0200 (Sun, 23 Apr 2006) | 2 lines
Update optparse to Optik 1.5.1.
........
r45658 | george.yoshida | 2006-04-23 11:27:10 +0200 (Sun, 23 Apr 2006) | 2 lines
wrap SyntaxError with \exception{}
........
r45660 | ronald.oussoren | 2006-04-23 13:59:25 +0200 (Sun, 23 Apr 2006) | 6 lines
Patch 1471925 - Weak linking support for OSX
This patch causes several symbols in the socket and posix module to be weakly
linked on OSX and disables usage of ftime on OSX. These changes make it possible
to use a binary build on OSX 10.4 on a 10.3 system.
........
r45661 | ronald.oussoren | 2006-04-23 14:36:23 +0200 (Sun, 23 Apr 2006) | 5 lines
Patch 1471761 - test for broken poll at runtime
This patch checks if poll is broken when the select module is loaded instead
of doing so at configure-time. This functionality is only active on Mac OS X.
........
r45662 | nick.coghlan | 2006-04-23 17:13:32 +0200 (Sun, 23 Apr 2006) | 1 line
Add a Context Types section to parallel the Iterator Types section (uses the same terminology as the 2.5a1 implementation)
........
r45663 | nick.coghlan | 2006-04-23 17:14:37 +0200 (Sun, 23 Apr 2006) | 1 line
Update contextlib documentation to use the same terminology as the module implementation
........
r45664 | gerhard.haering | 2006-04-23 17:24:26 +0200 (Sun, 23 Apr 2006) | 2 lines
Updated the sqlite3 module to the external pysqlite 2.2.2 version.
........
r45666 | nick.coghlan | 2006-04-23 17:39:16 +0200 (Sun, 23 Apr 2006) | 1 line
Update with statement documentation to use same terminology as 2.5a1 implementation
........
r45667 | nick.coghlan | 2006-04-23 18:05:04 +0200 (Sun, 23 Apr 2006) | 1 line
Add a (very) brief mention of the with statement to the end of chapter 8
........
r45668 | nick.coghlan | 2006-04-23 18:35:19 +0200 (Sun, 23 Apr 2006) | 1 line
Take 2 on mentioning the with statement, this time without inadvertently killing the Unicode examples
........
r45669 | nick.coghlan | 2006-04-23 19:04:07 +0200 (Sun, 23 Apr 2006) | 1 line
Backdated NEWS entry to record the implementation of PEP 338 for alpha 1
........
r45670 | tim.peters | 2006-04-23 20:13:45 +0200 (Sun, 23 Apr 2006) | 2 lines
Whitespace normalization.
........
r45671 | skip.montanaro | 2006-04-23 21:14:27 +0200 (Sun, 23 Apr 2006) | 1 line
first cut at trace module doc
........
r45672 | skip.montanaro | 2006-04-23 21:26:33 +0200 (Sun, 23 Apr 2006) | 1 line
minor tweak
........
r45673 | skip.montanaro | 2006-04-23 21:30:50 +0200 (Sun, 23 Apr 2006) | 1 line
it's always helpful if the example works...
........
r45674 | skip.montanaro | 2006-04-23 21:32:14 +0200 (Sun, 23 Apr 2006) | 1 line
correct example
........
r45675 | andrew.kuchling | 2006-04-23 23:01:04 +0200 (Sun, 23 Apr 2006) | 1 line
Edits to the PEP 343 section
........
r45676 | andrew.kuchling | 2006-04-23 23:51:10 +0200 (Sun, 23 Apr 2006) | 1 line
Add two items
........
r45677 | tim.peters | 2006-04-24 04:03:16 +0200 (Mon, 24 Apr 2006) | 5 lines
Bug #1337990: clarified that `doctest` does not support examples
requiring both expected output and an exception.
I'll backport to 2.4 next.
........
r45679 | nick.coghlan | 2006-04-24 05:04:43 +0200 (Mon, 24 Apr 2006) | 1 line
Note changes made to PEP 343 related documentation
........
r45681 | nick.coghlan | 2006-04-24 06:17:02 +0200 (Mon, 24 Apr 2006) | 1 line
Change PEP 343 related documentation to use the term context specifier instead of context object
........
r45682 | nick.coghlan | 2006-04-24 06:32:47 +0200 (Mon, 24 Apr 2006) | 1 line
Add unit tests for the -m and -c command line switches
........
r45683 | nick.coghlan | 2006-04-24 06:37:15 +0200 (Mon, 24 Apr 2006) | 1 line
Fix contextlib.nested to cope with exit methods raising and handling exceptions
........
r45685 | nick.coghlan | 2006-04-24 06:59:28 +0200 (Mon, 24 Apr 2006) | 1 line
Fix broken contextlib test from last checkin (I'd've sworn I tested that before checking it in. . .)
........
r45686 | nick.coghlan | 2006-04-24 07:24:26 +0200 (Mon, 24 Apr 2006) | 1 line
Back out new command line tests (broke buildbot)
........
r45687 | nick.coghlan | 2006-04-24 07:52:15 +0200 (Mon, 24 Apr 2006) | 1 line
More reliable version of new command line tests that just checks the exit codes
........
r45688 | thomas.wouters | 2006-04-24 13:37:13 +0200 (Mon, 24 Apr 2006) | 4 lines
Stop test_tcl's testLoadTk from leaking the Tk commands 'loadtk' registers.
........
r45690 | andrew.kuchling | 2006-04-24 16:30:47 +0200 (Mon, 24 Apr 2006) | 2 lines
Edits, using the new term
'context specifier' in a few places
........
r45697 | phillip.eby | 2006-04-24 22:53:13 +0200 (Mon, 24 Apr 2006) | 2 lines
Revert addition of setuptools
........
r45698 | tim.peters | 2006-04-25 00:45:13 +0200 (Tue, 25 Apr 2006) | 2 lines
Whitespace normalization.
........
r45700 | trent.mick | 2006-04-25 02:34:50 +0200 (Tue, 25 Apr 2006) | 4 lines
Put break at correct level so *all* root HKEYs acutally get checked for
an installed VC6. Otherwise only the first such tree gets checked and this
warning doesn't get displayed.
........
r45701 | tim.peters | 2006-04-25 05:31:36 +0200 (Tue, 25 Apr 2006) | 3 lines
Patch #1475231: add a new SKIP doctest option, thanks to
Edward Loper.
........
r45702 | neal.norwitz | 2006-04-25 07:04:35 +0200 (Tue, 25 Apr 2006) | 1 line
versionadded for SKIP
........
r45703 | neal.norwitz | 2006-04-25 07:05:03 +0200 (Tue, 25 Apr 2006) | 1 line
Restore Walters name
........
r45704 | neal.norwitz | 2006-04-25 07:49:42 +0200 (Tue, 25 Apr 2006) | 1 line
Revert previous change, SKIP had a versionadded elsewhere
........
r45706 | nick.coghlan | 2006-04-25 12:56:51 +0200 (Tue, 25 Apr 2006) | 31 lines
Move the PEP 343 documentation and implementation closer to the
terminology in the alpha 1 documentation.
- "context manager" reverts to its alpha 1 definition
- the term "context specifier" goes away entirely
- contextlib.GeneratorContextManager is renamed GeneratorContext
There are still a number of changes relative to alpha 1:
- the expression in the with statement is explicitly called the
"context expression" in the language reference
- the terms 'with statement context', 'context object' or 'with
statement context' are used in several places instead of a bare
'context'. The aim of this is to avoid ambiguity in relation to the
runtime context set up when the block is executed, and the context
objects that already exist in various application domains (such as
decimal.Context)
- contextlib.contextmanager is renamed to contextfactory
This best reflects the nature of the function resulting from the
use of that decorator
- decimal.ContextManager is renamed to WithStatementContext
Simple dropping the 'Manager' part wasn't possible due to the
fact that decimal.Context already exists and means something
different. WithStatementContext is ugly but workable.
A technically unrelated change snuck into this commit:
contextlib.closing now avoids the overhead of creating a
generator, since it's trivial to implement that particular
context manager directly.
........
r45707 | nick.coghlan | 2006-04-25 13:05:56 +0200 (Tue, 25 Apr 2006) | 1 line
Fix latex typo
........
r45708 | thomas.wouters | 2006-04-25 14:28:56 +0200 (Tue, 25 Apr 2006) | 4 lines
Fix markup glitch in unittest docs. Will backport.
........
r45710 | andrew.kuchling | 2006-04-25 14:31:38 +0200 (Tue, 25 Apr 2006) | 1 line
Add two items; easy_install is now off the table, though pkgutil still is
........
r45711 | andrew.kuchling | 2006-04-25 14:47:25 +0200 (Tue, 25 Apr 2006) | 1 line
Rework context terminology
........
r45712 | thomas.wouters | 2006-04-25 15:53:23 +0200 (Tue, 25 Apr 2006) | 9 lines
SF bug/patch #1433877: string parameter to ioctl not null terminated
The new char-array used in ioctl calls wasn't explicitly NUL-terminated;
quite probably the cause for the test_pty failures on Solaris that we
circumvented earlier. (I wasn't able to reproduce it with this patch, but it
has been somewhat elusive to start with.)
........
r45713 | george.yoshida | 2006-04-25 16:09:58 +0200 (Tue, 25 Apr 2006) | 2 lines
minor tweak
........
r45714 | thomas.wouters | 2006-04-25 17:08:10 +0200 (Tue, 25 Apr 2006) | 7 lines
Fix SF bug #1476111: SystemError in socket sendto. The AF_INET6 and
AF_PACKET cases in getsockaddrarg were missing their own checks for
tuple-ness of the address argument, which means a confusing SystemError was
raised by PyArg_ParseTuple instead.
........
r45715 | thomas.wouters | 2006-04-25 17:29:46 +0200 (Tue, 25 Apr 2006) | 10 lines
Define MAXPATHLEN to be at least PATH_MAX, if that's defined. Python uses
MAXPATHLEN-sized buffers for various output-buffers (like to realpath()),
and that's correct on BSD platforms, but not Linux (which uses PATH_MAX, and
does not define MAXPATHLEN.) Cursory googling suggests Linux is following a
newer standard than BSD, but in cases like this, who knows. Using the
greater of PATH_MAX and 1024 as a fallback for MAXPATHLEN seems to be the
most portable solution.
........
r45717 | thomas.heller | 2006-04-25 20:26:08 +0200 (Tue, 25 Apr 2006) | 3 lines
Fix compiler warnings on Darwin.
Patch by Brett Canon, see
https://sourceforge.net/tracker/?func=detail&atid=532156&aid=1475959&group_id=71702
........
r45718 | guido.van.rossum | 2006-04-25 22:12:45 +0200 (Tue, 25 Apr 2006) | 4 lines
Implement MvL's improvement on __context__ in Condition;
this can just call __context__ on the underlying lock.
(The same change for Semaphore does *not* work!)
........
r45721 | tim.peters | 2006-04-26 03:15:53 +0200 (Wed, 26 Apr 2006) | 13 lines
Rev 45706 renamed stuff in contextlib.py, but didn't rename
uses of it in test_with.py. As a result, test_with has been skipped
(due to failing imports) on all buildbot boxes since. Alas, that's
not a test failure -- you have to pay attention to the
1 skip unexpected on PLATFORM:
test_with
kinds of output at the ends of test runs to notice that this got
broken.
It's likely that more renaming in test_with.py would be desirable.
........
r45722 | fred.drake | 2006-04-26 07:15:41 +0200 (Wed, 26 Apr 2006) | 1 line
markup fixes, cleanup
........
r45723 | fred.drake | 2006-04-26 07:19:39 +0200 (Wed, 26 Apr 2006) | 1 line
minor adjustment suggested by Peter Gephardt
........
r45724 | neal.norwitz | 2006-04-26 07:34:03 +0200 (Wed, 26 Apr 2006) | 10 lines
Patch from Aldo Cortesi (OpenBSD buildbot owner).
After the patch (45590) to add extra debug stats to the gc module, Python
was crashing on OpenBSD due to:
Fatal Python error: Interpreter not initialized (version mismatch?)
This seems to occur due to calling collect() when initialized (in pythonrun.c)
is set to 0. Now, the import will occur in the init function which
shouldn't suffer this problem.
........
r45725 | neal.norwitz | 2006-04-26 08:26:12 +0200 (Wed, 26 Apr 2006) | 3 lines
Fix this test on Solaris. There can be embedded \r, so don't just replace
the one at the end.
........
r45727 | nick.coghlan | 2006-04-26 13:50:04 +0200 (Wed, 26 Apr 2006) | 1 line
Fix an error in the last contextlib.closing example
........
r45728 | andrew.kuchling | 2006-04-26 14:21:06 +0200 (Wed, 26 Apr 2006) | 1 line
[Bug #1475080] Fix example
........
r45729 | andrew.kuchling | 2006-04-26 14:23:39 +0200 (Wed, 26 Apr 2006) | 1 line
Add labels to all sections
........
r45730 | thomas.wouters | 2006-04-26 17:53:30 +0200 (Wed, 26 Apr 2006) | 7 lines
The result of SF patch #1471578: big-memory tests for strings, lists and
tuples. Lots to be added, still, but this will give big-memory people
something to play with in 2.5 alpha 2, and hopefully get more people to
write these tests.
........
r45731 | tim.peters | 2006-04-26 19:11:16 +0200 (Wed, 26 Apr 2006) | 2 lines
Whitespace normalization.
........
r45732 | martin.v.loewis | 2006-04-26 19:19:44 +0200 (Wed, 26 Apr 2006) | 1 line
Use GS- and bufferoverlowU.lib where appropriate, for AMD64.
........
r45733 | thomas.wouters | 2006-04-26 20:46:01 +0200 (Wed, 26 Apr 2006) | 5 lines
Add tests for += and *= on strings, and fix the memory-use estimate for the
list.extend tests (they were estimating half the actual use.)
........
r45734 | thomas.wouters | 2006-04-26 21:14:46 +0200 (Wed, 26 Apr 2006) | 5 lines
Some more test-size-estimate fixes: test_append and test_insert trigger a
list resize, which overallocates.
........
r45735 | hyeshik.chang | 2006-04-26 21:20:26 +0200 (Wed, 26 Apr 2006) | 3 lines
Fix build on MIPS for libffi. I haven't tested this yet because I
don't have an access on MIPS machines. Will be tested by buildbot. :)
........
r45737 | fred.drake | 2006-04-27 01:40:32 +0200 (Thu, 27 Apr 2006) | 1 line
one more place to use the current Python version
........
r45738 | fred.drake | 2006-04-27 02:02:24 +0200 (Thu, 27 Apr 2006) | 3 lines
- update version numbers in file names again, until we have a better way
- elaborate instructions for Cygwin support (closes SF #839709)
........
r45739 | fred.drake | 2006-04-27 02:20:14 +0200 (Thu, 27 Apr 2006) | 1 line
add missing word
........
r45740 | anthony.baxter | 2006-04-27 04:11:24 +0200 (Thu, 27 Apr 2006) | 2 lines
2.5a2
........
r45741 | anthony.baxter | 2006-04-27 04:13:13 +0200 (Thu, 27 Apr 2006) | 1 line
2.5a2
........
r45749 | andrew.kuchling | 2006-04-27 14:22:37 +0200 (Thu, 27 Apr 2006) | 1 line
Now that 2.5a2 is out, revert to the current date
........
r45750 | andrew.kuchling | 2006-04-27 14:23:07 +0200 (Thu, 27 Apr 2006) | 1 line
Bump document version
........
r45751 | andrew.kuchling | 2006-04-27 14:34:39 +0200 (Thu, 27 Apr 2006) | 6 lines
[Bug #1477102] Add necessary import to example
This may be a useful style question for the docs -- should examples show
the necessary imports, or should it be assumed that the reader will
figure it out? In the What's New, I'm not consistent but usually opt
for omitting the imports.
........
r45753 | andrew.kuchling | 2006-04-27 14:38:35 +0200 (Thu, 27 Apr 2006) | 1 line
[Bug #1477140] Import Error base class
........
r45754 | andrew.kuchling | 2006-04-27 14:42:54 +0200 (Thu, 27 Apr 2006) | 1 line
Mention the xmlrpclib.Error base class, which is used in one of the examples
........
r45756 | george.yoshida | 2006-04-27 15:41:07 +0200 (Thu, 27 Apr 2006) | 2 lines
markup fix
........
r45757 | thomas.wouters | 2006-04-27 15:46:59 +0200 (Thu, 27 Apr 2006) | 4 lines
Some more size-estimate fixes, for large-list-tests.
........
r45758 | thomas.heller | 2006-04-27 17:50:42 +0200 (Thu, 27 Apr 2006) | 3 lines
Rerun the libffi configuration if any of the files used for that
are newer then fficonfig.py.
........
r45766 | thomas.wouters | 2006-04-28 00:37:50 +0200 (Fri, 28 Apr 2006) | 6 lines
Some style fixes and size-calculation fixes. Also do the small-memory run
using a prime number, rather than a convenient power-of-2-and-multiple-of-5,
so incorrect testing algorithms fail more easily.
........
r45767 | thomas.wouters | 2006-04-28 00:38:32 +0200 (Fri, 28 Apr 2006) | 6 lines
Do the small-memory run of big-meormy tests using a prime number, rather
than a convenient power-of-2-and-multiple-of-5, so incorrect testing
algorithms fail more easily.
........
r45768 | david.goodger | 2006-04-28 00:53:05 +0200 (Fri, 28 Apr 2006) | 1 line
Added SVN access for Steven Bethard and Talin, for PEP updating.
........
r45770 | thomas.wouters | 2006-04-28 01:13:20 +0200 (Fri, 28 Apr 2006) | 16 lines
- Add new Warning class, ImportWarning
- Warn-raise ImportWarning when importing would have picked up a directory
as package, if only it'd had an __init__.py. This swaps two tests (for
case-ness and __init__-ness), but case-test is not really more expensive,
and it's not in a speed-critical section.
- Test for the new warning by importing a common non-package directory on
sys.path: site-packages
- In regrtest.py, silence warnings generated by the build-environment
because Modules/ (which is added to sys.path for Setup-created modules)
has 'zlib' and '_ctypes' directories without __init__.py's.
........
r45771 | thomas.wouters | 2006-04-28 01:41:27 +0200 (Fri, 28 Apr 2006) | 6 lines
Add more ignores of ImportWarnings; these are all just potential triggers
(since they won't trigger if zlib is already sucessfully imported); they
were found by grepping .py files, instead of looking at warning output :)
........
r45773 | neal.norwitz | 2006-04-28 06:32:20 +0200 (Fri, 28 Apr 2006) | 1 line
Add some whitespace to be more consistent.
........
r45774 | neal.norwitz | 2006-04-28 06:34:43 +0200 (Fri, 28 Apr 2006) | 5 lines
Try to really fix the slow buildbots this time.
Printing to stdout, doesn't mean the data was actually written.
It depends on the buffering, so we need to flush. This will hopefully
really fix the buildbots getting killed due to no output on the slow bots.
........
r45775 | neal.norwitz | 2006-04-28 07:28:05 +0200 (Fri, 28 Apr 2006) | 1 line
Fix some warnings on Mac OS X 10.4
........
r45776 | neal.norwitz | 2006-04-28 07:28:30 +0200 (Fri, 28 Apr 2006) | 1 line
Fix a warning on alpha
........
r45777 | neal.norwitz | 2006-04-28 07:28:54 +0200 (Fri, 28 Apr 2006) | 1 line
Fix a warning on ppc (debian)
........
r45778 | george.yoshida | 2006-04-28 18:09:45 +0200 (Fri, 28 Apr 2006) | 2 lines
fix markup glitch
........
r45780 | georg.brandl | 2006-04-28 18:31:17 +0200 (Fri, 28 Apr 2006) | 3 lines
Add SeaMonkey to the list of Mozilla browsers.
........
r45781 | georg.brandl | 2006-04-28 18:36:55 +0200 (Fri, 28 Apr 2006) | 2 lines
Bug #1475009: clarify ntpath.join behavior with absolute components
........
r45783 | george.yoshida | 2006-04-28 18:40:14 +0200 (Fri, 28 Apr 2006) | 2 lines
correct a dead link
........
r45785 | georg.brandl | 2006-04-28 18:54:25 +0200 (Fri, 28 Apr 2006) | 4 lines
Bug #1472949: stringify IOErrors in shutil.copytree when appending
them to the Error errors list.
........
r45786 | georg.brandl | 2006-04-28 18:58:52 +0200 (Fri, 28 Apr 2006) | 3 lines
Bug #1478326: don't allow '/' in distutils.util.get_platform machine names
since this value is used to name the build directory.
........
r45788 | thomas.heller | 2006-04-28 19:02:18 +0200 (Fri, 28 Apr 2006) | 1 line
Remove a duplicated test (the same test is in test_incomplete.py).
........
r45792 | georg.brandl | 2006-04-28 21:09:24 +0200 (Fri, 28 Apr 2006) | 3 lines
Bug #1478429: make datetime.datetime.fromtimestamp accept every float,
possibly "rounding up" to the next whole second.
........
r45796 | george.yoshida | 2006-04-29 04:43:30 +0200 (Sat, 29 Apr 2006) | 2 lines
grammar fix
........
r45800 | ronald.oussoren | 2006-04-29 13:31:35 +0200 (Sat, 29 Apr 2006) | 2 lines
Patch 1471883: --enable-universalsdk on Mac OS X
........
r45801 | andrew.kuchling | 2006-04-29 13:53:15 +0200 (Sat, 29 Apr 2006) | 1 line
Add item
........
r45802 | andrew.kuchling | 2006-04-29 14:10:28 +0200 (Sat, 29 Apr 2006) | 1 line
Make case of 'ZIP' consistent
........
r45803 | andrew.kuchling | 2006-04-29 14:10:43 +0200 (Sat, 29 Apr 2006) | 1 line
Add item
........
r45808 | martin.v.loewis | 2006-04-29 14:37:25 +0200 (Sat, 29 Apr 2006) | 3 lines
Further changes for #1471883: Edit Misc/NEWS, and
add expat_config.h.
........
r45809 | brett.cannon | 2006-04-29 23:29:50 +0200 (Sat, 29 Apr 2006) | 2 lines
Fix docstring for contextfactory; mentioned old contextmanager name.
........
r45810 | gerhard.haering | 2006-04-30 01:12:41 +0200 (Sun, 30 Apr 2006) | 3 lines
This is the start of documentation for the sqlite3 module. Please feel free to
find a better place for the link to it than alongside bsddb & friends.
........
r45811 | andrew.kuchling | 2006-04-30 03:07:09 +0200 (Sun, 30 Apr 2006) | 1 line
Add two items
........
r45814 | george.yoshida | 2006-04-30 05:49:56 +0200 (Sun, 30 Apr 2006) | 2 lines
Use \versionchanged instead of \versionadded for new parameter support.
........
r45815 | georg.brandl | 2006-04-30 09:06:11 +0200 (Sun, 30 Apr 2006) | 2 lines
Patch #1470846: fix urllib2 ProxyBasicAuthHandler.
........
r45817 | georg.brandl | 2006-04-30 10:57:35 +0200 (Sun, 30 Apr 2006) | 3 lines
In stdlib, use hashlib instead of deprecated md5 and sha modules.
........
r45819 | georg.brandl | 2006-04-30 11:23:59 +0200 (Sun, 30 Apr 2006) | 3 lines
Patch #1470976: don't NLST files when retrieving over FTP.
........
r45821 | georg.brandl | 2006-04-30 13:13:56 +0200 (Sun, 30 Apr 2006) | 6 lines
Bug #1473625: stop cPickle making float dumps locale dependent in protocol 0.
On the way, add a decorator to test_support to facilitate running single
test functions in different locales with automatic cleanup.
........
r45822 | phillip.eby | 2006-04-30 17:59:26 +0200 (Sun, 30 Apr 2006) | 2 lines
Fix infinite regress when inspecting <string> or <stdin> frames.
........
r45824 | georg.brandl | 2006-04-30 19:42:26 +0200 (Sun, 30 Apr 2006) | 3 lines
Fix another problem in inspect: if the module for an object cannot be found, don't try to give its __dict__ to linecache.
........
r45825 | georg.brandl | 2006-04-30 20:14:54 +0200 (Sun, 30 Apr 2006) | 3 lines
Patch #1472854: make the rlcompleter.Completer class usable on non-
UNIX platforms.
........
r45826 | georg.brandl | 2006-04-30 21:34:19 +0200 (Sun, 30 Apr 2006) | 3 lines
Patch #1479438: add \keyword markup for "with".
........
r45827 | andrew.kuchling | 2006-04-30 23:19:31 +0200 (Sun, 30 Apr 2006) | 1 line
Add urllib2 HOWTO from Michael Foord
........
r45828 | andrew.kuchling | 2006-04-30 23:19:49 +0200 (Sun, 30 Apr 2006) | 1 line
Add item
........
r45830 | barry.warsaw | 2006-05-01 05:03:02 +0200 (Mon, 01 May 2006) | 11 lines
Port forward from 2.4 branch:
Patch #1464708 from William McVey: fixed handling of nested comments in mail
addresses. E.g.
"Foo ((Foo Bar)) <foo@example.com>"
Fixes for both rfc822.py and email package. This patch needs to be back
ported to Python 2.3 for email 2.5.
........
r45832 | fred.drake | 2006-05-01 08:25:58 +0200 (Mon, 01 May 2006) | 4 lines
- minor clarification in section title
- markup adjustments
(there is clearly much to be done in this section)
........
r45833 | martin.v.loewis | 2006-05-01 08:28:01 +0200 (Mon, 01 May 2006) | 2 lines
Work around deadlock risk. Will backport.
........
r45836 | andrew.kuchling | 2006-05-01 14:45:02 +0200 (Mon, 01 May 2006) | 1 line
Some ElementTree fixes: import from xml, not xmlcore; fix case of module name; mention list() instead of getchildren()
........
r45837 | gerhard.haering | 2006-05-01 17:14:48 +0200 (Mon, 01 May 2006) | 3 lines
Further integration of the documentation for the sqlite3 module. There's still
quite some content to move over from the pysqlite manual, but it's a start now.
........
r45838 | martin.v.loewis | 2006-05-01 17:56:03 +0200 (Mon, 01 May 2006) | 2 lines
Rename uisample to text, drop all non-text tables.
........
r45839 | martin.v.loewis | 2006-05-01 18:12:44 +0200 (Mon, 01 May 2006) | 2 lines
Add msilib documentation.
........
r45840 | martin.v.loewis | 2006-05-01 18:14:16 +0200 (Mon, 01 May 2006) | 4 lines
Rename parameters to match the documentation (which
in turn matches Microsoft's documentation).
Drop unused parameter in CAB.append.
........
r45841 | fred.drake | 2006-05-01 18:28:54 +0200 (Mon, 01 May 2006) | 1 line
add dependency
........
r45842 | andrew.kuchling | 2006-05-01 18:30:25 +0200 (Mon, 01 May 2006) | 1 line
Markup fixes; add some XXX comments noting problems
........
r45843 | andrew.kuchling | 2006-05-01 18:32:49 +0200 (Mon, 01 May 2006) | 1 line
Add item
........
r45844 | andrew.kuchling | 2006-05-01 19:06:54 +0200 (Mon, 01 May 2006) | 1 line
Markup fixes
........
r45850 | neal.norwitz | 2006-05-02 06:43:14 +0200 (Tue, 02 May 2006) | 3 lines
SF #1479181: split open() and file() from being aliases for each other.
........
r45852 | neal.norwitz | 2006-05-02 08:23:22 +0200 (Tue, 02 May 2006) | 1 line
Try to fix breakage caused by patch #1479181, r45850
........
r45853 | fred.drake | 2006-05-02 08:53:59 +0200 (Tue, 02 May 2006) | 3 lines
SF #1479988: add methods to allow access to weakrefs for the
weakref.WeakKeyDictionary and weakref.WeakValueDictionary
........
r45854 | neal.norwitz | 2006-05-02 09:27:47 +0200 (Tue, 02 May 2006) | 5 lines
Fix breakage from patch 1471883 (r45800 & r45808) on OSF/1.
The problem was that pyconfig.h was being included before some system headers
which caused redefinitions and other breakage. This moves system headers
after expat_config.h which includes pyconfig.h.
........
r45855 | vinay.sajip | 2006-05-02 10:35:36 +0200 (Tue, 02 May 2006) | 1 line
Replaced my dumb way of calculating seconds to midnight with Tim Peters' much more sensible suggestion. What was I thinking ?!?
........
r45856 | andrew.kuchling | 2006-05-02 13:30:03 +0200 (Tue, 02 May 2006) | 1 line
Provide encoding as keyword argument; soften warning paragraph about encodings
........
r45858 | guido.van.rossum | 2006-05-02 19:36:09 +0200 (Tue, 02 May 2006) | 2 lines
Fix the formatting of KeyboardInterrupt -- a bad issubclass() call.
........
r45862 | guido.van.rossum | 2006-05-02 21:47:52 +0200 (Tue, 02 May 2006) | 7 lines
Get rid of __context__, per the latest changes to PEP 343 and python-dev
discussion.
There are two places of documentation that still mention __context__:
Doc/lib/libstdtypes.tex -- I wasn't quite sure how to rewrite that without
spending a whole lot of time thinking about it; and whatsnew, which Andrew
usually likes to change himself.
........
r45863 | armin.rigo | 2006-05-02 21:52:32 +0200 (Tue, 02 May 2006) | 4 lines
Documentation bug: PySet_Pop() returns a new reference (because the
caller becomes the owner of that reference).
........
r45864 | guido.van.rossum | 2006-05-02 22:47:36 +0200 (Tue, 02 May 2006) | 4 lines
Hopefully this will fix the spurious failures of test_mailbox.py that I'm
experiencing. (This code and mailbox.py itself are full of calls to file()
that should be calls to open() -- but I'm not fixing those.)
........
r45865 | andrew.kuchling | 2006-05-02 23:44:33 +0200 (Tue, 02 May 2006) | 1 line
Use open() instead of file()
........
r45866 | andrew.kuchling | 2006-05-03 00:47:49 +0200 (Wed, 03 May 2006) | 1 line
Update context manager section for removal of __context__
........
r45867 | fred.drake | 2006-05-03 03:46:52 +0200 (Wed, 03 May 2006) | 1 line
remove unnecessary assignment
........
r45868 | fred.drake | 2006-05-03 03:48:24 +0200 (Wed, 03 May 2006) | 4 lines
tell LaTeX2HTML to:
- use UTF-8 output
- not mess with the >>> prompt!
........
r45869 | fred.drake | 2006-05-03 04:04:40 +0200 (Wed, 03 May 2006) | 3 lines
avoid ugly markup based on the unfortunate conversions of ">>" and "<<" to
guillemets; no need for magic here
........
r45870 | fred.drake | 2006-05-03 04:12:47 +0200 (Wed, 03 May 2006) | 1 line
at least comment on why curly-quotes are not enabled
........
r45871 | fred.drake | 2006-05-03 04:27:40 +0200 (Wed, 03 May 2006) | 1 line
one more place to avoid extra markup
........
r45872 | fred.drake | 2006-05-03 04:29:09 +0200 (Wed, 03 May 2006) | 1 line
one more place to avoid extra markup (how many will there be?)
........
r45873 | fred.drake | 2006-05-03 04:29:39 +0200 (Wed, 03 May 2006) | 1 line
fix up whitespace in prompt strings
........
r45876 | tim.peters | 2006-05-03 06:46:14 +0200 (Wed, 03 May 2006) | 2 lines
Whitespace normalization.
........
r45877 | martin.v.loewis | 2006-05-03 06:52:04 +0200 (Wed, 03 May 2006) | 2 lines
Correct some formulations, fix XXX comments.
........
r45879 | georg.brandl | 2006-05-03 07:05:02 +0200 (Wed, 03 May 2006) | 2 lines
Patch #1480067: don't redirect HTTP digest auth in urllib2
........
r45881 | georg.brandl | 2006-05-03 07:15:10 +0200 (Wed, 03 May 2006) | 3 lines
Move network tests from test_urllib2 to test_urllib2net.
........
r45887 | nick.coghlan | 2006-05-03 15:02:47 +0200 (Wed, 03 May 2006) | 1 line
Finish bringing SVN into line with latest version of PEP 343 by getting rid of all remaining references to context objects that I could find. Without a __context__() method context objects no longer exist. Also get test_with working again, and adopt a suggestion from Neal for decimal.Context.get_manager()
........
r45888 | nick.coghlan | 2006-05-03 15:17:49 +0200 (Wed, 03 May 2006) | 1 line
Get rid of a couple more context object references, fix some markup and clarify what happens when a generator context function swallows an exception.
........
r45889 | georg.brandl | 2006-05-03 19:46:13 +0200 (Wed, 03 May 2006) | 3 lines
Add seamonkey to list of Windows browsers too.
........
r45890 | georg.brandl | 2006-05-03 20:03:22 +0200 (Wed, 03 May 2006) | 3 lines
RFE #1472176: In httplib, don't encode the netloc and hostname with "idna" if not necessary.
........
r45891 | georg.brandl | 2006-05-03 20:12:33 +0200 (Wed, 03 May 2006) | 2 lines
Bug #1472191: convert breakpoint indices to ints before comparing them to ints
........
r45893 | georg.brandl | 2006-05-03 20:18:32 +0200 (Wed, 03 May 2006) | 3 lines
Bug #1385040: don't allow "def foo(a=1, b): pass" in the compiler package.
........
r45894 | thomas.heller | 2006-05-03 20:35:39 +0200 (Wed, 03 May 2006) | 1 line
Don't fail the tests when libglut.so or libgle.so cannot be loaded.
........
r45895 | georg.brandl | 2006-05-04 07:08:10 +0200 (Thu, 04 May 2006) | 2 lines
Bug #1481530: allow "from os.path import ..." with imputil
........
r45897 | martin.v.loewis | 2006-05-04 07:51:03 +0200 (Thu, 04 May 2006) | 2 lines
Patch #1475845: Raise IndentationError for unexpected indent.
........
r45898 | martin.v.loewis | 2006-05-04 12:08:42 +0200 (Thu, 04 May 2006) | 1 line
Implement os.{chdir,rename,rmdir,remove} using Win32 directly.
........
r45899 | martin.v.loewis | 2006-05-04 14:04:27 +0200 (Thu, 04 May 2006) | 2 lines
Drop now-unnecessary arguments to posix_2str.
........
r45900 | martin.v.loewis | 2006-05-04 16:27:52 +0200 (Thu, 04 May 2006) | 1 line
Update checks to consider Windows error numbers.
........
r45913 | thomas.heller | 2006-05-05 20:42:14 +0200 (Fri, 05 May 2006) | 2 lines
Export the 'free' standard C function for use in the test suite.
........
r45914 | thomas.heller | 2006-05-05 20:43:24 +0200 (Fri, 05 May 2006) | 3 lines
Fix memory leaks in the ctypes test suite, reported by valgrind, by
free()ing the memory we allocate.
........
r45915 | thomas.heller | 2006-05-05 20:46:27 +0200 (Fri, 05 May 2006) | 1 line
oops - the function is exported as 'my_free', not 'free'.
........
r45916 | thomas.heller | 2006-05-05 21:14:24 +0200 (Fri, 05 May 2006) | 2 lines
Clean up.
........
r45920 | george.yoshida | 2006-05-06 15:09:45 +0200 (Sat, 06 May 2006) | 2 lines
describe optional arguments for DocFileSuite
........
r45924 | george.yoshida | 2006-05-06 16:16:51 +0200 (Sat, 06 May 2006) | 2 lines
Use \versionchanged for the feature change
........
r45925 | martin.v.loewis | 2006-05-06 18:32:54 +0200 (Sat, 06 May 2006) | 1 line
Port access, chmod, parts of getcwdu, mkdir, and utime to direct Win32 API.
........
r45926 | martin.v.loewis | 2006-05-06 22:04:08 +0200 (Sat, 06 May 2006) | 2 lines
Handle ERROR_ALREADY_EXISTS.
........
r45931 | andrew.kuchling | 2006-05-07 19:12:12 +0200 (Sun, 07 May 2006) | 1 line
[Patch #1479977] Revised version of urllib2 HOWTO, edited by John J. Lee
........
r45932 | andrew.kuchling | 2006-05-07 19:14:53 +0200 (Sun, 07 May 2006) | 1 line
Minor language edit
........
r45934 | georg.brandl | 2006-05-07 22:44:34 +0200 (Sun, 07 May 2006) | 3 lines
Patch #1483395: add new TLDs to cookielib
........
r45936 | martin.v.loewis | 2006-05-08 07:25:56 +0200 (Mon, 08 May 2006) | 2 lines
Add missing PyMem_Free.
........
r45938 | georg.brandl | 2006-05-08 19:28:47 +0200 (Mon, 08 May 2006) | 3 lines
Add test for rev. 45934.
........
r45939 | georg.brandl | 2006-05-08 19:36:08 +0200 (Mon, 08 May 2006) | 3 lines
Patch #1479302: Make urllib2 digest auth and basic auth play together.
........
r45940 | georg.brandl | 2006-05-08 19:48:01 +0200 (Mon, 08 May 2006) | 3 lines
Patch #1478993: take advantage of BaseException/Exception split in cookielib
........
r45941 | neal.norwitz | 2006-05-09 07:38:56 +0200 (Tue, 09 May 2006) | 5 lines
Micro optimization. In the first case, we know that frame->f_exc_type
is NULL, so there's no reason to do anything with it. In the second case,
we know frame->f_exc_type is not NULL, so we can just do an INCREF.
........
r45943 | thomas.heller | 2006-05-09 22:20:15 +0200 (Tue, 09 May 2006) | 2 lines
Disable a test that is unreliable.
........
r45944 | tim.peters | 2006-05-10 04:43:01 +0200 (Wed, 10 May 2006) | 4 lines
Variant of patch #1478292. doctest.register_optionflag(name)
shouldn't create a new flag when `name` is already the name of
an option flag.
........
r45947 | neal.norwitz | 2006-05-10 08:57:58 +0200 (Wed, 10 May 2006) | 14 lines
Fix problems found by Coverity.
longobject.c: also fix an ssize_t problem
<a> could have been NULL, so hoist the size calc to not use <a>.
_ssl.c: under fail: self is DECREF'd, but it would have been NULL.
_elementtree.c: delete self if there was an error.
_csv.c: I'm not sure if lineterminator could have been anything other than
a string. However, other string method calls are checked, so check this
one too.
........
r45948 | thomas.wouters | 2006-05-10 17:04:11 +0200 (Wed, 10 May 2006) | 4 lines
Ignore reflog.txt, too.
........
r45949 | georg.brandl | 2006-05-10 17:59:06 +0200 (Wed, 10 May 2006) | 3 lines
Bug #1482988: indicate more prominently that the Stats class is in the pstats module.
........
r45950 | georg.brandl | 2006-05-10 18:09:03 +0200 (Wed, 10 May 2006) | 2 lines
Bug #1485447: subprocess: document that the "cwd" parameter isn't used to find the executable. Misc. other markup fixes.
........
r45952 | georg.brandl | 2006-05-10 18:11:44 +0200 (Wed, 10 May 2006) | 2 lines
Bug #1484978: curses.panel: clarify that Panel objects are destroyed on garbage collection.
........
r45954 | georg.brandl | 2006-05-10 18:26:03 +0200 (Wed, 10 May 2006) | 4 lines
Patch #1484695: Update the tarfile module to version 0.8. This fixes
a couple of issues, notably handling of long file names using the
GNU LONGNAME extension.
........
r45955 | georg.brandl | 2006-05-10 19:13:20 +0200 (Wed, 10 May 2006) | 4 lines
Patch #721464: pdb.Pdb instances can now be given explicit stdin and
stdout arguments, making it possible to redirect input and output
for remote debugging.
........
r45956 | andrew.kuchling | 2006-05-10 19:19:04 +0200 (Wed, 10 May 2006) | 1 line
Clarify description of exception handling
........
r45957 | georg.brandl | 2006-05-10 22:09:23 +0200 (Wed, 10 May 2006) | 2 lines
Fix two small errors in argument lists.
........
r45960 | brett.cannon | 2006-05-11 07:11:33 +0200 (Thu, 11 May 2006) | 5 lines
Detect if %zd is supported by printf() during configure and sets
PY_FORMAT_SIZE_T appropriately. Removes warnings on
OS X under gcc 4.0.1 when PY_FORMAT_SIZE_T is set to "" instead of "z" as is
needed.
........
r45963 | neal.norwitz | 2006-05-11 09:51:59 +0200 (Thu, 11 May 2006) | 1 line
Don't mask a no memory error with a less meaningful one as discussed on python-checkins
........
r45964 | martin.v.loewis | 2006-05-11 15:28:43 +0200 (Thu, 11 May 2006) | 3 lines
Change WindowsError to carry the Win32 error code in winerror,
and the DOS error code in errno. Revert changes where
WindowsError catch blocks unnecessarily special-case OSError.
........
r45965 | george.yoshida | 2006-05-11 17:53:27 +0200 (Thu, 11 May 2006) | 2 lines
Grammar fix
........
r45967 | andrew.kuchling | 2006-05-11 18:32:24 +0200 (Thu, 11 May 2006) | 1 line
typo fix
........
r45968 | tim.peters | 2006-05-11 18:37:42 +0200 (Thu, 11 May 2006) | 5 lines
BaseThreadedTestCase.setup(): stop special-casing WindowsError.
Rev 45964 fiddled with WindowsError, and broke test_bsddb3 on all
the Windows buildbot slaves as a result. This should repair it.
........
r45969 | georg.brandl | 2006-05-11 21:57:09 +0200 (Thu, 11 May 2006) | 2 lines
Typo fix.
........
r45970 | tim.peters | 2006-05-12 03:57:59 +0200 (Fri, 12 May 2006) | 5 lines
SF patch #1473132: Improve docs for tp_clear and tp_traverse,
by Collin Winter.
Bugfix candidate (but I'm not going to bother).
........
r45974 | martin.v.loewis | 2006-05-12 14:27:28 +0200 (Fri, 12 May 2006) | 4 lines
Dynamically allocate path name buffer for Unicode
path name in listdir. Fixes #1431582.
Stop overallocating MAX_PATH characters for ANSI
path names. Stop assigning to errno.
........
r45975 | martin.v.loewis | 2006-05-12 15:57:36 +0200 (Fri, 12 May 2006) | 1 line
Move icon files into DLLs dir. Fixes #1477968.
........
r45976 | george.yoshida | 2006-05-12 18:40:11 +0200 (Fri, 12 May 2006) | 2 lines
At first there were 6 steps, but one was removed after that.
........
r45977 | martin.v.loewis | 2006-05-12 19:22:04 +0200 (Fri, 12 May 2006) | 1 line
Fix alignment error on Itanium.
........
r45978 | george.yoshida | 2006-05-12 19:25:26 +0200 (Fri, 12 May 2006) | 3 lines
Duplicated description about the illegal continue usage can be found in nearly the same place.
They are same, so keep the original one and remove the later-added one.
........
r45980 | thomas.heller | 2006-05-12 20:16:03 +0200 (Fri, 12 May 2006) | 2 lines
Add missing svn properties.
........
r45981 | thomas.heller | 2006-05-12 20:47:35 +0200 (Fri, 12 May 2006) | 1 line
set svn properties
........
r45982 | thomas.heller | 2006-05-12 21:31:46 +0200 (Fri, 12 May 2006) | 1 line
add svn:eol-style native svn:keywords Id
........
r45987 | gerhard.haering | 2006-05-13 01:49:49 +0200 (Sat, 13 May 2006) | 3 lines
Integrated the rest of the pysqlite reference manual into the Python
documentation. Ready to be reviewed and improved upon.
........
r45988 | george.yoshida | 2006-05-13 08:53:31 +0200 (Sat, 13 May 2006) | 2 lines
Add \exception markup
........
r45990 | martin.v.loewis | 2006-05-13 15:34:04 +0200 (Sat, 13 May 2006) | 2 lines
Revert 43315: Printing of %zd must be signed.
........
r45992 | tim.peters | 2006-05-14 01:28:20 +0200 (Sun, 14 May 2006) | 11 lines
Teach PyString_FromFormat, PyErr_Format, and PyString_FromFormatV
about "%u", "%lu" and "%zu" formats.
Since PyString_FromFormat and PyErr_Format have exactly the same rules
(both inherited from PyString_FromFormatV), it would be good if someone
with more LaTeX Fu changed one of them to just point to the other.
Their docs were way out of synch before this patch, and I just did a
mass copy+paste to repair that.
Not a backport candidate (this is a new feature).
........
r45993 | tim.peters | 2006-05-14 01:31:05 +0200 (Sun, 14 May 2006) | 2 lines
Typo repair.
........
r45994 | tim.peters | 2006-05-14 01:33:19 +0200 (Sun, 14 May 2006) | 2 lines
Remove lie in new comment.
........
r45995 | ronald.oussoren | 2006-05-14 21:56:34 +0200 (Sun, 14 May 2006) | 11 lines
Rework the build system for osx applications:
* Don't use xcodebuild for building PythonLauncher, but use a normal unix
makefile. This makes it a lot easier to use the same build flags as for the
rest of python (e.g. make a universal version of python launcher)
* Convert the mac makefile-s to makefile.in-s and use configure to set makefile
variables instead of forwarding them as command-line arguments
* Add a C version of pythonw, that we you can use '#!/usr/local/bin/pythonw'
* Build IDLE.app using bundlebuilder instead of BuildApplet, that will allow
easier modification of the bundle contents later on.
........
r45996 | ronald.oussoren | 2006-05-14 22:35:41 +0200 (Sun, 14 May 2006) | 6 lines
A first cut at replacing the icons on MacOS X. This replaces all icons by icons
based on the new python.org logo. These are also the first icons that are
"proper" OSX icons.
These icons were created by Jacob Rus.
........
r45997 | ronald.oussoren | 2006-05-14 23:07:41 +0200 (Sun, 14 May 2006) | 3 lines
I missed one small detail in my rewrite of the osx build files: the path
to the Python.app template.
........
r45998 | martin.v.loewis | 2006-05-15 07:51:36 +0200 (Mon, 15 May 2006) | 2 lines
Fix memory leak.
........
r45999 | neal.norwitz | 2006-05-15 08:48:14 +0200 (Mon, 15 May 2006) | 1 line
Move items implemented after a2 into the new a3 section
........
r46000 | neal.norwitz | 2006-05-15 09:04:36 +0200 (Mon, 15 May 2006) | 5 lines
- Bug #1487966: Fix SystemError with conditional expression in assignment
Most of the test_syntax changes are just updating the numbers.
........
r46001 | neal.norwitz | 2006-05-15 09:17:23 +0200 (Mon, 15 May 2006) | 1 line
Patch #1488312, Fix memory alignment problem on SPARC in unicode. Will backport
........
r46003 | martin.v.loewis | 2006-05-15 11:22:27 +0200 (Mon, 15 May 2006) | 3 lines
Remove bogus DECREF of self.
Change __str__() functions to METH_O.
Change WindowsError__str__ to use PyTuple_Pack.
........
r46005 | georg.brandl | 2006-05-15 21:30:35 +0200 (Mon, 15 May 2006) | 3 lines
[ 1488881 ] tarfile.py: support for file-objects and bz2 (cp. #1488634)
........
r46007 | tim.peters | 2006-05-15 22:44:10 +0200 (Mon, 15 May 2006) | 9 lines
ReadDetectFileobjTest: repair Windows disasters by opening
the file object in binary mode.
The Windows buildbot slaves shouldn't swap themselves to death
anymore. However, test_tarfile may still fail because of a
temp directory left behind from a previous failing run.
Windows buildbot owners may need to remove that directory
by hand.
........
r46009 | tim.peters | 2006-05-15 23:32:25 +0200 (Mon, 15 May 2006) | 3 lines
test_directory(): Remove the leftover temp directory that's making
the Windows buildbots fail test_tarfile.
........
r46010 | martin.v.loewis | 2006-05-16 09:05:37 +0200 (Tue, 16 May 2006) | 4 lines
- Test for sys/statvfs.h before including it, as statvfs is present
on some OSX installation, but its header file is not.
Will backport to 2.4
........
r46012 | georg.brandl | 2006-05-16 09:38:27 +0200 (Tue, 16 May 2006) | 3 lines
Patch #1435422: zlib's compress and decompress objects now have a
copy() method.
........
r46015 | andrew.kuchling | 2006-05-16 18:11:54 +0200 (Tue, 16 May 2006) | 1 line
Add item
........
r46016 | andrew.kuchling | 2006-05-16 18:27:31 +0200 (Tue, 16 May 2006) | 3 lines
PEP 243 has been withdrawn, so don't refer to it any more.
The PyPI upload material has been moved into the section on PEP314.
........
r46017 | george.yoshida | 2006-05-16 19:42:16 +0200 (Tue, 16 May 2006) | 2 lines
Update for 'ImportWarning'
........
r46018 | george.yoshida | 2006-05-16 20:07:00 +0200 (Tue, 16 May 2006) | 4 lines
Mention that Exception is now a subclass of BaseException.
Remove a sentence that says that BaseException inherits from BaseException.
(I guess this is just a copy & paste mistake.)
........
r46019 | george.yoshida | 2006-05-16 20:26:10 +0200 (Tue, 16 May 2006) | 2 lines
Document ImportWarning
........
r46020 | tim.peters | 2006-05-17 01:22:20 +0200 (Wed, 17 May 2006) | 2 lines
Whitespace normalization.
........
r46021 | tim.peters | 2006-05-17 01:24:08 +0200 (Wed, 17 May 2006) | 2 lines
Text files missing the SVN eol-style property.
........
r46022 | tim.peters | 2006-05-17 03:30:11 +0200 (Wed, 17 May 2006) | 2 lines
PyZlib_copy(), PyZlib_uncopy(): Repair leaks on the normal-case path.
........
r46023 | georg.brandl | 2006-05-17 16:06:07 +0200 (Wed, 17 May 2006) | 3 lines
Remove misleading comment about type-class unification.
........
r46024 | georg.brandl | 2006-05-17 16:11:36 +0200 (Wed, 17 May 2006) | 3 lines
Apply patch #1489784 from Michael Foord.
........
r46025 | georg.brandl | 2006-05-17 16:18:20 +0200 (Wed, 17 May 2006) | 3 lines
Fix typo in os.utime docstring (patch #1490189)
........
r46026 | georg.brandl | 2006-05-17 16:26:50 +0200 (Wed, 17 May 2006) | 3 lines
Patch #1490224: set time.altzone correctly on Cygwin.
........
r46027 | georg.brandl | 2006-05-17 16:45:06 +0200 (Wed, 17 May 2006) | 4 lines
Add global debug flag to cookielib to avoid heavy dependency on the logging module.
Resolves #1484758.
........
r46028 | georg.brandl | 2006-05-17 16:56:04 +0200 (Wed, 17 May 2006) | 3 lines
Patch #1486962: Several bugs in the turtle Tk demo module were fixed
and several features added, such as speed and geometry control.
........
r46029 | georg.brandl | 2006-05-17 17:17:00 +0200 (Wed, 17 May 2006) | 4 lines
Delay-import some large modules to speed up urllib2 import.
(fixes #1484793).
........
r46030 | georg.brandl | 2006-05-17 17:51:16 +0200 (Wed, 17 May 2006) | 3 lines
Patch #1180296: improve locale string formatting functions
........
r46032 | tim.peters | 2006-05-18 04:06:40 +0200 (Thu, 18 May 2006) | 2 lines
Whitespace normalization.
........
r46033 | georg.brandl | 2006-05-18 08:11:19 +0200 (Thu, 18 May 2006) | 3 lines
Amendments to patch #1484695.
........
r46034 | georg.brandl | 2006-05-18 08:18:06 +0200 (Thu, 18 May 2006) | 3 lines
Remove unused import.
........
r46035 | georg.brandl | 2006-05-18 08:33:27 +0200 (Thu, 18 May 2006) | 3 lines
Fix test_locale for platforms without a default thousands separator.
........
r46036 | neal.norwitz | 2006-05-18 08:51:46 +0200 (Thu, 18 May 2006) | 1 line
Little cleanup
........
r46037 | georg.brandl | 2006-05-18 09:01:27 +0200 (Thu, 18 May 2006) | 4 lines
Bug #1462152: file() now checks more thoroughly for invalid mode
strings and removes a possible "U" before passing the mode to the
C library function.
........
r46038 | georg.brandl | 2006-05-18 09:20:05 +0200 (Thu, 18 May 2006) | 3 lines
Bug #1490688: properly document %e, %f, %g format subtleties.
........
r46039 | vinay.sajip | 2006-05-18 09:28:58 +0200 (Thu, 18 May 2006) | 1 line
Changed status from "beta" to "production"; since logging has been part of the stdlib since 2.3, it should be safe to make this assertion ;-)
........
r46040 | ronald.oussoren | 2006-05-18 11:04:15 +0200 (Thu, 18 May 2006) | 2 lines
Fix some minor issues with the generated application bundles on MacOSX
........
r46041 | andrew.kuchling | 2006-05-19 02:03:55 +0200 (Fri, 19 May 2006) | 1 line
Typo fix; add clarifying word
........
r46044 | neal.norwitz | 2006-05-19 08:31:23 +0200 (Fri, 19 May 2006) | 3 lines
Fix #132 from Coverity, retval could have been derefed
if a continue inside a try failed.
........
r46045 | neal.norwitz | 2006-05-19 08:43:50 +0200 (Fri, 19 May 2006) | 2 lines
Fix #1474677, non-keyword argument following keyword.
........
r46046 | neal.norwitz | 2006-05-19 09:00:58 +0200 (Fri, 19 May 2006) | 4 lines
Bug/Patch #1481770: Use .so extension for shared libraries on HP-UX for ia64.
I suppose this could be backported if anyone cares.
........
r46047 | neal.norwitz | 2006-05-19 09:05:01 +0200 (Fri, 19 May 2006) | 7 lines
Oops, I forgot to include this file in the last commit (46046):
Bug/Patch #1481770: Use .so extension for shared libraries on HP-UX for ia64.
I suppose this could be backported if anyone cares.
........
r46050 | ronald.oussoren | 2006-05-19 20:17:31 +0200 (Fri, 19 May 2006) | 6 lines
* Change working directory to the users home
directory, that makes the file open/save
dialogs more useable.
* Don't use argv emulator, its not needed
for idle.
........
r46052 | tim.peters | 2006-05-19 21:16:34 +0200 (Fri, 19 May 2006) | 2 lines
Whitespace normalization.
........
r46054 | ronald.oussoren | 2006-05-20 08:17:01 +0200 (Sat, 20 May 2006) | 9 lines
Fix bug #1000914 (again).
This patches a file that is generated by bgen, however the code is now the
same as a current copy of bgen would generate. Without this patch most types
in the Carbon.CF module are unusable.
I haven't managed to coax bgen into generating a complete copy of _CFmodule.c
yet :-(, hence the manual patching.
........
r46055 | george.yoshida | 2006-05-20 17:36:19 +0200 (Sat, 20 May 2006) | 3 lines
- markup fix
- add clarifying words
........
r46057 | george.yoshida | 2006-05-20 18:29:14 +0200 (Sat, 20 May 2006) | 3 lines
- Add 'as' and 'with' as new keywords in 2.5.
- Regenerate keyword lists with reswords.py.
........
r46058 | george.yoshida | 2006-05-20 20:07:26 +0200 (Sat, 20 May 2006) | 2 lines
Apply patch #1492147 from Mike Foord.
........
r46059 | andrew.kuchling | 2006-05-20 21:25:16 +0200 (Sat, 20 May 2006) | 1 line
Minor edits
........
r46061 | george.yoshida | 2006-05-21 06:22:59 +0200 (Sun, 21 May 2006) | 2 lines
Fix the TeX compile error.
........
r46062 | george.yoshida | 2006-05-21 06:40:32 +0200 (Sun, 21 May 2006) | 2 lines
Apply patch #1492255 from Mike Foord.
........
r46063 | martin.v.loewis | 2006-05-22 10:48:14 +0200 (Mon, 22 May 2006) | 1 line
Patch 1490384: New Icons for the PC build.
........
r46064 | martin.v.loewis | 2006-05-22 11:15:18 +0200 (Mon, 22 May 2006) | 1 line
Patch #1492356: Port to Windows CE (patch set 1).
........
r46065 | tim.peters | 2006-05-22 13:29:41 +0200 (Mon, 22 May 2006) | 4 lines
Define SIZEOF_{DOUBLE,FLOAT} on Windows. Else
Michael Hudson's nice gimmicks for IEEE special
values (infinities, NaNs) don't work.
........
r46070 | bob.ippolito | 2006-05-22 16:31:24 +0200 (Mon, 22 May 2006) | 2 lines
GzipFile.readline performance improvement (~30-40%), patch #1281707
........
r46071 | bob.ippolito | 2006-05-22 17:22:46 +0200 (Mon, 22 May 2006) | 1 line
Revert gzip readline performance patch #1281707 until a more generic performance improvement can be found
........
r46073 | fredrik.lundh | 2006-05-22 17:35:12 +0200 (Mon, 22 May 2006) | 4 lines
docstring tweaks: count counts non-overlapping substrings, not
total number of occurences
........
r46075 | bob.ippolito | 2006-05-22 17:59:12 +0200 (Mon, 22 May 2006) | 1 line
Apply revised patch for GzipFile.readline performance #1281707
........
r46076 | fredrik.lundh | 2006-05-22 18:29:30 +0200 (Mon, 22 May 2006) | 3 lines
needforspeed: speed up unicode repeat, unicode string copy
........
r46079 | fredrik.lundh | 2006-05-22 19:12:58 +0200 (Mon, 22 May 2006) | 4 lines
needforspeed: use memcpy for "long" strings; use a better algorithm
for long repeats.
........
r46084 | tim.peters | 2006-05-22 21:17:04 +0200 (Mon, 22 May 2006) | 7 lines
PyUnicode_Join(): Recent code changes introduced new
compiler warnings on Windows (signed vs unsigned mismatch
in comparisons). Cleaned that up by switching more locals
to Py_ssize_t. Simplified overflow checking (it can _be_
simpler because while these things are declared as
Py_ssize_t, then should in fact never be negative).
........
r46085 | tim.peters | 2006-05-23 07:47:16 +0200 (Tue, 23 May 2006) | 3 lines
unicode_repeat(): Change type of local to Py_ssize_t,
since that's what it should be.
........
r46094 | fredrik.lundh | 2006-05-23 12:10:57 +0200 (Tue, 23 May 2006) | 3 lines
needforspeed: check first *and* last character before doing a full memcmp
........
r46095 | fredrik.lundh | 2006-05-23 12:12:21 +0200 (Tue, 23 May 2006) | 4 lines
needforspeed: fixed unicode "in" operator to use same implementation
approach as find/index
........
r46096 | richard.jones | 2006-05-23 12:37:38 +0200 (Tue, 23 May 2006) | 7 lines
Merge from rjones-funccall branch.
Applied patch zombie-frames-2.diff from sf patch 876206 with updates for
Python 2.5 and also modified to retain the free_list to avoid the 67%
slow-down in pybench recursion test. 5% speed up in function call pybench.
........
r46098 | ronald.oussoren | 2006-05-23 13:04:24 +0200 (Tue, 23 May 2006) | 2 lines
Avoid creating a mess when installing a framework for the second time.
........
r46101 | georg.brandl | 2006-05-23 13:17:21 +0200 (Tue, 23 May 2006) | 3 lines
PyErr_NewException now accepts a tuple of base classes as its
"base" parameter.
........
r46103 | ronald.oussoren | 2006-05-23 13:47:16 +0200 (Tue, 23 May 2006) | 3 lines
Disable linking extensions with -lpython2.5 for darwin. This should fix bug
#1487105.
........
r46104 | ronald.oussoren | 2006-05-23 14:01:11 +0200 (Tue, 23 May 2006) | 6 lines
Patch #1488098.
This patchs makes it possible to create a universal build on OSX 10.4 and use
the result to build extensions on 10.3. It also makes it possible to override
the '-arch' and '-isysroot' compiler arguments for specific extensions.
........
r46108 | andrew.kuchling | 2006-05-23 14:44:36 +0200 (Tue, 23 May 2006) | 1 line
Add some items; mention the sprint
........
r46109 | andrew.kuchling | 2006-05-23 14:47:01 +0200 (Tue, 23 May 2006) | 1 line
Mention string improvements
........
r46110 | andrew.kuchling | 2006-05-23 14:49:35 +0200 (Tue, 23 May 2006) | 4 lines
Use 'speed' instead of 'performance', because I agree with the argument
at http://zestyping.livejournal.com/193260.html that 'erformance' really means
something more general.
........
r46113 | ronald.oussoren | 2006-05-23 17:09:57 +0200 (Tue, 23 May 2006) | 2 lines
An improved script for building the binary distribution on MacOSX.
........
r46128 | richard.jones | 2006-05-23 20:28:17 +0200 (Tue, 23 May 2006) | 3 lines
Applied patch 1337051 by Neal Norwitz, saving 4 ints on frame objects.
........
r46129 | richard.jones | 2006-05-23 20:32:11 +0200 (Tue, 23 May 2006) | 1 line
fix broken merge
........
r46130 | bob.ippolito | 2006-05-23 20:41:17 +0200 (Tue, 23 May 2006) | 1 line
Update Misc/NEWS for gzip patch #1281707
........
r46131 | bob.ippolito | 2006-05-23 20:43:47 +0200 (Tue, 23 May 2006) | 1 line
Update Misc/NEWS for gzip patch #1281707
........
r46132 | fredrik.lundh | 2006-05-23 20:44:25 +0200 (Tue, 23 May 2006) | 7 lines
needforspeed: use append+reverse for rsplit, use "bloom filters" to
speed up splitlines and strip with charsets; etc. rsplit is now as
fast as split in all our tests (reverse takes no time at all), and
splitlines() is nearly as fast as a plain split("\n") in our tests.
and we're not done yet... ;-)
........
r46133 | tim.peters | 2006-05-23 20:45:30 +0200 (Tue, 23 May 2006) | 38 lines
Bug #1334662 / patch #1335972: int(string, base) wrong answers.
In rare cases of strings specifying true values near sys.maxint,
and oddball bases (not decimal or a power of 2), int(string, base)
could deliver insane answers. This repairs all such problems, and
also speeds string->int significantly. On my box, here are %
speedups for decimal strings of various lengths:
length speedup
------ -------
1 12.4%
2 15.7%
3 20.6%
4 28.1%
5 33.2%
6 37.5%
7 41.9%
8 46.3%
9 51.2%
10 19.5%
11 19.9%
12 23.9%
13 23.7%
14 23.3%
15 24.9%
16 25.3%
17 28.3%
18 27.9%
19 35.7%
Note that the difference between 9 and 10 is the difference between
short and long Python ints on a 32-bit box. The patch doesn't
actually do anything to speed conversion to long: the speedup is
due to detecting "unsigned long" overflow more quickly.
This is a bugfix candidate, but it's a non-trivial patch and it
would be painful to separate the "bug fix" from the "speed up" parts.
........
r46134 | bob.ippolito | 2006-05-23 20:46:41 +0200 (Tue, 23 May 2006) | 1 line
Patch #1493701: performance enhancements for struct module.
........
r46136 | andrew.kuchling | 2006-05-23 21:00:45 +0200 (Tue, 23 May 2006) | 1 line
Remove duplicate item
........
r46141 | bob.ippolito | 2006-05-23 21:09:51 +0200 (Tue, 23 May 2006) | 1 line
revert #1493701
........
r46142 | bob.ippolito | 2006-05-23 21:11:34 +0200 (Tue, 23 May 2006) | 1 line
patch #1493701: performance enhancements for struct module
........
r46144 | bob.ippolito | 2006-05-23 21:12:41 +0200 (Tue, 23 May 2006) | 1 line
patch #1493701: performance enhancements for struct module
........
r46148 | bob.ippolito | 2006-05-23 21:25:52 +0200 (Tue, 23 May 2006) | 1 line
fix linking issue, warnings, in struct
........
r46149 | andrew.kuchling | 2006-05-23 21:29:38 +0200 (Tue, 23 May 2006) | 1 line
Add two items
........
r46150 | bob.ippolito | 2006-05-23 21:31:23 +0200 (Tue, 23 May 2006) | 1 line
forward declaration for PyStructType
........
r46151 | bob.ippolito | 2006-05-23 21:32:25 +0200 (Tue, 23 May 2006) | 1 line
fix typo in _struct
........
r46152 | andrew.kuchling | 2006-05-23 21:32:35 +0200 (Tue, 23 May 2006) | 1 line
Add item
........
r46153 | tim.peters | 2006-05-23 21:34:37 +0200 (Tue, 23 May 2006) | 3 lines
Get the Windows build working again (recover from
`struct` module changes).
........
r46155 | fredrik.lundh | 2006-05-23 21:47:35 +0200 (Tue, 23 May 2006) | 3 lines
return 0 on misses, not -1.
........
r46156 | tim.peters | 2006-05-23 23:51:35 +0200 (Tue, 23 May 2006) | 4 lines
test_struct grew weird behavior under regrtest.py -R,
due to a module-level cache. Clearing the cache should
make it stop showing up in refleak reports.
........
r46157 | tim.peters | 2006-05-23 23:54:23 +0200 (Tue, 23 May 2006) | 2 lines
Whitespace normalization.
........
r46158 | tim.peters | 2006-05-23 23:55:53 +0200 (Tue, 23 May 2006) | 2 lines
Add missing svn:eol-style property to text files.
........
r46161 | fredrik.lundh | 2006-05-24 12:20:36 +0200 (Wed, 24 May 2006) | 3 lines
use Py_ssize_t for string indexes (thanks, neal!)
........
r46173 | fredrik.lundh | 2006-05-24 16:28:11 +0200 (Wed, 24 May 2006) | 14 lines
needforspeed: use "fastsearch" for count and findstring helpers. this
results in a 2.5x speedup on the stringbench count tests, and a 20x (!)
speedup on the stringbench search/find/contains test, compared to 2.5a2.
for more on the algorithm, see:
http://effbot.org/zone/stringlib.htm
if you get weird results, you can disable the new algoritm by undefining
USE_FAST in Objects/unicodeobject.c.
enjoy /F
........
r46182 | fredrik.lundh | 2006-05-24 17:11:01 +0200 (Wed, 24 May 2006) | 3 lines
needforspeedindeed: use fastsearch also for __contains__
........
r46184 | bob.ippolito | 2006-05-24 17:32:06 +0200 (Wed, 24 May 2006) | 1 line
refactor unpack, add unpack_from
........
r46189 | fredrik.lundh | 2006-05-24 18:35:18 +0200 (Wed, 24 May 2006) | 4 lines
needforspeed: refactored the replace code slightly; special-case
constant-length changes; use fastsearch to locate the first match.
........
r46198 | andrew.dalke | 2006-05-24 20:55:37 +0200 (Wed, 24 May 2006) | 10 lines
Added a slew of test for string replace, based various corner cases from
the Need For Speed sprint coding. Includes commented out overflow tests
which will be uncommented once the code is fixed.
This test will break the 8-bit string tests because
"".replace("", "A") == "" when it should == "A"
We have a fix for it, which should be added tomorrow.
........
r46200 | tim.peters | 2006-05-24 22:27:18 +0200 (Wed, 24 May 2006) | 2 lines
We can't leave the checked-in tests broken.
........
r46201 | tim.peters | 2006-05-24 22:29:44 +0200 (Wed, 24 May 2006) | 2 lines
Whitespace normalization.
........
r46202 | tim.peters | 2006-05-24 23:00:45 +0200 (Wed, 24 May 2006) | 4 lines
Disable the damn empty-string replace test -- it can't
be make to pass now for unicode if it passes for str, or
vice versa.
........
r46203 | tim.peters | 2006-05-24 23:10:40 +0200 (Wed, 24 May 2006) | 58 lines
Heavily fiddled variant of patch #1442927: PyLong_FromString optimization.
``long(str, base)`` is now up to 6x faster for non-power-of-2 bases. The
largest speedup is for inputs with about 1000 decimal digits. Conversion
from non-power-of-2 bases remains quadratic-time in the number of input
digits (it was and remains linear-time for bases 2, 4, 8, 16 and 32).
Speedups at various lengths for decimal inputs, comparing 2.4.3 with
current trunk. Note that it's actually a bit slower for 1-digit strings:
len speedup
---- -------
1 -4.5%
2 4.6%
3 8.3%
4 12.7%
5 16.9%
6 28.6%
7 35.5%
8 44.3%
9 46.6%
10 55.3%
11 65.7%
12 77.7%
13 73.4%
14 75.3%
15 85.2%
16 103.0%
17 95.1%
18 112.8%
19 117.9%
20 128.3%
30 174.5%
40 209.3%
50 236.3%
60 254.3%
70 262.9%
80 295.8%
90 297.3%
100 324.5%
200 374.6%
300 403.1%
400 391.1%
500 388.7%
600 440.6%
700 468.7%
800 498.0%
900 507.2%
1000 501.2%
2000 450.2%
3000 463.2%
4000 452.5%
5000 440.6%
6000 439.6%
7000 424.8%
8000 418.1%
9000 417.7%
........
r46204 | andrew.kuchling | 2006-05-25 02:23:03 +0200 (Thu, 25 May 2006) | 1 line
Minor edits; add an item
........
r46205 | fred.drake | 2006-05-25 04:42:25 +0200 (Thu, 25 May 2006) | 3 lines
fix broken links in PDF
(SF patch #1281291, contributed by Rory Yorke)
........
r46208 | walter.doerwald | 2006-05-25 10:53:28 +0200 (Thu, 25 May 2006) | 2 lines
Replace tab inside comment with space.
........
r46209 | thomas.wouters | 2006-05-25 13:25:51 +0200 (Thu, 25 May 2006) | 4 lines
Fix #1488915, Multiple dots in relative import statement raise SyntaxError.
........
r46210 | thomas.wouters | 2006-05-25 13:26:25 +0200 (Thu, 25 May 2006) | 5 lines
Update graminit.c for the fix for #1488915, Multiple dots in relative import
statement raise SyntaxError, and add testcase.
........
r46211 | andrew.kuchling | 2006-05-25 14:27:59 +0200 (Thu, 25 May 2006) | 1 line
Add entry; and fix a typo
........
r46214 | fredrik.lundh | 2006-05-25 17:22:03 +0200 (Thu, 25 May 2006) | 7 lines
needforspeed: speed up upper and lower for 8-bit string objects.
(the unicode versions of these are still 2x faster on windows,
though...)
based on work by Andrew Dalke, with tweaks by yours truly.
........
r46216 | fredrik.lundh | 2006-05-25 17:49:45 +0200 (Thu, 25 May 2006) | 5 lines
needforspeed: make new upper/lower work properly for single-character
strings too... (thanks to georg brandl for spotting the exact problem
faster than anyone else)
........
r46217 | kristjan.jonsson | 2006-05-25 17:53:30 +0200 (Thu, 25 May 2006) | 1 line
Added a new macro, Py_IS_FINITE(X). On windows there is an intrinsic for this and it is more efficient than to use !Py_IS_INFINITE(X) && !Py_IS_NAN(X). No change on other platforms
........
r46219 | fredrik.lundh | 2006-05-25 18:10:12 +0200 (Thu, 25 May 2006) | 4 lines
needforspeed: _toupper/_tolower is a SUSv2 thing; fall back on ISO C
versions if they're not defined.
........
r46220 | andrew.kuchling | 2006-05-25 18:23:15 +0200 (Thu, 25 May 2006) | 1 line
Fix comment typos
........
r46221 | andrew.dalke | 2006-05-25 18:30:52 +0200 (Thu, 25 May 2006) | 2 lines
Added tests for implementation error we came up with in the need for speed sprint.
........
r46222 | andrew.kuchling | 2006-05-25 18:34:54 +0200 (Thu, 25 May 2006) | 1 line
Fix another typo
........
r46223 | kristjan.jonsson | 2006-05-25 18:39:27 +0200 (Thu, 25 May 2006) | 1 line
Fix incorrect documentation for the Py_IS_FINITE(X) macro.
........
r46224 | fredrik.lundh | 2006-05-25 18:46:54 +0200 (Thu, 25 May 2006) | 3 lines
needforspeed: check for overflow in replace (from Andrew Dalke)
........
r46226 | fredrik.lundh | 2006-05-25 19:08:14 +0200 (Thu, 25 May 2006) | 5 lines
needforspeed: new replace implementation by Andrew Dalke. replace is
now about 3x faster on my machine, for the replace tests from string-
bench.
........
r46227 | tim.peters | 2006-05-25 19:34:03 +0200 (Thu, 25 May 2006) | 5 lines
A new table to help string->integer conversion was added yesterday to
both mystrtoul.c and longobject.c. Share the table instead. Also
cut its size by 64 entries (they had been used for an inscrutable
trick originally, but the code no longer tries to use that trick).
........
r46229 | andrew.dalke | 2006-05-25 19:53:00 +0200 (Thu, 25 May 2006) | 11 lines
Fixed problem identified by Georg. The special-case in-place code for replace
made a copy of the string using PyString_FromStringAndSize(s, n) and modify
the copied string in-place. However, 1 (and 0) character strings are shared
from a cache. This cause "A".replace("A", "a") to change the cached version
of "A" -- used by everyone.
Now may the copy with NULL as the string and do the memcpy manually. I've
added regression tests to check if this happens in the future. Perhaps
there should be a PyString_Copy for this case?
........
r46230 | fredrik.lundh | 2006-05-25 19:55:31 +0200 (Thu, 25 May 2006) | 4 lines
needforspeed: use "fastsearch" for count. this results in a 3x speedup
for the related stringbench tests.
........
r46231 | andrew.dalke | 2006-05-25 20:03:25 +0200 (Thu, 25 May 2006) | 4 lines
Code had returned an ssize_t, upcast to long, then converted with PyInt_FromLong.
Now using PyInt_FromSsize_t.
........
r46233 | andrew.kuchling | 2006-05-25 20:11:16 +0200 (Thu, 25 May 2006) | 1 line
Comment typo
........
r46234 | andrew.dalke | 2006-05-25 20:18:39 +0200 (Thu, 25 May 2006) | 4 lines
Added overflow test for adding two (very) large strings where the
new string is over max Py_ssize_t. I have no way to test it on my
box or any box I have access to. At least it doesn't break anything.
........
r46235 | bob.ippolito | 2006-05-25 20:20:23 +0200 (Thu, 25 May 2006) | 1 line
Faster path for PyLong_FromLongLong, using PyLong_FromLong algorithm
........
r46238 | georg.brandl | 2006-05-25 20:44:09 +0200 (Thu, 25 May 2006) | 3 lines
Guard the _active.remove() call to avoid errors when there is no _active list.
........
r46239 | fredrik.lundh | 2006-05-25 20:44:29 +0200 (Thu, 25 May 2006) | 4 lines
needforspeed: use fastsearch also for find/index and contains. the
related tests are now about 10x faster.
........
r46240 | bob.ippolito | 2006-05-25 20:44:50 +0200 (Thu, 25 May 2006) | 1 line
Struct now unpacks to PY_LONG_LONG directly when possible, also include #ifdef'ed out code that will return int instead of long when in bounds (not active since it's an API and doc change)
........
r46241 | jack.diederich | 2006-05-25 20:47:15 +0200 (Thu, 25 May 2006) | 1 line
* eliminate warning by reverting tmp_s type to 'const char*'
........
r46242 | bob.ippolito | 2006-05-25 21:03:19 +0200 (Thu, 25 May 2006) | 1 line
Fix Cygwin compiler issue
........
r46243 | bob.ippolito | 2006-05-25 21:15:27 +0200 (Thu, 25 May 2006) | 1 line
fix a struct regression where long would be returned for short unsigned integers
........
r46244 | georg.brandl | 2006-05-25 21:15:31 +0200 (Thu, 25 May 2006) | 4 lines
Replace PyObject_CallFunction calls with only object args
with PyObject_CallFunctionObjArgs, which is 30% faster.
........
r46245 | fredrik.lundh | 2006-05-25 21:19:05 +0200 (Thu, 25 May 2006) | 3 lines
needforspeed: use insert+reverse instead of append
........
r46246 | bob.ippolito | 2006-05-25 21:33:38 +0200 (Thu, 25 May 2006) | 1 line
Use LONG_MIN and LONG_MAX to check Python integer bounds instead of the incorrect INT_MIN and INT_MAX
........
r46248 | bob.ippolito | 2006-05-25 21:56:56 +0200 (Thu, 25 May 2006) | 1 line
Use faster struct pack/unpack functions for the endian table that matches the host's
........
r46249 | bob.ippolito | 2006-05-25 21:59:56 +0200 (Thu, 25 May 2006) | 1 line
enable darwin/x86 support for libffi and hence ctypes (doesn't yet support --enable-universalsdk)
........
r46252 | georg.brandl | 2006-05-25 22:28:10 +0200 (Thu, 25 May 2006) | 4 lines
Someone seems to just have copy-pasted the docs of
tp_compare to tp_richcompare ;)
........
r46253 | brett.cannon | 2006-05-25 22:44:08 +0200 (Thu, 25 May 2006) | 2 lines
Swap out bare malloc()/free() use for PyMem_MALLOC()/PyMem_FREE() .
........
r46254 | bob.ippolito | 2006-05-25 22:52:38 +0200 (Thu, 25 May 2006) | 1 line
squelch gcc4 darwin/x86 compiler warnings
........
r46255 | bob.ippolito | 2006-05-25 23:09:45 +0200 (Thu, 25 May 2006) | 1 line
fix test_float regression and 64-bit size mismatch issue
........
r46256 | georg.brandl | 2006-05-25 23:11:56 +0200 (Thu, 25 May 2006) | 3 lines
Add a x-ref to newer calling APIs.
........
r46257 | ronald.oussoren | 2006-05-25 23:30:54 +0200 (Thu, 25 May 2006) | 2 lines
Fix minor typo in prep_cif.c
........
r46259 | brett.cannon | 2006-05-25 23:33:11 +0200 (Thu, 25 May 2006) | 4 lines
Change test_values so that it compares the lowercasing of group names since getgrall() can return all lowercase names while getgrgid() returns proper casing.
Discovered on Ubuntu 5.04 (custom).
........
r46261 | tim.peters | 2006-05-25 23:50:17 +0200 (Thu, 25 May 2006) | 7 lines
Some Win64 pre-release in 2000 didn't support
QueryPerformanceCounter(), but we believe Win64 does
support it now. So use in time.clock().
It would be peachy if someone with a Win64 box tried
this ;-)
........
r46262 | tim.peters | 2006-05-25 23:52:19 +0200 (Thu, 25 May 2006) | 2 lines
Whitespace normalization.
........
r46263 | bob.ippolito | 2006-05-25 23:58:05 +0200 (Thu, 25 May 2006) | 1 line
Add missing files from x86 darwin ctypes patch
........
r46264 | brett.cannon | 2006-05-26 00:00:14 +0200 (Fri, 26 May 2006) | 2 lines
Move over to use of METH_O and METH_NOARGS.
........
r46265 | tim.peters | 2006-05-26 00:25:25 +0200 (Fri, 26 May 2006) | 3 lines
Repair idiot typo, and complete the job of trying to
use the Windows time.clock() implementation on Win64.
........
r46266 | tim.peters | 2006-05-26 00:28:46 +0200 (Fri, 26 May 2006) | 9 lines
Patch #1494387: SVN longobject.c compiler warnings
The SIGCHECK macro defined here has always been bizarre, but
it apparently causes compiler warnings on "Sun Studio 11".
I believe the warnings are bogus, but it doesn't hurt to make
the macro definition saner.
Bugfix candidate (but I'm not going to bother).
........
r46268 | fredrik.lundh | 2006-05-26 01:27:53 +0200 (Fri, 26 May 2006) | 8 lines
needforspeed: partition for 8-bit strings. for some simple tests,
this is on par with a corresponding find, and nearly twice as fast
as split(sep, 1)
full tests, a unicode version, and documentation will follow to-
morrow.
........
r46271 | andrew.kuchling | 2006-05-26 03:46:22 +0200 (Fri, 26 May 2006) | 1 line
Add Soc student
........
r46272 | ronald.oussoren | 2006-05-26 10:41:25 +0200 (Fri, 26 May 2006) | 3 lines
Without this patch OSX users couldn't add new help sources because the code
tried to update one item in a tuple.
........
r46273 | fredrik.lundh | 2006-05-26 10:54:28 +0200 (Fri, 26 May 2006) | 5 lines
needforspeed: partition implementation, part two.
feel free to improve the documentation and the docstrings.
........
r46274 | georg.brandl | 2006-05-26 11:05:54 +0200 (Fri, 26 May 2006) | 3 lines
Clarify docs for str.partition().
........
r46278 | fredrik.lundh | 2006-05-26 11:46:59 +0200 (Fri, 26 May 2006) | 5 lines
needforspeed: use METH_O for argument handling, which made partition some
~15% faster for the current tests (which is noticable faster than a corre-
sponding find call). thanks to neal-who-never-sleeps for the tip.
........
r46280 | fredrik.lundh | 2006-05-26 12:27:17 +0200 (Fri, 26 May 2006) | 5 lines
needforspeed: use Py_ssize_t for the fastsearch counter and skip
length (thanks, neal!). and yes, I've verified that this doesn't
slow things down ;-)
........
r46285 | andrew.dalke | 2006-05-26 13:11:38 +0200 (Fri, 26 May 2006) | 2 lines
Added a few more test cases for whitespace split. These strings have leading whitespace.
........
r46286 | jack.diederich | 2006-05-26 13:15:17 +0200 (Fri, 26 May 2006) | 1 line
use Py_ssize_t in places that may need it
........
r46287 | andrew.dalke | 2006-05-26 13:15:22 +0200 (Fri, 26 May 2006) | 2 lines
Added split whitespace checks for characters other than space.
........
r46288 | ronald.oussoren | 2006-05-26 13:17:55 +0200 (Fri, 26 May 2006) | 2 lines
Fix buglet in postinstall script, it would generate an invalid .cshrc file.
........
r46290 | georg.brandl | 2006-05-26 13:26:11 +0200 (Fri, 26 May 2006) | 3 lines
Add "partition" to UserString.
........
r46291 | fredrik.lundh | 2006-05-26 13:29:39 +0200 (Fri, 26 May 2006) | 5 lines
needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
for SRE and others. applied Py_LOCAL to relevant portion of ceval,
which gives a 1-2% speedup on my machine. ymmv.
........
r46292 | jack.diederich | 2006-05-26 13:37:20 +0200 (Fri, 26 May 2006) | 1 line
when generating python code prefer to generate valid python code
........
r46293 | fredrik.lundh | 2006-05-26 13:38:15 +0200 (Fri, 26 May 2006) | 3 lines
use Py_LOCAL also for string and unicode objects
........
r46294 | ronald.oussoren | 2006-05-26 13:38:39 +0200 (Fri, 26 May 2006) | 12 lines
- Search the sqlite specific search directories
after the normal include directories when looking
for the version of sqlite to use.
- On OSX:
* Extract additional include and link directories
from the CFLAGS and LDFLAGS, if the user has
bothered to specify them we might as wel use them.
* Add '-Wl,-search_paths_first' to the extra_link_args
for readline and sqlite. This makes it possible to
use a static library to override the system provided
dynamic library.
........
r46295 | ronald.oussoren | 2006-05-26 13:43:26 +0200 (Fri, 26 May 2006) | 6 lines
Integrate installing a framework in the 'make install'
target. Until now users had to use 'make frameworkinstall'
to install python when it is configured with '--enable-framework'.
This tends to confuse users that don't hunt for readme files
hidden in platform specific directories :-)
........
r46297 | fredrik.lundh | 2006-05-26 13:54:04 +0200 (Fri, 26 May 2006) | 4 lines
needforspeed: added PY_LOCAL_AGGRESSIVE macro to enable "aggressive"
LOCAL inlining; also added some missing whitespace
........
r46298 | andrew.kuchling | 2006-05-26 14:01:44 +0200 (Fri, 26 May 2006) | 1 line
Typo fixes
........
r46299 | fredrik.lundh | 2006-05-26 14:01:49 +0200 (Fri, 26 May 2006) | 4 lines
Py_LOCAL shouldn't be used for data; it works for some .NET 2003 compilers,
but Trent's copy thinks that it's an anachronism...
........
r46300 | martin.blais | 2006-05-26 14:03:27 +0200 (Fri, 26 May 2006) | 12 lines
Support for buffer protocol for socket and struct.
* Added socket.recv_buf() and socket.recvfrom_buf() methods, that use the buffer
protocol (send and sendto already did).
* Added struct.pack_to(), that is the corresponding buffer compatible method to
unpack_from().
* Fixed minor typos in arraymodule.
........
r46302 | ronald.oussoren | 2006-05-26 14:23:20 +0200 (Fri, 26 May 2006) | 6 lines
- Remove previous version of the binary distribution script for OSX
- Some small bugfixes for the IDLE.app wrapper
- Tweaks to build-installer to ensure that python gets build in the right way,
including sqlite3.
- Updated readme files
........
r46305 | tim.peters | 2006-05-26 14:26:21 +0200 (Fri, 26 May 2006) | 2 lines
Whitespace normalization.
........
r46307 | andrew.dalke | 2006-05-26 14:28:15 +0200 (Fri, 26 May 2006) | 7 lines
I like tests.
The new split functions use a preallocated list. Added tests which exceed
the preallocation size, to exercise list appends/resizes.
Also added more edge case tests.
........
r46308 | andrew.dalke | 2006-05-26 14:31:00 +0200 (Fri, 26 May 2006) | 2 lines
Test cases for off-by-one errors in string split with multicharacter pattern.
........
r46309 | tim.peters | 2006-05-26 14:31:20 +0200 (Fri, 26 May 2006) | 2 lines
Whitespace normalization.
........
r46313 | andrew.kuchling | 2006-05-26 14:39:48 +0200 (Fri, 26 May 2006) | 1 line
Add str.partition()
........
r46314 | bob.ippolito | 2006-05-26 14:52:53 +0200 (Fri, 26 May 2006) | 1 line
quick hack to fix busted binhex test
........
r46316 | andrew.dalke | 2006-05-26 15:05:55 +0200 (Fri, 26 May 2006) | 2 lines
Added more rstrip tests, including for prealloc'ed arrays
........
r46320 | bob.ippolito | 2006-05-26 15:15:44 +0200 (Fri, 26 May 2006) | 1 line
fix #1229380 No struct.pack exception for some out of range integers
........
r46325 | tim.peters | 2006-05-26 15:39:17 +0200 (Fri, 26 May 2006) | 2 lines
Use open() to open files (was using file()).
........
r46327 | andrew.dalke | 2006-05-26 16:00:45 +0200 (Fri, 26 May 2006) | 37 lines
Changes to string.split/rsplit on whitespace to preallocate space in the
results list.
Originally it allocated 0 items and used the list growth during append. Now
it preallocates 12 items so the first few appends don't need list reallocs.
("Here are some words ."*2).split(None, 1) is 7% faster
("Here are some words ."*2).split() is is 15% faster
(Your milage may vary, see dealership for details.)
File parsing like this
for line in f:
count += len(line.split())
is also about 15% faster. There is a slowdown of about 3% for large
strings because of the additional overhead of checking if the append is
to a preallocated region of the list or not. This will be the rare case.
It could be improved with special case code but we decided it was not
useful enough.
There is a cost of 12*sizeof(PyObject *) bytes per list. For the normal
case of file parsing this is not a problem because of the lists have
a short lifetime. We have not come up with cases where this is a problem
in real life.
I chose 12 because human text averages about 11 words per line in books,
one of my data sets averages 6.2 words with a final peak at 11 words per
line, and I work with a tab delimited data set with 8 tabs per line (or
9 words per line). 12 encompasses all of these.
Also changed the last rstrip code to append then reverse, rather than
doing insert(0). The strip() and rstrip() times are now comparable.
........
r46328 | tim.peters | 2006-05-26 16:02:05 +0200 (Fri, 26 May 2006) | 5 lines
Explicitly close files. I'm trying to stop the frequent spurious test_tarfile
failures on Windows buildbots, but it's hard to know how since the regrtest
failure output is useless here, and it never fails when a buildbot slave runs
test_tarfile the second time in verbose mode.
........
r46329 | andrew.kuchling | 2006-05-26 16:03:41 +0200 (Fri, 26 May 2006) | 1 line
Add buffer support for struct, socket
........
r46330 | andrew.kuchling | 2006-05-26 16:04:19 +0200 (Fri, 26 May 2006) | 1 line
Typo fix
........
r46331 | bob.ippolito | 2006-05-26 16:07:23 +0200 (Fri, 26 May 2006) | 1 line
Fix distutils so that libffi will cross-compile between darwin/x86 and darwin/ppc
........
r46333 | bob.ippolito | 2006-05-26 16:23:21 +0200 (Fri, 26 May 2006) | 1 line
Fix _struct typo that broke some 64-bit platforms
........
r46335 | bob.ippolito | 2006-05-26 16:29:35 +0200 (Fri, 26 May 2006) | 1 line
Enable PY_USE_INT_WHEN_POSSIBLE in struct
........
r46343 | andrew.dalke | 2006-05-26 17:21:01 +0200 (Fri, 26 May 2006) | 2 lines
Eeked out another 3% or so performance in split whitespace by cleaning up the algorithm.
........
r46352 | andrew.dalke | 2006-05-26 18:22:52 +0200 (Fri, 26 May 2006) | 3 lines
Test for more edge strip cases; leading and trailing separator gets removed
even with strip(..., 0)
........
r46354 | bob.ippolito | 2006-05-26 18:23:28 +0200 (Fri, 26 May 2006) | 1 line
fix signed/unsigned mismatch in struct
........
r46355 | steve.holden | 2006-05-26 18:27:59 +0200 (Fri, 26 May 2006) | 5 lines
Add -t option to allow easy test selection.
Action verbose option correctly.
Tweak operation counts. Add empty and new instances tests.
Enable comparisons across different warp factors. Change version.
........
r46356 | fredrik.lundh | 2006-05-26 18:32:42 +0200 (Fri, 26 May 2006) | 3 lines
needforspeed: use Py_LOCAL on a few more locals in stringobject.c
........
r46357 | thomas.heller | 2006-05-26 18:42:44 +0200 (Fri, 26 May 2006) | 4 lines
For now, I gave up with automatic conversion of reST to Python-latex,
so I'm writing this in latex now.
Skeleton for the ctypes reference.
........
r46358 | tim.peters | 2006-05-26 18:49:28 +0200 (Fri, 26 May 2006) | 3 lines
Repair Windows compiler warnings about mixing
signed and unsigned integral types in comparisons.
........
r46359 | tim.peters | 2006-05-26 18:52:04 +0200 (Fri, 26 May 2006) | 2 lines
Whitespace normalization.
........
r46360 | tim.peters | 2006-05-26 18:53:04 +0200 (Fri, 26 May 2006) | 2 lines
Add missing svn:eol-style property to text files.
........
r46362 | fredrik.lundh | 2006-05-26 19:04:58 +0200 (Fri, 26 May 2006) | 3 lines
needforspeed: stringlib refactoring (in progress)
........
r46363 | thomas.heller | 2006-05-26 19:18:33 +0200 (Fri, 26 May 2006) | 1 line
Write some docs.
........
r46364 | fredrik.lundh | 2006-05-26 19:22:38 +0200 (Fri, 26 May 2006) | 3 lines
needforspeed: stringlib refactoring (in progress)
........
r46366 | fredrik.lundh | 2006-05-26 19:26:39 +0200 (Fri, 26 May 2006) | 3 lines
needforspeed: cleanup
........
r46367 | fredrik.lundh | 2006-05-26 19:31:41 +0200 (Fri, 26 May 2006) | 4 lines
needforspeed: remove remaining USE_FAST macros; if fastsearch was
broken, someone would have noticed by now ;-)
........
r46368 | steve.holden | 2006-05-26 19:41:32 +0200 (Fri, 26 May 2006) | 5 lines
Use minimum calibration time rather than avergae to avoid
the illusion of negative run times. Halt with an error if
run times go below 10 ms, indicating that results will be
unreliable.
........
r46370 | thomas.heller | 2006-05-26 19:47:40 +0200 (Fri, 26 May 2006) | 2 lines
Reordered, and wrote more docs.
........
r46372 | georg.brandl | 2006-05-26 20:03:31 +0200 (Fri, 26 May 2006) | 9 lines
Need for speed: Patch #921466 : sys.path_importer_cache is now used to cache valid and
invalid file paths for the built-in import machinery which leads to
fewer open calls on startup.
Also fix issue with PEP 302 style import hooks which lead to more open()
calls than necessary.
........
r46373 | fredrik.lundh | 2006-05-26 20:05:34 +0200 (Fri, 26 May 2006) | 3 lines
removed unnecessary include
........
r46377 | fredrik.lundh | 2006-05-26 20:15:38 +0200 (Fri, 26 May 2006) | 3 lines
needforspeed: added rpartition implementation
........
r46380 | fredrik.lundh | 2006-05-26 20:24:15 +0200 (Fri, 26 May 2006) | 5 lines
needspeed: rpartition documentation, tests, and a bug fixes.
feel free to add more tests and improve the documentation.
........
r46381 | steve.holden | 2006-05-26 20:26:21 +0200 (Fri, 26 May 2006) | 4 lines
Revert tests to MAL's original round sizes to retiain comparability
from long ago and far away. Stop calling this pybench 1.4 because it
isn't. Remove the empty test, which was a bad idea.
........
r46387 | andrew.kuchling | 2006-05-26 20:41:18 +0200 (Fri, 26 May 2006) | 1 line
Add rpartition() and path caching
........
r46388 | andrew.dalke | 2006-05-26 21:02:09 +0200 (Fri, 26 May 2006) | 10 lines
substring split now uses /F's fast string matching algorithm.
(If compiled without FAST search support, changed the pre-memcmp test
to check the last character as well as the first. This gave a 25%
speedup for my test case.)
Rewrote the split algorithms so they stop when maxsplit gets to 0.
Previously they did a string match first then checked if the maxsplit
was reached. The new way prevents a needless string search.
........
r46391 | brett.cannon | 2006-05-26 21:04:47 +0200 (Fri, 26 May 2006) | 2 lines
Change C spacing to 4 spaces by default to match PEP 7 for new C files.
........
r46392 | georg.brandl | 2006-05-26 21:04:47 +0200 (Fri, 26 May 2006) | 3 lines
Exception isn't the root of all exception classes anymore.
........
r46397 | fredrik.lundh | 2006-05-26 21:23:21 +0200 (Fri, 26 May 2006) | 3 lines
added rpartition method to UserString class
........
r46398 | fredrik.lundh | 2006-05-26 21:24:53 +0200 (Fri, 26 May 2006) | 4 lines
needforspeed: stringlib refactoring, continued. added count and
find helpers; updated unicodeobject to use stringlib_count
........
r46400 | fredrik.lundh | 2006-05-26 21:29:05 +0200 (Fri, 26 May 2006) | 4 lines
needforspeed: stringlib refactoring: use stringlib/find for unicode
find
........
r46403 | fredrik.lundh | 2006-05-26 21:33:03 +0200 (Fri, 26 May 2006) | 3 lines
needforspeed: use a macro to fix slice indexes
........
r46404 | thomas.heller | 2006-05-26 21:43:45 +0200 (Fri, 26 May 2006) | 1 line
Write more docs.
........
r46406 | fredrik.lundh | 2006-05-26 21:48:07 +0200 (Fri, 26 May 2006) | 3 lines
needforspeed: stringlib refactoring: use stringlib/find for string find
........
r46407 | andrew.kuchling | 2006-05-26 21:51:10 +0200 (Fri, 26 May 2006) | 1 line
Comment typo
........
r46409 | georg.brandl | 2006-05-26 22:04:44 +0200 (Fri, 26 May 2006) | 3 lines
Replace Py_BuildValue("OO") by PyTuple_Pack.
........
r46411 | georg.brandl | 2006-05-26 22:14:47 +0200 (Fri, 26 May 2006) | 2 lines
Patch #1492218: document None being a constant.
........
r46415 | georg.brandl | 2006-05-26 22:22:50 +0200 (Fri, 26 May 2006) | 3 lines
Simplify calling.
........
r46416 | andrew.dalke | 2006-05-26 22:25:22 +0200 (Fri, 26 May 2006) | 4 lines
Added limits to the replace code so it does not count all of the matching
patterns in a string, only the number needed by the max limit.
........
r46417 | bob.ippolito | 2006-05-26 22:25:23 +0200 (Fri, 26 May 2006) | 1 line
enable all of the struct tests, use ssize_t, fix some whitespace
........
r46418 | tim.peters | 2006-05-26 22:56:56 +0200 (Fri, 26 May 2006) | 2 lines
Record Iceland sprint attendees.
........
r46421 | tim.peters | 2006-05-26 23:51:13 +0200 (Fri, 26 May 2006) | 2 lines
Whitespace normalization.
........
r46422 | steve.holden | 2006-05-27 00:17:54 +0200 (Sat, 27 May 2006) | 2 lines
Add Richard Tew to developers
........
r46423 | steve.holden | 2006-05-27 00:33:20 +0200 (Sat, 27 May 2006) | 2 lines
Update help text and documentaition.
........
r46424 | steve.holden | 2006-05-27 00:39:27 +0200 (Sat, 27 May 2006) | 2 lines
Blasted typos ...
........
r46425 | andrew.dalke | 2006-05-27 00:49:03 +0200 (Sat, 27 May 2006) | 2 lines
Added description of why splitlines doesn't use the prealloc strategy
........
r46426 | tim.peters | 2006-05-27 01:14:37 +0200 (Sat, 27 May 2006) | 19 lines
Patch 1145039.
set_exc_info(), reset_exc_info(): By exploiting the
likely (who knows?) invariant that when an exception's
`type` is NULL, its `value` and `traceback` are also NULL,
save some cycles in heavily-executed code.
This is a "a kronar saved is a kronar earned" patch: the
speedup isn't reliably measurable, but it obviously does
reduce the operation count in the normal (no exception
raised) path through PyEval_EvalFrameEx().
The tim-exc_sanity branch tries to push this harder, but
is still blowing up (at least in part due to pre-existing
subtle bugs that appear to have no other visible
consequences!).
Not a bugfix candidate.
........
r46429 | steve.holden | 2006-05-27 02:51:52 +0200 (Sat, 27 May 2006) | 2 lines
Reinstate new-style object tests.
........
r46430 | neal.norwitz | 2006-05-27 07:18:57 +0200 (Sat, 27 May 2006) | 1 line
Fix compiler warning (and whitespace) on Mac OS 10.4. (A lot of this code looked duplicated, I wonder if a utility function could help reduce the duplication here.)
........
r46431 | neal.norwitz | 2006-05-27 07:21:30 +0200 (Sat, 27 May 2006) | 4 lines
Fix Coverity warnings.
- Check the correct variable (str_obj, not str) for NULL
- sep_len was already verified it wasn't 0
........
r46432 | martin.v.loewis | 2006-05-27 10:36:52 +0200 (Sat, 27 May 2006) | 2 lines
Patch 1494554: Update numeric properties to Unicode 4.1.
........
r46433 | martin.v.loewis | 2006-05-27 10:54:29 +0200 (Sat, 27 May 2006) | 2 lines
Explain why 'consumed' is initialized.
........
r46436 | fredrik.lundh | 2006-05-27 12:05:10 +0200 (Sat, 27 May 2006) | 3 lines
needforspeed: more stringlib refactoring
........
r46438 | fredrik.lundh | 2006-05-27 12:39:48 +0200 (Sat, 27 May 2006) | 5 lines
needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
lining killed performance on certain Intel boxes, and the "aggressive"
macro itself gives most of the benefits on others.
........
r46439 | andrew.dalke | 2006-05-27 13:04:36 +0200 (Sat, 27 May 2006) | 2 lines
fixed typo
........
r46440 | martin.v.loewis | 2006-05-27 13:07:49 +0200 (Sat, 27 May 2006) | 2 lines
Revert bogus change committed in 46432 to this file.
........
r46444 | andrew.kuchling | 2006-05-27 13:26:33 +0200 (Sat, 27 May 2006) | 1 line
Add Py_LOCAL macros
........
r46450 | bob.ippolito | 2006-05-27 13:47:12 +0200 (Sat, 27 May 2006) | 1 line
Remove the range checking and int usage #defines from _struct and strip out the now-dead code
........
r46454 | bob.ippolito | 2006-05-27 14:11:36 +0200 (Sat, 27 May 2006) | 1 line
Fix up struct docstrings, add struct.pack_to function for symmetry
........
r46456 | richard.jones | 2006-05-27 14:29:24 +0200 (Sat, 27 May 2006) | 2 lines
Conversion of exceptions over from faked-up classes to new-style C types.
........
r46457 | georg.brandl | 2006-05-27 14:30:25 +0200 (Sat, 27 May 2006) | 3 lines
Add news item for new-style exception class branch merge.
........
r46458 | tim.peters | 2006-05-27 14:36:53 +0200 (Sat, 27 May 2006) | 3 lines
More random thrashing trying to understand spurious
Windows failures. Who's keeping a bz2 file open?
........
r46460 | andrew.kuchling | 2006-05-27 15:44:37 +0200 (Sat, 27 May 2006) | 1 line
Mention new-style exceptions
........
r46461 | richard.jones | 2006-05-27 15:50:42 +0200 (Sat, 27 May 2006) | 1 line
credit where credit is due
........
r46462 | georg.brandl | 2006-05-27 16:02:03 +0200 (Sat, 27 May 2006) | 3 lines
Always close BZ2Proxy object. Remove unnecessary struct usage.
........
r46463 | tim.peters | 2006-05-27 16:13:13 +0200 (Sat, 27 May 2006) | 2 lines
The cheery optimism of old age.
........
r46464 | andrew.dalke | 2006-05-27 16:16:40 +0200 (Sat, 27 May 2006) | 2 lines
cleanup - removed trailing whitespace
........
r46465 | georg.brandl | 2006-05-27 16:41:55 +0200 (Sat, 27 May 2006) | 3 lines
Remove spurious semicolons after macro invocations.
........
r46468 | fredrik.lundh | 2006-05-27 16:58:20 +0200 (Sat, 27 May 2006) | 4 lines
needforspeed: replace improvements, changed to Py_LOCAL_INLINE
where appropriate
........
r46469 | fredrik.lundh | 2006-05-27 17:20:22 +0200 (Sat, 27 May 2006) | 4 lines
needforspeed: stringlib refactoring: changed find_obj to find_slice,
to enable use from stringobject
........
r46470 | fredrik.lundh | 2006-05-27 17:26:19 +0200 (Sat, 27 May 2006) | 3 lines
needforspeed: stringlib refactoring: use find_slice for stringobject
........
r46472 | kristjan.jonsson | 2006-05-27 17:41:31 +0200 (Sat, 27 May 2006) | 1 line
Add a PCBuild8 build directory for building with Visual Studio .NET 2005. Contains a special project to perform profile guided optimizations on the pythoncore.dll, by instrumenting and running pybench.py
........
r46473 | jack.diederich | 2006-05-27 17:44:34 +0200 (Sat, 27 May 2006) | 3 lines
needforspeed: use PyObject_MALLOC instead of system malloc for small
allocations. Use PyMem_MALLOC for larger (1k+) chunks. 1%-2% speedup.
........
r46474 | bob.ippolito | 2006-05-27 17:53:49 +0200 (Sat, 27 May 2006) | 1 line
fix struct regression on 64-bit platforms
........
r46475 | richard.jones | 2006-05-27 18:07:28 +0200 (Sat, 27 May 2006) | 1 line
doc string additions and tweaks
........
r46477 | richard.jones | 2006-05-27 18:15:11 +0200 (Sat, 27 May 2006) | 1 line
move semicolons
........
r46478 | george.yoshida | 2006-05-27 18:32:44 +0200 (Sat, 27 May 2006) | 2 lines
minor markup nits
........
r46488 | george.yoshida | 2006-05-27 18:51:43 +0200 (Sat, 27 May 2006) | 3 lines
End of Ch.3 is now about "with statement".
Avoid obsolescence by directly referring to the section.
........
r46489 | george.yoshida | 2006-05-27 19:09:17 +0200 (Sat, 27 May 2006) | 2 lines
fix typo
........
2006-05-27 16:21:47 -03:00
|
|
|
PyOS_ascii_formatd(c_str + 1, sizeof(c_str) - 2, "%.17g", x);
|
|
|
|
/* Extend the formatted string with a newline character */
|
|
|
|
strcat(c_str, "\n");
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, c_str, strlen(c_str)) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return 0;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
save_string(Picklerobject *self, PyObject *args, int doput)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
int size, len;
|
|
|
|
PyObject *repr=0;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((size = PyString_Size(args)) < 0)
|
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!self->bin) {
|
|
|
|
char *repr_str;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
static char string = STRING;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( repr = PyObject_Repr(args)))
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((len = PyString_Size(repr)) < 0)
|
|
|
|
goto err;
|
|
|
|
repr_str = PyString_AS_STRING((PyStringObject *)repr);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, &string, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto err;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, repr_str, len) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto err;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, "\n", 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto err;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_XDECREF(repr);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int i;
|
|
|
|
char c_str[5];
|
|
|
|
|
|
|
|
if ((size = PyString_Size(args)) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (size < 256) {
|
|
|
|
c_str[0] = SHORT_BINSTRING;
|
|
|
|
c_str[1] = size;
|
|
|
|
len = 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
c_str[0] = BINSTRING;
|
|
|
|
for (i = 1; i < 5; i++)
|
|
|
|
c_str[i] = (int)(size >> ((i - 1) * 8));
|
|
|
|
len = 5;
|
|
|
|
}
|
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, c_str, len) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (size > 128 && Pdata_Check(self->file)) {
|
|
|
|
if (write_other(self, NULL, 0) < 0) return -1;
|
|
|
|
PDATA_APPEND(self->file, args, -1);
|
|
|
|
}
|
|
|
|
else {
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self,
|
|
|
|
PyString_AS_STRING(
|
|
|
|
(PyStringObject *)args),
|
|
|
|
size) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (doput)
|
|
|
|
if (put(self, args) < 0)
|
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return 0;
|
1998-11-25 12:18:00 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
err:
|
|
|
|
Py_XDECREF(repr);
|
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-17 15:39:25 -03:00
|
|
|
#ifdef Py_USING_UNICODE
|
2000-12-18 22:08:38 -04:00
|
|
|
/* A copy of PyUnicode_EncodeRawUnicodeEscape() that also translates
|
|
|
|
backslash and newline characters to \uXXXX escapes. */
|
|
|
|
static PyObject *
|
|
|
|
modified_EncodeRawUnicodeEscape(const Py_UNICODE *s, int size)
|
|
|
|
{
|
2002-04-01 13:40:08 -04:00
|
|
|
PyObject *repr;
|
|
|
|
char *p;
|
|
|
|
char *q;
|
|
|
|
|
|
|
|
static const char *hexdigit = "0123456789ABCDEF";
|
|
|
|
|
|
|
|
repr = PyString_FromStringAndSize(NULL, 6 * size);
|
|
|
|
if (repr == NULL)
|
|
|
|
return NULL;
|
|
|
|
if (size == 0)
|
|
|
|
return repr;
|
|
|
|
|
|
|
|
p = q = PyString_AS_STRING(repr);
|
|
|
|
while (size-- > 0) {
|
|
|
|
Py_UNICODE ch = *s++;
|
|
|
|
/* Map 16-bit characters to '\uxxxx' */
|
|
|
|
if (ch >= 256 || ch == '\\' || ch == '\n') {
|
|
|
|
*p++ = '\\';
|
|
|
|
*p++ = 'u';
|
|
|
|
*p++ = hexdigit[(ch >> 12) & 0xf];
|
|
|
|
*p++ = hexdigit[(ch >> 8) & 0xf];
|
|
|
|
*p++ = hexdigit[(ch >> 4) & 0xf];
|
|
|
|
*p++ = hexdigit[ch & 15];
|
|
|
|
}
|
|
|
|
/* Copy everything else as-is */
|
|
|
|
else
|
|
|
|
*p++ = (char) ch;
|
|
|
|
}
|
|
|
|
*p = '\0';
|
2002-04-27 15:44:32 -03:00
|
|
|
_PyString_Resize(&repr, p - q);
|
2000-12-18 22:08:38 -04:00
|
|
|
return repr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-10 19:11:40 -04:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
save_unicode(Picklerobject *self, PyObject *args, int doput)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
int size, len;
|
|
|
|
PyObject *repr=0;
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!PyUnicode_Check(args))
|
|
|
|
return -1;
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!self->bin) {
|
|
|
|
char *repr_str;
|
|
|
|
static char string = UNICODE;
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
repr = modified_EncodeRawUnicodeEscape(
|
|
|
|
PyUnicode_AS_UNICODE(args), PyUnicode_GET_SIZE(args));
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!repr)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((len = PyString_Size(repr)) < 0)
|
|
|
|
goto err;
|
|
|
|
repr_str = PyString_AS_STRING((PyStringObject *)repr);
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, &string, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto err;
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, repr_str, len) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto err;
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, "\n", 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto err;
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_XDECREF(repr);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int i;
|
|
|
|
char c_str[5];
|
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( repr = PyUnicode_AsUTF8String(args)))
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if ((size = PyString_Size(repr)) < 0)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
c_str[0] = BINUNICODE;
|
|
|
|
for (i = 1; i < 5; i++)
|
|
|
|
c_str[i] = (int)(size >> ((i - 1) * 8));
|
|
|
|
len = 5;
|
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, c_str, len) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
if (size > 128 && Pdata_Check(self->file)) {
|
|
|
|
if (write_other(self, NULL, 0) < 0)
|
|
|
|
goto err;
|
|
|
|
PDATA_APPEND(self->file, repr, -1);
|
|
|
|
}
|
|
|
|
else {
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, PyString_AS_STRING(repr),
|
|
|
|
size) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
Py_DECREF(repr);
|
|
|
|
}
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (doput)
|
|
|
|
if (put(self, args) < 0)
|
|
|
|
return -1;
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return 0;
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
err:
|
|
|
|
Py_XDECREF(repr);
|
|
|
|
return -1;
|
2000-03-10 19:11:40 -04:00
|
|
|
}
|
2001-08-17 15:39:25 -03:00
|
|
|
#endif
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2003-02-02 16:29:39 -04:00
|
|
|
/* A helper for save_tuple. Push the len elements in tuple t on the stack. */
|
|
|
|
static int
|
2003-02-04 23:46:17 -04:00
|
|
|
store_tuple_elements(Picklerobject *self, PyObject *t, int len)
|
2003-02-02 16:29:39 -04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int res = -1; /* guilty until proved innocent */
|
|
|
|
|
|
|
|
assert(PyTuple_Size(t) == len);
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2003-02-02 16:29:39 -04:00
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
PyObject *element = PyTuple_GET_ITEM(t, i);
|
|
|
|
|
|
|
|
if (element == NULL)
|
|
|
|
goto finally;
|
|
|
|
if (save(self, element, 0) < 0)
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
res = 0;
|
|
|
|
|
|
|
|
finally:
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Tuples are ubiquitous in the pickle protocols, so many techniques are
|
|
|
|
* used across protocols to minimize the space needed to pickle them.
|
2003-02-04 23:46:17 -04:00
|
|
|
* Tuples are also the only builtin immutable type that can be recursive
|
2003-02-02 16:29:39 -04:00
|
|
|
* (a tuple can be reached from itself), and that requires some subtle
|
|
|
|
* magic so that it works in all cases. IOW, this is a long routine.
|
|
|
|
*/
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
save_tuple(Picklerobject *self, PyObject *args)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2003-02-02 16:29:39 -04:00
|
|
|
PyObject *py_tuple_id = NULL;
|
|
|
|
int len, i;
|
|
|
|
int res = -1;
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
static char tuple = TUPLE;
|
2003-02-02 16:29:39 -04:00
|
|
|
static char pop = POP;
|
|
|
|
static char pop_mark = POP_MARK;
|
|
|
|
static char len2opcode[] = {EMPTY_TUPLE, TUPLE1, TUPLE2, TUPLE3};
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((len = PyTuple_Size(args)) < 0)
|
|
|
|
goto finally;
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2003-02-02 16:29:39 -04:00
|
|
|
if (len == 0) {
|
|
|
|
char c_str[2];
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2003-02-02 16:29:39 -04:00
|
|
|
if (self->proto) {
|
|
|
|
c_str[0] = EMPTY_TUPLE;
|
|
|
|
len = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
c_str[0] = MARK;
|
|
|
|
c_str[1] = TUPLE;
|
|
|
|
len = 2;
|
|
|
|
}
|
|
|
|
if (self->write_func(self, c_str, len) >= 0)
|
|
|
|
res = 0;
|
|
|
|
/* Don't memoize an empty tuple. */
|
|
|
|
goto finally;
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2003-02-02 16:29:39 -04:00
|
|
|
/* A non-empty tuple. */
|
|
|
|
|
|
|
|
/* id(tuple) isn't in the memo now. If it shows up there after
|
|
|
|
* saving the tuple elements, the tuple must be recursive, in
|
|
|
|
* which case we'll pop everything we put on the stack, and fetch
|
|
|
|
* its value from the memo.
|
|
|
|
*/
|
|
|
|
py_tuple_id = PyLong_FromVoidPtr(args);
|
|
|
|
if (py_tuple_id == NULL)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 16:29:39 -04:00
|
|
|
if (len <= 3 && self->proto >= 2) {
|
|
|
|
/* Use TUPLE{1,2,3} opcodes. */
|
2003-02-04 23:46:17 -04:00
|
|
|
if (store_tuple_elements(self, args, len) < 0)
|
2003-02-02 16:29:39 -04:00
|
|
|
goto finally;
|
2002-04-01 13:40:08 -04:00
|
|
|
if (PyDict_GetItem(self->memo, py_tuple_id)) {
|
2003-02-02 16:29:39 -04:00
|
|
|
/* pop the len elements */
|
|
|
|
for (i = 0; i < len; ++i)
|
|
|
|
if (self->write_func(self, &pop, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
2003-02-02 16:29:39 -04:00
|
|
|
/* fetch from memo */
|
2002-04-01 13:40:08 -04:00
|
|
|
if (get(self, py_tuple_id) < 0)
|
|
|
|
goto finally;
|
|
|
|
res = 0;
|
|
|
|
goto finally;
|
|
|
|
}
|
2003-02-02 16:29:39 -04:00
|
|
|
/* Not recursive. */
|
|
|
|
if (self->write_func(self, len2opcode + len, 1) < 0)
|
|
|
|
goto finally;
|
|
|
|
goto memoize;
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 16:29:39 -04:00
|
|
|
/* proto < 2 and len > 0, or proto >= 2 and len > 3.
|
|
|
|
* Generate MARK elt1 elt2 ... TUPLE
|
|
|
|
*/
|
|
|
|
if (self->write_func(self, &MARKv, 1) < 0)
|
|
|
|
goto finally;
|
|
|
|
|
2003-02-04 23:46:17 -04:00
|
|
|
if (store_tuple_elements(self, args, len) < 0)
|
2003-02-02 16:29:39 -04:00
|
|
|
goto finally;
|
|
|
|
|
|
|
|
if (PyDict_GetItem(self->memo, py_tuple_id)) {
|
|
|
|
/* pop the stack stuff we pushed */
|
|
|
|
if (self->bin) {
|
|
|
|
if (self->write_func(self, &pop_mark, 1) < 0)
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Note that we pop one more than len, to remove
|
|
|
|
* the MARK too.
|
|
|
|
*/
|
|
|
|
for (i = 0; i <= len; i++)
|
|
|
|
if (self->write_func(self, &pop, 1) < 0)
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
/* fetch from memo */
|
|
|
|
if (get(self, py_tuple_id) >= 0)
|
|
|
|
res = 0;
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 16:29:39 -04:00
|
|
|
/* Not recursive. */
|
|
|
|
if (self->write_func(self, &tuple, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2003-02-02 16:29:39 -04:00
|
|
|
memoize:
|
|
|
|
if (put(self, args) >= 0)
|
|
|
|
res = 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
finally:
|
|
|
|
Py_XDECREF(py_tuple_id);
|
|
|
|
return res;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
2003-02-11 17:06:20 -04:00
|
|
|
/* iter is an iterator giving items, and we batch up chunks of
|
|
|
|
* MARK item item ... item APPENDS
|
|
|
|
* opcode sequences. Calling code should have arranged to first create an
|
|
|
|
* empty list, or list-like object, for the APPENDS to operate on.
|
|
|
|
* Returns 0 on success, <0 on error.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
batch_list(Picklerobject *self, PyObject *iter)
|
|
|
|
{
|
|
|
|
PyObject *obj;
|
|
|
|
PyObject *slice[BATCHSIZE];
|
|
|
|
int i, n;
|
|
|
|
|
|
|
|
static char append = APPEND;
|
|
|
|
static char appends = APPENDS;
|
|
|
|
|
|
|
|
assert(iter != NULL);
|
|
|
|
|
|
|
|
if (self->proto == 0) {
|
|
|
|
/* APPENDS isn't available; do one at a time. */
|
|
|
|
for (;;) {
|
|
|
|
obj = PyIter_Next(iter);
|
|
|
|
if (obj == NULL) {
|
|
|
|
if (PyErr_Occurred())
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i = save(self, obj, 0);
|
|
|
|
Py_DECREF(obj);
|
|
|
|
if (i < 0)
|
|
|
|
return -1;
|
|
|
|
if (self->write_func(self, &append, 1) < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* proto > 0: write in batches of BATCHSIZE. */
|
|
|
|
do {
|
|
|
|
/* Get next group of (no more than) BATCHSIZE elements. */
|
|
|
|
for (n = 0; n < BATCHSIZE; ++n) {
|
|
|
|
obj = PyIter_Next(iter);
|
|
|
|
if (obj == NULL) {
|
|
|
|
if (PyErr_Occurred())
|
|
|
|
goto BatchFailed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
slice[n] = obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n > 1) {
|
|
|
|
/* Pump out MARK, slice[0:n], APPENDS. */
|
|
|
|
if (self->write_func(self, &MARKv, 1) < 0)
|
|
|
|
goto BatchFailed;
|
|
|
|
for (i = 0; i < n; ++i) {
|
|
|
|
if (save(self, slice[i], 0) < 0)
|
|
|
|
goto BatchFailed;
|
|
|
|
}
|
|
|
|
if (self->write_func(self, &appends, 1) < 0)
|
|
|
|
goto BatchFailed;
|
|
|
|
}
|
|
|
|
else if (n == 1) {
|
|
|
|
if (save(self, slice[0], 0) < 0)
|
|
|
|
goto BatchFailed;
|
|
|
|
if (self->write_func(self, &append, 1) < 0)
|
|
|
|
goto BatchFailed;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < n; ++i) {
|
|
|
|
Py_DECREF(slice[i]);
|
|
|
|
}
|
2003-02-12 01:28:58 -04:00
|
|
|
} while (n == BATCHSIZE);
|
2003-02-11 17:06:20 -04:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
BatchFailed:
|
|
|
|
while (--n >= 0) {
|
|
|
|
Py_DECREF(slice[n]);
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
save_list(Picklerobject *self, PyObject *args)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2003-02-11 17:06:20 -04:00
|
|
|
int res = -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
char s[3];
|
2003-02-11 17:06:20 -04:00
|
|
|
int len;
|
|
|
|
PyObject *iter;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (self->fast && !fast_save_enter(self, args))
|
|
|
|
goto finally;
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
|
2003-02-11 17:06:20 -04:00
|
|
|
/* Create an empty list. */
|
2002-04-01 13:40:08 -04:00
|
|
|
if (self->bin) {
|
|
|
|
s[0] = EMPTY_LIST;
|
2003-02-11 17:06:20 -04:00
|
|
|
len = 1;
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
s[0] = MARK;
|
|
|
|
s[1] = LIST;
|
2003-02-11 17:06:20 -04:00
|
|
|
len = 2;
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-11 17:06:20 -04:00
|
|
|
if (self->write_func(self, s, len) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-11 17:06:20 -04:00
|
|
|
/* Get list length, and bow out early if empty. */
|
|
|
|
if ((len = PyList_Size(args)) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-11 17:06:20 -04:00
|
|
|
/* Memoize. */
|
2002-04-01 13:40:08 -04:00
|
|
|
if (len == 0) {
|
2003-02-12 01:28:58 -04:00
|
|
|
if (put(self, args) >= 0)
|
|
|
|
res = 0;
|
|
|
|
goto finally;
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
2003-02-12 01:28:58 -04:00
|
|
|
if (put2(self, args) < 0)
|
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-11 17:06:20 -04:00
|
|
|
/* Materialize the list elements. */
|
|
|
|
iter = PyObject_GetIter(args);
|
|
|
|
if (iter == NULL)
|
|
|
|
goto finally;
|
|
|
|
res = batch_list(self, iter);
|
|
|
|
Py_DECREF(iter);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
finally:
|
|
|
|
if (self->fast && !fast_save_leave(self, args))
|
|
|
|
res = -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return res;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
2003-02-11 18:43:24 -04:00
|
|
|
/* iter is an iterator giving (key, value) pairs, and we batch up chunks of
|
|
|
|
* MARK key value ... key value SETITEMS
|
|
|
|
* opcode sequences. Calling code should have arranged to first create an
|
|
|
|
* empty dict, or dict-like object, for the SETITEMS to operate on.
|
|
|
|
* Returns 0 on success, <0 on error.
|
|
|
|
*
|
|
|
|
* This is very much like batch_list(). The difference between saving
|
|
|
|
* elements directly, and picking apart two-tuples, is so long-winded at
|
|
|
|
* the C level, though, that attempts to combine these routines were too
|
|
|
|
* ugly to bear.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
batch_dict(Picklerobject *self, PyObject *iter)
|
|
|
|
{
|
|
|
|
PyObject *p;
|
|
|
|
PyObject *slice[BATCHSIZE];
|
|
|
|
int i, n;
|
|
|
|
|
|
|
|
static char setitem = SETITEM;
|
|
|
|
static char setitems = SETITEMS;
|
|
|
|
|
|
|
|
assert(iter != NULL);
|
|
|
|
|
|
|
|
if (self->proto == 0) {
|
|
|
|
/* SETITEMS isn't available; do one at a time. */
|
|
|
|
for (;;) {
|
|
|
|
p = PyIter_Next(iter);
|
|
|
|
if (p == NULL) {
|
|
|
|
if (PyErr_Occurred())
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!PyTuple_Check(p) || PyTuple_Size(p) != 2) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "dict items "
|
|
|
|
"iterator must return 2-tuples");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
i = save(self, PyTuple_GET_ITEM(p, 0), 0);
|
|
|
|
if (i >= 0)
|
|
|
|
i = save(self, PyTuple_GET_ITEM(p, 1), 0);
|
|
|
|
Py_DECREF(p);
|
|
|
|
if (i < 0)
|
|
|
|
return -1;
|
|
|
|
if (self->write_func(self, &setitem, 1) < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* proto > 0: write in batches of BATCHSIZE. */
|
|
|
|
do {
|
|
|
|
/* Get next group of (no more than) BATCHSIZE elements. */
|
|
|
|
for (n = 0; n < BATCHSIZE; ++n) {
|
|
|
|
p = PyIter_Next(iter);
|
|
|
|
if (p == NULL) {
|
|
|
|
if (PyErr_Occurred())
|
|
|
|
goto BatchFailed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!PyTuple_Check(p) || PyTuple_Size(p) != 2) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "dict items "
|
|
|
|
"iterator must return 2-tuples");
|
|
|
|
goto BatchFailed;
|
|
|
|
}
|
|
|
|
slice[n] = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n > 1) {
|
|
|
|
/* Pump out MARK, slice[0:n], SETITEMS. */
|
|
|
|
if (self->write_func(self, &MARKv, 1) < 0)
|
|
|
|
goto BatchFailed;
|
|
|
|
for (i = 0; i < n; ++i) {
|
|
|
|
p = slice[i];
|
|
|
|
if (save(self, PyTuple_GET_ITEM(p, 0), 0) < 0)
|
|
|
|
goto BatchFailed;
|
|
|
|
if (save(self, PyTuple_GET_ITEM(p, 1), 0) < 0)
|
|
|
|
goto BatchFailed;
|
|
|
|
}
|
|
|
|
if (self->write_func(self, &setitems, 1) < 0)
|
|
|
|
goto BatchFailed;
|
|
|
|
}
|
|
|
|
else if (n == 1) {
|
|
|
|
p = slice[0];
|
|
|
|
if (save(self, PyTuple_GET_ITEM(p, 0), 0) < 0)
|
|
|
|
goto BatchFailed;
|
|
|
|
if (save(self, PyTuple_GET_ITEM(p, 1), 0) < 0)
|
|
|
|
goto BatchFailed;
|
|
|
|
if (self->write_func(self, &setitem, 1) < 0)
|
|
|
|
goto BatchFailed;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < n; ++i) {
|
|
|
|
Py_DECREF(slice[i]);
|
|
|
|
}
|
2003-02-12 01:28:58 -04:00
|
|
|
} while (n == BATCHSIZE);
|
2003-02-11 18:43:24 -04:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
BatchFailed:
|
|
|
|
while (--n >= 0) {
|
|
|
|
Py_DECREF(slice[n]);
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
save_dict(Picklerobject *self, PyObject *args)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2003-02-11 18:43:24 -04:00
|
|
|
int res = -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
char s[3];
|
2003-02-11 18:43:24 -04:00
|
|
|
int len;
|
|
|
|
PyObject *iter;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (self->fast && !fast_save_enter(self, args))
|
|
|
|
goto finally;
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
|
2003-02-11 18:43:24 -04:00
|
|
|
/* Create an empty dict. */
|
2002-04-01 13:40:08 -04:00
|
|
|
if (self->bin) {
|
|
|
|
s[0] = EMPTY_DICT;
|
|
|
|
len = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
s[0] = MARK;
|
|
|
|
s[1] = DICT;
|
|
|
|
len = 2;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, s, len) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-11 18:43:24 -04:00
|
|
|
/* Get dict size, and bow out early if empty. */
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((len = PyDict_Size(args)) < 0)
|
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (len == 0) {
|
2003-02-12 01:28:58 -04:00
|
|
|
if (put(self, args) >= 0)
|
|
|
|
res = 0;
|
|
|
|
goto finally;
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
2003-02-12 01:28:58 -04:00
|
|
|
if (put2(self, args) < 0)
|
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-11 18:43:24 -04:00
|
|
|
/* Materialize the dict items. */
|
|
|
|
iter = PyObject_CallMethod(args, "iteritems", "()");
|
|
|
|
if (iter == NULL)
|
|
|
|
goto finally;
|
|
|
|
res = batch_dict(self, iter);
|
|
|
|
Py_DECREF(iter);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
finally:
|
|
|
|
if (self->fast && !fast_save_leave(self, args))
|
|
|
|
res = -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return res;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
2001-03-17 00:50:51 -04:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
save_inst(Picklerobject *self, PyObject *args)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *class = 0, *module = 0, *name = 0, *state = 0,
|
|
|
|
*getinitargs_func = 0, *getstate_func = 0, *class_args = 0;
|
|
|
|
char *module_str, *name_str;
|
|
|
|
int module_size, name_size, res = -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
static char inst = INST, obj = OBJ, build = BUILD;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (self->fast && !fast_save_enter(self, args))
|
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, &MARKv, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( class = PyObject_GetAttr(args, __class___str)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (self->bin) {
|
|
|
|
if (save(self, class, 0) < 0)
|
|
|
|
goto finally;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((getinitargs_func = PyObject_GetAttr(args, __getinitargs___str))) {
|
|
|
|
PyObject *element = 0;
|
|
|
|
int i, len;
|
1998-11-25 12:18:00 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!( class_args =
|
2003-02-01 02:24:36 -04:00
|
|
|
PyObject_Call(getinitargs_func, empty_tuple, NULL)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((len = PyObject_Size(class_args)) < 0)
|
|
|
|
goto finally;
|
1998-11-25 12:18:00 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
for (i = 0; i < len; i++) {
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( element = PySequence_GetItem(class_args, i)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (save(self, element, 0) < 0) {
|
|
|
|
Py_DECREF(element);
|
|
|
|
goto finally;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_DECREF(element);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2003-06-16 17:19:49 -03:00
|
|
|
if (PyErr_ExceptionMatches(PyExc_AttributeError))
|
|
|
|
PyErr_Clear();
|
|
|
|
else
|
|
|
|
goto finally;
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!self->bin) {
|
|
|
|
if (!( name = ((PyClassObject *)class)->cl_name )) {
|
|
|
|
PyErr_SetString(PicklingError, "class has no name");
|
|
|
|
goto finally;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( module = whichmodule(class, name)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((module_size = PyString_Size(module)) < 0 ||
|
|
|
|
(name_size = PyString_Size(name)) < 0)
|
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
module_str = PyString_AS_STRING((PyStringObject *)module);
|
|
|
|
name_str = PyString_AS_STRING((PyStringObject *)name);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, &inst, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, module_str, module_size) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, "\n", 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, name_str, name_size) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, "\n", 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
|
|
|
}
|
2003-02-02 14:29:33 -04:00
|
|
|
else if (self->write_func(self, &obj, 1) < 0) {
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
|
|
|
}
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((getstate_func = PyObject_GetAttr(args, __getstate___str))) {
|
|
|
|
state = PyObject_Call(getstate_func, empty_tuple, NULL);
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!state)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
else {
|
2003-06-16 17:19:49 -03:00
|
|
|
if (PyErr_ExceptionMatches(PyExc_AttributeError))
|
|
|
|
PyErr_Clear();
|
|
|
|
else
|
|
|
|
goto finally;
|
2002-04-01 13:40:08 -04:00
|
|
|
|
|
|
|
if (!( state = PyObject_GetAttr(args, __dict___str))) {
|
2003-06-16 17:19:49 -03:00
|
|
|
if (PyErr_ExceptionMatches(PyExc_AttributeError))
|
|
|
|
PyErr_Clear();
|
|
|
|
else
|
|
|
|
goto finally;
|
2002-04-01 13:40:08 -04:00
|
|
|
res = 0;
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!PyDict_Check(state)) {
|
|
|
|
if (put2(self, args) < 0)
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (put(self, args) < 0)
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (save(self, state, 0) < 0)
|
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, &build, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
res = 0;
|
|
|
|
|
|
|
|
finally:
|
|
|
|
if (self->fast && !fast_save_leave(self, args))
|
|
|
|
res = -1;
|
|
|
|
|
|
|
|
Py_XDECREF(module);
|
|
|
|
Py_XDECREF(class);
|
|
|
|
Py_XDECREF(state);
|
|
|
|
Py_XDECREF(getinitargs_func);
|
|
|
|
Py_XDECREF(getstate_func);
|
|
|
|
Py_XDECREF(class_args);
|
|
|
|
|
|
|
|
return res;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
save_global(Picklerobject *self, PyObject *args, PyObject *name)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2002-07-11 19:02:33 -03:00
|
|
|
PyObject *global_name = 0, *module = 0, *mod = 0, *klass = 0;
|
2002-04-01 13:40:08 -04:00
|
|
|
char *name_str, *module_str;
|
|
|
|
int module_size, name_size, res = -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
static char global = GLOBAL;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (name) {
|
|
|
|
global_name = name;
|
|
|
|
Py_INCREF(global_name);
|
|
|
|
}
|
|
|
|
else {
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( global_name = PyObject_GetAttr(args, __name___str)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
|
|
|
}
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( module = whichmodule(args, global_name)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((module_size = PyString_Size(module)) < 0 ||
|
|
|
|
(name_size = PyString_Size(global_name)) < 0)
|
|
|
|
goto finally;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
module_str = PyString_AS_STRING((PyStringObject *)module);
|
|
|
|
name_str = PyString_AS_STRING((PyStringObject *)global_name);
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-12-24 14:10:07 -04:00
|
|
|
/* XXX This can be doing a relative import. Clearly it shouldn't,
|
|
|
|
but I don't know how to stop it. :-( */
|
2002-04-01 13:40:08 -04:00
|
|
|
mod = PyImport_ImportModule(module_str);
|
|
|
|
if (mod == NULL) {
|
|
|
|
cPickle_ErrFormat(PicklingError,
|
2003-02-18 16:50:45 -04:00
|
|
|
"Can't pickle %s: import of module %s "
|
|
|
|
"failed",
|
|
|
|
"OS", args, module);
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
|
|
|
}
|
2002-07-11 19:01:40 -03:00
|
|
|
klass = PyObject_GetAttrString(mod, name_str);
|
2002-04-01 13:40:08 -04:00
|
|
|
if (klass == NULL) {
|
|
|
|
cPickle_ErrFormat(PicklingError,
|
2003-02-18 16:50:45 -04:00
|
|
|
"Can't pickle %s: attribute lookup %s.%s "
|
|
|
|
"failed",
|
2002-04-01 13:40:08 -04:00
|
|
|
"OSS", args, module, global_name);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
if (klass != args) {
|
2002-07-11 19:01:40 -03:00
|
|
|
Py_DECREF(klass);
|
2002-04-01 13:40:08 -04:00
|
|
|
cPickle_ErrFormat(PicklingError,
|
2003-02-04 16:56:09 -04:00
|
|
|
"Can't pickle %s: it's not the same object "
|
|
|
|
"as %s.%s",
|
2002-04-01 13:40:08 -04:00
|
|
|
"OSS", args, module, global_name);
|
|
|
|
goto finally;
|
|
|
|
}
|
2002-07-11 19:01:40 -03:00
|
|
|
Py_DECREF(klass);
|
2002-04-01 13:40:08 -04:00
|
|
|
|
2003-02-04 16:56:09 -04:00
|
|
|
if (self->proto >= 2) {
|
|
|
|
/* See whether this is in the extension registry, and if
|
|
|
|
* so generate an EXT opcode.
|
|
|
|
*/
|
|
|
|
PyObject *py_code; /* extension code as Python object */
|
2003-02-04 17:47:44 -04:00
|
|
|
long code; /* extension code as C value */
|
2003-02-04 16:56:09 -04:00
|
|
|
char c_str[5];
|
|
|
|
int n;
|
|
|
|
|
|
|
|
PyTuple_SET_ITEM(two_tuple, 0, module);
|
|
|
|
PyTuple_SET_ITEM(two_tuple, 1, global_name);
|
|
|
|
py_code = PyDict_GetItem(extension_registry, two_tuple);
|
|
|
|
if (py_code == NULL)
|
|
|
|
goto gen_global; /* not registered */
|
|
|
|
|
|
|
|
/* Verify py_code has the right type and value. */
|
|
|
|
if (!PyInt_Check(py_code)) {
|
|
|
|
cPickle_ErrFormat(PicklingError, "Can't pickle %s: "
|
2003-02-04 23:53:10 -04:00
|
|
|
"extension code %s isn't an integer",
|
2003-02-04 16:56:09 -04:00
|
|
|
"OO", args, py_code);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
code = PyInt_AS_LONG(py_code);
|
|
|
|
if (code <= 0 || code > 0x7fffffffL) {
|
|
|
|
cPickle_ErrFormat(PicklingError, "Can't pickle %s: "
|
|
|
|
"extension code %ld is out of range",
|
|
|
|
"Ol", args, code);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate an EXT opcode. */
|
|
|
|
if (code <= 0xff) {
|
|
|
|
c_str[0] = EXT1;
|
|
|
|
c_str[1] = (char)code;
|
|
|
|
n = 2;
|
|
|
|
}
|
|
|
|
else if (code <= 0xffff) {
|
|
|
|
c_str[0] = EXT2;
|
|
|
|
c_str[1] = (char)(code & 0xff);
|
|
|
|
c_str[2] = (char)((code >> 8) & 0xff);
|
|
|
|
n = 3;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
c_str[0] = EXT4;
|
|
|
|
c_str[1] = (char)(code & 0xff);
|
|
|
|
c_str[2] = (char)((code >> 8) & 0xff);
|
|
|
|
c_str[3] = (char)((code >> 16) & 0xff);
|
|
|
|
c_str[4] = (char)((code >> 24) & 0xff);
|
|
|
|
n = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (self->write_func(self, c_str, n) >= 0)
|
|
|
|
res = 0;
|
|
|
|
goto finally; /* and don't memoize */
|
|
|
|
}
|
|
|
|
|
|
|
|
gen_global:
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, &global, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, module_str, module_size) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, "\n", 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, name_str, name_size) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, "\n", 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (put(self, args) < 0)
|
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
res = 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
finally:
|
|
|
|
Py_XDECREF(module);
|
|
|
|
Py_XDECREF(global_name);
|
|
|
|
Py_XDECREF(mod);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2001-03-17 00:50:51 -04:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
save_pers(Picklerobject *self, PyObject *args, PyObject *f)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *pid = 0;
|
|
|
|
int size, res = -1;
|
|
|
|
|
|
|
|
static char persid = PERSID, binpersid = BINPERSID;
|
|
|
|
|
|
|
|
Py_INCREF(args);
|
|
|
|
ARG_TUP(self, args);
|
|
|
|
if (self->arg) {
|
|
|
|
pid = PyObject_Call(f, self->arg, NULL);
|
|
|
|
FREE_ARG_TUP(self);
|
|
|
|
}
|
|
|
|
if (! pid) return -1;
|
|
|
|
|
|
|
|
if (pid != Py_None) {
|
|
|
|
if (!self->bin) {
|
|
|
|
if (!PyString_Check(pid)) {
|
|
|
|
PyErr_SetString(PicklingError,
|
|
|
|
"persistent id must be string");
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, &persid, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
|
|
|
|
|
|
|
if ((size = PyString_Size(pid)) < 0)
|
|
|
|
goto finally;
|
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self,
|
|
|
|
PyString_AS_STRING(
|
|
|
|
(PyStringObject *)pid),
|
|
|
|
size) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, "\n", 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
|
|
|
|
|
|
|
res = 1;
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
else if (save(self, pid, 1) >= 0) {
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->write_func(self, &binpersid, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
res = -1;
|
|
|
|
else
|
|
|
|
res = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
finally:
|
|
|
|
Py_XDECREF(pid);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return res;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-14 19:05:28 -04:00
|
|
|
/* We're saving ob, and args is the 2-thru-5 tuple returned by the
|
|
|
|
* appropriate __reduce__ method for ob.
|
|
|
|
*/
|
2002-04-01 13:40:08 -04:00
|
|
|
static int
|
2003-02-14 19:05:28 -04:00
|
|
|
save_reduce(Picklerobject *self, PyObject *args, PyObject *ob)
|
|
|
|
{
|
|
|
|
PyObject *callable;
|
|
|
|
PyObject *argtup;
|
|
|
|
PyObject *state = NULL;
|
|
|
|
PyObject *listitems = NULL;
|
|
|
|
PyObject *dictitems = NULL;
|
|
|
|
|
|
|
|
int use_newobj = self->proto >= 2;
|
|
|
|
|
|
|
|
static char reduce = REDUCE;
|
|
|
|
static char build = BUILD;
|
|
|
|
static char newobj = NEWOBJ;
|
|
|
|
|
|
|
|
if (! PyArg_UnpackTuple(args, "save_reduce", 2, 5,
|
|
|
|
&callable,
|
|
|
|
&argtup,
|
|
|
|
&state,
|
|
|
|
&listitems,
|
|
|
|
&dictitems))
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
|
2004-12-07 03:05:57 -04:00
|
|
|
if (!PyTuple_Check(argtup)) {
|
|
|
|
PyErr_SetString(PicklingError,
|
|
|
|
"args from reduce() should be a tuple");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2003-02-14 19:05:28 -04:00
|
|
|
if (state == Py_None)
|
|
|
|
state = NULL;
|
|
|
|
if (listitems == Py_None)
|
|
|
|
listitems = NULL;
|
|
|
|
if (dictitems == Py_None)
|
|
|
|
dictitems = NULL;
|
2002-04-01 13:40:08 -04:00
|
|
|
|
2003-02-14 19:05:28 -04:00
|
|
|
/* Protocol 2 special case: if callable's name is __newobj__, use
|
|
|
|
* NEWOBJ. This consumes a lot of code.
|
|
|
|
*/
|
|
|
|
if (use_newobj) {
|
|
|
|
PyObject *temp = PyObject_GetAttr(callable, __name___str);
|
|
|
|
|
|
|
|
if (temp == NULL) {
|
2003-06-16 17:19:49 -03:00
|
|
|
if (PyErr_ExceptionMatches(PyExc_AttributeError))
|
|
|
|
PyErr_Clear();
|
|
|
|
else
|
|
|
|
return -1;
|
2003-02-14 19:05:28 -04:00
|
|
|
use_newobj = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
use_newobj = PyString_Check(temp) &&
|
|
|
|
strcmp(PyString_AS_STRING(temp),
|
|
|
|
"__newobj__") == 0;
|
|
|
|
Py_DECREF(temp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (use_newobj) {
|
|
|
|
PyObject *cls;
|
|
|
|
PyObject *newargtup;
|
|
|
|
int n, i;
|
|
|
|
|
|
|
|
/* Sanity checks. */
|
|
|
|
n = PyTuple_Size(argtup);
|
|
|
|
if (n < 1) {
|
|
|
|
PyErr_SetString(PicklingError, "__newobj__ arglist "
|
|
|
|
"is empty");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
cls = PyTuple_GET_ITEM(argtup, 0);
|
|
|
|
if (! PyObject_HasAttrString(cls, "__new__")) {
|
|
|
|
PyErr_SetString(PicklingError, "args[0] from "
|
|
|
|
"__newobj__ args has no __new__");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX How could ob be NULL? */
|
|
|
|
if (ob != NULL) {
|
|
|
|
PyObject *ob_dot_class;
|
2002-04-01 13:40:08 -04:00
|
|
|
|
2003-02-14 19:05:28 -04:00
|
|
|
ob_dot_class = PyObject_GetAttr(ob, __class___str);
|
2003-06-16 17:19:49 -03:00
|
|
|
if (ob_dot_class == NULL) {
|
|
|
|
if (PyErr_ExceptionMatches(
|
|
|
|
PyExc_AttributeError))
|
|
|
|
PyErr_Clear();
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
2003-02-14 19:05:28 -04:00
|
|
|
i = ob_dot_class != cls; /* true iff a problem */
|
|
|
|
Py_XDECREF(ob_dot_class);
|
|
|
|
if (i) {
|
|
|
|
PyErr_SetString(PicklingError, "args[0] from "
|
|
|
|
"__newobj__ args has the wrong class");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save the class and its __new__ arguments. */
|
|
|
|
if (save(self, cls, 0) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
newargtup = PyTuple_New(n-1); /* argtup[1:] */
|
|
|
|
if (newargtup == NULL)
|
|
|
|
return -1;
|
|
|
|
for (i = 1; i < n; ++i) {
|
|
|
|
PyObject *temp = PyTuple_GET_ITEM(argtup, i);
|
|
|
|
Py_INCREF(temp);
|
|
|
|
PyTuple_SET_ITEM(newargtup, i-1, temp);
|
|
|
|
}
|
|
|
|
i = save(self, newargtup, 0) < 0;
|
|
|
|
Py_DECREF(newargtup);
|
|
|
|
if (i < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* Add NEWOBJ opcode. */
|
|
|
|
if (self->write_func(self, &newobj, 1) < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Not using NEWOBJ. */
|
|
|
|
if (save(self, callable, 0) < 0 ||
|
|
|
|
save(self, argtup, 0) < 0 ||
|
|
|
|
self->write_func(self, &reduce, 1) < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Memoize. */
|
|
|
|
/* XXX How can ob be NULL? */
|
2002-04-01 13:40:08 -04:00
|
|
|
if (ob != NULL) {
|
|
|
|
if (state && !PyDict_Check(state)) {
|
|
|
|
if (put2(self, ob) < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
2003-02-14 19:05:28 -04:00
|
|
|
else if (put(self, ob) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
}
|
2001-03-17 00:50:51 -04:00
|
|
|
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-14 19:05:28 -04:00
|
|
|
if (listitems && batch_list(self, listitems) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (dictitems && batch_dict(self, dictitems) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (state) {
|
|
|
|
if (save(self, state, 0) < 0 ||
|
|
|
|
self->write_func(self, &build, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return 0;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-02 16:29:39 -04:00
|
|
|
save(Picklerobject *self, PyObject *args, int pers_save)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyTypeObject *type;
|
2003-02-14 19:05:28 -04:00
|
|
|
PyObject *py_ob_id = 0, *__reduce__ = 0, *t = 0;
|
|
|
|
PyObject *arg_tup;
|
|
|
|
int res = -1;
|
|
|
|
int tmp, size;
|
2002-04-01 13:40:08 -04:00
|
|
|
|
2002-08-04 05:20:23 -03:00
|
|
|
if (self->nesting++ > Py_GetRecursionLimit()){
|
|
|
|
PyErr_SetString(PyExc_RuntimeError,
|
|
|
|
"maximum recursion depth exceeded");
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!pers_save && self->pers_func) {
|
|
|
|
if ((tmp = save_pers(self, args, self->pers_func)) != 0) {
|
|
|
|
res = tmp;
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args == Py_None) {
|
|
|
|
res = save_none(self, args);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
|
|
|
|
type = args->ob_type;
|
|
|
|
|
|
|
|
switch (type->tp_name[0]) {
|
2002-04-03 18:41:51 -04:00
|
|
|
case 'b':
|
|
|
|
if (args == Py_False || args == Py_True) {
|
|
|
|
res = save_bool(self, args);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
break;
|
1997-04-09 14:36:32 -03:00
|
|
|
case 'i':
|
2002-04-01 13:40:08 -04:00
|
|
|
if (type == &PyInt_Type) {
|
|
|
|
res = save_int(self, args);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
break;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
|
|
|
case 'l':
|
2002-04-01 13:40:08 -04:00
|
|
|
if (type == &PyLong_Type) {
|
|
|
|
res = save_long(self, args);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
break;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
|
|
|
case 'f':
|
2002-04-01 13:40:08 -04:00
|
|
|
if (type == &PyFloat_Type) {
|
|
|
|
res = save_float(self, args);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
break;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
|
|
|
case 't':
|
2003-02-02 16:29:39 -04:00
|
|
|
if (type == &PyTuple_Type && PyTuple_Size(args) == 0) {
|
|
|
|
res = save_tuple(self, args);
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
break;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
|
|
|
case 's':
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((type == &PyString_Type) && (PyString_GET_SIZE(args) < 2)) {
|
|
|
|
res = save_string(self, args, 0);
|
|
|
|
goto finally;
|
|
|
|
}
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2001-08-17 15:39:25 -03:00
|
|
|
#ifdef Py_USING_UNICODE
|
2000-03-10 19:11:40 -04:00
|
|
|
case 'u':
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((type == &PyUnicode_Type) && (PyString_GET_SIZE(args) < 2)) {
|
|
|
|
res = save_unicode(self, args, 0);
|
|
|
|
goto finally;
|
|
|
|
}
|
2001-08-17 15:39:25 -03:00
|
|
|
#endif
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (args->ob_refcnt > 1) {
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( py_ob_id = PyLong_FromVoidPtr(args)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (PyDict_GetItem(self->memo, py_ob_id)) {
|
|
|
|
if (get(self, py_ob_id) < 0)
|
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
res = 0;
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
switch (type->tp_name[0]) {
|
1997-04-09 14:36:32 -03:00
|
|
|
case 's':
|
2002-04-01 13:40:08 -04:00
|
|
|
if (type == &PyString_Type) {
|
|
|
|
res = save_string(self, args, 1);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
break;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2001-08-17 15:39:25 -03:00
|
|
|
#ifdef Py_USING_UNICODE
|
2000-03-10 19:11:40 -04:00
|
|
|
case 'u':
|
2002-04-01 13:40:08 -04:00
|
|
|
if (type == &PyUnicode_Type) {
|
|
|
|
res = save_unicode(self, args, 1);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
break;
|
2001-08-17 15:39:25 -03:00
|
|
|
#endif
|
2000-03-10 19:11:40 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
case 't':
|
2002-04-01 13:40:08 -04:00
|
|
|
if (type == &PyTuple_Type) {
|
|
|
|
res = save_tuple(self, args);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
if (type == &PyType_Type) {
|
|
|
|
res = save_global(self, args, NULL);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
break;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
|
|
|
case 'l':
|
2002-04-01 13:40:08 -04:00
|
|
|
if (type == &PyList_Type) {
|
|
|
|
res = save_list(self, args);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
break;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
|
|
|
case 'd':
|
2002-04-01 13:40:08 -04:00
|
|
|
if (type == &PyDict_Type) {
|
|
|
|
res = save_dict(self, args);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
break;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
|
|
|
case 'i':
|
2002-04-01 13:40:08 -04:00
|
|
|
if (type == &PyInstance_Type) {
|
|
|
|
res = save_inst(self, args);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
break;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
|
|
|
case 'c':
|
2002-04-01 13:40:08 -04:00
|
|
|
if (type == &PyClass_Type) {
|
|
|
|
res = save_global(self, args, NULL);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
break;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
|
|
|
case 'f':
|
2002-04-01 13:40:08 -04:00
|
|
|
if (type == &PyFunction_Type) {
|
|
|
|
res = save_global(self, args, NULL);
|
2004-02-26 12:21:45 -04:00
|
|
|
if (res && PyErr_ExceptionMatches(PickleError)) {
|
|
|
|
/* fall back to reduce */
|
|
|
|
PyErr_Clear();
|
|
|
|
break;
|
|
|
|
}
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
break;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
|
|
|
case 'b':
|
2002-04-01 13:40:08 -04:00
|
|
|
if (type == &PyCFunction_Type) {
|
|
|
|
res = save_global(self, args, NULL);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pers_save && self->inst_pers_func) {
|
|
|
|
if ((tmp = save_pers(self, args, self->inst_pers_func)) != 0) {
|
|
|
|
res = tmp;
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-16 16:47:43 -03:00
|
|
|
if (PyType_IsSubtype(type, &PyType_Type)) {
|
|
|
|
res = save_global(self, args, NULL);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
|
2003-02-18 21:45:13 -04:00
|
|
|
/* Get a reduction callable, and call it. This may come from
|
|
|
|
* copy_reg.dispatch_table, the object's __reduce_ex__ method,
|
|
|
|
* or the object's __reduce__ method.
|
2003-02-14 19:05:28 -04:00
|
|
|
*/
|
2003-02-13 17:03:57 -04:00
|
|
|
__reduce__ = PyDict_GetItem(dispatch_table, (PyObject *)type);
|
|
|
|
if (__reduce__ != NULL) {
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_INCREF(__reduce__);
|
2003-02-18 21:45:13 -04:00
|
|
|
Py_INCREF(args);
|
|
|
|
ARG_TUP(self, args);
|
|
|
|
if (self->arg) {
|
|
|
|
t = PyObject_Call(__reduce__, self->arg, NULL);
|
|
|
|
FREE_ARG_TUP(self);
|
|
|
|
}
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
|
|
|
else {
|
2003-02-18 21:45:13 -04:00
|
|
|
/* Check for a __reduce_ex__ method. */
|
|
|
|
__reduce__ = PyObject_GetAttr(args, __reduce_ex___str);
|
|
|
|
if (__reduce__ != NULL) {
|
|
|
|
t = PyInt_FromLong(self->proto);
|
|
|
|
if (t != NULL) {
|
|
|
|
ARG_TUP(self, t);
|
|
|
|
t = NULL;
|
|
|
|
if (self->arg) {
|
|
|
|
t = PyObject_Call(__reduce__,
|
|
|
|
self->arg, NULL);
|
|
|
|
FREE_ARG_TUP(self);
|
|
|
|
}
|
|
|
|
}
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
2003-02-18 21:45:13 -04:00
|
|
|
else {
|
2003-06-16 17:19:49 -03:00
|
|
|
if (PyErr_ExceptionMatches(PyExc_AttributeError))
|
|
|
|
PyErr_Clear();
|
|
|
|
else
|
|
|
|
goto finally;
|
2003-02-18 21:45:13 -04:00
|
|
|
/* Check for a __reduce__ method. */
|
|
|
|
__reduce__ = PyObject_GetAttr(args, __reduce___str);
|
|
|
|
if (__reduce__ != NULL) {
|
|
|
|
t = PyObject_Call(__reduce__,
|
|
|
|
empty_tuple, NULL);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PyErr_SetObject(UnpickleableError, args);
|
|
|
|
goto finally;
|
|
|
|
}
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
2003-02-14 19:05:28 -04:00
|
|
|
}
|
2002-04-01 13:40:08 -04:00
|
|
|
|
2003-02-14 19:05:28 -04:00
|
|
|
if (t == NULL)
|
|
|
|
goto finally;
|
2002-04-01 13:40:08 -04:00
|
|
|
|
2003-02-14 19:05:28 -04:00
|
|
|
if (PyString_Check(t)) {
|
|
|
|
res = save_global(self, args, t);
|
|
|
|
goto finally;
|
|
|
|
}
|
2002-04-01 13:40:08 -04:00
|
|
|
|
2003-02-14 19:05:28 -04:00
|
|
|
if (! PyTuple_Check(t)) {
|
|
|
|
cPickle_ErrFormat(PicklingError, "Value returned by "
|
|
|
|
"%s must be string or tuple",
|
2003-02-13 17:03:57 -04:00
|
|
|
"O", __reduce__);
|
2003-02-14 19:05:28 -04:00
|
|
|
goto finally;
|
|
|
|
}
|
2002-04-01 13:40:08 -04:00
|
|
|
|
2003-02-14 19:05:28 -04:00
|
|
|
size = PyTuple_Size(t);
|
|
|
|
if (size < 2 || size > 5) {
|
|
|
|
cPickle_ErrFormat(PicklingError, "tuple returned by "
|
|
|
|
"%s must contain 2 through 5 elements",
|
|
|
|
"O", __reduce__);
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
|
2003-02-14 19:05:28 -04:00
|
|
|
arg_tup = PyTuple_GET_ITEM(t, 1);
|
|
|
|
if (!(PyTuple_Check(arg_tup) || arg_tup == Py_None)) {
|
|
|
|
cPickle_ErrFormat(PicklingError, "Second element of "
|
|
|
|
"tuple returned by %s must be a tuple",
|
|
|
|
"O", __reduce__);
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = save_reduce(self, t, args);
|
2002-04-01 13:40:08 -04:00
|
|
|
|
|
|
|
finally:
|
2002-08-04 05:20:23 -03:00
|
|
|
self->nesting--;
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_XDECREF(py_ob_id);
|
|
|
|
Py_XDECREF(__reduce__);
|
|
|
|
Py_XDECREF(t);
|
|
|
|
|
|
|
|
return res;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
dump(Picklerobject *self, PyObject *args)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
static char stop = STOP;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 12:09:05 -04:00
|
|
|
if (self->proto >= 2) {
|
|
|
|
char bytes[2];
|
|
|
|
|
|
|
|
bytes[0] = PROTO;
|
2003-02-02 12:16:30 -04:00
|
|
|
assert(self->proto >= 0 && self->proto < 256);
|
|
|
|
bytes[1] = (char)self->proto;
|
2003-02-02 12:09:05 -04:00
|
|
|
if (self->write_func(self, bytes, 2) < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (save(self, args, 0) < 0)
|
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 12:09:05 -04:00
|
|
|
if (self->write_func(self, &stop, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 12:09:05 -04:00
|
|
|
if (self->write_func(self, NULL, 0) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return 0;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static PyObject *
|
2003-02-01 02:24:36 -04:00
|
|
|
Pickle_clear_memo(Picklerobject *self, PyObject *args)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2003-02-01 02:24:36 -04:00
|
|
|
if (self->memo)
|
2002-04-01 13:40:08 -04:00
|
|
|
PyDict_Clear(self->memo);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
1998-11-25 12:18:00 -04:00
|
|
|
}
|
1997-04-09 14:36:32 -03:00
|
|
|
|
1998-11-25 12:18:00 -04:00
|
|
|
static PyObject *
|
2003-02-01 02:24:36 -04:00
|
|
|
Pickle_getvalue(Picklerobject *self, PyObject *args)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
int l, i, rsize, ssize, clear=1, lm;
|
|
|
|
long ik;
|
|
|
|
PyObject *k, *r;
|
|
|
|
char *s, *p, *have_get;
|
|
|
|
Pdata *data;
|
|
|
|
|
|
|
|
/* Can be called by Python code or C code */
|
2003-02-01 02:24:36 -04:00
|
|
|
if (args && !PyArg_ParseTuple(args, "|i:getvalue", &clear))
|
2002-04-01 13:40:08 -04:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Check to make sure we are based on a list */
|
|
|
|
if (! Pdata_Check(self->file)) {
|
|
|
|
PyErr_SetString(PicklingError,
|
|
|
|
"Attempt to getvalue() a non-list-based pickler");
|
|
|
|
return NULL;
|
|
|
|
}
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
/* flush write buffer */
|
|
|
|
if (write_other(self, NULL, 0) < 0) return NULL;
|
|
|
|
|
|
|
|
data=(Pdata*)self->file;
|
|
|
|
l=data->length;
|
|
|
|
|
|
|
|
/* set up an array to hold get/put status */
|
2003-02-02 14:08:34 -04:00
|
|
|
lm = PyDict_Size(self->memo);
|
|
|
|
if (lm < 0) return NULL;
|
2002-04-01 13:40:08 -04:00
|
|
|
lm++;
|
2003-02-02 14:08:34 -04:00
|
|
|
have_get = malloc(lm);
|
|
|
|
if (have_get == NULL) return PyErr_NoMemory();
|
|
|
|
memset(have_get, 0, lm);
|
2002-04-01 13:40:08 -04:00
|
|
|
|
|
|
|
/* Scan for gets. */
|
2003-02-02 14:08:34 -04:00
|
|
|
for (rsize = 0, i = l; --i >= 0; ) {
|
|
|
|
k = data->data[i];
|
2002-04-01 13:40:08 -04:00
|
|
|
|
2003-02-02 14:08:34 -04:00
|
|
|
if (PyString_Check(k))
|
2002-04-01 13:40:08 -04:00
|
|
|
rsize += PyString_GET_SIZE(k);
|
|
|
|
|
|
|
|
else if (PyInt_Check(k)) { /* put */
|
2003-02-02 14:08:34 -04:00
|
|
|
ik = PyInt_AS_LONG((PyIntObject*)k);
|
|
|
|
if (ik >= lm || ik == 0) {
|
2002-04-01 13:40:08 -04:00
|
|
|
PyErr_SetString(PicklingError,
|
|
|
|
"Invalid get data");
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-02-02 14:08:34 -04:00
|
|
|
if (have_get[ik]) /* with matching get */
|
|
|
|
rsize += ik < 256 ? 2 : 5;
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
else if (! (PyTuple_Check(k) &&
|
|
|
|
PyTuple_GET_SIZE(k) == 2 &&
|
2003-02-02 14:08:34 -04:00
|
|
|
PyInt_Check((k = PyTuple_GET_ITEM(k, 0))))
|
2002-04-01 13:40:08 -04:00
|
|
|
) {
|
|
|
|
PyErr_SetString(PicklingError,
|
|
|
|
"Unexpected data in internal list");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
else { /* put */
|
2003-02-02 14:08:34 -04:00
|
|
|
ik = PyInt_AS_LONG((PyIntObject *)k);
|
|
|
|
if (ik >= lm || ik == 0) {
|
2002-04-01 13:40:08 -04:00
|
|
|
PyErr_SetString(PicklingError,
|
|
|
|
"Invalid get data");
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-02-02 14:08:34 -04:00
|
|
|
have_get[ik] = 1;
|
|
|
|
rsize += ik < 256 ? 2 : 5;
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
|
|
|
}
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
/* Now generate the result */
|
2003-02-02 14:08:34 -04:00
|
|
|
r = PyString_FromStringAndSize(NULL, rsize);
|
|
|
|
if (r == NULL) goto err;
|
|
|
|
s = PyString_AS_STRING((PyStringObject *)r);
|
2002-04-01 13:40:08 -04:00
|
|
|
|
2003-02-02 14:08:34 -04:00
|
|
|
for (i = 0; i < l; i++) {
|
|
|
|
k = data->data[i];
|
2002-04-01 13:40:08 -04:00
|
|
|
|
|
|
|
if (PyString_Check(k)) {
|
2003-02-02 14:08:34 -04:00
|
|
|
ssize = PyString_GET_SIZE(k);
|
2002-04-01 13:40:08 -04:00
|
|
|
if (ssize) {
|
2003-02-02 14:08:34 -04:00
|
|
|
p=PyString_AS_STRING((PyStringObject *)k);
|
|
|
|
while (--ssize >= 0)
|
|
|
|
*s++ = *p++;
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (PyTuple_Check(k)) { /* get */
|
2003-02-02 14:08:34 -04:00
|
|
|
ik = PyInt_AS_LONG((PyIntObject *)
|
|
|
|
PyTuple_GET_ITEM(k, 0));
|
2002-04-01 13:40:08 -04:00
|
|
|
if (ik < 256) {
|
|
|
|
*s++ = BINGET;
|
|
|
|
*s++ = (int)(ik & 0xff);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*s++ = LONG_BINGET;
|
|
|
|
*s++ = (int)(ik & 0xff);
|
|
|
|
*s++ = (int)((ik >> 8) & 0xff);
|
|
|
|
*s++ = (int)((ik >> 16) & 0xff);
|
|
|
|
*s++ = (int)((ik >> 24) & 0xff);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else { /* put */
|
2003-02-02 14:08:34 -04:00
|
|
|
ik = PyInt_AS_LONG((PyIntObject*)k);
|
2002-04-01 13:40:08 -04:00
|
|
|
|
|
|
|
if (have_get[ik]) { /* with matching get */
|
|
|
|
if (ik < 256) {
|
|
|
|
*s++ = BINPUT;
|
|
|
|
*s++ = (int)(ik & 0xff);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*s++ = LONG_BINPUT;
|
|
|
|
*s++ = (int)(ik & 0xff);
|
|
|
|
*s++ = (int)((ik >> 8) & 0xff);
|
|
|
|
*s++ = (int)((ik >> 16) & 0xff);
|
|
|
|
*s++ = (int)((ik >> 24) & 0xff);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (clear) {
|
|
|
|
PyDict_Clear(self->memo);
|
2003-02-02 14:08:34 -04:00
|
|
|
Pdata_clear(data, 0);
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
free(have_get);
|
|
|
|
return r;
|
|
|
|
err:
|
|
|
|
free(have_get);
|
|
|
|
return NULL;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
1997-08-13 00:14:41 -03:00
|
|
|
static PyObject *
|
2003-02-01 02:24:36 -04:00
|
|
|
Pickler_dump(Picklerobject *self, PyObject *args)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *ob;
|
|
|
|
int get=0;
|
1998-11-25 12:18:00 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( PyArg_ParseTuple(args, "O|i:dump", &ob, &get)))
|
2002-04-01 13:40:08 -04:00
|
|
|
return NULL;
|
1998-11-25 12:18:00 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (dump(self, ob) < 0)
|
|
|
|
return NULL;
|
1998-11-25 12:18:00 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (get) return Pickle_getvalue(self, NULL);
|
1998-11-25 12:18:00 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
/* XXX Why does dump() return self? */
|
|
|
|
Py_INCREF(self);
|
|
|
|
return (PyObject*)self;
|
1997-08-13 00:14:41 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1998-11-25 12:18:00 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
static struct PyMethodDef Pickler_methods[] =
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2002-03-31 10:44:22 -04:00
|
|
|
{"dump", (PyCFunction)Pickler_dump, METH_VARARGS,
|
2002-08-13 19:20:41 -03:00
|
|
|
PyDoc_STR("dump(object) -- "
|
|
|
|
"Write an object in pickle format to the object's pickle stream")},
|
2002-05-01 17:36:39 -03:00
|
|
|
{"clear_memo", (PyCFunction)Pickle_clear_memo, METH_NOARGS,
|
2002-08-13 19:20:41 -03:00
|
|
|
PyDoc_STR("clear_memo() -- Clear the picklers memo")},
|
2002-03-31 10:44:22 -04:00
|
|
|
{"getvalue", (PyCFunction)Pickle_getvalue, METH_VARARGS,
|
2002-08-13 19:20:41 -03:00
|
|
|
PyDoc_STR("getvalue() -- Finish picking a list-based pickle")},
|
1997-04-09 14:36:32 -03:00
|
|
|
{NULL, NULL} /* sentinel */
|
1997-01-06 18:59:08 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static Picklerobject *
|
2003-02-01 12:45:06 -04:00
|
|
|
newPicklerobject(PyObject *file, int proto)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
Picklerobject *self;
|
|
|
|
|
2003-02-01 12:45:06 -04:00
|
|
|
if (proto < 0)
|
2003-02-13 11:44:41 -04:00
|
|
|
proto = HIGHEST_PROTOCOL;
|
|
|
|
if (proto > HIGHEST_PROTOCOL) {
|
2003-02-01 12:45:06 -04:00
|
|
|
PyErr_Format(PyExc_ValueError, "pickle protocol %d asked for; "
|
|
|
|
"the highest available protocol is %d",
|
2003-02-13 11:44:41 -04:00
|
|
|
proto, HIGHEST_PROTOCOL);
|
2002-04-01 13:40:08 -04:00
|
|
|
return NULL;
|
2003-02-01 12:45:06 -04:00
|
|
|
}
|
2002-04-01 13:40:08 -04:00
|
|
|
|
2003-04-09 18:05:12 -03:00
|
|
|
self = PyObject_GC_New(Picklerobject, &Picklertype);
|
2003-02-01 12:45:06 -04:00
|
|
|
if (self == NULL)
|
|
|
|
return NULL;
|
|
|
|
self->proto = proto;
|
|
|
|
self->bin = proto > 0;
|
2002-04-01 13:40:08 -04:00
|
|
|
self->fp = NULL;
|
|
|
|
self->write = NULL;
|
|
|
|
self->memo = NULL;
|
|
|
|
self->arg = NULL;
|
|
|
|
self->pers_func = NULL;
|
|
|
|
self->inst_pers_func = NULL;
|
|
|
|
self->write_buf = NULL;
|
|
|
|
self->fast = 0;
|
2002-08-04 05:20:23 -03:00
|
|
|
self->nesting = 0;
|
2002-04-01 13:40:08 -04:00
|
|
|
self->fast_container = 0;
|
|
|
|
self->fast_memo = NULL;
|
|
|
|
self->buf_size = 0;
|
|
|
|
self->dispatch_table = NULL;
|
|
|
|
|
2003-02-01 12:45:06 -04:00
|
|
|
self->file = NULL;
|
2002-04-01 13:40:08 -04:00
|
|
|
if (file)
|
|
|
|
Py_INCREF(file);
|
2003-02-01 12:45:06 -04:00
|
|
|
else {
|
|
|
|
file = Pdata_New();
|
|
|
|
if (file == NULL)
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
self->file = file;
|
2002-04-01 13:40:08 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( self->memo = PyDict_New()))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
if (PyFile_Check(file)) {
|
|
|
|
self->fp = PyFile_AsFile(file);
|
|
|
|
if (self->fp == NULL) {
|
2003-02-01 12:45:06 -04:00
|
|
|
PyErr_SetString(PyExc_ValueError,
|
|
|
|
"I/O operation on closed file");
|
2002-04-01 13:40:08 -04:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
self->write_func = write_file;
|
|
|
|
}
|
|
|
|
else if (PycStringIO_OutputCheck(file)) {
|
|
|
|
self->write_func = write_cStringIO;
|
|
|
|
}
|
|
|
|
else if (file == Py_None) {
|
|
|
|
self->write_func = write_none;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
self->write_func = write_other;
|
|
|
|
|
|
|
|
if (! Pdata_Check(file)) {
|
|
|
|
self->write = PyObject_GetAttr(file, write_str);
|
|
|
|
if (!self->write) {
|
|
|
|
PyErr_Clear();
|
2003-02-01 02:24:36 -04:00
|
|
|
PyErr_SetString(PyExc_TypeError,
|
2002-04-01 13:40:08 -04:00
|
|
|
"argument must have 'write' "
|
|
|
|
"attribute");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-01 12:45:06 -04:00
|
|
|
self->write_buf = (char *)PyMem_Malloc(WRITE_BUF_SIZE);
|
|
|
|
if (self->write_buf == NULL) {
|
2002-04-01 13:40:08 -04:00
|
|
|
PyErr_NoMemory();
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PyEval_GetRestricted()) {
|
|
|
|
/* Restricted execution, get private tables */
|
2003-02-03 20:21:07 -04:00
|
|
|
PyObject *m = PyImport_Import(copy_reg_str);
|
2002-04-01 13:40:08 -04:00
|
|
|
|
2003-02-03 20:21:07 -04:00
|
|
|
if (m == NULL)
|
|
|
|
goto err;
|
|
|
|
self->dispatch_table = PyObject_GetAttr(m, dispatch_table_str);
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_DECREF(m);
|
2003-02-03 20:21:07 -04:00
|
|
|
if (self->dispatch_table == NULL)
|
|
|
|
goto err;
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
|
|
|
else {
|
2003-02-03 20:21:07 -04:00
|
|
|
self->dispatch_table = dispatch_table;
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_INCREF(dispatch_table);
|
|
|
|
}
|
2003-04-09 18:05:12 -03:00
|
|
|
PyObject_GC_Track(self);
|
2002-04-01 13:40:08 -04:00
|
|
|
|
|
|
|
return self;
|
|
|
|
|
|
|
|
err:
|
2003-02-01 12:45:06 -04:00
|
|
|
Py_DECREF(self);
|
2002-04-01 13:40:08 -04:00
|
|
|
return NULL;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
2004-07-27 02:22:33 -03:00
|
|
|
get_Pickler(PyObject *self, PyObject *args, PyObject *kwds)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2006-02-27 12:46:16 -04:00
|
|
|
static char *kwlist[] = {"file", "protocol", NULL};
|
2002-04-01 13:40:08 -04:00
|
|
|
PyObject *file = NULL;
|
2003-02-01 12:45:06 -04:00
|
|
|
int proto = 0;
|
2002-04-01 13:40:08 -04:00
|
|
|
|
2003-02-13 19:00:26 -04:00
|
|
|
/* XXX
|
2004-07-27 02:22:33 -03:00
|
|
|
* The documented signature is Pickler(file, protocol=0), but this
|
2003-02-13 19:00:26 -04:00
|
|
|
* accepts Pickler() and Pickler(integer) too. The meaning then
|
|
|
|
* is clear as mud, undocumented, and not supported by pickle.py.
|
|
|
|
* I'm told Zope uses this, but I haven't traced into this code
|
|
|
|
* far enough to figure out what it means.
|
2003-02-01 12:45:06 -04:00
|
|
|
*/
|
|
|
|
if (!PyArg_ParseTuple(args, "|i:Pickler", &proto)) {
|
2002-04-01 13:40:08 -04:00
|
|
|
PyErr_Clear();
|
2003-02-01 12:45:06 -04:00
|
|
|
proto = 0;
|
2004-07-27 02:22:33 -03:00
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|i:Pickler",
|
|
|
|
kwlist, &file, &proto))
|
2002-04-01 13:40:08 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
2003-02-01 12:45:06 -04:00
|
|
|
return (PyObject *)newPicklerobject(file, proto);
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2003-02-01 02:24:36 -04:00
|
|
|
Pickler_dealloc(Picklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2003-04-09 18:05:12 -03:00
|
|
|
PyObject_GC_UnTrack(self);
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_XDECREF(self->write);
|
|
|
|
Py_XDECREF(self->memo);
|
|
|
|
Py_XDECREF(self->fast_memo);
|
|
|
|
Py_XDECREF(self->arg);
|
|
|
|
Py_XDECREF(self->file);
|
|
|
|
Py_XDECREF(self->pers_func);
|
|
|
|
Py_XDECREF(self->inst_pers_func);
|
|
|
|
Py_XDECREF(self->dispatch_table);
|
2003-02-01 12:45:06 -04:00
|
|
|
PyMem_Free(self->write_buf);
|
2003-05-21 18:29:48 -03:00
|
|
|
self->ob_type->tp_free((PyObject *)self);
|
2003-04-09 18:05:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
Pickler_traverse(Picklerobject *self, visitproc visit, void *arg)
|
|
|
|
{
|
2006-04-21 07:40:58 -03:00
|
|
|
Py_VISIT(self->write);
|
|
|
|
Py_VISIT(self->memo);
|
|
|
|
Py_VISIT(self->fast_memo);
|
|
|
|
Py_VISIT(self->arg);
|
|
|
|
Py_VISIT(self->file);
|
|
|
|
Py_VISIT(self->pers_func);
|
|
|
|
Py_VISIT(self->inst_pers_func);
|
|
|
|
Py_VISIT(self->dispatch_table);
|
2003-04-09 18:05:12 -03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
Pickler_clear(Picklerobject *self)
|
|
|
|
{
|
2006-04-21 07:40:58 -03:00
|
|
|
Py_CLEAR(self->write);
|
|
|
|
Py_CLEAR(self->memo);
|
|
|
|
Py_CLEAR(self->fast_memo);
|
|
|
|
Py_CLEAR(self->arg);
|
|
|
|
Py_CLEAR(self->file);
|
|
|
|
Py_CLEAR(self->pers_func);
|
|
|
|
Py_CLEAR(self->inst_pers_func);
|
|
|
|
Py_CLEAR(self->dispatch_table);
|
2003-04-09 18:05:12 -03:00
|
|
|
return 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
Pickler_get_pers_func(Picklerobject *p)
|
|
|
|
{
|
2002-04-01 13:40:08 -04:00
|
|
|
if (p->pers_func == NULL)
|
|
|
|
PyErr_SetString(PyExc_AttributeError, "persistent_id");
|
|
|
|
else
|
|
|
|
Py_INCREF(p->pers_func);
|
|
|
|
return p->pers_func;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
static int
|
|
|
|
Pickler_set_pers_func(Picklerobject *p, PyObject *v)
|
|
|
|
{
|
2002-04-01 13:40:08 -04:00
|
|
|
if (v == NULL) {
|
|
|
|
PyErr_SetString(PyExc_TypeError,
|
|
|
|
"attribute deletion is not supported");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
Py_XDECREF(p->pers_func);
|
|
|
|
Py_INCREF(v);
|
|
|
|
p->pers_func = v;
|
|
|
|
return 0;
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
}
|
2001-03-17 00:50:51 -04:00
|
|
|
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
static int
|
|
|
|
Pickler_set_inst_pers_func(Picklerobject *p, PyObject *v)
|
|
|
|
{
|
2002-04-01 13:40:08 -04:00
|
|
|
if (v == NULL) {
|
|
|
|
PyErr_SetString(PyExc_TypeError,
|
|
|
|
"attribute deletion is not supported");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
Py_XDECREF(p->inst_pers_func);
|
|
|
|
Py_INCREF(v);
|
|
|
|
p->inst_pers_func = v;
|
|
|
|
return 0;
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
}
|
1997-04-09 14:36:32 -03:00
|
|
|
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
static PyObject *
|
|
|
|
Pickler_get_memo(Picklerobject *p)
|
|
|
|
{
|
2002-04-01 13:40:08 -04:00
|
|
|
if (p->memo == NULL)
|
|
|
|
PyErr_SetString(PyExc_AttributeError, "memo");
|
|
|
|
else
|
|
|
|
Py_INCREF(p->memo);
|
|
|
|
return p->memo;
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
}
|
1998-08-13 20:13:52 -03:00
|
|
|
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
static int
|
|
|
|
Pickler_set_memo(Picklerobject *p, PyObject *v)
|
|
|
|
{
|
2002-04-01 13:40:08 -04:00
|
|
|
if (v == NULL) {
|
|
|
|
PyErr_SetString(PyExc_TypeError,
|
|
|
|
"attribute deletion is not supported");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (!PyDict_Check(v)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "memo must be a dictionary");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
Py_XDECREF(p->memo);
|
|
|
|
Py_INCREF(v);
|
|
|
|
p->memo = v;
|
|
|
|
return 0;
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
}
|
1998-08-13 20:13:52 -03:00
|
|
|
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
static PyObject *
|
|
|
|
Pickler_get_error(Picklerobject *p)
|
|
|
|
{
|
2002-04-01 13:40:08 -04:00
|
|
|
/* why is this an attribute on the Pickler? */
|
|
|
|
Py_INCREF(PicklingError);
|
|
|
|
return PicklingError;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
static PyMemberDef Pickler_members[] = {
|
|
|
|
{"binary", T_INT, offsetof(Picklerobject, bin)},
|
|
|
|
{"fast", T_INT, offsetof(Picklerobject, fast)},
|
2001-10-16 14:10:49 -03:00
|
|
|
{NULL}
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
static PyGetSetDef Pickler_getsets[] = {
|
2003-02-01 02:24:36 -04:00
|
|
|
{"persistent_id", (getter)Pickler_get_pers_func,
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
(setter)Pickler_set_pers_func},
|
|
|
|
{"inst_persistent_id", NULL, (setter)Pickler_set_inst_pers_func},
|
|
|
|
{"memo", (getter)Pickler_get_memo, (setter)Pickler_set_memo},
|
2001-10-16 14:10:49 -03:00
|
|
|
{"PicklingError", (getter)Pickler_get_error, NULL},
|
|
|
|
{NULL}
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
};
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(Picklertype__doc__,
|
|
|
|
"Objects that know how to pickle objects\n");
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-12-08 11:15:16 -04:00
|
|
|
static PyTypeObject Picklertype = {
|
|
|
|
PyObject_HEAD_INIT(NULL)
|
1997-04-09 14:36:32 -03:00
|
|
|
0, /*ob_size*/
|
2001-12-08 14:02:58 -04:00
|
|
|
"cPickle.Pickler", /*tp_name*/
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
sizeof(Picklerobject), /*tp_basicsize*/
|
|
|
|
0,
|
|
|
|
(destructor)Pickler_dealloc, /* tp_dealloc */
|
|
|
|
0, /* tp_print */
|
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
|
|
|
0, /* tp_compare */
|
|
|
|
0, /* tp_repr */
|
|
|
|
0, /* tp_as_number */
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
0, /* tp_hash */
|
|
|
|
0, /* tp_call */
|
|
|
|
0, /* tp_str */
|
2003-01-06 08:41:26 -04:00
|
|
|
PyObject_GenericGetAttr, /* tp_getattro */
|
|
|
|
PyObject_GenericSetAttr, /* tp_setattro */
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
0, /* tp_as_buffer */
|
2003-04-09 18:05:12 -03:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
Picklertype__doc__, /* tp_doc */
|
2003-04-09 18:05:12 -03:00
|
|
|
(traverseproc)Pickler_traverse, /* tp_traverse */
|
|
|
|
(inquiry)Pickler_clear, /* tp_clear */
|
Progress on SF bug #466175 and general cleanup.
Add a fast_container member to Picklerobject. If fast is true, then
fast_container counts the depth of nested container calls. If the
depth exceeds FAST_LIMIT (2000), the fast flag is ignored and the
normal checks occur. This approach is much like the approach for
prevent stack overflow for comparison and reprs of recursive objects
(e.g. [[...]]).
- Fast container used for save_list(), save_dict(), and
save_inst().
XXX Not clear which other save_xxx() functions should use it.
Make Picklerobject into new-style types, using PyObject_GenericGetAttr()
and PyObject_GenericSetAttr().
- Use PyMemberDef for binary and fast members
- Use PyGetSetDef for persistent_id, inst_persistent_id, memo, and
PicklingError.
XXX Not all of these seem like they need to use getset, but it's
not clear why the old getattr() and setattr() had such odd
semantics. One change is that the getvalue() attribute will
exist on all Picklers, not just list-based picklers; I think
this is a more rationale interface.
There is a long laundry list of other changes:
- Remove unused #defines for PyList_SET_ITEM() etc.
- Make some of the indentation consistent
- Replace uses of cPickle_PyMapping_HasKey() where the first
argument is self->memo with calls to PyDict_GetItem(), because
self->memo must be a dictionary.
- Don't bother to check if cPickle_PyMapping_HasKey() returns < 0,
because it can only return 0 or 1.
- Replace uses of PyObject_CallObject() with PyObject_Call(), when
we can guarantee that the argument tuple is really a tuple.
Performance impacts of these changes:
- 5% speedup for normal pickling
- No change to fast-mode pickling.
XXX Really need tests for all the features in cPickle that aren't in
pickle.
2001-10-12 01:11:06 -03:00
|
|
|
0, /* tp_richcompare */
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
0, /* tp_iter */
|
|
|
|
0, /* tp_iternext */
|
|
|
|
Pickler_methods, /* tp_methods */
|
|
|
|
Pickler_members, /* tp_members */
|
|
|
|
Pickler_getsets, /* tp_getset */
|
1997-12-08 11:15:16 -04:00
|
|
|
};
|
1997-04-09 14:36:32 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2003-02-01 02:24:36 -04:00
|
|
|
find_class(PyObject *py_module_name, PyObject *py_global_name, PyObject *fc)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *global = 0, *module;
|
|
|
|
|
|
|
|
if (fc) {
|
|
|
|
if (fc==Py_None) {
|
2003-02-13 19:00:26 -04:00
|
|
|
PyErr_SetString(UnpicklingError, "Global and instance "
|
|
|
|
"pickles are not supported.");
|
2002-04-01 13:40:08 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Inherits test_gzip/test_tarfile failures on 64-bit platforms from the trunk,
but I don't want the merge to hang around too long (even though the regular
p3yk-contributors are/have been busy with other things.)
Merged revisions 45621-46490 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r45621 | george.yoshida | 2006-04-21 18:34:17 +0200 (Fri, 21 Apr 2006) | 2 lines
Correct the grammar
........
r45622 | tim.peters | 2006-04-21 18:34:54 +0200 (Fri, 21 Apr 2006) | 2 lines
Whitespace normalization.
........
r45624 | thomas.heller | 2006-04-21 18:48:56 +0200 (Fri, 21 Apr 2006) | 1 line
Merge in changes from ctypes 0.9.9.6 upstream version.
........
r45625 | thomas.heller | 2006-04-21 18:51:04 +0200 (Fri, 21 Apr 2006) | 1 line
Merge in changes from ctypes 0.9.9.6 upstream version.
........
r45630 | thomas.heller | 2006-04-21 20:29:17 +0200 (Fri, 21 Apr 2006) | 8 lines
Documentation for ctypes.
I think that 'generic operating system services' is the best category.
Note that the Doc/lib/libctypes.latex file is generated from reST sources.
You are welcome to make typo fixes, and I'll try to keep the reST sources
in sync, but markup changes would be lost - they should be fixed in the tool
that creates the latex file.
The conversion script is external/ctypes/docs/manual/mkpydoc.py.
........
r45631 | tim.peters | 2006-04-21 23:18:10 +0200 (Fri, 21 Apr 2006) | 24 lines
SF bug #1473760 TempFile can hang on Windows.
Python 2.4 changed ntpath.abspath to do an import
inside the function. As a result, due to Python's
import lock, anything calling abspath on Windows
(directly, or indirectly like tempfile.TemporaryFile)
hung when it was called from a thread spawned as a
side effect of importing a module.
This is a depressingly frequent problem, and
deserves a more general fix. I'm settling for
a micro-fix here because this specific one accounts
for a report of Zope Corp's ZEO hanging on Windows,
and it was an odd way to change abspath to begin
with (ntpath needs a different implementation
depending on whether we're actually running on
Windows, and the _obvious_ way to arrange for that
is not to bury a possibly-failing import _inside_
the function).
Note that if/when other micro-fixes of this kind
get made, the new Lib/test/threaded_import_hangers.py
is a convenient place to add tests for them.
........
r45634 | phillip.eby | 2006-04-21 23:53:37 +0200 (Fri, 21 Apr 2006) | 2 lines
Guido wrote contextlib, not me, but thanks anyway. ;)
........
r45636 | andrew.kuchling | 2006-04-22 03:51:41 +0200 (Sat, 22 Apr 2006) | 1 line
Typo fixes
........
r45638 | andrew.kuchling | 2006-04-22 03:58:40 +0200 (Sat, 22 Apr 2006) | 1 line
Fix comment typo
........
r45639 | andrew.kuchling | 2006-04-22 04:06:03 +0200 (Sat, 22 Apr 2006) | 8 lines
Make copy of test_mailbox.py. We'll still want to check the backward
compatibility classes in the new mailbox.py that I'll be committing in
a few minutes.
One change has been made: the tests use len(mbox) instead of len(mbox.boxes).
The 'boxes' attribute was never documented and contains some internal state
that seems unlikely to have been useful.
........
r45640 | andrew.kuchling | 2006-04-22 04:32:43 +0200 (Sat, 22 Apr 2006) | 16 lines
Add Gregory K. Johnson's revised version of mailbox.py (funded by
the 2005 Summer of Code).
The revision adds a number of new mailbox classes that support adding
and removing messages; these classes also support mailbox locking and
default to using email.Message instead of rfc822.Message.
The old mailbox classes are largely left alone for backward compatibility.
The exception is the Maildir class, which was present in the old module
and now inherits from the new classes. The Maildir class's interface
is pretty simple, though, so I think it'll be compatible with existing
code.
(The change to the NEWS file also adds a missing word to a different
news item, which unfortunately required rewrapping the line.)
........
r45641 | tim.peters | 2006-04-22 07:52:59 +0200 (Sat, 22 Apr 2006) | 2 lines
Whitespace normalization.
........
r45642 | neal.norwitz | 2006-04-22 08:07:46 +0200 (Sat, 22 Apr 2006) | 1 line
Add libctypes as a dep
........
r45643 | martin.v.loewis | 2006-04-22 13:15:41 +0200 (Sat, 22 Apr 2006) | 1 line
Fix more ssize_t problems.
........
r45644 | martin.v.loewis | 2006-04-22 13:40:03 +0200 (Sat, 22 Apr 2006) | 1 line
Fix more ssize_t issues.
........
r45645 | george.yoshida | 2006-04-22 17:10:49 +0200 (Sat, 22 Apr 2006) | 2 lines
Typo fixes
........
r45647 | martin.v.loewis | 2006-04-22 17:19:54 +0200 (Sat, 22 Apr 2006) | 1 line
Port to Python 2.5. Drop .DEF file. Change output file names to .pyd.
........
r45648 | george.yoshida | 2006-04-22 17:27:14 +0200 (Sat, 22 Apr 2006) | 3 lines
- add versionadded tag
- make arbitrary arguments come last
........
r45649 | hyeshik.chang | 2006-04-22 17:48:15 +0200 (Sat, 22 Apr 2006) | 3 lines
Remove $CJKCodecs$ RCS tags. The CJKCodecs isn't maintained outside
anymore.
........
r45654 | greg.ward | 2006-04-23 05:47:58 +0200 (Sun, 23 Apr 2006) | 2 lines
Update optparse to Optik 1.5.1.
........
r45658 | george.yoshida | 2006-04-23 11:27:10 +0200 (Sun, 23 Apr 2006) | 2 lines
wrap SyntaxError with \exception{}
........
r45660 | ronald.oussoren | 2006-04-23 13:59:25 +0200 (Sun, 23 Apr 2006) | 6 lines
Patch 1471925 - Weak linking support for OSX
This patch causes several symbols in the socket and posix module to be weakly
linked on OSX and disables usage of ftime on OSX. These changes make it possible
to use a binary build on OSX 10.4 on a 10.3 system.
........
r45661 | ronald.oussoren | 2006-04-23 14:36:23 +0200 (Sun, 23 Apr 2006) | 5 lines
Patch 1471761 - test for broken poll at runtime
This patch checks if poll is broken when the select module is loaded instead
of doing so at configure-time. This functionality is only active on Mac OS X.
........
r45662 | nick.coghlan | 2006-04-23 17:13:32 +0200 (Sun, 23 Apr 2006) | 1 line
Add a Context Types section to parallel the Iterator Types section (uses the same terminology as the 2.5a1 implementation)
........
r45663 | nick.coghlan | 2006-04-23 17:14:37 +0200 (Sun, 23 Apr 2006) | 1 line
Update contextlib documentation to use the same terminology as the module implementation
........
r45664 | gerhard.haering | 2006-04-23 17:24:26 +0200 (Sun, 23 Apr 2006) | 2 lines
Updated the sqlite3 module to the external pysqlite 2.2.2 version.
........
r45666 | nick.coghlan | 2006-04-23 17:39:16 +0200 (Sun, 23 Apr 2006) | 1 line
Update with statement documentation to use same terminology as 2.5a1 implementation
........
r45667 | nick.coghlan | 2006-04-23 18:05:04 +0200 (Sun, 23 Apr 2006) | 1 line
Add a (very) brief mention of the with statement to the end of chapter 8
........
r45668 | nick.coghlan | 2006-04-23 18:35:19 +0200 (Sun, 23 Apr 2006) | 1 line
Take 2 on mentioning the with statement, this time without inadvertently killing the Unicode examples
........
r45669 | nick.coghlan | 2006-04-23 19:04:07 +0200 (Sun, 23 Apr 2006) | 1 line
Backdated NEWS entry to record the implementation of PEP 338 for alpha 1
........
r45670 | tim.peters | 2006-04-23 20:13:45 +0200 (Sun, 23 Apr 2006) | 2 lines
Whitespace normalization.
........
r45671 | skip.montanaro | 2006-04-23 21:14:27 +0200 (Sun, 23 Apr 2006) | 1 line
first cut at trace module doc
........
r45672 | skip.montanaro | 2006-04-23 21:26:33 +0200 (Sun, 23 Apr 2006) | 1 line
minor tweak
........
r45673 | skip.montanaro | 2006-04-23 21:30:50 +0200 (Sun, 23 Apr 2006) | 1 line
it's always helpful if the example works...
........
r45674 | skip.montanaro | 2006-04-23 21:32:14 +0200 (Sun, 23 Apr 2006) | 1 line
correct example
........
r45675 | andrew.kuchling | 2006-04-23 23:01:04 +0200 (Sun, 23 Apr 2006) | 1 line
Edits to the PEP 343 section
........
r45676 | andrew.kuchling | 2006-04-23 23:51:10 +0200 (Sun, 23 Apr 2006) | 1 line
Add two items
........
r45677 | tim.peters | 2006-04-24 04:03:16 +0200 (Mon, 24 Apr 2006) | 5 lines
Bug #1337990: clarified that `doctest` does not support examples
requiring both expected output and an exception.
I'll backport to 2.4 next.
........
r45679 | nick.coghlan | 2006-04-24 05:04:43 +0200 (Mon, 24 Apr 2006) | 1 line
Note changes made to PEP 343 related documentation
........
r45681 | nick.coghlan | 2006-04-24 06:17:02 +0200 (Mon, 24 Apr 2006) | 1 line
Change PEP 343 related documentation to use the term context specifier instead of context object
........
r45682 | nick.coghlan | 2006-04-24 06:32:47 +0200 (Mon, 24 Apr 2006) | 1 line
Add unit tests for the -m and -c command line switches
........
r45683 | nick.coghlan | 2006-04-24 06:37:15 +0200 (Mon, 24 Apr 2006) | 1 line
Fix contextlib.nested to cope with exit methods raising and handling exceptions
........
r45685 | nick.coghlan | 2006-04-24 06:59:28 +0200 (Mon, 24 Apr 2006) | 1 line
Fix broken contextlib test from last checkin (I'd've sworn I tested that before checking it in. . .)
........
r45686 | nick.coghlan | 2006-04-24 07:24:26 +0200 (Mon, 24 Apr 2006) | 1 line
Back out new command line tests (broke buildbot)
........
r45687 | nick.coghlan | 2006-04-24 07:52:15 +0200 (Mon, 24 Apr 2006) | 1 line
More reliable version of new command line tests that just checks the exit codes
........
r45688 | thomas.wouters | 2006-04-24 13:37:13 +0200 (Mon, 24 Apr 2006) | 4 lines
Stop test_tcl's testLoadTk from leaking the Tk commands 'loadtk' registers.
........
r45690 | andrew.kuchling | 2006-04-24 16:30:47 +0200 (Mon, 24 Apr 2006) | 2 lines
Edits, using the new term
'context specifier' in a few places
........
r45697 | phillip.eby | 2006-04-24 22:53:13 +0200 (Mon, 24 Apr 2006) | 2 lines
Revert addition of setuptools
........
r45698 | tim.peters | 2006-04-25 00:45:13 +0200 (Tue, 25 Apr 2006) | 2 lines
Whitespace normalization.
........
r45700 | trent.mick | 2006-04-25 02:34:50 +0200 (Tue, 25 Apr 2006) | 4 lines
Put break at correct level so *all* root HKEYs acutally get checked for
an installed VC6. Otherwise only the first such tree gets checked and this
warning doesn't get displayed.
........
r45701 | tim.peters | 2006-04-25 05:31:36 +0200 (Tue, 25 Apr 2006) | 3 lines
Patch #1475231: add a new SKIP doctest option, thanks to
Edward Loper.
........
r45702 | neal.norwitz | 2006-04-25 07:04:35 +0200 (Tue, 25 Apr 2006) | 1 line
versionadded for SKIP
........
r45703 | neal.norwitz | 2006-04-25 07:05:03 +0200 (Tue, 25 Apr 2006) | 1 line
Restore Walters name
........
r45704 | neal.norwitz | 2006-04-25 07:49:42 +0200 (Tue, 25 Apr 2006) | 1 line
Revert previous change, SKIP had a versionadded elsewhere
........
r45706 | nick.coghlan | 2006-04-25 12:56:51 +0200 (Tue, 25 Apr 2006) | 31 lines
Move the PEP 343 documentation and implementation closer to the
terminology in the alpha 1 documentation.
- "context manager" reverts to its alpha 1 definition
- the term "context specifier" goes away entirely
- contextlib.GeneratorContextManager is renamed GeneratorContext
There are still a number of changes relative to alpha 1:
- the expression in the with statement is explicitly called the
"context expression" in the language reference
- the terms 'with statement context', 'context object' or 'with
statement context' are used in several places instead of a bare
'context'. The aim of this is to avoid ambiguity in relation to the
runtime context set up when the block is executed, and the context
objects that already exist in various application domains (such as
decimal.Context)
- contextlib.contextmanager is renamed to contextfactory
This best reflects the nature of the function resulting from the
use of that decorator
- decimal.ContextManager is renamed to WithStatementContext
Simple dropping the 'Manager' part wasn't possible due to the
fact that decimal.Context already exists and means something
different. WithStatementContext is ugly but workable.
A technically unrelated change snuck into this commit:
contextlib.closing now avoids the overhead of creating a
generator, since it's trivial to implement that particular
context manager directly.
........
r45707 | nick.coghlan | 2006-04-25 13:05:56 +0200 (Tue, 25 Apr 2006) | 1 line
Fix latex typo
........
r45708 | thomas.wouters | 2006-04-25 14:28:56 +0200 (Tue, 25 Apr 2006) | 4 lines
Fix markup glitch in unittest docs. Will backport.
........
r45710 | andrew.kuchling | 2006-04-25 14:31:38 +0200 (Tue, 25 Apr 2006) | 1 line
Add two items; easy_install is now off the table, though pkgutil still is
........
r45711 | andrew.kuchling | 2006-04-25 14:47:25 +0200 (Tue, 25 Apr 2006) | 1 line
Rework context terminology
........
r45712 | thomas.wouters | 2006-04-25 15:53:23 +0200 (Tue, 25 Apr 2006) | 9 lines
SF bug/patch #1433877: string parameter to ioctl not null terminated
The new char-array used in ioctl calls wasn't explicitly NUL-terminated;
quite probably the cause for the test_pty failures on Solaris that we
circumvented earlier. (I wasn't able to reproduce it with this patch, but it
has been somewhat elusive to start with.)
........
r45713 | george.yoshida | 2006-04-25 16:09:58 +0200 (Tue, 25 Apr 2006) | 2 lines
minor tweak
........
r45714 | thomas.wouters | 2006-04-25 17:08:10 +0200 (Tue, 25 Apr 2006) | 7 lines
Fix SF bug #1476111: SystemError in socket sendto. The AF_INET6 and
AF_PACKET cases in getsockaddrarg were missing their own checks for
tuple-ness of the address argument, which means a confusing SystemError was
raised by PyArg_ParseTuple instead.
........
r45715 | thomas.wouters | 2006-04-25 17:29:46 +0200 (Tue, 25 Apr 2006) | 10 lines
Define MAXPATHLEN to be at least PATH_MAX, if that's defined. Python uses
MAXPATHLEN-sized buffers for various output-buffers (like to realpath()),
and that's correct on BSD platforms, but not Linux (which uses PATH_MAX, and
does not define MAXPATHLEN.) Cursory googling suggests Linux is following a
newer standard than BSD, but in cases like this, who knows. Using the
greater of PATH_MAX and 1024 as a fallback for MAXPATHLEN seems to be the
most portable solution.
........
r45717 | thomas.heller | 2006-04-25 20:26:08 +0200 (Tue, 25 Apr 2006) | 3 lines
Fix compiler warnings on Darwin.
Patch by Brett Canon, see
https://sourceforge.net/tracker/?func=detail&atid=532156&aid=1475959&group_id=71702
........
r45718 | guido.van.rossum | 2006-04-25 22:12:45 +0200 (Tue, 25 Apr 2006) | 4 lines
Implement MvL's improvement on __context__ in Condition;
this can just call __context__ on the underlying lock.
(The same change for Semaphore does *not* work!)
........
r45721 | tim.peters | 2006-04-26 03:15:53 +0200 (Wed, 26 Apr 2006) | 13 lines
Rev 45706 renamed stuff in contextlib.py, but didn't rename
uses of it in test_with.py. As a result, test_with has been skipped
(due to failing imports) on all buildbot boxes since. Alas, that's
not a test failure -- you have to pay attention to the
1 skip unexpected on PLATFORM:
test_with
kinds of output at the ends of test runs to notice that this got
broken.
It's likely that more renaming in test_with.py would be desirable.
........
r45722 | fred.drake | 2006-04-26 07:15:41 +0200 (Wed, 26 Apr 2006) | 1 line
markup fixes, cleanup
........
r45723 | fred.drake | 2006-04-26 07:19:39 +0200 (Wed, 26 Apr 2006) | 1 line
minor adjustment suggested by Peter Gephardt
........
r45724 | neal.norwitz | 2006-04-26 07:34:03 +0200 (Wed, 26 Apr 2006) | 10 lines
Patch from Aldo Cortesi (OpenBSD buildbot owner).
After the patch (45590) to add extra debug stats to the gc module, Python
was crashing on OpenBSD due to:
Fatal Python error: Interpreter not initialized (version mismatch?)
This seems to occur due to calling collect() when initialized (in pythonrun.c)
is set to 0. Now, the import will occur in the init function which
shouldn't suffer this problem.
........
r45725 | neal.norwitz | 2006-04-26 08:26:12 +0200 (Wed, 26 Apr 2006) | 3 lines
Fix this test on Solaris. There can be embedded \r, so don't just replace
the one at the end.
........
r45727 | nick.coghlan | 2006-04-26 13:50:04 +0200 (Wed, 26 Apr 2006) | 1 line
Fix an error in the last contextlib.closing example
........
r45728 | andrew.kuchling | 2006-04-26 14:21:06 +0200 (Wed, 26 Apr 2006) | 1 line
[Bug #1475080] Fix example
........
r45729 | andrew.kuchling | 2006-04-26 14:23:39 +0200 (Wed, 26 Apr 2006) | 1 line
Add labels to all sections
........
r45730 | thomas.wouters | 2006-04-26 17:53:30 +0200 (Wed, 26 Apr 2006) | 7 lines
The result of SF patch #1471578: big-memory tests for strings, lists and
tuples. Lots to be added, still, but this will give big-memory people
something to play with in 2.5 alpha 2, and hopefully get more people to
write these tests.
........
r45731 | tim.peters | 2006-04-26 19:11:16 +0200 (Wed, 26 Apr 2006) | 2 lines
Whitespace normalization.
........
r45732 | martin.v.loewis | 2006-04-26 19:19:44 +0200 (Wed, 26 Apr 2006) | 1 line
Use GS- and bufferoverlowU.lib where appropriate, for AMD64.
........
r45733 | thomas.wouters | 2006-04-26 20:46:01 +0200 (Wed, 26 Apr 2006) | 5 lines
Add tests for += and *= on strings, and fix the memory-use estimate for the
list.extend tests (they were estimating half the actual use.)
........
r45734 | thomas.wouters | 2006-04-26 21:14:46 +0200 (Wed, 26 Apr 2006) | 5 lines
Some more test-size-estimate fixes: test_append and test_insert trigger a
list resize, which overallocates.
........
r45735 | hyeshik.chang | 2006-04-26 21:20:26 +0200 (Wed, 26 Apr 2006) | 3 lines
Fix build on MIPS for libffi. I haven't tested this yet because I
don't have an access on MIPS machines. Will be tested by buildbot. :)
........
r45737 | fred.drake | 2006-04-27 01:40:32 +0200 (Thu, 27 Apr 2006) | 1 line
one more place to use the current Python version
........
r45738 | fred.drake | 2006-04-27 02:02:24 +0200 (Thu, 27 Apr 2006) | 3 lines
- update version numbers in file names again, until we have a better way
- elaborate instructions for Cygwin support (closes SF #839709)
........
r45739 | fred.drake | 2006-04-27 02:20:14 +0200 (Thu, 27 Apr 2006) | 1 line
add missing word
........
r45740 | anthony.baxter | 2006-04-27 04:11:24 +0200 (Thu, 27 Apr 2006) | 2 lines
2.5a2
........
r45741 | anthony.baxter | 2006-04-27 04:13:13 +0200 (Thu, 27 Apr 2006) | 1 line
2.5a2
........
r45749 | andrew.kuchling | 2006-04-27 14:22:37 +0200 (Thu, 27 Apr 2006) | 1 line
Now that 2.5a2 is out, revert to the current date
........
r45750 | andrew.kuchling | 2006-04-27 14:23:07 +0200 (Thu, 27 Apr 2006) | 1 line
Bump document version
........
r45751 | andrew.kuchling | 2006-04-27 14:34:39 +0200 (Thu, 27 Apr 2006) | 6 lines
[Bug #1477102] Add necessary import to example
This may be a useful style question for the docs -- should examples show
the necessary imports, or should it be assumed that the reader will
figure it out? In the What's New, I'm not consistent but usually opt
for omitting the imports.
........
r45753 | andrew.kuchling | 2006-04-27 14:38:35 +0200 (Thu, 27 Apr 2006) | 1 line
[Bug #1477140] Import Error base class
........
r45754 | andrew.kuchling | 2006-04-27 14:42:54 +0200 (Thu, 27 Apr 2006) | 1 line
Mention the xmlrpclib.Error base class, which is used in one of the examples
........
r45756 | george.yoshida | 2006-04-27 15:41:07 +0200 (Thu, 27 Apr 2006) | 2 lines
markup fix
........
r45757 | thomas.wouters | 2006-04-27 15:46:59 +0200 (Thu, 27 Apr 2006) | 4 lines
Some more size-estimate fixes, for large-list-tests.
........
r45758 | thomas.heller | 2006-04-27 17:50:42 +0200 (Thu, 27 Apr 2006) | 3 lines
Rerun the libffi configuration if any of the files used for that
are newer then fficonfig.py.
........
r45766 | thomas.wouters | 2006-04-28 00:37:50 +0200 (Fri, 28 Apr 2006) | 6 lines
Some style fixes and size-calculation fixes. Also do the small-memory run
using a prime number, rather than a convenient power-of-2-and-multiple-of-5,
so incorrect testing algorithms fail more easily.
........
r45767 | thomas.wouters | 2006-04-28 00:38:32 +0200 (Fri, 28 Apr 2006) | 6 lines
Do the small-memory run of big-meormy tests using a prime number, rather
than a convenient power-of-2-and-multiple-of-5, so incorrect testing
algorithms fail more easily.
........
r45768 | david.goodger | 2006-04-28 00:53:05 +0200 (Fri, 28 Apr 2006) | 1 line
Added SVN access for Steven Bethard and Talin, for PEP updating.
........
r45770 | thomas.wouters | 2006-04-28 01:13:20 +0200 (Fri, 28 Apr 2006) | 16 lines
- Add new Warning class, ImportWarning
- Warn-raise ImportWarning when importing would have picked up a directory
as package, if only it'd had an __init__.py. This swaps two tests (for
case-ness and __init__-ness), but case-test is not really more expensive,
and it's not in a speed-critical section.
- Test for the new warning by importing a common non-package directory on
sys.path: site-packages
- In regrtest.py, silence warnings generated by the build-environment
because Modules/ (which is added to sys.path for Setup-created modules)
has 'zlib' and '_ctypes' directories without __init__.py's.
........
r45771 | thomas.wouters | 2006-04-28 01:41:27 +0200 (Fri, 28 Apr 2006) | 6 lines
Add more ignores of ImportWarnings; these are all just potential triggers
(since they won't trigger if zlib is already sucessfully imported); they
were found by grepping .py files, instead of looking at warning output :)
........
r45773 | neal.norwitz | 2006-04-28 06:32:20 +0200 (Fri, 28 Apr 2006) | 1 line
Add some whitespace to be more consistent.
........
r45774 | neal.norwitz | 2006-04-28 06:34:43 +0200 (Fri, 28 Apr 2006) | 5 lines
Try to really fix the slow buildbots this time.
Printing to stdout, doesn't mean the data was actually written.
It depends on the buffering, so we need to flush. This will hopefully
really fix the buildbots getting killed due to no output on the slow bots.
........
r45775 | neal.norwitz | 2006-04-28 07:28:05 +0200 (Fri, 28 Apr 2006) | 1 line
Fix some warnings on Mac OS X 10.4
........
r45776 | neal.norwitz | 2006-04-28 07:28:30 +0200 (Fri, 28 Apr 2006) | 1 line
Fix a warning on alpha
........
r45777 | neal.norwitz | 2006-04-28 07:28:54 +0200 (Fri, 28 Apr 2006) | 1 line
Fix a warning on ppc (debian)
........
r45778 | george.yoshida | 2006-04-28 18:09:45 +0200 (Fri, 28 Apr 2006) | 2 lines
fix markup glitch
........
r45780 | georg.brandl | 2006-04-28 18:31:17 +0200 (Fri, 28 Apr 2006) | 3 lines
Add SeaMonkey to the list of Mozilla browsers.
........
r45781 | georg.brandl | 2006-04-28 18:36:55 +0200 (Fri, 28 Apr 2006) | 2 lines
Bug #1475009: clarify ntpath.join behavior with absolute components
........
r45783 | george.yoshida | 2006-04-28 18:40:14 +0200 (Fri, 28 Apr 2006) | 2 lines
correct a dead link
........
r45785 | georg.brandl | 2006-04-28 18:54:25 +0200 (Fri, 28 Apr 2006) | 4 lines
Bug #1472949: stringify IOErrors in shutil.copytree when appending
them to the Error errors list.
........
r45786 | georg.brandl | 2006-04-28 18:58:52 +0200 (Fri, 28 Apr 2006) | 3 lines
Bug #1478326: don't allow '/' in distutils.util.get_platform machine names
since this value is used to name the build directory.
........
r45788 | thomas.heller | 2006-04-28 19:02:18 +0200 (Fri, 28 Apr 2006) | 1 line
Remove a duplicated test (the same test is in test_incomplete.py).
........
r45792 | georg.brandl | 2006-04-28 21:09:24 +0200 (Fri, 28 Apr 2006) | 3 lines
Bug #1478429: make datetime.datetime.fromtimestamp accept every float,
possibly "rounding up" to the next whole second.
........
r45796 | george.yoshida | 2006-04-29 04:43:30 +0200 (Sat, 29 Apr 2006) | 2 lines
grammar fix
........
r45800 | ronald.oussoren | 2006-04-29 13:31:35 +0200 (Sat, 29 Apr 2006) | 2 lines
Patch 1471883: --enable-universalsdk on Mac OS X
........
r45801 | andrew.kuchling | 2006-04-29 13:53:15 +0200 (Sat, 29 Apr 2006) | 1 line
Add item
........
r45802 | andrew.kuchling | 2006-04-29 14:10:28 +0200 (Sat, 29 Apr 2006) | 1 line
Make case of 'ZIP' consistent
........
r45803 | andrew.kuchling | 2006-04-29 14:10:43 +0200 (Sat, 29 Apr 2006) | 1 line
Add item
........
r45808 | martin.v.loewis | 2006-04-29 14:37:25 +0200 (Sat, 29 Apr 2006) | 3 lines
Further changes for #1471883: Edit Misc/NEWS, and
add expat_config.h.
........
r45809 | brett.cannon | 2006-04-29 23:29:50 +0200 (Sat, 29 Apr 2006) | 2 lines
Fix docstring for contextfactory; mentioned old contextmanager name.
........
r45810 | gerhard.haering | 2006-04-30 01:12:41 +0200 (Sun, 30 Apr 2006) | 3 lines
This is the start of documentation for the sqlite3 module. Please feel free to
find a better place for the link to it than alongside bsddb & friends.
........
r45811 | andrew.kuchling | 2006-04-30 03:07:09 +0200 (Sun, 30 Apr 2006) | 1 line
Add two items
........
r45814 | george.yoshida | 2006-04-30 05:49:56 +0200 (Sun, 30 Apr 2006) | 2 lines
Use \versionchanged instead of \versionadded for new parameter support.
........
r45815 | georg.brandl | 2006-04-30 09:06:11 +0200 (Sun, 30 Apr 2006) | 2 lines
Patch #1470846: fix urllib2 ProxyBasicAuthHandler.
........
r45817 | georg.brandl | 2006-04-30 10:57:35 +0200 (Sun, 30 Apr 2006) | 3 lines
In stdlib, use hashlib instead of deprecated md5 and sha modules.
........
r45819 | georg.brandl | 2006-04-30 11:23:59 +0200 (Sun, 30 Apr 2006) | 3 lines
Patch #1470976: don't NLST files when retrieving over FTP.
........
r45821 | georg.brandl | 2006-04-30 13:13:56 +0200 (Sun, 30 Apr 2006) | 6 lines
Bug #1473625: stop cPickle making float dumps locale dependent in protocol 0.
On the way, add a decorator to test_support to facilitate running single
test functions in different locales with automatic cleanup.
........
r45822 | phillip.eby | 2006-04-30 17:59:26 +0200 (Sun, 30 Apr 2006) | 2 lines
Fix infinite regress when inspecting <string> or <stdin> frames.
........
r45824 | georg.brandl | 2006-04-30 19:42:26 +0200 (Sun, 30 Apr 2006) | 3 lines
Fix another problem in inspect: if the module for an object cannot be found, don't try to give its __dict__ to linecache.
........
r45825 | georg.brandl | 2006-04-30 20:14:54 +0200 (Sun, 30 Apr 2006) | 3 lines
Patch #1472854: make the rlcompleter.Completer class usable on non-
UNIX platforms.
........
r45826 | georg.brandl | 2006-04-30 21:34:19 +0200 (Sun, 30 Apr 2006) | 3 lines
Patch #1479438: add \keyword markup for "with".
........
r45827 | andrew.kuchling | 2006-04-30 23:19:31 +0200 (Sun, 30 Apr 2006) | 1 line
Add urllib2 HOWTO from Michael Foord
........
r45828 | andrew.kuchling | 2006-04-30 23:19:49 +0200 (Sun, 30 Apr 2006) | 1 line
Add item
........
r45830 | barry.warsaw | 2006-05-01 05:03:02 +0200 (Mon, 01 May 2006) | 11 lines
Port forward from 2.4 branch:
Patch #1464708 from William McVey: fixed handling of nested comments in mail
addresses. E.g.
"Foo ((Foo Bar)) <foo@example.com>"
Fixes for both rfc822.py and email package. This patch needs to be back
ported to Python 2.3 for email 2.5.
........
r45832 | fred.drake | 2006-05-01 08:25:58 +0200 (Mon, 01 May 2006) | 4 lines
- minor clarification in section title
- markup adjustments
(there is clearly much to be done in this section)
........
r45833 | martin.v.loewis | 2006-05-01 08:28:01 +0200 (Mon, 01 May 2006) | 2 lines
Work around deadlock risk. Will backport.
........
r45836 | andrew.kuchling | 2006-05-01 14:45:02 +0200 (Mon, 01 May 2006) | 1 line
Some ElementTree fixes: import from xml, not xmlcore; fix case of module name; mention list() instead of getchildren()
........
r45837 | gerhard.haering | 2006-05-01 17:14:48 +0200 (Mon, 01 May 2006) | 3 lines
Further integration of the documentation for the sqlite3 module. There's still
quite some content to move over from the pysqlite manual, but it's a start now.
........
r45838 | martin.v.loewis | 2006-05-01 17:56:03 +0200 (Mon, 01 May 2006) | 2 lines
Rename uisample to text, drop all non-text tables.
........
r45839 | martin.v.loewis | 2006-05-01 18:12:44 +0200 (Mon, 01 May 2006) | 2 lines
Add msilib documentation.
........
r45840 | martin.v.loewis | 2006-05-01 18:14:16 +0200 (Mon, 01 May 2006) | 4 lines
Rename parameters to match the documentation (which
in turn matches Microsoft's documentation).
Drop unused parameter in CAB.append.
........
r45841 | fred.drake | 2006-05-01 18:28:54 +0200 (Mon, 01 May 2006) | 1 line
add dependency
........
r45842 | andrew.kuchling | 2006-05-01 18:30:25 +0200 (Mon, 01 May 2006) | 1 line
Markup fixes; add some XXX comments noting problems
........
r45843 | andrew.kuchling | 2006-05-01 18:32:49 +0200 (Mon, 01 May 2006) | 1 line
Add item
........
r45844 | andrew.kuchling | 2006-05-01 19:06:54 +0200 (Mon, 01 May 2006) | 1 line
Markup fixes
........
r45850 | neal.norwitz | 2006-05-02 06:43:14 +0200 (Tue, 02 May 2006) | 3 lines
SF #1479181: split open() and file() from being aliases for each other.
........
r45852 | neal.norwitz | 2006-05-02 08:23:22 +0200 (Tue, 02 May 2006) | 1 line
Try to fix breakage caused by patch #1479181, r45850
........
r45853 | fred.drake | 2006-05-02 08:53:59 +0200 (Tue, 02 May 2006) | 3 lines
SF #1479988: add methods to allow access to weakrefs for the
weakref.WeakKeyDictionary and weakref.WeakValueDictionary
........
r45854 | neal.norwitz | 2006-05-02 09:27:47 +0200 (Tue, 02 May 2006) | 5 lines
Fix breakage from patch 1471883 (r45800 & r45808) on OSF/1.
The problem was that pyconfig.h was being included before some system headers
which caused redefinitions and other breakage. This moves system headers
after expat_config.h which includes pyconfig.h.
........
r45855 | vinay.sajip | 2006-05-02 10:35:36 +0200 (Tue, 02 May 2006) | 1 line
Replaced my dumb way of calculating seconds to midnight with Tim Peters' much more sensible suggestion. What was I thinking ?!?
........
r45856 | andrew.kuchling | 2006-05-02 13:30:03 +0200 (Tue, 02 May 2006) | 1 line
Provide encoding as keyword argument; soften warning paragraph about encodings
........
r45858 | guido.van.rossum | 2006-05-02 19:36:09 +0200 (Tue, 02 May 2006) | 2 lines
Fix the formatting of KeyboardInterrupt -- a bad issubclass() call.
........
r45862 | guido.van.rossum | 2006-05-02 21:47:52 +0200 (Tue, 02 May 2006) | 7 lines
Get rid of __context__, per the latest changes to PEP 343 and python-dev
discussion.
There are two places of documentation that still mention __context__:
Doc/lib/libstdtypes.tex -- I wasn't quite sure how to rewrite that without
spending a whole lot of time thinking about it; and whatsnew, which Andrew
usually likes to change himself.
........
r45863 | armin.rigo | 2006-05-02 21:52:32 +0200 (Tue, 02 May 2006) | 4 lines
Documentation bug: PySet_Pop() returns a new reference (because the
caller becomes the owner of that reference).
........
r45864 | guido.van.rossum | 2006-05-02 22:47:36 +0200 (Tue, 02 May 2006) | 4 lines
Hopefully this will fix the spurious failures of test_mailbox.py that I'm
experiencing. (This code and mailbox.py itself are full of calls to file()
that should be calls to open() -- but I'm not fixing those.)
........
r45865 | andrew.kuchling | 2006-05-02 23:44:33 +0200 (Tue, 02 May 2006) | 1 line
Use open() instead of file()
........
r45866 | andrew.kuchling | 2006-05-03 00:47:49 +0200 (Wed, 03 May 2006) | 1 line
Update context manager section for removal of __context__
........
r45867 | fred.drake | 2006-05-03 03:46:52 +0200 (Wed, 03 May 2006) | 1 line
remove unnecessary assignment
........
r45868 | fred.drake | 2006-05-03 03:48:24 +0200 (Wed, 03 May 2006) | 4 lines
tell LaTeX2HTML to:
- use UTF-8 output
- not mess with the >>> prompt!
........
r45869 | fred.drake | 2006-05-03 04:04:40 +0200 (Wed, 03 May 2006) | 3 lines
avoid ugly markup based on the unfortunate conversions of ">>" and "<<" to
guillemets; no need for magic here
........
r45870 | fred.drake | 2006-05-03 04:12:47 +0200 (Wed, 03 May 2006) | 1 line
at least comment on why curly-quotes are not enabled
........
r45871 | fred.drake | 2006-05-03 04:27:40 +0200 (Wed, 03 May 2006) | 1 line
one more place to avoid extra markup
........
r45872 | fred.drake | 2006-05-03 04:29:09 +0200 (Wed, 03 May 2006) | 1 line
one more place to avoid extra markup (how many will there be?)
........
r45873 | fred.drake | 2006-05-03 04:29:39 +0200 (Wed, 03 May 2006) | 1 line
fix up whitespace in prompt strings
........
r45876 | tim.peters | 2006-05-03 06:46:14 +0200 (Wed, 03 May 2006) | 2 lines
Whitespace normalization.
........
r45877 | martin.v.loewis | 2006-05-03 06:52:04 +0200 (Wed, 03 May 2006) | 2 lines
Correct some formulations, fix XXX comments.
........
r45879 | georg.brandl | 2006-05-03 07:05:02 +0200 (Wed, 03 May 2006) | 2 lines
Patch #1480067: don't redirect HTTP digest auth in urllib2
........
r45881 | georg.brandl | 2006-05-03 07:15:10 +0200 (Wed, 03 May 2006) | 3 lines
Move network tests from test_urllib2 to test_urllib2net.
........
r45887 | nick.coghlan | 2006-05-03 15:02:47 +0200 (Wed, 03 May 2006) | 1 line
Finish bringing SVN into line with latest version of PEP 343 by getting rid of all remaining references to context objects that I could find. Without a __context__() method context objects no longer exist. Also get test_with working again, and adopt a suggestion from Neal for decimal.Context.get_manager()
........
r45888 | nick.coghlan | 2006-05-03 15:17:49 +0200 (Wed, 03 May 2006) | 1 line
Get rid of a couple more context object references, fix some markup and clarify what happens when a generator context function swallows an exception.
........
r45889 | georg.brandl | 2006-05-03 19:46:13 +0200 (Wed, 03 May 2006) | 3 lines
Add seamonkey to list of Windows browsers too.
........
r45890 | georg.brandl | 2006-05-03 20:03:22 +0200 (Wed, 03 May 2006) | 3 lines
RFE #1472176: In httplib, don't encode the netloc and hostname with "idna" if not necessary.
........
r45891 | georg.brandl | 2006-05-03 20:12:33 +0200 (Wed, 03 May 2006) | 2 lines
Bug #1472191: convert breakpoint indices to ints before comparing them to ints
........
r45893 | georg.brandl | 2006-05-03 20:18:32 +0200 (Wed, 03 May 2006) | 3 lines
Bug #1385040: don't allow "def foo(a=1, b): pass" in the compiler package.
........
r45894 | thomas.heller | 2006-05-03 20:35:39 +0200 (Wed, 03 May 2006) | 1 line
Don't fail the tests when libglut.so or libgle.so cannot be loaded.
........
r45895 | georg.brandl | 2006-05-04 07:08:10 +0200 (Thu, 04 May 2006) | 2 lines
Bug #1481530: allow "from os.path import ..." with imputil
........
r45897 | martin.v.loewis | 2006-05-04 07:51:03 +0200 (Thu, 04 May 2006) | 2 lines
Patch #1475845: Raise IndentationError for unexpected indent.
........
r45898 | martin.v.loewis | 2006-05-04 12:08:42 +0200 (Thu, 04 May 2006) | 1 line
Implement os.{chdir,rename,rmdir,remove} using Win32 directly.
........
r45899 | martin.v.loewis | 2006-05-04 14:04:27 +0200 (Thu, 04 May 2006) | 2 lines
Drop now-unnecessary arguments to posix_2str.
........
r45900 | martin.v.loewis | 2006-05-04 16:27:52 +0200 (Thu, 04 May 2006) | 1 line
Update checks to consider Windows error numbers.
........
r45913 | thomas.heller | 2006-05-05 20:42:14 +0200 (Fri, 05 May 2006) | 2 lines
Export the 'free' standard C function for use in the test suite.
........
r45914 | thomas.heller | 2006-05-05 20:43:24 +0200 (Fri, 05 May 2006) | 3 lines
Fix memory leaks in the ctypes test suite, reported by valgrind, by
free()ing the memory we allocate.
........
r45915 | thomas.heller | 2006-05-05 20:46:27 +0200 (Fri, 05 May 2006) | 1 line
oops - the function is exported as 'my_free', not 'free'.
........
r45916 | thomas.heller | 2006-05-05 21:14:24 +0200 (Fri, 05 May 2006) | 2 lines
Clean up.
........
r45920 | george.yoshida | 2006-05-06 15:09:45 +0200 (Sat, 06 May 2006) | 2 lines
describe optional arguments for DocFileSuite
........
r45924 | george.yoshida | 2006-05-06 16:16:51 +0200 (Sat, 06 May 2006) | 2 lines
Use \versionchanged for the feature change
........
r45925 | martin.v.loewis | 2006-05-06 18:32:54 +0200 (Sat, 06 May 2006) | 1 line
Port access, chmod, parts of getcwdu, mkdir, and utime to direct Win32 API.
........
r45926 | martin.v.loewis | 2006-05-06 22:04:08 +0200 (Sat, 06 May 2006) | 2 lines
Handle ERROR_ALREADY_EXISTS.
........
r45931 | andrew.kuchling | 2006-05-07 19:12:12 +0200 (Sun, 07 May 2006) | 1 line
[Patch #1479977] Revised version of urllib2 HOWTO, edited by John J. Lee
........
r45932 | andrew.kuchling | 2006-05-07 19:14:53 +0200 (Sun, 07 May 2006) | 1 line
Minor language edit
........
r45934 | georg.brandl | 2006-05-07 22:44:34 +0200 (Sun, 07 May 2006) | 3 lines
Patch #1483395: add new TLDs to cookielib
........
r45936 | martin.v.loewis | 2006-05-08 07:25:56 +0200 (Mon, 08 May 2006) | 2 lines
Add missing PyMem_Free.
........
r45938 | georg.brandl | 2006-05-08 19:28:47 +0200 (Mon, 08 May 2006) | 3 lines
Add test for rev. 45934.
........
r45939 | georg.brandl | 2006-05-08 19:36:08 +0200 (Mon, 08 May 2006) | 3 lines
Patch #1479302: Make urllib2 digest auth and basic auth play together.
........
r45940 | georg.brandl | 2006-05-08 19:48:01 +0200 (Mon, 08 May 2006) | 3 lines
Patch #1478993: take advantage of BaseException/Exception split in cookielib
........
r45941 | neal.norwitz | 2006-05-09 07:38:56 +0200 (Tue, 09 May 2006) | 5 lines
Micro optimization. In the first case, we know that frame->f_exc_type
is NULL, so there's no reason to do anything with it. In the second case,
we know frame->f_exc_type is not NULL, so we can just do an INCREF.
........
r45943 | thomas.heller | 2006-05-09 22:20:15 +0200 (Tue, 09 May 2006) | 2 lines
Disable a test that is unreliable.
........
r45944 | tim.peters | 2006-05-10 04:43:01 +0200 (Wed, 10 May 2006) | 4 lines
Variant of patch #1478292. doctest.register_optionflag(name)
shouldn't create a new flag when `name` is already the name of
an option flag.
........
r45947 | neal.norwitz | 2006-05-10 08:57:58 +0200 (Wed, 10 May 2006) | 14 lines
Fix problems found by Coverity.
longobject.c: also fix an ssize_t problem
<a> could have been NULL, so hoist the size calc to not use <a>.
_ssl.c: under fail: self is DECREF'd, but it would have been NULL.
_elementtree.c: delete self if there was an error.
_csv.c: I'm not sure if lineterminator could have been anything other than
a string. However, other string method calls are checked, so check this
one too.
........
r45948 | thomas.wouters | 2006-05-10 17:04:11 +0200 (Wed, 10 May 2006) | 4 lines
Ignore reflog.txt, too.
........
r45949 | georg.brandl | 2006-05-10 17:59:06 +0200 (Wed, 10 May 2006) | 3 lines
Bug #1482988: indicate more prominently that the Stats class is in the pstats module.
........
r45950 | georg.brandl | 2006-05-10 18:09:03 +0200 (Wed, 10 May 2006) | 2 lines
Bug #1485447: subprocess: document that the "cwd" parameter isn't used to find the executable. Misc. other markup fixes.
........
r45952 | georg.brandl | 2006-05-10 18:11:44 +0200 (Wed, 10 May 2006) | 2 lines
Bug #1484978: curses.panel: clarify that Panel objects are destroyed on garbage collection.
........
r45954 | georg.brandl | 2006-05-10 18:26:03 +0200 (Wed, 10 May 2006) | 4 lines
Patch #1484695: Update the tarfile module to version 0.8. This fixes
a couple of issues, notably handling of long file names using the
GNU LONGNAME extension.
........
r45955 | georg.brandl | 2006-05-10 19:13:20 +0200 (Wed, 10 May 2006) | 4 lines
Patch #721464: pdb.Pdb instances can now be given explicit stdin and
stdout arguments, making it possible to redirect input and output
for remote debugging.
........
r45956 | andrew.kuchling | 2006-05-10 19:19:04 +0200 (Wed, 10 May 2006) | 1 line
Clarify description of exception handling
........
r45957 | georg.brandl | 2006-05-10 22:09:23 +0200 (Wed, 10 May 2006) | 2 lines
Fix two small errors in argument lists.
........
r45960 | brett.cannon | 2006-05-11 07:11:33 +0200 (Thu, 11 May 2006) | 5 lines
Detect if %zd is supported by printf() during configure and sets
PY_FORMAT_SIZE_T appropriately. Removes warnings on
OS X under gcc 4.0.1 when PY_FORMAT_SIZE_T is set to "" instead of "z" as is
needed.
........
r45963 | neal.norwitz | 2006-05-11 09:51:59 +0200 (Thu, 11 May 2006) | 1 line
Don't mask a no memory error with a less meaningful one as discussed on python-checkins
........
r45964 | martin.v.loewis | 2006-05-11 15:28:43 +0200 (Thu, 11 May 2006) | 3 lines
Change WindowsError to carry the Win32 error code in winerror,
and the DOS error code in errno. Revert changes where
WindowsError catch blocks unnecessarily special-case OSError.
........
r45965 | george.yoshida | 2006-05-11 17:53:27 +0200 (Thu, 11 May 2006) | 2 lines
Grammar fix
........
r45967 | andrew.kuchling | 2006-05-11 18:32:24 +0200 (Thu, 11 May 2006) | 1 line
typo fix
........
r45968 | tim.peters | 2006-05-11 18:37:42 +0200 (Thu, 11 May 2006) | 5 lines
BaseThreadedTestCase.setup(): stop special-casing WindowsError.
Rev 45964 fiddled with WindowsError, and broke test_bsddb3 on all
the Windows buildbot slaves as a result. This should repair it.
........
r45969 | georg.brandl | 2006-05-11 21:57:09 +0200 (Thu, 11 May 2006) | 2 lines
Typo fix.
........
r45970 | tim.peters | 2006-05-12 03:57:59 +0200 (Fri, 12 May 2006) | 5 lines
SF patch #1473132: Improve docs for tp_clear and tp_traverse,
by Collin Winter.
Bugfix candidate (but I'm not going to bother).
........
r45974 | martin.v.loewis | 2006-05-12 14:27:28 +0200 (Fri, 12 May 2006) | 4 lines
Dynamically allocate path name buffer for Unicode
path name in listdir. Fixes #1431582.
Stop overallocating MAX_PATH characters for ANSI
path names. Stop assigning to errno.
........
r45975 | martin.v.loewis | 2006-05-12 15:57:36 +0200 (Fri, 12 May 2006) | 1 line
Move icon files into DLLs dir. Fixes #1477968.
........
r45976 | george.yoshida | 2006-05-12 18:40:11 +0200 (Fri, 12 May 2006) | 2 lines
At first there were 6 steps, but one was removed after that.
........
r45977 | martin.v.loewis | 2006-05-12 19:22:04 +0200 (Fri, 12 May 2006) | 1 line
Fix alignment error on Itanium.
........
r45978 | george.yoshida | 2006-05-12 19:25:26 +0200 (Fri, 12 May 2006) | 3 lines
Duplicated description about the illegal continue usage can be found in nearly the same place.
They are same, so keep the original one and remove the later-added one.
........
r45980 | thomas.heller | 2006-05-12 20:16:03 +0200 (Fri, 12 May 2006) | 2 lines
Add missing svn properties.
........
r45981 | thomas.heller | 2006-05-12 20:47:35 +0200 (Fri, 12 May 2006) | 1 line
set svn properties
........
r45982 | thomas.heller | 2006-05-12 21:31:46 +0200 (Fri, 12 May 2006) | 1 line
add svn:eol-style native svn:keywords Id
........
r45987 | gerhard.haering | 2006-05-13 01:49:49 +0200 (Sat, 13 May 2006) | 3 lines
Integrated the rest of the pysqlite reference manual into the Python
documentation. Ready to be reviewed and improved upon.
........
r45988 | george.yoshida | 2006-05-13 08:53:31 +0200 (Sat, 13 May 2006) | 2 lines
Add \exception markup
........
r45990 | martin.v.loewis | 2006-05-13 15:34:04 +0200 (Sat, 13 May 2006) | 2 lines
Revert 43315: Printing of %zd must be signed.
........
r45992 | tim.peters | 2006-05-14 01:28:20 +0200 (Sun, 14 May 2006) | 11 lines
Teach PyString_FromFormat, PyErr_Format, and PyString_FromFormatV
about "%u", "%lu" and "%zu" formats.
Since PyString_FromFormat and PyErr_Format have exactly the same rules
(both inherited from PyString_FromFormatV), it would be good if someone
with more LaTeX Fu changed one of them to just point to the other.
Their docs were way out of synch before this patch, and I just did a
mass copy+paste to repair that.
Not a backport candidate (this is a new feature).
........
r45993 | tim.peters | 2006-05-14 01:31:05 +0200 (Sun, 14 May 2006) | 2 lines
Typo repair.
........
r45994 | tim.peters | 2006-05-14 01:33:19 +0200 (Sun, 14 May 2006) | 2 lines
Remove lie in new comment.
........
r45995 | ronald.oussoren | 2006-05-14 21:56:34 +0200 (Sun, 14 May 2006) | 11 lines
Rework the build system for osx applications:
* Don't use xcodebuild for building PythonLauncher, but use a normal unix
makefile. This makes it a lot easier to use the same build flags as for the
rest of python (e.g. make a universal version of python launcher)
* Convert the mac makefile-s to makefile.in-s and use configure to set makefile
variables instead of forwarding them as command-line arguments
* Add a C version of pythonw, that we you can use '#!/usr/local/bin/pythonw'
* Build IDLE.app using bundlebuilder instead of BuildApplet, that will allow
easier modification of the bundle contents later on.
........
r45996 | ronald.oussoren | 2006-05-14 22:35:41 +0200 (Sun, 14 May 2006) | 6 lines
A first cut at replacing the icons on MacOS X. This replaces all icons by icons
based on the new python.org logo. These are also the first icons that are
"proper" OSX icons.
These icons were created by Jacob Rus.
........
r45997 | ronald.oussoren | 2006-05-14 23:07:41 +0200 (Sun, 14 May 2006) | 3 lines
I missed one small detail in my rewrite of the osx build files: the path
to the Python.app template.
........
r45998 | martin.v.loewis | 2006-05-15 07:51:36 +0200 (Mon, 15 May 2006) | 2 lines
Fix memory leak.
........
r45999 | neal.norwitz | 2006-05-15 08:48:14 +0200 (Mon, 15 May 2006) | 1 line
Move items implemented after a2 into the new a3 section
........
r46000 | neal.norwitz | 2006-05-15 09:04:36 +0200 (Mon, 15 May 2006) | 5 lines
- Bug #1487966: Fix SystemError with conditional expression in assignment
Most of the test_syntax changes are just updating the numbers.
........
r46001 | neal.norwitz | 2006-05-15 09:17:23 +0200 (Mon, 15 May 2006) | 1 line
Patch #1488312, Fix memory alignment problem on SPARC in unicode. Will backport
........
r46003 | martin.v.loewis | 2006-05-15 11:22:27 +0200 (Mon, 15 May 2006) | 3 lines
Remove bogus DECREF of self.
Change __str__() functions to METH_O.
Change WindowsError__str__ to use PyTuple_Pack.
........
r46005 | georg.brandl | 2006-05-15 21:30:35 +0200 (Mon, 15 May 2006) | 3 lines
[ 1488881 ] tarfile.py: support for file-objects and bz2 (cp. #1488634)
........
r46007 | tim.peters | 2006-05-15 22:44:10 +0200 (Mon, 15 May 2006) | 9 lines
ReadDetectFileobjTest: repair Windows disasters by opening
the file object in binary mode.
The Windows buildbot slaves shouldn't swap themselves to death
anymore. However, test_tarfile may still fail because of a
temp directory left behind from a previous failing run.
Windows buildbot owners may need to remove that directory
by hand.
........
r46009 | tim.peters | 2006-05-15 23:32:25 +0200 (Mon, 15 May 2006) | 3 lines
test_directory(): Remove the leftover temp directory that's making
the Windows buildbots fail test_tarfile.
........
r46010 | martin.v.loewis | 2006-05-16 09:05:37 +0200 (Tue, 16 May 2006) | 4 lines
- Test for sys/statvfs.h before including it, as statvfs is present
on some OSX installation, but its header file is not.
Will backport to 2.4
........
r46012 | georg.brandl | 2006-05-16 09:38:27 +0200 (Tue, 16 May 2006) | 3 lines
Patch #1435422: zlib's compress and decompress objects now have a
copy() method.
........
r46015 | andrew.kuchling | 2006-05-16 18:11:54 +0200 (Tue, 16 May 2006) | 1 line
Add item
........
r46016 | andrew.kuchling | 2006-05-16 18:27:31 +0200 (Tue, 16 May 2006) | 3 lines
PEP 243 has been withdrawn, so don't refer to it any more.
The PyPI upload material has been moved into the section on PEP314.
........
r46017 | george.yoshida | 2006-05-16 19:42:16 +0200 (Tue, 16 May 2006) | 2 lines
Update for 'ImportWarning'
........
r46018 | george.yoshida | 2006-05-16 20:07:00 +0200 (Tue, 16 May 2006) | 4 lines
Mention that Exception is now a subclass of BaseException.
Remove a sentence that says that BaseException inherits from BaseException.
(I guess this is just a copy & paste mistake.)
........
r46019 | george.yoshida | 2006-05-16 20:26:10 +0200 (Tue, 16 May 2006) | 2 lines
Document ImportWarning
........
r46020 | tim.peters | 2006-05-17 01:22:20 +0200 (Wed, 17 May 2006) | 2 lines
Whitespace normalization.
........
r46021 | tim.peters | 2006-05-17 01:24:08 +0200 (Wed, 17 May 2006) | 2 lines
Text files missing the SVN eol-style property.
........
r46022 | tim.peters | 2006-05-17 03:30:11 +0200 (Wed, 17 May 2006) | 2 lines
PyZlib_copy(), PyZlib_uncopy(): Repair leaks on the normal-case path.
........
r46023 | georg.brandl | 2006-05-17 16:06:07 +0200 (Wed, 17 May 2006) | 3 lines
Remove misleading comment about type-class unification.
........
r46024 | georg.brandl | 2006-05-17 16:11:36 +0200 (Wed, 17 May 2006) | 3 lines
Apply patch #1489784 from Michael Foord.
........
r46025 | georg.brandl | 2006-05-17 16:18:20 +0200 (Wed, 17 May 2006) | 3 lines
Fix typo in os.utime docstring (patch #1490189)
........
r46026 | georg.brandl | 2006-05-17 16:26:50 +0200 (Wed, 17 May 2006) | 3 lines
Patch #1490224: set time.altzone correctly on Cygwin.
........
r46027 | georg.brandl | 2006-05-17 16:45:06 +0200 (Wed, 17 May 2006) | 4 lines
Add global debug flag to cookielib to avoid heavy dependency on the logging module.
Resolves #1484758.
........
r46028 | georg.brandl | 2006-05-17 16:56:04 +0200 (Wed, 17 May 2006) | 3 lines
Patch #1486962: Several bugs in the turtle Tk demo module were fixed
and several features added, such as speed and geometry control.
........
r46029 | georg.brandl | 2006-05-17 17:17:00 +0200 (Wed, 17 May 2006) | 4 lines
Delay-import some large modules to speed up urllib2 import.
(fixes #1484793).
........
r46030 | georg.brandl | 2006-05-17 17:51:16 +0200 (Wed, 17 May 2006) | 3 lines
Patch #1180296: improve locale string formatting functions
........
r46032 | tim.peters | 2006-05-18 04:06:40 +0200 (Thu, 18 May 2006) | 2 lines
Whitespace normalization.
........
r46033 | georg.brandl | 2006-05-18 08:11:19 +0200 (Thu, 18 May 2006) | 3 lines
Amendments to patch #1484695.
........
r46034 | georg.brandl | 2006-05-18 08:18:06 +0200 (Thu, 18 May 2006) | 3 lines
Remove unused import.
........
r46035 | georg.brandl | 2006-05-18 08:33:27 +0200 (Thu, 18 May 2006) | 3 lines
Fix test_locale for platforms without a default thousands separator.
........
r46036 | neal.norwitz | 2006-05-18 08:51:46 +0200 (Thu, 18 May 2006) | 1 line
Little cleanup
........
r46037 | georg.brandl | 2006-05-18 09:01:27 +0200 (Thu, 18 May 2006) | 4 lines
Bug #1462152: file() now checks more thoroughly for invalid mode
strings and removes a possible "U" before passing the mode to the
C library function.
........
r46038 | georg.brandl | 2006-05-18 09:20:05 +0200 (Thu, 18 May 2006) | 3 lines
Bug #1490688: properly document %e, %f, %g format subtleties.
........
r46039 | vinay.sajip | 2006-05-18 09:28:58 +0200 (Thu, 18 May 2006) | 1 line
Changed status from "beta" to "production"; since logging has been part of the stdlib since 2.3, it should be safe to make this assertion ;-)
........
r46040 | ronald.oussoren | 2006-05-18 11:04:15 +0200 (Thu, 18 May 2006) | 2 lines
Fix some minor issues with the generated application bundles on MacOSX
........
r46041 | andrew.kuchling | 2006-05-19 02:03:55 +0200 (Fri, 19 May 2006) | 1 line
Typo fix; add clarifying word
........
r46044 | neal.norwitz | 2006-05-19 08:31:23 +0200 (Fri, 19 May 2006) | 3 lines
Fix #132 from Coverity, retval could have been derefed
if a continue inside a try failed.
........
r46045 | neal.norwitz | 2006-05-19 08:43:50 +0200 (Fri, 19 May 2006) | 2 lines
Fix #1474677, non-keyword argument following keyword.
........
r46046 | neal.norwitz | 2006-05-19 09:00:58 +0200 (Fri, 19 May 2006) | 4 lines
Bug/Patch #1481770: Use .so extension for shared libraries on HP-UX for ia64.
I suppose this could be backported if anyone cares.
........
r46047 | neal.norwitz | 2006-05-19 09:05:01 +0200 (Fri, 19 May 2006) | 7 lines
Oops, I forgot to include this file in the last commit (46046):
Bug/Patch #1481770: Use .so extension for shared libraries on HP-UX for ia64.
I suppose this could be backported if anyone cares.
........
r46050 | ronald.oussoren | 2006-05-19 20:17:31 +0200 (Fri, 19 May 2006) | 6 lines
* Change working directory to the users home
directory, that makes the file open/save
dialogs more useable.
* Don't use argv emulator, its not needed
for idle.
........
r46052 | tim.peters | 2006-05-19 21:16:34 +0200 (Fri, 19 May 2006) | 2 lines
Whitespace normalization.
........
r46054 | ronald.oussoren | 2006-05-20 08:17:01 +0200 (Sat, 20 May 2006) | 9 lines
Fix bug #1000914 (again).
This patches a file that is generated by bgen, however the code is now the
same as a current copy of bgen would generate. Without this patch most types
in the Carbon.CF module are unusable.
I haven't managed to coax bgen into generating a complete copy of _CFmodule.c
yet :-(, hence the manual patching.
........
r46055 | george.yoshida | 2006-05-20 17:36:19 +0200 (Sat, 20 May 2006) | 3 lines
- markup fix
- add clarifying words
........
r46057 | george.yoshida | 2006-05-20 18:29:14 +0200 (Sat, 20 May 2006) | 3 lines
- Add 'as' and 'with' as new keywords in 2.5.
- Regenerate keyword lists with reswords.py.
........
r46058 | george.yoshida | 2006-05-20 20:07:26 +0200 (Sat, 20 May 2006) | 2 lines
Apply patch #1492147 from Mike Foord.
........
r46059 | andrew.kuchling | 2006-05-20 21:25:16 +0200 (Sat, 20 May 2006) | 1 line
Minor edits
........
r46061 | george.yoshida | 2006-05-21 06:22:59 +0200 (Sun, 21 May 2006) | 2 lines
Fix the TeX compile error.
........
r46062 | george.yoshida | 2006-05-21 06:40:32 +0200 (Sun, 21 May 2006) | 2 lines
Apply patch #1492255 from Mike Foord.
........
r46063 | martin.v.loewis | 2006-05-22 10:48:14 +0200 (Mon, 22 May 2006) | 1 line
Patch 1490384: New Icons for the PC build.
........
r46064 | martin.v.loewis | 2006-05-22 11:15:18 +0200 (Mon, 22 May 2006) | 1 line
Patch #1492356: Port to Windows CE (patch set 1).
........
r46065 | tim.peters | 2006-05-22 13:29:41 +0200 (Mon, 22 May 2006) | 4 lines
Define SIZEOF_{DOUBLE,FLOAT} on Windows. Else
Michael Hudson's nice gimmicks for IEEE special
values (infinities, NaNs) don't work.
........
r46070 | bob.ippolito | 2006-05-22 16:31:24 +0200 (Mon, 22 May 2006) | 2 lines
GzipFile.readline performance improvement (~30-40%), patch #1281707
........
r46071 | bob.ippolito | 2006-05-22 17:22:46 +0200 (Mon, 22 May 2006) | 1 line
Revert gzip readline performance patch #1281707 until a more generic performance improvement can be found
........
r46073 | fredrik.lundh | 2006-05-22 17:35:12 +0200 (Mon, 22 May 2006) | 4 lines
docstring tweaks: count counts non-overlapping substrings, not
total number of occurences
........
r46075 | bob.ippolito | 2006-05-22 17:59:12 +0200 (Mon, 22 May 2006) | 1 line
Apply revised patch for GzipFile.readline performance #1281707
........
r46076 | fredrik.lundh | 2006-05-22 18:29:30 +0200 (Mon, 22 May 2006) | 3 lines
needforspeed: speed up unicode repeat, unicode string copy
........
r46079 | fredrik.lundh | 2006-05-22 19:12:58 +0200 (Mon, 22 May 2006) | 4 lines
needforspeed: use memcpy for "long" strings; use a better algorithm
for long repeats.
........
r46084 | tim.peters | 2006-05-22 21:17:04 +0200 (Mon, 22 May 2006) | 7 lines
PyUnicode_Join(): Recent code changes introduced new
compiler warnings on Windows (signed vs unsigned mismatch
in comparisons). Cleaned that up by switching more locals
to Py_ssize_t. Simplified overflow checking (it can _be_
simpler because while these things are declared as
Py_ssize_t, then should in fact never be negative).
........
r46085 | tim.peters | 2006-05-23 07:47:16 +0200 (Tue, 23 May 2006) | 3 lines
unicode_repeat(): Change type of local to Py_ssize_t,
since that's what it should be.
........
r46094 | fredrik.lundh | 2006-05-23 12:10:57 +0200 (Tue, 23 May 2006) | 3 lines
needforspeed: check first *and* last character before doing a full memcmp
........
r46095 | fredrik.lundh | 2006-05-23 12:12:21 +0200 (Tue, 23 May 2006) | 4 lines
needforspeed: fixed unicode "in" operator to use same implementation
approach as find/index
........
r46096 | richard.jones | 2006-05-23 12:37:38 +0200 (Tue, 23 May 2006) | 7 lines
Merge from rjones-funccall branch.
Applied patch zombie-frames-2.diff from sf patch 876206 with updates for
Python 2.5 and also modified to retain the free_list to avoid the 67%
slow-down in pybench recursion test. 5% speed up in function call pybench.
........
r46098 | ronald.oussoren | 2006-05-23 13:04:24 +0200 (Tue, 23 May 2006) | 2 lines
Avoid creating a mess when installing a framework for the second time.
........
r46101 | georg.brandl | 2006-05-23 13:17:21 +0200 (Tue, 23 May 2006) | 3 lines
PyErr_NewException now accepts a tuple of base classes as its
"base" parameter.
........
r46103 | ronald.oussoren | 2006-05-23 13:47:16 +0200 (Tue, 23 May 2006) | 3 lines
Disable linking extensions with -lpython2.5 for darwin. This should fix bug
#1487105.
........
r46104 | ronald.oussoren | 2006-05-23 14:01:11 +0200 (Tue, 23 May 2006) | 6 lines
Patch #1488098.
This patchs makes it possible to create a universal build on OSX 10.4 and use
the result to build extensions on 10.3. It also makes it possible to override
the '-arch' and '-isysroot' compiler arguments for specific extensions.
........
r46108 | andrew.kuchling | 2006-05-23 14:44:36 +0200 (Tue, 23 May 2006) | 1 line
Add some items; mention the sprint
........
r46109 | andrew.kuchling | 2006-05-23 14:47:01 +0200 (Tue, 23 May 2006) | 1 line
Mention string improvements
........
r46110 | andrew.kuchling | 2006-05-23 14:49:35 +0200 (Tue, 23 May 2006) | 4 lines
Use 'speed' instead of 'performance', because I agree with the argument
at http://zestyping.livejournal.com/193260.html that 'erformance' really means
something more general.
........
r46113 | ronald.oussoren | 2006-05-23 17:09:57 +0200 (Tue, 23 May 2006) | 2 lines
An improved script for building the binary distribution on MacOSX.
........
r46128 | richard.jones | 2006-05-23 20:28:17 +0200 (Tue, 23 May 2006) | 3 lines
Applied patch 1337051 by Neal Norwitz, saving 4 ints on frame objects.
........
r46129 | richard.jones | 2006-05-23 20:32:11 +0200 (Tue, 23 May 2006) | 1 line
fix broken merge
........
r46130 | bob.ippolito | 2006-05-23 20:41:17 +0200 (Tue, 23 May 2006) | 1 line
Update Misc/NEWS for gzip patch #1281707
........
r46131 | bob.ippolito | 2006-05-23 20:43:47 +0200 (Tue, 23 May 2006) | 1 line
Update Misc/NEWS for gzip patch #1281707
........
r46132 | fredrik.lundh | 2006-05-23 20:44:25 +0200 (Tue, 23 May 2006) | 7 lines
needforspeed: use append+reverse for rsplit, use "bloom filters" to
speed up splitlines and strip with charsets; etc. rsplit is now as
fast as split in all our tests (reverse takes no time at all), and
splitlines() is nearly as fast as a plain split("\n") in our tests.
and we're not done yet... ;-)
........
r46133 | tim.peters | 2006-05-23 20:45:30 +0200 (Tue, 23 May 2006) | 38 lines
Bug #1334662 / patch #1335972: int(string, base) wrong answers.
In rare cases of strings specifying true values near sys.maxint,
and oddball bases (not decimal or a power of 2), int(string, base)
could deliver insane answers. This repairs all such problems, and
also speeds string->int significantly. On my box, here are %
speedups for decimal strings of various lengths:
length speedup
------ -------
1 12.4%
2 15.7%
3 20.6%
4 28.1%
5 33.2%
6 37.5%
7 41.9%
8 46.3%
9 51.2%
10 19.5%
11 19.9%
12 23.9%
13 23.7%
14 23.3%
15 24.9%
16 25.3%
17 28.3%
18 27.9%
19 35.7%
Note that the difference between 9 and 10 is the difference between
short and long Python ints on a 32-bit box. The patch doesn't
actually do anything to speed conversion to long: the speedup is
due to detecting "unsigned long" overflow more quickly.
This is a bugfix candidate, but it's a non-trivial patch and it
would be painful to separate the "bug fix" from the "speed up" parts.
........
r46134 | bob.ippolito | 2006-05-23 20:46:41 +0200 (Tue, 23 May 2006) | 1 line
Patch #1493701: performance enhancements for struct module.
........
r46136 | andrew.kuchling | 2006-05-23 21:00:45 +0200 (Tue, 23 May 2006) | 1 line
Remove duplicate item
........
r46141 | bob.ippolito | 2006-05-23 21:09:51 +0200 (Tue, 23 May 2006) | 1 line
revert #1493701
........
r46142 | bob.ippolito | 2006-05-23 21:11:34 +0200 (Tue, 23 May 2006) | 1 line
patch #1493701: performance enhancements for struct module
........
r46144 | bob.ippolito | 2006-05-23 21:12:41 +0200 (Tue, 23 May 2006) | 1 line
patch #1493701: performance enhancements for struct module
........
r46148 | bob.ippolito | 2006-05-23 21:25:52 +0200 (Tue, 23 May 2006) | 1 line
fix linking issue, warnings, in struct
........
r46149 | andrew.kuchling | 2006-05-23 21:29:38 +0200 (Tue, 23 May 2006) | 1 line
Add two items
........
r46150 | bob.ippolito | 2006-05-23 21:31:23 +0200 (Tue, 23 May 2006) | 1 line
forward declaration for PyStructType
........
r46151 | bob.ippolito | 2006-05-23 21:32:25 +0200 (Tue, 23 May 2006) | 1 line
fix typo in _struct
........
r46152 | andrew.kuchling | 2006-05-23 21:32:35 +0200 (Tue, 23 May 2006) | 1 line
Add item
........
r46153 | tim.peters | 2006-05-23 21:34:37 +0200 (Tue, 23 May 2006) | 3 lines
Get the Windows build working again (recover from
`struct` module changes).
........
r46155 | fredrik.lundh | 2006-05-23 21:47:35 +0200 (Tue, 23 May 2006) | 3 lines
return 0 on misses, not -1.
........
r46156 | tim.peters | 2006-05-23 23:51:35 +0200 (Tue, 23 May 2006) | 4 lines
test_struct grew weird behavior under regrtest.py -R,
due to a module-level cache. Clearing the cache should
make it stop showing up in refleak reports.
........
r46157 | tim.peters | 2006-05-23 23:54:23 +0200 (Tue, 23 May 2006) | 2 lines
Whitespace normalization.
........
r46158 | tim.peters | 2006-05-23 23:55:53 +0200 (Tue, 23 May 2006) | 2 lines
Add missing svn:eol-style property to text files.
........
r46161 | fredrik.lundh | 2006-05-24 12:20:36 +0200 (Wed, 24 May 2006) | 3 lines
use Py_ssize_t for string indexes (thanks, neal!)
........
r46173 | fredrik.lundh | 2006-05-24 16:28:11 +0200 (Wed, 24 May 2006) | 14 lines
needforspeed: use "fastsearch" for count and findstring helpers. this
results in a 2.5x speedup on the stringbench count tests, and a 20x (!)
speedup on the stringbench search/find/contains test, compared to 2.5a2.
for more on the algorithm, see:
http://effbot.org/zone/stringlib.htm
if you get weird results, you can disable the new algoritm by undefining
USE_FAST in Objects/unicodeobject.c.
enjoy /F
........
r46182 | fredrik.lundh | 2006-05-24 17:11:01 +0200 (Wed, 24 May 2006) | 3 lines
needforspeedindeed: use fastsearch also for __contains__
........
r46184 | bob.ippolito | 2006-05-24 17:32:06 +0200 (Wed, 24 May 2006) | 1 line
refactor unpack, add unpack_from
........
r46189 | fredrik.lundh | 2006-05-24 18:35:18 +0200 (Wed, 24 May 2006) | 4 lines
needforspeed: refactored the replace code slightly; special-case
constant-length changes; use fastsearch to locate the first match.
........
r46198 | andrew.dalke | 2006-05-24 20:55:37 +0200 (Wed, 24 May 2006) | 10 lines
Added a slew of test for string replace, based various corner cases from
the Need For Speed sprint coding. Includes commented out overflow tests
which will be uncommented once the code is fixed.
This test will break the 8-bit string tests because
"".replace("", "A") == "" when it should == "A"
We have a fix for it, which should be added tomorrow.
........
r46200 | tim.peters | 2006-05-24 22:27:18 +0200 (Wed, 24 May 2006) | 2 lines
We can't leave the checked-in tests broken.
........
r46201 | tim.peters | 2006-05-24 22:29:44 +0200 (Wed, 24 May 2006) | 2 lines
Whitespace normalization.
........
r46202 | tim.peters | 2006-05-24 23:00:45 +0200 (Wed, 24 May 2006) | 4 lines
Disable the damn empty-string replace test -- it can't
be make to pass now for unicode if it passes for str, or
vice versa.
........
r46203 | tim.peters | 2006-05-24 23:10:40 +0200 (Wed, 24 May 2006) | 58 lines
Heavily fiddled variant of patch #1442927: PyLong_FromString optimization.
``long(str, base)`` is now up to 6x faster for non-power-of-2 bases. The
largest speedup is for inputs with about 1000 decimal digits. Conversion
from non-power-of-2 bases remains quadratic-time in the number of input
digits (it was and remains linear-time for bases 2, 4, 8, 16 and 32).
Speedups at various lengths for decimal inputs, comparing 2.4.3 with
current trunk. Note that it's actually a bit slower for 1-digit strings:
len speedup
---- -------
1 -4.5%
2 4.6%
3 8.3%
4 12.7%
5 16.9%
6 28.6%
7 35.5%
8 44.3%
9 46.6%
10 55.3%
11 65.7%
12 77.7%
13 73.4%
14 75.3%
15 85.2%
16 103.0%
17 95.1%
18 112.8%
19 117.9%
20 128.3%
30 174.5%
40 209.3%
50 236.3%
60 254.3%
70 262.9%
80 295.8%
90 297.3%
100 324.5%
200 374.6%
300 403.1%
400 391.1%
500 388.7%
600 440.6%
700 468.7%
800 498.0%
900 507.2%
1000 501.2%
2000 450.2%
3000 463.2%
4000 452.5%
5000 440.6%
6000 439.6%
7000 424.8%
8000 418.1%
9000 417.7%
........
r46204 | andrew.kuchling | 2006-05-25 02:23:03 +0200 (Thu, 25 May 2006) | 1 line
Minor edits; add an item
........
r46205 | fred.drake | 2006-05-25 04:42:25 +0200 (Thu, 25 May 2006) | 3 lines
fix broken links in PDF
(SF patch #1281291, contributed by Rory Yorke)
........
r46208 | walter.doerwald | 2006-05-25 10:53:28 +0200 (Thu, 25 May 2006) | 2 lines
Replace tab inside comment with space.
........
r46209 | thomas.wouters | 2006-05-25 13:25:51 +0200 (Thu, 25 May 2006) | 4 lines
Fix #1488915, Multiple dots in relative import statement raise SyntaxError.
........
r46210 | thomas.wouters | 2006-05-25 13:26:25 +0200 (Thu, 25 May 2006) | 5 lines
Update graminit.c for the fix for #1488915, Multiple dots in relative import
statement raise SyntaxError, and add testcase.
........
r46211 | andrew.kuchling | 2006-05-25 14:27:59 +0200 (Thu, 25 May 2006) | 1 line
Add entry; and fix a typo
........
r46214 | fredrik.lundh | 2006-05-25 17:22:03 +0200 (Thu, 25 May 2006) | 7 lines
needforspeed: speed up upper and lower for 8-bit string objects.
(the unicode versions of these are still 2x faster on windows,
though...)
based on work by Andrew Dalke, with tweaks by yours truly.
........
r46216 | fredrik.lundh | 2006-05-25 17:49:45 +0200 (Thu, 25 May 2006) | 5 lines
needforspeed: make new upper/lower work properly for single-character
strings too... (thanks to georg brandl for spotting the exact problem
faster than anyone else)
........
r46217 | kristjan.jonsson | 2006-05-25 17:53:30 +0200 (Thu, 25 May 2006) | 1 line
Added a new macro, Py_IS_FINITE(X). On windows there is an intrinsic for this and it is more efficient than to use !Py_IS_INFINITE(X) && !Py_IS_NAN(X). No change on other platforms
........
r46219 | fredrik.lundh | 2006-05-25 18:10:12 +0200 (Thu, 25 May 2006) | 4 lines
needforspeed: _toupper/_tolower is a SUSv2 thing; fall back on ISO C
versions if they're not defined.
........
r46220 | andrew.kuchling | 2006-05-25 18:23:15 +0200 (Thu, 25 May 2006) | 1 line
Fix comment typos
........
r46221 | andrew.dalke | 2006-05-25 18:30:52 +0200 (Thu, 25 May 2006) | 2 lines
Added tests for implementation error we came up with in the need for speed sprint.
........
r46222 | andrew.kuchling | 2006-05-25 18:34:54 +0200 (Thu, 25 May 2006) | 1 line
Fix another typo
........
r46223 | kristjan.jonsson | 2006-05-25 18:39:27 +0200 (Thu, 25 May 2006) | 1 line
Fix incorrect documentation for the Py_IS_FINITE(X) macro.
........
r46224 | fredrik.lundh | 2006-05-25 18:46:54 +0200 (Thu, 25 May 2006) | 3 lines
needforspeed: check for overflow in replace (from Andrew Dalke)
........
r46226 | fredrik.lundh | 2006-05-25 19:08:14 +0200 (Thu, 25 May 2006) | 5 lines
needforspeed: new replace implementation by Andrew Dalke. replace is
now about 3x faster on my machine, for the replace tests from string-
bench.
........
r46227 | tim.peters | 2006-05-25 19:34:03 +0200 (Thu, 25 May 2006) | 5 lines
A new table to help string->integer conversion was added yesterday to
both mystrtoul.c and longobject.c. Share the table instead. Also
cut its size by 64 entries (they had been used for an inscrutable
trick originally, but the code no longer tries to use that trick).
........
r46229 | andrew.dalke | 2006-05-25 19:53:00 +0200 (Thu, 25 May 2006) | 11 lines
Fixed problem identified by Georg. The special-case in-place code for replace
made a copy of the string using PyString_FromStringAndSize(s, n) and modify
the copied string in-place. However, 1 (and 0) character strings are shared
from a cache. This cause "A".replace("A", "a") to change the cached version
of "A" -- used by everyone.
Now may the copy with NULL as the string and do the memcpy manually. I've
added regression tests to check if this happens in the future. Perhaps
there should be a PyString_Copy for this case?
........
r46230 | fredrik.lundh | 2006-05-25 19:55:31 +0200 (Thu, 25 May 2006) | 4 lines
needforspeed: use "fastsearch" for count. this results in a 3x speedup
for the related stringbench tests.
........
r46231 | andrew.dalke | 2006-05-25 20:03:25 +0200 (Thu, 25 May 2006) | 4 lines
Code had returned an ssize_t, upcast to long, then converted with PyInt_FromLong.
Now using PyInt_FromSsize_t.
........
r46233 | andrew.kuchling | 2006-05-25 20:11:16 +0200 (Thu, 25 May 2006) | 1 line
Comment typo
........
r46234 | andrew.dalke | 2006-05-25 20:18:39 +0200 (Thu, 25 May 2006) | 4 lines
Added overflow test for adding two (very) large strings where the
new string is over max Py_ssize_t. I have no way to test it on my
box or any box I have access to. At least it doesn't break anything.
........
r46235 | bob.ippolito | 2006-05-25 20:20:23 +0200 (Thu, 25 May 2006) | 1 line
Faster path for PyLong_FromLongLong, using PyLong_FromLong algorithm
........
r46238 | georg.brandl | 2006-05-25 20:44:09 +0200 (Thu, 25 May 2006) | 3 lines
Guard the _active.remove() call to avoid errors when there is no _active list.
........
r46239 | fredrik.lundh | 2006-05-25 20:44:29 +0200 (Thu, 25 May 2006) | 4 lines
needforspeed: use fastsearch also for find/index and contains. the
related tests are now about 10x faster.
........
r46240 | bob.ippolito | 2006-05-25 20:44:50 +0200 (Thu, 25 May 2006) | 1 line
Struct now unpacks to PY_LONG_LONG directly when possible, also include #ifdef'ed out code that will return int instead of long when in bounds (not active since it's an API and doc change)
........
r46241 | jack.diederich | 2006-05-25 20:47:15 +0200 (Thu, 25 May 2006) | 1 line
* eliminate warning by reverting tmp_s type to 'const char*'
........
r46242 | bob.ippolito | 2006-05-25 21:03:19 +0200 (Thu, 25 May 2006) | 1 line
Fix Cygwin compiler issue
........
r46243 | bob.ippolito | 2006-05-25 21:15:27 +0200 (Thu, 25 May 2006) | 1 line
fix a struct regression where long would be returned for short unsigned integers
........
r46244 | georg.brandl | 2006-05-25 21:15:31 +0200 (Thu, 25 May 2006) | 4 lines
Replace PyObject_CallFunction calls with only object args
with PyObject_CallFunctionObjArgs, which is 30% faster.
........
r46245 | fredrik.lundh | 2006-05-25 21:19:05 +0200 (Thu, 25 May 2006) | 3 lines
needforspeed: use insert+reverse instead of append
........
r46246 | bob.ippolito | 2006-05-25 21:33:38 +0200 (Thu, 25 May 2006) | 1 line
Use LONG_MIN and LONG_MAX to check Python integer bounds instead of the incorrect INT_MIN and INT_MAX
........
r46248 | bob.ippolito | 2006-05-25 21:56:56 +0200 (Thu, 25 May 2006) | 1 line
Use faster struct pack/unpack functions for the endian table that matches the host's
........
r46249 | bob.ippolito | 2006-05-25 21:59:56 +0200 (Thu, 25 May 2006) | 1 line
enable darwin/x86 support for libffi and hence ctypes (doesn't yet support --enable-universalsdk)
........
r46252 | georg.brandl | 2006-05-25 22:28:10 +0200 (Thu, 25 May 2006) | 4 lines
Someone seems to just have copy-pasted the docs of
tp_compare to tp_richcompare ;)
........
r46253 | brett.cannon | 2006-05-25 22:44:08 +0200 (Thu, 25 May 2006) | 2 lines
Swap out bare malloc()/free() use for PyMem_MALLOC()/PyMem_FREE() .
........
r46254 | bob.ippolito | 2006-05-25 22:52:38 +0200 (Thu, 25 May 2006) | 1 line
squelch gcc4 darwin/x86 compiler warnings
........
r46255 | bob.ippolito | 2006-05-25 23:09:45 +0200 (Thu, 25 May 2006) | 1 line
fix test_float regression and 64-bit size mismatch issue
........
r46256 | georg.brandl | 2006-05-25 23:11:56 +0200 (Thu, 25 May 2006) | 3 lines
Add a x-ref to newer calling APIs.
........
r46257 | ronald.oussoren | 2006-05-25 23:30:54 +0200 (Thu, 25 May 2006) | 2 lines
Fix minor typo in prep_cif.c
........
r46259 | brett.cannon | 2006-05-25 23:33:11 +0200 (Thu, 25 May 2006) | 4 lines
Change test_values so that it compares the lowercasing of group names since getgrall() can return all lowercase names while getgrgid() returns proper casing.
Discovered on Ubuntu 5.04 (custom).
........
r46261 | tim.peters | 2006-05-25 23:50:17 +0200 (Thu, 25 May 2006) | 7 lines
Some Win64 pre-release in 2000 didn't support
QueryPerformanceCounter(), but we believe Win64 does
support it now. So use in time.clock().
It would be peachy if someone with a Win64 box tried
this ;-)
........
r46262 | tim.peters | 2006-05-25 23:52:19 +0200 (Thu, 25 May 2006) | 2 lines
Whitespace normalization.
........
r46263 | bob.ippolito | 2006-05-25 23:58:05 +0200 (Thu, 25 May 2006) | 1 line
Add missing files from x86 darwin ctypes patch
........
r46264 | brett.cannon | 2006-05-26 00:00:14 +0200 (Fri, 26 May 2006) | 2 lines
Move over to use of METH_O and METH_NOARGS.
........
r46265 | tim.peters | 2006-05-26 00:25:25 +0200 (Fri, 26 May 2006) | 3 lines
Repair idiot typo, and complete the job of trying to
use the Windows time.clock() implementation on Win64.
........
r46266 | tim.peters | 2006-05-26 00:28:46 +0200 (Fri, 26 May 2006) | 9 lines
Patch #1494387: SVN longobject.c compiler warnings
The SIGCHECK macro defined here has always been bizarre, but
it apparently causes compiler warnings on "Sun Studio 11".
I believe the warnings are bogus, but it doesn't hurt to make
the macro definition saner.
Bugfix candidate (but I'm not going to bother).
........
r46268 | fredrik.lundh | 2006-05-26 01:27:53 +0200 (Fri, 26 May 2006) | 8 lines
needforspeed: partition for 8-bit strings. for some simple tests,
this is on par with a corresponding find, and nearly twice as fast
as split(sep, 1)
full tests, a unicode version, and documentation will follow to-
morrow.
........
r46271 | andrew.kuchling | 2006-05-26 03:46:22 +0200 (Fri, 26 May 2006) | 1 line
Add Soc student
........
r46272 | ronald.oussoren | 2006-05-26 10:41:25 +0200 (Fri, 26 May 2006) | 3 lines
Without this patch OSX users couldn't add new help sources because the code
tried to update one item in a tuple.
........
r46273 | fredrik.lundh | 2006-05-26 10:54:28 +0200 (Fri, 26 May 2006) | 5 lines
needforspeed: partition implementation, part two.
feel free to improve the documentation and the docstrings.
........
r46274 | georg.brandl | 2006-05-26 11:05:54 +0200 (Fri, 26 May 2006) | 3 lines
Clarify docs for str.partition().
........
r46278 | fredrik.lundh | 2006-05-26 11:46:59 +0200 (Fri, 26 May 2006) | 5 lines
needforspeed: use METH_O for argument handling, which made partition some
~15% faster for the current tests (which is noticable faster than a corre-
sponding find call). thanks to neal-who-never-sleeps for the tip.
........
r46280 | fredrik.lundh | 2006-05-26 12:27:17 +0200 (Fri, 26 May 2006) | 5 lines
needforspeed: use Py_ssize_t for the fastsearch counter and skip
length (thanks, neal!). and yes, I've verified that this doesn't
slow things down ;-)
........
r46285 | andrew.dalke | 2006-05-26 13:11:38 +0200 (Fri, 26 May 2006) | 2 lines
Added a few more test cases for whitespace split. These strings have leading whitespace.
........
r46286 | jack.diederich | 2006-05-26 13:15:17 +0200 (Fri, 26 May 2006) | 1 line
use Py_ssize_t in places that may need it
........
r46287 | andrew.dalke | 2006-05-26 13:15:22 +0200 (Fri, 26 May 2006) | 2 lines
Added split whitespace checks for characters other than space.
........
r46288 | ronald.oussoren | 2006-05-26 13:17:55 +0200 (Fri, 26 May 2006) | 2 lines
Fix buglet in postinstall script, it would generate an invalid .cshrc file.
........
r46290 | georg.brandl | 2006-05-26 13:26:11 +0200 (Fri, 26 May 2006) | 3 lines
Add "partition" to UserString.
........
r46291 | fredrik.lundh | 2006-05-26 13:29:39 +0200 (Fri, 26 May 2006) | 5 lines
needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
for SRE and others. applied Py_LOCAL to relevant portion of ceval,
which gives a 1-2% speedup on my machine. ymmv.
........
r46292 | jack.diederich | 2006-05-26 13:37:20 +0200 (Fri, 26 May 2006) | 1 line
when generating python code prefer to generate valid python code
........
r46293 | fredrik.lundh | 2006-05-26 13:38:15 +0200 (Fri, 26 May 2006) | 3 lines
use Py_LOCAL also for string and unicode objects
........
r46294 | ronald.oussoren | 2006-05-26 13:38:39 +0200 (Fri, 26 May 2006) | 12 lines
- Search the sqlite specific search directories
after the normal include directories when looking
for the version of sqlite to use.
- On OSX:
* Extract additional include and link directories
from the CFLAGS and LDFLAGS, if the user has
bothered to specify them we might as wel use them.
* Add '-Wl,-search_paths_first' to the extra_link_args
for readline and sqlite. This makes it possible to
use a static library to override the system provided
dynamic library.
........
r46295 | ronald.oussoren | 2006-05-26 13:43:26 +0200 (Fri, 26 May 2006) | 6 lines
Integrate installing a framework in the 'make install'
target. Until now users had to use 'make frameworkinstall'
to install python when it is configured with '--enable-framework'.
This tends to confuse users that don't hunt for readme files
hidden in platform specific directories :-)
........
r46297 | fredrik.lundh | 2006-05-26 13:54:04 +0200 (Fri, 26 May 2006) | 4 lines
needforspeed: added PY_LOCAL_AGGRESSIVE macro to enable "aggressive"
LOCAL inlining; also added some missing whitespace
........
r46298 | andrew.kuchling | 2006-05-26 14:01:44 +0200 (Fri, 26 May 2006) | 1 line
Typo fixes
........
r46299 | fredrik.lundh | 2006-05-26 14:01:49 +0200 (Fri, 26 May 2006) | 4 lines
Py_LOCAL shouldn't be used for data; it works for some .NET 2003 compilers,
but Trent's copy thinks that it's an anachronism...
........
r46300 | martin.blais | 2006-05-26 14:03:27 +0200 (Fri, 26 May 2006) | 12 lines
Support for buffer protocol for socket and struct.
* Added socket.recv_buf() and socket.recvfrom_buf() methods, that use the buffer
protocol (send and sendto already did).
* Added struct.pack_to(), that is the corresponding buffer compatible method to
unpack_from().
* Fixed minor typos in arraymodule.
........
r46302 | ronald.oussoren | 2006-05-26 14:23:20 +0200 (Fri, 26 May 2006) | 6 lines
- Remove previous version of the binary distribution script for OSX
- Some small bugfixes for the IDLE.app wrapper
- Tweaks to build-installer to ensure that python gets build in the right way,
including sqlite3.
- Updated readme files
........
r46305 | tim.peters | 2006-05-26 14:26:21 +0200 (Fri, 26 May 2006) | 2 lines
Whitespace normalization.
........
r46307 | andrew.dalke | 2006-05-26 14:28:15 +0200 (Fri, 26 May 2006) | 7 lines
I like tests.
The new split functions use a preallocated list. Added tests which exceed
the preallocation size, to exercise list appends/resizes.
Also added more edge case tests.
........
r46308 | andrew.dalke | 2006-05-26 14:31:00 +0200 (Fri, 26 May 2006) | 2 lines
Test cases for off-by-one errors in string split with multicharacter pattern.
........
r46309 | tim.peters | 2006-05-26 14:31:20 +0200 (Fri, 26 May 2006) | 2 lines
Whitespace normalization.
........
r46313 | andrew.kuchling | 2006-05-26 14:39:48 +0200 (Fri, 26 May 2006) | 1 line
Add str.partition()
........
r46314 | bob.ippolito | 2006-05-26 14:52:53 +0200 (Fri, 26 May 2006) | 1 line
quick hack to fix busted binhex test
........
r46316 | andrew.dalke | 2006-05-26 15:05:55 +0200 (Fri, 26 May 2006) | 2 lines
Added more rstrip tests, including for prealloc'ed arrays
........
r46320 | bob.ippolito | 2006-05-26 15:15:44 +0200 (Fri, 26 May 2006) | 1 line
fix #1229380 No struct.pack exception for some out of range integers
........
r46325 | tim.peters | 2006-05-26 15:39:17 +0200 (Fri, 26 May 2006) | 2 lines
Use open() to open files (was using file()).
........
r46327 | andrew.dalke | 2006-05-26 16:00:45 +0200 (Fri, 26 May 2006) | 37 lines
Changes to string.split/rsplit on whitespace to preallocate space in the
results list.
Originally it allocated 0 items and used the list growth during append. Now
it preallocates 12 items so the first few appends don't need list reallocs.
("Here are some words ."*2).split(None, 1) is 7% faster
("Here are some words ."*2).split() is is 15% faster
(Your milage may vary, see dealership for details.)
File parsing like this
for line in f:
count += len(line.split())
is also about 15% faster. There is a slowdown of about 3% for large
strings because of the additional overhead of checking if the append is
to a preallocated region of the list or not. This will be the rare case.
It could be improved with special case code but we decided it was not
useful enough.
There is a cost of 12*sizeof(PyObject *) bytes per list. For the normal
case of file parsing this is not a problem because of the lists have
a short lifetime. We have not come up with cases where this is a problem
in real life.
I chose 12 because human text averages about 11 words per line in books,
one of my data sets averages 6.2 words with a final peak at 11 words per
line, and I work with a tab delimited data set with 8 tabs per line (or
9 words per line). 12 encompasses all of these.
Also changed the last rstrip code to append then reverse, rather than
doing insert(0). The strip() and rstrip() times are now comparable.
........
r46328 | tim.peters | 2006-05-26 16:02:05 +0200 (Fri, 26 May 2006) | 5 lines
Explicitly close files. I'm trying to stop the frequent spurious test_tarfile
failures on Windows buildbots, but it's hard to know how since the regrtest
failure output is useless here, and it never fails when a buildbot slave runs
test_tarfile the second time in verbose mode.
........
r46329 | andrew.kuchling | 2006-05-26 16:03:41 +0200 (Fri, 26 May 2006) | 1 line
Add buffer support for struct, socket
........
r46330 | andrew.kuchling | 2006-05-26 16:04:19 +0200 (Fri, 26 May 2006) | 1 line
Typo fix
........
r46331 | bob.ippolito | 2006-05-26 16:07:23 +0200 (Fri, 26 May 2006) | 1 line
Fix distutils so that libffi will cross-compile between darwin/x86 and darwin/ppc
........
r46333 | bob.ippolito | 2006-05-26 16:23:21 +0200 (Fri, 26 May 2006) | 1 line
Fix _struct typo that broke some 64-bit platforms
........
r46335 | bob.ippolito | 2006-05-26 16:29:35 +0200 (Fri, 26 May 2006) | 1 line
Enable PY_USE_INT_WHEN_POSSIBLE in struct
........
r46343 | andrew.dalke | 2006-05-26 17:21:01 +0200 (Fri, 26 May 2006) | 2 lines
Eeked out another 3% or so performance in split whitespace by cleaning up the algorithm.
........
r46352 | andrew.dalke | 2006-05-26 18:22:52 +0200 (Fri, 26 May 2006) | 3 lines
Test for more edge strip cases; leading and trailing separator gets removed
even with strip(..., 0)
........
r46354 | bob.ippolito | 2006-05-26 18:23:28 +0200 (Fri, 26 May 2006) | 1 line
fix signed/unsigned mismatch in struct
........
r46355 | steve.holden | 2006-05-26 18:27:59 +0200 (Fri, 26 May 2006) | 5 lines
Add -t option to allow easy test selection.
Action verbose option correctly.
Tweak operation counts. Add empty and new instances tests.
Enable comparisons across different warp factors. Change version.
........
r46356 | fredrik.lundh | 2006-05-26 18:32:42 +0200 (Fri, 26 May 2006) | 3 lines
needforspeed: use Py_LOCAL on a few more locals in stringobject.c
........
r46357 | thomas.heller | 2006-05-26 18:42:44 +0200 (Fri, 26 May 2006) | 4 lines
For now, I gave up with automatic conversion of reST to Python-latex,
so I'm writing this in latex now.
Skeleton for the ctypes reference.
........
r46358 | tim.peters | 2006-05-26 18:49:28 +0200 (Fri, 26 May 2006) | 3 lines
Repair Windows compiler warnings about mixing
signed and unsigned integral types in comparisons.
........
r46359 | tim.peters | 2006-05-26 18:52:04 +0200 (Fri, 26 May 2006) | 2 lines
Whitespace normalization.
........
r46360 | tim.peters | 2006-05-26 18:53:04 +0200 (Fri, 26 May 2006) | 2 lines
Add missing svn:eol-style property to text files.
........
r46362 | fredrik.lundh | 2006-05-26 19:04:58 +0200 (Fri, 26 May 2006) | 3 lines
needforspeed: stringlib refactoring (in progress)
........
r46363 | thomas.heller | 2006-05-26 19:18:33 +0200 (Fri, 26 May 2006) | 1 line
Write some docs.
........
r46364 | fredrik.lundh | 2006-05-26 19:22:38 +0200 (Fri, 26 May 2006) | 3 lines
needforspeed: stringlib refactoring (in progress)
........
r46366 | fredrik.lundh | 2006-05-26 19:26:39 +0200 (Fri, 26 May 2006) | 3 lines
needforspeed: cleanup
........
r46367 | fredrik.lundh | 2006-05-26 19:31:41 +0200 (Fri, 26 May 2006) | 4 lines
needforspeed: remove remaining USE_FAST macros; if fastsearch was
broken, someone would have noticed by now ;-)
........
r46368 | steve.holden | 2006-05-26 19:41:32 +0200 (Fri, 26 May 2006) | 5 lines
Use minimum calibration time rather than avergae to avoid
the illusion of negative run times. Halt with an error if
run times go below 10 ms, indicating that results will be
unreliable.
........
r46370 | thomas.heller | 2006-05-26 19:47:40 +0200 (Fri, 26 May 2006) | 2 lines
Reordered, and wrote more docs.
........
r46372 | georg.brandl | 2006-05-26 20:03:31 +0200 (Fri, 26 May 2006) | 9 lines
Need for speed: Patch #921466 : sys.path_importer_cache is now used to cache valid and
invalid file paths for the built-in import machinery which leads to
fewer open calls on startup.
Also fix issue with PEP 302 style import hooks which lead to more open()
calls than necessary.
........
r46373 | fredrik.lundh | 2006-05-26 20:05:34 +0200 (Fri, 26 May 2006) | 3 lines
removed unnecessary include
........
r46377 | fredrik.lundh | 2006-05-26 20:15:38 +0200 (Fri, 26 May 2006) | 3 lines
needforspeed: added rpartition implementation
........
r46380 | fredrik.lundh | 2006-05-26 20:24:15 +0200 (Fri, 26 May 2006) | 5 lines
needspeed: rpartition documentation, tests, and a bug fixes.
feel free to add more tests and improve the documentation.
........
r46381 | steve.holden | 2006-05-26 20:26:21 +0200 (Fri, 26 May 2006) | 4 lines
Revert tests to MAL's original round sizes to retiain comparability
from long ago and far away. Stop calling this pybench 1.4 because it
isn't. Remove the empty test, which was a bad idea.
........
r46387 | andrew.kuchling | 2006-05-26 20:41:18 +0200 (Fri, 26 May 2006) | 1 line
Add rpartition() and path caching
........
r46388 | andrew.dalke | 2006-05-26 21:02:09 +0200 (Fri, 26 May 2006) | 10 lines
substring split now uses /F's fast string matching algorithm.
(If compiled without FAST search support, changed the pre-memcmp test
to check the last character as well as the first. This gave a 25%
speedup for my test case.)
Rewrote the split algorithms so they stop when maxsplit gets to 0.
Previously they did a string match first then checked if the maxsplit
was reached. The new way prevents a needless string search.
........
r46391 | brett.cannon | 2006-05-26 21:04:47 +0200 (Fri, 26 May 2006) | 2 lines
Change C spacing to 4 spaces by default to match PEP 7 for new C files.
........
r46392 | georg.brandl | 2006-05-26 21:04:47 +0200 (Fri, 26 May 2006) | 3 lines
Exception isn't the root of all exception classes anymore.
........
r46397 | fredrik.lundh | 2006-05-26 21:23:21 +0200 (Fri, 26 May 2006) | 3 lines
added rpartition method to UserString class
........
r46398 | fredrik.lundh | 2006-05-26 21:24:53 +0200 (Fri, 26 May 2006) | 4 lines
needforspeed: stringlib refactoring, continued. added count and
find helpers; updated unicodeobject to use stringlib_count
........
r46400 | fredrik.lundh | 2006-05-26 21:29:05 +0200 (Fri, 26 May 2006) | 4 lines
needforspeed: stringlib refactoring: use stringlib/find for unicode
find
........
r46403 | fredrik.lundh | 2006-05-26 21:33:03 +0200 (Fri, 26 May 2006) | 3 lines
needforspeed: use a macro to fix slice indexes
........
r46404 | thomas.heller | 2006-05-26 21:43:45 +0200 (Fri, 26 May 2006) | 1 line
Write more docs.
........
r46406 | fredrik.lundh | 2006-05-26 21:48:07 +0200 (Fri, 26 May 2006) | 3 lines
needforspeed: stringlib refactoring: use stringlib/find for string find
........
r46407 | andrew.kuchling | 2006-05-26 21:51:10 +0200 (Fri, 26 May 2006) | 1 line
Comment typo
........
r46409 | georg.brandl | 2006-05-26 22:04:44 +0200 (Fri, 26 May 2006) | 3 lines
Replace Py_BuildValue("OO") by PyTuple_Pack.
........
r46411 | georg.brandl | 2006-05-26 22:14:47 +0200 (Fri, 26 May 2006) | 2 lines
Patch #1492218: document None being a constant.
........
r46415 | georg.brandl | 2006-05-26 22:22:50 +0200 (Fri, 26 May 2006) | 3 lines
Simplify calling.
........
r46416 | andrew.dalke | 2006-05-26 22:25:22 +0200 (Fri, 26 May 2006) | 4 lines
Added limits to the replace code so it does not count all of the matching
patterns in a string, only the number needed by the max limit.
........
r46417 | bob.ippolito | 2006-05-26 22:25:23 +0200 (Fri, 26 May 2006) | 1 line
enable all of the struct tests, use ssize_t, fix some whitespace
........
r46418 | tim.peters | 2006-05-26 22:56:56 +0200 (Fri, 26 May 2006) | 2 lines
Record Iceland sprint attendees.
........
r46421 | tim.peters | 2006-05-26 23:51:13 +0200 (Fri, 26 May 2006) | 2 lines
Whitespace normalization.
........
r46422 | steve.holden | 2006-05-27 00:17:54 +0200 (Sat, 27 May 2006) | 2 lines
Add Richard Tew to developers
........
r46423 | steve.holden | 2006-05-27 00:33:20 +0200 (Sat, 27 May 2006) | 2 lines
Update help text and documentaition.
........
r46424 | steve.holden | 2006-05-27 00:39:27 +0200 (Sat, 27 May 2006) | 2 lines
Blasted typos ...
........
r46425 | andrew.dalke | 2006-05-27 00:49:03 +0200 (Sat, 27 May 2006) | 2 lines
Added description of why splitlines doesn't use the prealloc strategy
........
r46426 | tim.peters | 2006-05-27 01:14:37 +0200 (Sat, 27 May 2006) | 19 lines
Patch 1145039.
set_exc_info(), reset_exc_info(): By exploiting the
likely (who knows?) invariant that when an exception's
`type` is NULL, its `value` and `traceback` are also NULL,
save some cycles in heavily-executed code.
This is a "a kronar saved is a kronar earned" patch: the
speedup isn't reliably measurable, but it obviously does
reduce the operation count in the normal (no exception
raised) path through PyEval_EvalFrameEx().
The tim-exc_sanity branch tries to push this harder, but
is still blowing up (at least in part due to pre-existing
subtle bugs that appear to have no other visible
consequences!).
Not a bugfix candidate.
........
r46429 | steve.holden | 2006-05-27 02:51:52 +0200 (Sat, 27 May 2006) | 2 lines
Reinstate new-style object tests.
........
r46430 | neal.norwitz | 2006-05-27 07:18:57 +0200 (Sat, 27 May 2006) | 1 line
Fix compiler warning (and whitespace) on Mac OS 10.4. (A lot of this code looked duplicated, I wonder if a utility function could help reduce the duplication here.)
........
r46431 | neal.norwitz | 2006-05-27 07:21:30 +0200 (Sat, 27 May 2006) | 4 lines
Fix Coverity warnings.
- Check the correct variable (str_obj, not str) for NULL
- sep_len was already verified it wasn't 0
........
r46432 | martin.v.loewis | 2006-05-27 10:36:52 +0200 (Sat, 27 May 2006) | 2 lines
Patch 1494554: Update numeric properties to Unicode 4.1.
........
r46433 | martin.v.loewis | 2006-05-27 10:54:29 +0200 (Sat, 27 May 2006) | 2 lines
Explain why 'consumed' is initialized.
........
r46436 | fredrik.lundh | 2006-05-27 12:05:10 +0200 (Sat, 27 May 2006) | 3 lines
needforspeed: more stringlib refactoring
........
r46438 | fredrik.lundh | 2006-05-27 12:39:48 +0200 (Sat, 27 May 2006) | 5 lines
needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
lining killed performance on certain Intel boxes, and the "aggressive"
macro itself gives most of the benefits on others.
........
r46439 | andrew.dalke | 2006-05-27 13:04:36 +0200 (Sat, 27 May 2006) | 2 lines
fixed typo
........
r46440 | martin.v.loewis | 2006-05-27 13:07:49 +0200 (Sat, 27 May 2006) | 2 lines
Revert bogus change committed in 46432 to this file.
........
r46444 | andrew.kuchling | 2006-05-27 13:26:33 +0200 (Sat, 27 May 2006) | 1 line
Add Py_LOCAL macros
........
r46450 | bob.ippolito | 2006-05-27 13:47:12 +0200 (Sat, 27 May 2006) | 1 line
Remove the range checking and int usage #defines from _struct and strip out the now-dead code
........
r46454 | bob.ippolito | 2006-05-27 14:11:36 +0200 (Sat, 27 May 2006) | 1 line
Fix up struct docstrings, add struct.pack_to function for symmetry
........
r46456 | richard.jones | 2006-05-27 14:29:24 +0200 (Sat, 27 May 2006) | 2 lines
Conversion of exceptions over from faked-up classes to new-style C types.
........
r46457 | georg.brandl | 2006-05-27 14:30:25 +0200 (Sat, 27 May 2006) | 3 lines
Add news item for new-style exception class branch merge.
........
r46458 | tim.peters | 2006-05-27 14:36:53 +0200 (Sat, 27 May 2006) | 3 lines
More random thrashing trying to understand spurious
Windows failures. Who's keeping a bz2 file open?
........
r46460 | andrew.kuchling | 2006-05-27 15:44:37 +0200 (Sat, 27 May 2006) | 1 line
Mention new-style exceptions
........
r46461 | richard.jones | 2006-05-27 15:50:42 +0200 (Sat, 27 May 2006) | 1 line
credit where credit is due
........
r46462 | georg.brandl | 2006-05-27 16:02:03 +0200 (Sat, 27 May 2006) | 3 lines
Always close BZ2Proxy object. Remove unnecessary struct usage.
........
r46463 | tim.peters | 2006-05-27 16:13:13 +0200 (Sat, 27 May 2006) | 2 lines
The cheery optimism of old age.
........
r46464 | andrew.dalke | 2006-05-27 16:16:40 +0200 (Sat, 27 May 2006) | 2 lines
cleanup - removed trailing whitespace
........
r46465 | georg.brandl | 2006-05-27 16:41:55 +0200 (Sat, 27 May 2006) | 3 lines
Remove spurious semicolons after macro invocations.
........
r46468 | fredrik.lundh | 2006-05-27 16:58:20 +0200 (Sat, 27 May 2006) | 4 lines
needforspeed: replace improvements, changed to Py_LOCAL_INLINE
where appropriate
........
r46469 | fredrik.lundh | 2006-05-27 17:20:22 +0200 (Sat, 27 May 2006) | 4 lines
needforspeed: stringlib refactoring: changed find_obj to find_slice,
to enable use from stringobject
........
r46470 | fredrik.lundh | 2006-05-27 17:26:19 +0200 (Sat, 27 May 2006) | 3 lines
needforspeed: stringlib refactoring: use find_slice for stringobject
........
r46472 | kristjan.jonsson | 2006-05-27 17:41:31 +0200 (Sat, 27 May 2006) | 1 line
Add a PCBuild8 build directory for building with Visual Studio .NET 2005. Contains a special project to perform profile guided optimizations on the pythoncore.dll, by instrumenting and running pybench.py
........
r46473 | jack.diederich | 2006-05-27 17:44:34 +0200 (Sat, 27 May 2006) | 3 lines
needforspeed: use PyObject_MALLOC instead of system malloc for small
allocations. Use PyMem_MALLOC for larger (1k+) chunks. 1%-2% speedup.
........
r46474 | bob.ippolito | 2006-05-27 17:53:49 +0200 (Sat, 27 May 2006) | 1 line
fix struct regression on 64-bit platforms
........
r46475 | richard.jones | 2006-05-27 18:07:28 +0200 (Sat, 27 May 2006) | 1 line
doc string additions and tweaks
........
r46477 | richard.jones | 2006-05-27 18:15:11 +0200 (Sat, 27 May 2006) | 1 line
move semicolons
........
r46478 | george.yoshida | 2006-05-27 18:32:44 +0200 (Sat, 27 May 2006) | 2 lines
minor markup nits
........
r46488 | george.yoshida | 2006-05-27 18:51:43 +0200 (Sat, 27 May 2006) | 3 lines
End of Ch.3 is now about "with statement".
Avoid obsolescence by directly referring to the section.
........
r46489 | george.yoshida | 2006-05-27 19:09:17 +0200 (Sat, 27 May 2006) | 2 lines
fix typo
........
2006-05-27 16:21:47 -03:00
|
|
|
return PyObject_CallFunctionObjArgs(fc, py_module_name,
|
|
|
|
py_global_name, NULL);
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
module = PySys_GetObject("modules");
|
|
|
|
if (module == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
module = PyDict_GetItem(module, py_module_name);
|
|
|
|
if (module == NULL) {
|
|
|
|
module = PyImport_Import(py_module_name);
|
|
|
|
if (!module)
|
|
|
|
return NULL;
|
|
|
|
global = PyObject_GetAttr(module, py_global_name);
|
|
|
|
Py_DECREF(module);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
global = PyObject_GetAttr(module, py_global_name);
|
|
|
|
return global;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
marker(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
if (self->num_marks < 1) {
|
|
|
|
PyErr_SetString(UnpicklingError, "could not find MARK");
|
|
|
|
return -1;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return self->marks[--self->num_marks];
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
2001-03-17 00:50:51 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_none(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PDATA_APPEND(self->stack, Py_None, -1);
|
|
|
|
return 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
1999-02-04 10:54:04 -04:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
bad_readline(void)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyErr_SetString(UnpicklingError, "pickle data was truncated");
|
|
|
|
return -1;
|
1999-02-04 10:54:04 -04:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_int(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *py_int = 0;
|
|
|
|
char *endptr, *s;
|
|
|
|
int len, res = -1;
|
|
|
|
long l;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if ((len = self->readline_func(self, &s)) < 0) return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
if (len < 2) return bad_readline();
|
|
|
|
if (!( s=pystrndup(s,len))) return -1;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
l = strtol(s, &endptr, 0);
|
|
|
|
|
|
|
|
if (errno || (*endptr != '\n') || (endptr[1] != '\0')) {
|
|
|
|
/* Hm, maybe we've got something long. Let's try reading
|
|
|
|
it as a Python long object. */
|
|
|
|
errno = 0;
|
|
|
|
py_int = PyLong_FromString(s, NULL, 0);
|
|
|
|
if (py_int == NULL) {
|
|
|
|
PyErr_SetString(PyExc_ValueError,
|
|
|
|
"could not convert string to int");
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2002-04-05 15:30:08 -04:00
|
|
|
if (len == 3 && (l == 0 || l == 1)) {
|
|
|
|
if (!( py_int = PyBool_FromLong(l))) goto finally;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!( py_int = PyInt_FromLong(l))) goto finally;
|
|
|
|
}
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
free(s);
|
|
|
|
PDATA_PUSH(self->stack, py_int, -1);
|
|
|
|
return 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
finally:
|
|
|
|
free(s);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return res;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 13:59:11 -04:00
|
|
|
static int
|
|
|
|
load_bool(Unpicklerobject *self, PyObject *boolean)
|
|
|
|
{
|
|
|
|
assert(boolean == Py_True || boolean == Py_False);
|
2003-02-03 11:45:56 -04:00
|
|
|
PDATA_APPEND(self->stack, boolean, -1);
|
2003-02-02 13:59:11 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments. Fixed an undetected-overflow bug in readline_file().
longobject.c: Fixed a really stupid bug in the new _PyLong_NumBits.
pickle.py: Fixed stupid bug in save_long(): When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4(): they *returned* the unpickled long instead of pushing
it on the stack. The return values were ignored. Tests passed
before only because save_long() pickled the long twice.
Fixed bugs in encode_long().
Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time. I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that. It would be more valuable to make long(string, 16) linear time.
pickletester.py: Added a global "protocols" vector so tests can try
all the protocols in a sane way. Changed test_ints() and test_unicode()
to do so. Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle: cPickle proto 2 for longs is linear-time).
2003-02-01 22:57:53 -04:00
|
|
|
/* s contains x bytes of a little-endian integer. Return its value as a
|
|
|
|
* C int. Obscure: when x is 1 or 2, this is an unsigned little-endian
|
|
|
|
* int, but when x is 4 it's a signed one. This is an historical source
|
|
|
|
* of x-platform bugs.
|
|
|
|
*/
|
2002-04-01 13:40:08 -04:00
|
|
|
static long
|
cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments. Fixed an undetected-overflow bug in readline_file().
longobject.c: Fixed a really stupid bug in the new _PyLong_NumBits.
pickle.py: Fixed stupid bug in save_long(): When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4(): they *returned* the unpickled long instead of pushing
it on the stack. The return values were ignored. Tests passed
before only because save_long() pickled the long twice.
Fixed bugs in encode_long().
Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time. I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that. It would be more valuable to make long(string, 16) linear time.
pickletester.py: Added a global "protocols" vector so tests can try
all the protocols in a sane way. Changed test_ints() and test_unicode()
to do so. Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle: cPickle proto 2 for longs is linear-time).
2003-02-01 22:57:53 -04:00
|
|
|
calc_binint(char *s, int x)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
unsigned char c;
|
|
|
|
int i;
|
|
|
|
long l;
|
|
|
|
|
|
|
|
for (i = 0, l = 0L; i < x; i++) {
|
|
|
|
c = (unsigned char)s[i];
|
|
|
|
l |= (long)c << (i * 8);
|
|
|
|
}
|
2001-04-09 22:54:42 -03:00
|
|
|
#if SIZEOF_LONG > 4
|
2002-04-01 13:40:08 -04:00
|
|
|
/* Unlike BININT1 and BININT2, BININT (more accurately BININT4)
|
|
|
|
* is signed, so on a box with longs bigger than 4 bytes we need
|
|
|
|
* to extend a BININT's sign bit to the full width.
|
|
|
|
*/
|
|
|
|
if (x == 4 && l & (1L << 31))
|
|
|
|
l |= (~0L) << 32;
|
2001-04-09 22:54:42 -03:00
|
|
|
#endif
|
2002-04-01 13:40:08 -04:00
|
|
|
return l;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_binintx(Unpicklerobject *self, char *s, int x)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *py_int = 0;
|
|
|
|
long l;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
l = calc_binint(s, x);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( py_int = PyInt_FromLong(l)))
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
PDATA_PUSH(self->stack, py_int, -1);
|
|
|
|
return 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_binint(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
char *s;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->read_func(self, &s, 4) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return load_binintx(self, s, 4);
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_binint1(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
char *s;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->read_func(self, &s, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return load_binintx(self, s, 1);
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_binint2(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
char *s;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->read_func(self, &s, 2) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return load_binintx(self, s, 2);
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
2001-03-17 00:50:51 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_long(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *l = 0;
|
|
|
|
char *end, *s;
|
|
|
|
int len, res = -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if ((len = self->readline_func(self, &s)) < 0) return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
if (len < 2) return bad_readline();
|
|
|
|
if (!( s=pystrndup(s,len))) return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( l = PyLong_FromString(s, &end, 0)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
free(s);
|
|
|
|
PDATA_PUSH(self->stack, l, -1);
|
|
|
|
return 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
finally:
|
|
|
|
free(s);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return res;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments. Fixed an undetected-overflow bug in readline_file().
longobject.c: Fixed a really stupid bug in the new _PyLong_NumBits.
pickle.py: Fixed stupid bug in save_long(): When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4(): they *returned* the unpickled long instead of pushing
it on the stack. The return values were ignored. Tests passed
before only because save_long() pickled the long twice.
Fixed bugs in encode_long().
Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time. I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that. It would be more valuable to make long(string, 16) linear time.
pickletester.py: Added a global "protocols" vector so tests can try
all the protocols in a sane way. Changed test_ints() and test_unicode()
to do so. Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle: cPickle proto 2 for longs is linear-time).
2003-02-01 22:57:53 -04:00
|
|
|
/* 'size' bytes contain the # of bytes of little-endian 256's-complement
|
|
|
|
* data following.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
load_counted_long(Unpicklerobject *self, int size)
|
|
|
|
{
|
2006-02-15 13:27:45 -04:00
|
|
|
Py_ssize_t i;
|
cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments. Fixed an undetected-overflow bug in readline_file().
longobject.c: Fixed a really stupid bug in the new _PyLong_NumBits.
pickle.py: Fixed stupid bug in save_long(): When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4(): they *returned* the unpickled long instead of pushing
it on the stack. The return values were ignored. Tests passed
before only because save_long() pickled the long twice.
Fixed bugs in encode_long().
Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time. I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that. It would be more valuable to make long(string, 16) linear time.
pickletester.py: Added a global "protocols" vector so tests can try
all the protocols in a sane way. Changed test_ints() and test_unicode()
to do so. Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle: cPickle proto 2 for longs is linear-time).
2003-02-01 22:57:53 -04:00
|
|
|
char *nbytes;
|
|
|
|
unsigned char *pdata;
|
|
|
|
PyObject *along;
|
|
|
|
|
|
|
|
assert(size == 1 || size == 4);
|
|
|
|
i = self->read_func(self, &nbytes, size);
|
|
|
|
if (i < 0) return -1;
|
|
|
|
|
|
|
|
size = calc_binint(nbytes, size);
|
|
|
|
if (size < 0) {
|
|
|
|
/* Corrupt or hostile pickle -- we never write one like
|
|
|
|
* this.
|
|
|
|
*/
|
2003-02-03 18:07:24 -04:00
|
|
|
PyErr_SetString(UnpicklingError, "LONG pickle has negative "
|
cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments. Fixed an undetected-overflow bug in readline_file().
longobject.c: Fixed a really stupid bug in the new _PyLong_NumBits.
pickle.py: Fixed stupid bug in save_long(): When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4(): they *returned* the unpickled long instead of pushing
it on the stack. The return values were ignored. Tests passed
before only because save_long() pickled the long twice.
Fixed bugs in encode_long().
Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time. I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that. It would be more valuable to make long(string, 16) linear time.
pickletester.py: Added a global "protocols" vector so tests can try
all the protocols in a sane way. Changed test_ints() and test_unicode()
to do so. Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle: cPickle proto 2 for longs is linear-time).
2003-02-01 22:57:53 -04:00
|
|
|
"byte count");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size == 0)
|
|
|
|
along = PyLong_FromLong(0L);
|
|
|
|
else {
|
|
|
|
/* Read the raw little-endian bytes & convert. */
|
2003-02-02 13:08:33 -04:00
|
|
|
i = self->read_func(self, (char **)&pdata, size);
|
cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments. Fixed an undetected-overflow bug in readline_file().
longobject.c: Fixed a really stupid bug in the new _PyLong_NumBits.
pickle.py: Fixed stupid bug in save_long(): When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4(): they *returned* the unpickled long instead of pushing
it on the stack. The return values were ignored. Tests passed
before only because save_long() pickled the long twice.
Fixed bugs in encode_long().
Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time. I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that. It would be more valuable to make long(string, 16) linear time.
pickletester.py: Added a global "protocols" vector so tests can try
all the protocols in a sane way. Changed test_ints() and test_unicode()
to do so. Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle: cPickle proto 2 for longs is linear-time).
2003-02-01 22:57:53 -04:00
|
|
|
if (i < 0) return -1;
|
|
|
|
along = _PyLong_FromByteArray(pdata, (size_t)size,
|
|
|
|
1 /* little endian */, 1 /* signed */);
|
|
|
|
}
|
|
|
|
if (along == NULL)
|
|
|
|
return -1;
|
|
|
|
PDATA_PUSH(self->stack, along, -1);
|
|
|
|
return 0;
|
|
|
|
}
|
2001-03-17 00:50:51 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_float(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *py_float = 0;
|
|
|
|
char *endptr, *s;
|
|
|
|
int len, res = -1;
|
|
|
|
double d;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if ((len = self->readline_func(self, &s)) < 0) return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
if (len < 2) return bad_readline();
|
|
|
|
if (!( s=pystrndup(s,len))) return -1;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
errno = 0;
|
2004-06-08 15:52:54 -03:00
|
|
|
d = PyOS_ascii_strtod(s, &endptr);
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (errno || (endptr[0] != '\n') || (endptr[1] != '\0')) {
|
|
|
|
PyErr_SetString(PyExc_ValueError,
|
|
|
|
"could not convert string to float");
|
|
|
|
goto finally;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( py_float = PyFloat_FromDouble(d)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
free(s);
|
|
|
|
PDATA_PUSH(self->stack, py_float, -1);
|
|
|
|
return 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
finally:
|
|
|
|
free(s);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return res;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_binfloat(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2003-03-20 16:53:32 -04:00
|
|
|
PyObject *py_float;
|
2002-04-01 13:40:08 -04:00
|
|
|
double x;
|
|
|
|
char *p;
|
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->read_func(self, &p, 8) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
|
2003-03-20 16:53:32 -04:00
|
|
|
x = _PyFloat_Unpack8((unsigned char *)p, 0);
|
|
|
|
if (x == -1.0 && PyErr_Occurred())
|
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-03-20 16:53:32 -04:00
|
|
|
py_float = PyFloat_FromDouble(x);
|
|
|
|
if (py_float == NULL)
|
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
PDATA_PUSH(self->stack, py_float, -1);
|
|
|
|
return 0;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_string(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *str = 0;
|
2002-08-14 04:46:28 -03:00
|
|
|
int len, res = -1;
|
|
|
|
char *s, *p;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if ((len = self->readline_func(self, &s)) < 0) return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
if (len < 2) return bad_readline();
|
|
|
|
if (!( s=pystrndup(s,len))) return -1;
|
|
|
|
|
2002-08-14 04:46:28 -03:00
|
|
|
|
|
|
|
/* Strip outermost quotes */
|
|
|
|
while (s[len-1] <= ' ')
|
|
|
|
len--;
|
|
|
|
if(s[0]=='"' && s[len-1]=='"'){
|
|
|
|
s[len-1] = '\0';
|
|
|
|
p = s + 1 ;
|
|
|
|
len -= 2;
|
|
|
|
} else if(s[0]=='\'' && s[len-1]=='\''){
|
|
|
|
s[len-1] = '\0';
|
|
|
|
p = s + 1 ;
|
|
|
|
len -= 2;
|
|
|
|
} else
|
2002-04-01 13:40:08 -04:00
|
|
|
goto insecure;
|
|
|
|
/********************************************/
|
1997-12-08 11:15:16 -04:00
|
|
|
|
2002-08-14 04:46:28 -03:00
|
|
|
str = PyString_DecodeEscape(p, len, NULL, 0, NULL);
|
|
|
|
if (str) {
|
|
|
|
PDATA_PUSH(self->stack, str, -1);
|
|
|
|
res = 0;
|
|
|
|
}
|
2002-04-01 13:40:08 -04:00
|
|
|
free(s);
|
|
|
|
return res;
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
insecure:
|
|
|
|
free(s);
|
|
|
|
PyErr_SetString(PyExc_ValueError,"insecure string pickle");
|
|
|
|
return -1;
|
2001-03-17 00:50:51 -04:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_binstring(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *py_string = 0;
|
|
|
|
long l;
|
|
|
|
char *s;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->read_func(self, &s, 4) < 0) return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
l = calc_binint(s, 4);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->read_func(self, &s, l) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( py_string = PyString_FromStringAndSize(s, l)))
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
PDATA_PUSH(self->stack, py_string, -1);
|
|
|
|
return 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_short_binstring(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *py_string = 0;
|
|
|
|
unsigned char l;
|
|
|
|
char *s;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->read_func(self, &s, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
l = (unsigned char)s[0];
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->read_func(self, &s, l) < 0) return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!( py_string = PyString_FromStringAndSize(s, l))) return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
PDATA_PUSH(self->stack, py_string, -1);
|
|
|
|
return 0;
|
2001-03-17 00:50:51 -04:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
2001-08-17 15:39:25 -03:00
|
|
|
#ifdef Py_USING_UNICODE
|
2000-03-10 19:11:40 -04:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_unicode(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *str = 0;
|
|
|
|
int len, res = -1;
|
|
|
|
char *s;
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if ((len = self->readline_func(self, &s)) < 0) return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
if (len < 1) return bad_readline();
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( str = PyUnicode_DecodeRawUnicodeEscape(s, len - 1, NULL)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
PDATA_PUSH(self->stack, str, -1);
|
|
|
|
return 0;
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
finally:
|
|
|
|
return res;
|
2001-03-17 00:50:51 -04:00
|
|
|
}
|
2001-08-17 15:39:25 -03:00
|
|
|
#endif
|
2000-03-10 19:11:40 -04:00
|
|
|
|
|
|
|
|
2001-08-17 15:39:25 -03:00
|
|
|
#ifdef Py_USING_UNICODE
|
2000-03-10 19:11:40 -04:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_binunicode(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *unicode;
|
|
|
|
long l;
|
|
|
|
char *s;
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->read_func(self, &s, 4) < 0) return -1;
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
l = calc_binint(s, 4);
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->read_func(self, &s, l) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( unicode = PyUnicode_DecodeUTF8(s, l, NULL)))
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
PDATA_PUSH(self->stack, unicode, -1);
|
|
|
|
return 0;
|
2000-03-10 19:11:40 -04:00
|
|
|
}
|
2001-08-17 15:39:25 -03:00
|
|
|
#endif
|
2000-03-10 19:11:40 -04:00
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_tuple(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *tup;
|
|
|
|
int i;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((i = marker(self)) < 0) return -1;
|
|
|
|
if (!( tup=Pdata_popTuple(self->stack, i))) return -1;
|
|
|
|
PDATA_PUSH(self->stack, tup, -1);
|
|
|
|
return 0;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-02 16:29:39 -04:00
|
|
|
load_counted_tuple(Unpicklerobject *self, int len)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2003-02-02 16:29:39 -04:00
|
|
|
PyObject *tup = PyTuple_New(len);
|
|
|
|
|
|
|
|
if (tup == NULL)
|
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 16:29:39 -04:00
|
|
|
while (--len >= 0) {
|
|
|
|
PyObject *element;
|
|
|
|
|
|
|
|
PDATA_POP(self->stack, element);
|
|
|
|
if (element == NULL)
|
|
|
|
return -1;
|
|
|
|
PyTuple_SET_ITEM(tup, len, element);
|
|
|
|
}
|
2002-04-01 13:40:08 -04:00
|
|
|
PDATA_PUSH(self->stack, tup, -1);
|
|
|
|
return 0;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_empty_list(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *list;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!( list=PyList_New(0))) return -1;
|
|
|
|
PDATA_PUSH(self->stack, list, -1);
|
|
|
|
return 0;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_empty_dict(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *dict;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!( dict=PyDict_New())) return -1;
|
|
|
|
PDATA_PUSH(self->stack, dict, -1);
|
|
|
|
return 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_list(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *list = 0;
|
|
|
|
int i;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((i = marker(self)) < 0) return -1;
|
|
|
|
if (!( list=Pdata_popList(self->stack, i))) return -1;
|
|
|
|
PDATA_PUSH(self->stack, list, -1);
|
|
|
|
return 0;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_dict(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *dict, *key, *value;
|
|
|
|
int i, j, k;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((i = marker(self)) < 0) return -1;
|
|
|
|
j=self->stack->length;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!( dict = PyDict_New())) return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
for (k = i+1; k < j; k += 2) {
|
|
|
|
key =self->stack->data[k-1];
|
|
|
|
value=self->stack->data[k ];
|
|
|
|
if (PyDict_SetItem(dict, key, value) < 0) {
|
|
|
|
Py_DECREF(dict);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Pdata_clear(self->stack, i);
|
|
|
|
PDATA_PUSH(self->stack, dict, -1);
|
|
|
|
return 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2003-02-01 02:24:36 -04:00
|
|
|
Instance_New(PyObject *cls, PyObject *args)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2003-01-31 22:16:37 -04:00
|
|
|
PyObject *r = 0;
|
2002-04-01 13:40:08 -04:00
|
|
|
|
|
|
|
if (PyClass_Check(cls)) {
|
|
|
|
int l;
|
|
|
|
|
|
|
|
if ((l=PyObject_Size(args)) < 0) goto err;
|
|
|
|
if (!( l )) {
|
|
|
|
PyObject *__getinitargs__;
|
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
__getinitargs__ = PyObject_GetAttr(cls,
|
2003-06-16 17:19:49 -03:00
|
|
|
__getinitargs___str);
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!__getinitargs__) {
|
2003-02-01 02:24:36 -04:00
|
|
|
/* We have a class with no __getinitargs__,
|
2002-04-01 13:40:08 -04:00
|
|
|
so bypass usual construction */
|
|
|
|
PyObject *inst;
|
|
|
|
|
|
|
|
PyErr_Clear();
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( inst=PyInstance_NewRaw(cls, NULL)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto err;
|
|
|
|
return inst;
|
|
|
|
}
|
|
|
|
Py_DECREF(__getinitargs__);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((r=PyInstance_New(cls, args, NULL))) return r;
|
|
|
|
else goto err;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((r=PyObject_CallObject(cls, args))) return r;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
err:
|
|
|
|
{
|
|
|
|
PyObject *tp, *v, *tb;
|
|
|
|
|
|
|
|
PyErr_Fetch(&tp, &v, &tb);
|
2003-10-12 16:09:37 -03:00
|
|
|
if ((r=PyTuple_Pack(3,v,cls,args))) {
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_XDECREF(v);
|
|
|
|
v=r;
|
|
|
|
}
|
|
|
|
PyErr_Restore(tp,v,tb);
|
|
|
|
}
|
|
|
|
return NULL;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
2001-03-17 00:50:51 -04:00
|
|
|
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_obj(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *class, *tup, *obj=0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if ((i = marker(self)) < 0) return -1;
|
|
|
|
if (!( tup=Pdata_popTuple(self->stack, i+1))) return -1;
|
|
|
|
PDATA_POP(self->stack, class);
|
|
|
|
if (class) {
|
|
|
|
obj = Instance_New(class, tup);
|
|
|
|
Py_DECREF(class);
|
|
|
|
}
|
|
|
|
Py_DECREF(tup);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (! obj) return -1;
|
|
|
|
PDATA_PUSH(self->stack, obj, -1);
|
|
|
|
return 0;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_inst(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *tup, *class=0, *obj=0, *module_name, *class_name;
|
|
|
|
int i, len;
|
|
|
|
char *s;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((i = marker(self)) < 0) return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if ((len = self->readline_func(self, &s)) < 0) return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
if (len < 2) return bad_readline();
|
|
|
|
module_name = PyString_FromStringAndSize(s, len - 1);
|
|
|
|
if (!module_name) return -1;
|
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if ((len = self->readline_func(self, &s)) >= 0) {
|
2002-04-01 13:40:08 -04:00
|
|
|
if (len < 2) return bad_readline();
|
|
|
|
if ((class_name = PyString_FromStringAndSize(s, len - 1))) {
|
2003-02-01 02:24:36 -04:00
|
|
|
class = find_class(module_name, class_name,
|
2002-04-01 13:40:08 -04:00
|
|
|
self->find_class);
|
|
|
|
Py_DECREF(class_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Py_DECREF(module_name);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (! class) return -1;
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((tup=Pdata_popTuple(self->stack, i))) {
|
|
|
|
obj = Instance_New(class, tup);
|
|
|
|
Py_DECREF(tup);
|
|
|
|
}
|
|
|
|
Py_DECREF(class);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (! obj) return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
PDATA_PUSH(self->stack, obj, -1);
|
|
|
|
return 0;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-13 14:24:14 -04:00
|
|
|
static int
|
|
|
|
load_newobj(Unpicklerobject *self)
|
|
|
|
{
|
|
|
|
PyObject *args = NULL;
|
|
|
|
PyObject *clsraw = NULL;
|
|
|
|
PyTypeObject *cls; /* clsraw cast to its true type */
|
|
|
|
PyObject *obj;
|
|
|
|
|
|
|
|
/* Stack is ... cls argtuple, and we want to call
|
|
|
|
* cls.__new__(cls, *argtuple).
|
|
|
|
*/
|
|
|
|
PDATA_POP(self->stack, args);
|
|
|
|
if (args == NULL) goto Fail;
|
|
|
|
if (! PyTuple_Check(args)) {
|
|
|
|
PyErr_SetString(UnpicklingError, "NEWOBJ expected an arg "
|
|
|
|
"tuple.");
|
|
|
|
goto Fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
PDATA_POP(self->stack, clsraw);
|
|
|
|
cls = (PyTypeObject *)clsraw;
|
|
|
|
if (cls == NULL) goto Fail;
|
|
|
|
if (! PyType_Check(cls)) {
|
|
|
|
PyErr_SetString(UnpicklingError, "NEWOBJ class argument "
|
|
|
|
"isn't a type object");
|
|
|
|
goto Fail;
|
|
|
|
}
|
|
|
|
if (cls->tp_new == NULL) {
|
|
|
|
PyErr_SetString(UnpicklingError, "NEWOBJ class argument "
|
|
|
|
"has NULL tp_new");
|
|
|
|
goto Fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call __new__. */
|
|
|
|
obj = cls->tp_new(cls, args, NULL);
|
|
|
|
if (obj == NULL) goto Fail;
|
|
|
|
|
|
|
|
Py_DECREF(args);
|
|
|
|
Py_DECREF(clsraw);
|
|
|
|
PDATA_PUSH(self->stack, obj, -1);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
Fail:
|
|
|
|
Py_XDECREF(args);
|
|
|
|
Py_XDECREF(clsraw);
|
|
|
|
return -1;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_global(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *class = 0, *module_name = 0, *class_name = 0;
|
|
|
|
int len;
|
|
|
|
char *s;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if ((len = self->readline_func(self, &s)) < 0) return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
if (len < 2) return bad_readline();
|
|
|
|
module_name = PyString_FromStringAndSize(s, len - 1);
|
|
|
|
if (!module_name) return -1;
|
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if ((len = self->readline_func(self, &s)) >= 0) {
|
2002-12-06 22:43:28 -04:00
|
|
|
if (len < 2) {
|
|
|
|
Py_DECREF(module_name);
|
|
|
|
return bad_readline();
|
|
|
|
}
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((class_name = PyString_FromStringAndSize(s, len - 1))) {
|
2003-02-01 02:24:36 -04:00
|
|
|
class = find_class(module_name, class_name,
|
2002-04-01 13:40:08 -04:00
|
|
|
self->find_class);
|
|
|
|
Py_DECREF(class_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Py_DECREF(module_name);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (! class) return -1;
|
|
|
|
PDATA_PUSH(self->stack, class, -1);
|
|
|
|
return 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_persid(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *pid = 0;
|
|
|
|
int len;
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
if (self->pers_func) {
|
2003-02-02 14:29:33 -04:00
|
|
|
if ((len = self->readline_func(self, &s)) < 0) return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
if (len < 2) return bad_readline();
|
|
|
|
|
|
|
|
pid = PyString_FromStringAndSize(s, len - 1);
|
|
|
|
if (!pid) return -1;
|
|
|
|
|
|
|
|
if (PyList_Check(self->pers_func)) {
|
|
|
|
if (PyList_Append(self->pers_func, pid) < 0) {
|
|
|
|
Py_DECREF(pid);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ARG_TUP(self, pid);
|
|
|
|
if (self->arg) {
|
2003-02-01 02:24:36 -04:00
|
|
|
pid = PyObject_Call(self->pers_func, self->arg,
|
2002-04-01 13:40:08 -04:00
|
|
|
NULL);
|
|
|
|
FREE_ARG_TUP(self);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! pid) return -1;
|
|
|
|
|
|
|
|
PDATA_PUSH(self->stack, pid, -1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PyErr_SetString(UnpicklingError,
|
|
|
|
"A load persistent id instruction was encountered,\n"
|
|
|
|
"but no persistent_load function was specified.");
|
|
|
|
return -1;
|
|
|
|
}
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_binpersid(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *pid = 0;
|
|
|
|
|
|
|
|
if (self->pers_func) {
|
|
|
|
PDATA_POP(self->stack, pid);
|
|
|
|
if (! pid) return -1;
|
|
|
|
|
|
|
|
if (PyList_Check(self->pers_func)) {
|
|
|
|
if (PyList_Append(self->pers_func, pid) < 0) {
|
|
|
|
Py_DECREF(pid);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ARG_TUP(self, pid);
|
|
|
|
if (self->arg) {
|
|
|
|
pid = PyObject_Call(self->pers_func, self->arg,
|
|
|
|
NULL);
|
|
|
|
FREE_ARG_TUP(self);
|
|
|
|
}
|
|
|
|
if (! pid) return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
PDATA_PUSH(self->stack, pid, -1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PyErr_SetString(UnpicklingError,
|
|
|
|
"A load persistent id instruction was encountered,\n"
|
|
|
|
"but no persistent_load function was specified.");
|
|
|
|
return -1;
|
|
|
|
}
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_pop(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (!( (len=self->stack->length) > 0 )) return stackUnderflow();
|
|
|
|
|
|
|
|
/* Note that we split the (pickle.py) stack into two stacks,
|
|
|
|
an object stack and a mark stack. We have to be clever and
|
|
|
|
pop the right one. We do this by looking at the top of the
|
|
|
|
mark stack.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((self->num_marks > 0) &&
|
|
|
|
(self->marks[self->num_marks - 1] == len))
|
|
|
|
self->num_marks--;
|
|
|
|
else {
|
|
|
|
len--;
|
|
|
|
Py_DECREF(self->stack->data[len]);
|
|
|
|
self->stack->length=len;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_pop_mark(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
int i;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((i = marker(self)) < 0)
|
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
Pdata_clear(self->stack, i);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_dup(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *last;
|
|
|
|
int len;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((len = self->stack->length) <= 0) return stackUnderflow();
|
|
|
|
last=self->stack->data[len-1];
|
|
|
|
Py_INCREF(last);
|
|
|
|
PDATA_PUSH(self->stack, last, -1);
|
|
|
|
return 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_get(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *py_str = 0, *value = 0;
|
|
|
|
int len;
|
|
|
|
char *s;
|
|
|
|
int rc;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if ((len = self->readline_func(self, &s)) < 0) return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
if (len < 2) return bad_readline();
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!( py_str = PyString_FromStringAndSize(s, len - 1))) return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
value = PyDict_GetItem(self->memo, py_str);
|
|
|
|
if (! value) {
|
|
|
|
PyErr_SetObject(BadPickleGet, py_str);
|
|
|
|
rc = -1;
|
2003-02-13 19:00:26 -04:00
|
|
|
}
|
|
|
|
else {
|
2002-04-01 13:40:08 -04:00
|
|
|
PDATA_APPEND(self->stack, value, -1);
|
|
|
|
rc = 0;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_DECREF(py_str);
|
|
|
|
return rc;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_binget(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *py_key = 0, *value = 0;
|
|
|
|
unsigned char key;
|
|
|
|
char *s;
|
|
|
|
int rc;
|
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->read_func(self, &s, 1) < 0) return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
|
|
|
|
key = (unsigned char)s[0];
|
|
|
|
if (!( py_key = PyInt_FromLong((long)key))) return -1;
|
|
|
|
|
|
|
|
value = PyDict_GetItem(self->memo, py_key);
|
|
|
|
if (! value) {
|
|
|
|
PyErr_SetObject(BadPickleGet, py_key);
|
|
|
|
rc = -1;
|
2003-02-13 19:00:26 -04:00
|
|
|
}
|
|
|
|
else {
|
2002-04-01 13:40:08 -04:00
|
|
|
PDATA_APPEND(self->stack, value, -1);
|
|
|
|
rc = 0;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_DECREF(py_key);
|
|
|
|
return rc;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_long_binget(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *py_key = 0, *value = 0;
|
|
|
|
unsigned char c;
|
|
|
|
char *s;
|
|
|
|
long key;
|
|
|
|
int rc;
|
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->read_func(self, &s, 4) < 0) return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
|
|
|
|
c = (unsigned char)s[0];
|
|
|
|
key = (long)c;
|
|
|
|
c = (unsigned char)s[1];
|
|
|
|
key |= (long)c << 8;
|
|
|
|
c = (unsigned char)s[2];
|
|
|
|
key |= (long)c << 16;
|
|
|
|
c = (unsigned char)s[3];
|
|
|
|
key |= (long)c << 24;
|
|
|
|
|
|
|
|
if (!( py_key = PyInt_FromLong((long)key))) return -1;
|
|
|
|
|
|
|
|
value = PyDict_GetItem(self->memo, py_key);
|
|
|
|
if (! value) {
|
|
|
|
PyErr_SetObject(BadPickleGet, py_key);
|
|
|
|
rc = -1;
|
2003-02-13 19:00:26 -04:00
|
|
|
}
|
|
|
|
else {
|
2002-04-01 13:40:08 -04:00
|
|
|
PDATA_APPEND(self->stack, value, -1);
|
|
|
|
rc = 0;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_DECREF(py_key);
|
|
|
|
return rc;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-04 01:06:17 -04:00
|
|
|
/* Push an object from the extension registry (EXT[124]). nbytes is
|
|
|
|
* the number of bytes following the opcode, holding the index (code) value.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
load_extension(Unpicklerobject *self, int nbytes)
|
|
|
|
{
|
|
|
|
char *codebytes; /* the nbytes bytes after the opcode */
|
|
|
|
long code; /* calc_binint returns long */
|
|
|
|
PyObject *py_code; /* code as a Python int */
|
|
|
|
PyObject *obj; /* the object to push */
|
|
|
|
PyObject *pair; /* (module_name, class_name) */
|
|
|
|
PyObject *module_name, *class_name;
|
|
|
|
|
|
|
|
assert(nbytes == 1 || nbytes == 2 || nbytes == 4);
|
|
|
|
if (self->read_func(self, &codebytes, nbytes) < 0) return -1;
|
|
|
|
code = calc_binint(codebytes, nbytes);
|
|
|
|
if (code <= 0) { /* note that 0 is forbidden */
|
|
|
|
/* Corrupt or hostile pickle. */
|
|
|
|
PyErr_SetString(UnpicklingError, "EXT specifies code <= 0");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look for the code in the cache. */
|
|
|
|
py_code = PyInt_FromLong(code);
|
|
|
|
if (py_code == NULL) return -1;
|
|
|
|
obj = PyDict_GetItem(extension_cache, py_code);
|
|
|
|
if (obj != NULL) {
|
|
|
|
/* Bingo. */
|
|
|
|
Py_DECREF(py_code);
|
|
|
|
PDATA_APPEND(self->stack, obj, -1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look up the (module_name, class_name) pair. */
|
|
|
|
pair = PyDict_GetItem(inverted_registry, py_code);
|
|
|
|
if (pair == NULL) {
|
|
|
|
Py_DECREF(py_code);
|
|
|
|
PyErr_Format(PyExc_ValueError, "unregistered extension "
|
|
|
|
"code %ld", code);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* Since the extension registry is manipulable via Python code,
|
2003-02-04 01:20:32 -04:00
|
|
|
* confirm that pair is really a 2-tuple of strings.
|
2003-02-04 01:06:17 -04:00
|
|
|
*/
|
|
|
|
if (!PyTuple_Check(pair) || PyTuple_Size(pair) != 2 ||
|
|
|
|
!PyString_Check(module_name = PyTuple_GET_ITEM(pair, 0)) ||
|
|
|
|
!PyString_Check(class_name = PyTuple_GET_ITEM(pair, 1))) {
|
|
|
|
Py_DECREF(py_code);
|
|
|
|
PyErr_Format(PyExc_ValueError, "_inverted_registry[%ld] "
|
|
|
|
"isn't a 2-tuple of strings", code);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* Load the object. */
|
|
|
|
obj = find_class(module_name, class_name, self->find_class);
|
|
|
|
if (obj == NULL) {
|
|
|
|
Py_DECREF(py_code);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* Cache code -> obj. */
|
|
|
|
code = PyDict_SetItem(extension_cache, py_code, obj);
|
|
|
|
Py_DECREF(py_code);
|
|
|
|
if (code < 0) {
|
|
|
|
Py_DECREF(obj);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
PDATA_PUSH(self->stack, obj, -1);
|
|
|
|
return 0;
|
|
|
|
}
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_put(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *py_str = 0, *value = 0;
|
|
|
|
int len, l;
|
|
|
|
char *s;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if ((l = self->readline_func(self, &s)) < 0) return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
if (l < 2) return bad_readline();
|
|
|
|
if (!( len=self->stack->length )) return stackUnderflow();
|
|
|
|
if (!( py_str = PyString_FromStringAndSize(s, l - 1))) return -1;
|
|
|
|
value=self->stack->data[len-1];
|
|
|
|
l=PyDict_SetItem(self->memo, py_str, value);
|
|
|
|
Py_DECREF(py_str);
|
|
|
|
return l;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_binput(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *py_key = 0, *value = 0;
|
|
|
|
unsigned char key;
|
|
|
|
char *s;
|
|
|
|
int len;
|
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->read_func(self, &s, 1) < 0) return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!( (len=self->stack->length) > 0 )) return stackUnderflow();
|
|
|
|
|
|
|
|
key = (unsigned char)s[0];
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!( py_key = PyInt_FromLong((long)key))) return -1;
|
|
|
|
value=self->stack->data[len-1];
|
|
|
|
len=PyDict_SetItem(self->memo, py_key, value);
|
|
|
|
Py_DECREF(py_key);
|
|
|
|
return len;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_long_binput(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *py_key = 0, *value = 0;
|
|
|
|
long key;
|
|
|
|
unsigned char c;
|
|
|
|
char *s;
|
|
|
|
int len;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->read_func(self, &s, 4) < 0) return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!( len=self->stack->length )) return stackUnderflow();
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
c = (unsigned char)s[0];
|
|
|
|
key = (long)c;
|
|
|
|
c = (unsigned char)s[1];
|
|
|
|
key |= (long)c << 8;
|
|
|
|
c = (unsigned char)s[2];
|
|
|
|
key |= (long)c << 16;
|
|
|
|
c = (unsigned char)s[3];
|
|
|
|
key |= (long)c << 24;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!( py_key = PyInt_FromLong(key))) return -1;
|
|
|
|
value=self->stack->data[len-1];
|
|
|
|
len=PyDict_SetItem(self->memo, py_key, value);
|
|
|
|
Py_DECREF(py_key);
|
|
|
|
return len;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
do_append(Unpicklerobject *self, int x)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *value = 0, *list = 0, *append_method = 0;
|
|
|
|
int len, i;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
len=self->stack->length;
|
|
|
|
if (!( len >= x && x > 0 )) return stackUnderflow();
|
|
|
|
/* nothing to do */
|
2003-02-01 02:24:36 -04:00
|
|
|
if (len==x) return 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
list=self->stack->data[x-1];
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (PyList_Check(list)) {
|
|
|
|
PyObject *slice;
|
|
|
|
int list_len;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
slice=Pdata_popList(self->stack, x);
|
|
|
|
list_len = PyList_GET_SIZE(list);
|
|
|
|
i=PyList_SetSlice(list, list_len, list_len, slice);
|
|
|
|
Py_DECREF(slice);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( append_method = PyObject_GetAttr(list, append_str)))
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
for (i = x; i < len; i++) {
|
|
|
|
PyObject *junk;
|
|
|
|
|
|
|
|
value=self->stack->data[i];
|
|
|
|
junk=0;
|
|
|
|
ARG_TUP(self, value);
|
|
|
|
if (self->arg) {
|
2003-02-01 02:24:36 -04:00
|
|
|
junk = PyObject_Call(append_method, self->arg,
|
2002-04-01 13:40:08 -04:00
|
|
|
NULL);
|
|
|
|
FREE_ARG_TUP(self);
|
|
|
|
}
|
|
|
|
if (! junk) {
|
|
|
|
Pdata_clear(self->stack, i+1);
|
|
|
|
self->stack->length=x;
|
|
|
|
Py_DECREF(append_method);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
Py_DECREF(junk);
|
|
|
|
}
|
|
|
|
self->stack->length=x;
|
|
|
|
Py_DECREF(append_method);
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return 0;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2001-03-17 00:50:51 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_append(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
return do_append(self, self->stack->length - 1);
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_appends(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
return do_append(self, marker(self));
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
do_setitems(Unpicklerobject *self, int x)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *value = 0, *key = 0, *dict = 0;
|
|
|
|
int len, i, r=0;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!( (len=self->stack->length) >= x
|
|
|
|
&& x > 0 )) return stackUnderflow();
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
dict=self->stack->data[x-1];
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
for (i = x+1; i < len; i += 2) {
|
|
|
|
key =self->stack->data[i-1];
|
|
|
|
value=self->stack->data[i ];
|
|
|
|
if (PyObject_SetItem(dict, key, value) < 0) {
|
|
|
|
r=-1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
Pdata_clear(self->stack, x);
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return r;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_setitem(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
return do_setitems(self, self->stack->length - 2);
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_setitems(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
return do_setitems(self, marker(self));
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_build(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2003-02-14 23:01:11 -04:00
|
|
|
PyObject *state, *inst, *slotstate;
|
|
|
|
PyObject *__setstate__;
|
|
|
|
PyObject *d_key, *d_value;
|
2006-02-15 13:27:45 -04:00
|
|
|
Py_ssize_t i;
|
2003-02-14 23:01:11 -04:00
|
|
|
int res = -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
|
2003-02-14 23:01:11 -04:00
|
|
|
/* Stack is ... instance, state. We want to leave instance at
|
|
|
|
* the stack top, possibly mutated via instance.__setstate__(state).
|
|
|
|
*/
|
|
|
|
if (self->stack->length < 2)
|
|
|
|
return stackUnderflow();
|
|
|
|
PDATA_POP(self->stack, state);
|
|
|
|
if (state == NULL)
|
|
|
|
return -1;
|
|
|
|
inst = self->stack->data[self->stack->length - 1];
|
2002-04-01 13:40:08 -04:00
|
|
|
|
2003-02-14 23:01:11 -04:00
|
|
|
__setstate__ = PyObject_GetAttr(inst, __setstate___str);
|
|
|
|
if (__setstate__ != NULL) {
|
|
|
|
PyObject *junk = NULL;
|
|
|
|
|
|
|
|
/* The explicit __setstate__ is responsible for everything. */
|
|
|
|
ARG_TUP(self, state);
|
2002-04-01 13:40:08 -04:00
|
|
|
if (self->arg) {
|
|
|
|
junk = PyObject_Call(__setstate__, self->arg, NULL);
|
|
|
|
FREE_ARG_TUP(self);
|
|
|
|
}
|
|
|
|
Py_DECREF(__setstate__);
|
2003-02-14 23:01:11 -04:00
|
|
|
if (junk == NULL)
|
|
|
|
return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_DECREF(junk);
|
|
|
|
return 0;
|
|
|
|
}
|
2003-06-16 17:19:49 -03:00
|
|
|
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
|
|
|
|
return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
PyErr_Clear();
|
2003-02-14 23:01:11 -04:00
|
|
|
|
|
|
|
/* A default __setstate__. First see whether state embeds a
|
|
|
|
* slot state dict too (a proto 2 addition).
|
|
|
|
*/
|
|
|
|
if (PyTuple_Check(state) && PyTuple_Size(state) == 2) {
|
|
|
|
PyObject *temp = state;
|
|
|
|
state = PyTuple_GET_ITEM(temp, 0);
|
|
|
|
slotstate = PyTuple_GET_ITEM(temp, 1);
|
|
|
|
Py_INCREF(state);
|
|
|
|
Py_INCREF(slotstate);
|
|
|
|
Py_DECREF(temp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
slotstate = NULL;
|
|
|
|
|
|
|
|
/* Set inst.__dict__ from the state dict (if any). */
|
|
|
|
if (state != Py_None) {
|
|
|
|
PyObject *dict;
|
|
|
|
if (! PyDict_Check(state)) {
|
|
|
|
PyErr_SetString(UnpicklingError, "state is not a "
|
|
|
|
"dictionary");
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
dict = PyObject_GetAttr(inst, __dict___str);
|
|
|
|
if (dict == NULL)
|
|
|
|
goto finally;
|
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
i = 0;
|
2003-02-14 23:01:11 -04:00
|
|
|
while (PyDict_Next(state, &i, &d_key, &d_value)) {
|
|
|
|
if (PyObject_SetItem(dict, d_key, d_value) < 0)
|
|
|
|
goto finally;
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
2003-02-14 23:01:11 -04:00
|
|
|
Py_DECREF(dict);
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-14 23:01:11 -04:00
|
|
|
/* Also set instance attributes from the slotstate dict (if any). */
|
|
|
|
if (slotstate != NULL) {
|
|
|
|
if (! PyDict_Check(slotstate)) {
|
|
|
|
PyErr_SetString(UnpicklingError, "slot state is not "
|
|
|
|
"a dictionary");
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
i = 0;
|
|
|
|
while (PyDict_Next(slotstate, &i, &d_key, &d_value)) {
|
|
|
|
if (PyObject_SetAttr(inst, d_key, d_value) < 0)
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
res = 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-14 23:01:11 -04:00
|
|
|
finally:
|
|
|
|
Py_DECREF(state);
|
|
|
|
Py_XDECREF(slotstate);
|
|
|
|
return res;
|
2002-04-01 13:40:08 -04:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2000-05-09 15:14:50 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_mark(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
int s;
|
|
|
|
|
|
|
|
/* Note that we split the (pickle.py) stack into two stacks, an
|
|
|
|
object stack and a mark stack. Here we push a mark onto the
|
|
|
|
mark stack.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((self->num_marks + 1) >= self->marks_size) {
|
|
|
|
s=self->marks_size+20;
|
|
|
|
if (s <= self->num_marks) s=self->num_marks + 1;
|
|
|
|
if (self->marks == NULL)
|
|
|
|
self->marks=(int *)malloc(s * sizeof(int));
|
|
|
|
else
|
2003-02-01 02:24:36 -04:00
|
|
|
self->marks=(int *)realloc(self->marks,
|
2002-04-01 13:40:08 -04:00
|
|
|
s * sizeof(int));
|
|
|
|
if (! self->marks) {
|
|
|
|
PyErr_NoMemory();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
self->marks_size = s;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
self->marks[self->num_marks++] = self->stack->length;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return 0;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
load_reduce(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *callable = 0, *arg_tup = 0, *ob = 0;
|
|
|
|
|
|
|
|
PDATA_POP(self->stack, arg_tup);
|
|
|
|
if (! arg_tup) return -1;
|
|
|
|
PDATA_POP(self->stack, callable);
|
|
|
|
if (callable) {
|
|
|
|
ob = Instance_New(callable, arg_tup);
|
|
|
|
Py_DECREF(callable);
|
|
|
|
}
|
|
|
|
Py_DECREF(arg_tup);
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (! ob) return -1;
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
PDATA_PUSH(self->stack, ob, -1);
|
|
|
|
return 0;
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2003-02-02 12:09:05 -04:00
|
|
|
/* Just raises an error if we don't know the protocol specified. PROTO
|
|
|
|
* is the first opcode for protocols >= 2.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
load_proto(Unpicklerobject *self)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char *protobyte;
|
|
|
|
|
|
|
|
i = self->read_func(self, &protobyte, 1);
|
|
|
|
if (i < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
i = calc_binint(protobyte, 1);
|
|
|
|
/* No point checking for < 0, since calc_binint returns an unsigned
|
|
|
|
* int when chewing on 1 byte.
|
|
|
|
*/
|
|
|
|
assert(i >= 0);
|
2003-02-13 11:44:41 -04:00
|
|
|
if (i <= HIGHEST_PROTOCOL)
|
2003-02-02 12:09:05 -04:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
PyErr_Format(PyExc_ValueError, "unsupported pickle protocol: %d", i);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static PyObject *
|
2003-02-01 02:24:36 -04:00
|
|
|
load(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *err = 0, *val = 0;
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
self->num_marks = 0;
|
|
|
|
if (self->stack->length) Pdata_clear(self->stack, 0);
|
|
|
|
|
|
|
|
while (1) {
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->read_func(self, &s, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
switch (s[0]) {
|
|
|
|
case NONE:
|
|
|
|
if (load_none(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BININT:
|
|
|
|
if (load_binint(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BININT1:
|
|
|
|
if (load_binint1(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BININT2:
|
|
|
|
if (load_binint2(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case INT:
|
|
|
|
if (load_int(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case LONG:
|
|
|
|
if (load_long(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments. Fixed an undetected-overflow bug in readline_file().
longobject.c: Fixed a really stupid bug in the new _PyLong_NumBits.
pickle.py: Fixed stupid bug in save_long(): When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4(): they *returned* the unpickled long instead of pushing
it on the stack. The return values were ignored. Tests passed
before only because save_long() pickled the long twice.
Fixed bugs in encode_long().
Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time. I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that. It would be more valuable to make long(string, 16) linear time.
pickletester.py: Added a global "protocols" vector so tests can try
all the protocols in a sane way. Changed test_ints() and test_unicode()
to do so. Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle: cPickle proto 2 for longs is linear-time).
2003-02-01 22:57:53 -04:00
|
|
|
case LONG1:
|
|
|
|
if (load_counted_long(self, 1) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case LONG4:
|
|
|
|
if (load_counted_long(self, 4) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
case FLOAT:
|
|
|
|
if (load_float(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BINFLOAT:
|
|
|
|
if (load_binfloat(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BINSTRING:
|
|
|
|
if (load_binstring(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case SHORT_BINSTRING:
|
|
|
|
if (load_short_binstring(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case STRING:
|
|
|
|
if (load_string(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2001-08-17 15:39:25 -03:00
|
|
|
#ifdef Py_USING_UNICODE
|
2002-04-01 13:40:08 -04:00
|
|
|
case UNICODE:
|
|
|
|
if (load_unicode(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BINUNICODE:
|
|
|
|
if (load_binunicode(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
2001-08-17 15:39:25 -03:00
|
|
|
#endif
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
case EMPTY_TUPLE:
|
2003-02-02 16:29:39 -04:00
|
|
|
if (load_counted_tuple(self, 0) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case TUPLE1:
|
|
|
|
if (load_counted_tuple(self, 1) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case TUPLE2:
|
|
|
|
if (load_counted_tuple(self, 2) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case TUPLE3:
|
|
|
|
if (load_counted_tuple(self, 3) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case TUPLE:
|
|
|
|
if (load_tuple(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case EMPTY_LIST:
|
|
|
|
if (load_empty_list(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case LIST:
|
|
|
|
if (load_list(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case EMPTY_DICT:
|
|
|
|
if (load_empty_dict(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case DICT:
|
|
|
|
if (load_dict(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case OBJ:
|
|
|
|
if (load_obj(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case INST:
|
|
|
|
if (load_inst(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
2003-02-13 14:24:14 -04:00
|
|
|
case NEWOBJ:
|
|
|
|
if (load_newobj(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
case GLOBAL:
|
|
|
|
if (load_global(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case APPEND:
|
|
|
|
if (load_append(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case APPENDS:
|
|
|
|
if (load_appends(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BUILD:
|
|
|
|
if (load_build(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case DUP:
|
|
|
|
if (load_dup(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BINGET:
|
|
|
|
if (load_binget(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case LONG_BINGET:
|
|
|
|
if (load_long_binget(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case GET:
|
|
|
|
if (load_get(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
2003-02-04 01:06:17 -04:00
|
|
|
case EXT1:
|
|
|
|
if (load_extension(self, 1) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case EXT2:
|
|
|
|
if (load_extension(self, 2) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case EXT4:
|
|
|
|
if (load_extension(self, 4) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
2002-04-01 13:40:08 -04:00
|
|
|
case MARK:
|
|
|
|
if (load_mark(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BINPUT:
|
|
|
|
if (load_binput(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case LONG_BINPUT:
|
|
|
|
if (load_long_binput(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case PUT:
|
|
|
|
if (load_put(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case POP:
|
|
|
|
if (load_pop(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case POP_MARK:
|
|
|
|
if (load_pop_mark(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case SETITEM:
|
|
|
|
if (load_setitem(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case SETITEMS:
|
|
|
|
if (load_setitems(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case STOP:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PERSID:
|
|
|
|
if (load_persid(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BINPERSID:
|
|
|
|
if (load_binpersid(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case REDUCE:
|
|
|
|
if (load_reduce(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
2003-02-02 12:09:05 -04:00
|
|
|
case PROTO:
|
|
|
|
if (load_proto(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
2003-02-02 13:59:11 -04:00
|
|
|
case NEWTRUE:
|
|
|
|
if (load_bool(self, Py_True) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case NEWFALSE:
|
|
|
|
if (load_bool(self, Py_False) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
case '\0':
|
|
|
|
/* end of file */
|
|
|
|
PyErr_SetNone(PyExc_EOFError);
|
|
|
|
break;
|
2003-02-01 02:24:36 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
default:
|
2003-02-01 02:24:36 -04:00
|
|
|
cPickle_ErrFormat(UnpicklingError,
|
2002-04-01 13:40:08 -04:00
|
|
|
"invalid load key, '%s'.",
|
|
|
|
"c", s[0]);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((err = PyErr_Occurred())) {
|
|
|
|
if (err == PyExc_EOFError) {
|
|
|
|
PyErr_SetNone(PyExc_EOFError);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
PDATA_POP(self->stack, val);
|
|
|
|
return val;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
2001-03-17 00:50:51 -04:00
|
|
|
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-12-03 21:13:01 -04:00
|
|
|
/* No-load functions to support noload, which is used to
|
|
|
|
find persistent references. */
|
|
|
|
|
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
noload_obj(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
int i;
|
1997-12-03 21:13:01 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if ((i = marker(self)) < 0) return -1;
|
|
|
|
return Pdata_clear(self->stack, i+1);
|
1997-12-03 21:13:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
noload_inst(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
if ((i = marker(self)) < 0) return -1;
|
|
|
|
Pdata_clear(self->stack, i);
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->readline_func(self, &s) < 0) return -1;
|
|
|
|
if (self->readline_func(self, &s) < 0) return -1;
|
2003-02-13 14:24:14 -04:00
|
|
|
PDATA_APPEND(self->stack, Py_None, -1);
|
2002-04-01 13:40:08 -04:00
|
|
|
return 0;
|
1997-12-03 21:13:01 -04:00
|
|
|
}
|
|
|
|
|
2003-02-13 14:24:14 -04:00
|
|
|
static int
|
|
|
|
noload_newobj(Unpicklerobject *self)
|
|
|
|
{
|
|
|
|
PyObject *obj;
|
|
|
|
|
|
|
|
PDATA_POP(self->stack, obj); /* pop argtuple */
|
|
|
|
if (obj == NULL) return -1;
|
|
|
|
Py_DECREF(obj);
|
|
|
|
|
|
|
|
PDATA_POP(self->stack, obj); /* pop cls */
|
|
|
|
if (obj == NULL) return -1;
|
|
|
|
Py_DECREF(obj);
|
|
|
|
|
|
|
|
PDATA_APPEND(self->stack, Py_None, -1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1997-12-03 21:13:01 -04:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
noload_global(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
char *s;
|
1997-12-03 21:13:01 -04:00
|
|
|
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->readline_func(self, &s) < 0) return -1;
|
|
|
|
if (self->readline_func(self, &s) < 0) return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
PDATA_APPEND(self->stack, Py_None,-1);
|
|
|
|
return 0;
|
1997-12-03 21:13:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
noload_reduce(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
1997-12-03 21:13:01 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (self->stack->length < 2) return stackUnderflow();
|
|
|
|
Pdata_clear(self->stack, self->stack->length-2);
|
|
|
|
PDATA_APPEND(self->stack, Py_None,-1);
|
|
|
|
return 0;
|
1997-12-03 21:13:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
noload_build(Unpicklerobject *self) {
|
|
|
|
|
1998-11-25 12:18:00 -04:00
|
|
|
if (self->stack->length < 1) return stackUnderflow();
|
|
|
|
Pdata_clear(self->stack, self->stack->length-1);
|
1998-12-04 14:48:44 -04:00
|
|
|
return 0;
|
1997-12-03 21:13:01 -04:00
|
|
|
}
|
|
|
|
|
2003-02-04 01:06:17 -04:00
|
|
|
static int
|
|
|
|
noload_extension(Unpicklerobject *self, int nbytes)
|
|
|
|
{
|
|
|
|
char *codebytes;
|
|
|
|
|
|
|
|
assert(nbytes == 1 || nbytes == 2 || nbytes == 4);
|
|
|
|
if (self->read_func(self, &codebytes, nbytes) < 0) return -1;
|
|
|
|
PDATA_APPEND(self->stack, Py_None, -1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1997-12-03 21:13:01 -04:00
|
|
|
|
|
|
|
static PyObject *
|
2003-02-01 02:24:36 -04:00
|
|
|
noload(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *err = 0, *val = 0;
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
self->num_marks = 0;
|
|
|
|
Pdata_clear(self->stack, 0);
|
|
|
|
|
|
|
|
while (1) {
|
2003-02-02 14:29:33 -04:00
|
|
|
if (self->read_func(self, &s, 1) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
switch (s[0]) {
|
|
|
|
case NONE:
|
|
|
|
if (load_none(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BININT:
|
|
|
|
if (load_binint(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BININT1:
|
|
|
|
if (load_binint1(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BININT2:
|
|
|
|
if (load_binint2(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case INT:
|
|
|
|
if (load_int(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case LONG:
|
|
|
|
if (load_long(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
2003-02-02 12:09:05 -04:00
|
|
|
case LONG1:
|
|
|
|
if (load_counted_long(self, 1) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case LONG4:
|
|
|
|
if (load_counted_long(self, 4) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
case FLOAT:
|
|
|
|
if (load_float(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BINFLOAT:
|
|
|
|
if (load_binfloat(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BINSTRING:
|
|
|
|
if (load_binstring(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case SHORT_BINSTRING:
|
|
|
|
if (load_short_binstring(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case STRING:
|
|
|
|
if (load_string(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
1997-12-03 21:13:01 -04:00
|
|
|
|
2001-08-17 15:39:25 -03:00
|
|
|
#ifdef Py_USING_UNICODE
|
2002-04-01 13:40:08 -04:00
|
|
|
case UNICODE:
|
|
|
|
if (load_unicode(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BINUNICODE:
|
|
|
|
if (load_binunicode(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
2001-08-17 15:39:25 -03:00
|
|
|
#endif
|
2000-03-10 19:11:40 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
case EMPTY_TUPLE:
|
2003-02-02 16:29:39 -04:00
|
|
|
if (load_counted_tuple(self, 0) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case TUPLE1:
|
|
|
|
if (load_counted_tuple(self, 1) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case TUPLE2:
|
|
|
|
if (load_counted_tuple(self, 2) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case TUPLE3:
|
|
|
|
if (load_counted_tuple(self, 3) < 0)
|
2002-04-01 13:40:08 -04:00
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case TUPLE:
|
|
|
|
if (load_tuple(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case EMPTY_LIST:
|
|
|
|
if (load_empty_list(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case LIST:
|
|
|
|
if (load_list(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case EMPTY_DICT:
|
|
|
|
if (load_empty_dict(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case DICT:
|
|
|
|
if (load_dict(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case OBJ:
|
|
|
|
if (noload_obj(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case INST:
|
|
|
|
if (noload_inst(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
2003-02-13 14:24:14 -04:00
|
|
|
case NEWOBJ:
|
|
|
|
if (noload_newobj(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
case GLOBAL:
|
|
|
|
if (noload_global(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case APPEND:
|
|
|
|
if (load_append(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case APPENDS:
|
|
|
|
if (load_appends(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BUILD:
|
|
|
|
if (noload_build(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case DUP:
|
|
|
|
if (load_dup(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BINGET:
|
|
|
|
if (load_binget(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case LONG_BINGET:
|
|
|
|
if (load_long_binget(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case GET:
|
|
|
|
if (load_get(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
2003-02-04 01:06:17 -04:00
|
|
|
case EXT1:
|
|
|
|
if (noload_extension(self, 1) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case EXT2:
|
|
|
|
if (noload_extension(self, 2) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case EXT4:
|
|
|
|
if (noload_extension(self, 4) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
case MARK:
|
|
|
|
if (load_mark(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BINPUT:
|
|
|
|
if (load_binput(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case LONG_BINPUT:
|
|
|
|
if (load_long_binput(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case PUT:
|
|
|
|
if (load_put(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case POP:
|
|
|
|
if (load_pop(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case POP_MARK:
|
|
|
|
if (load_pop_mark(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case SETITEM:
|
|
|
|
if (load_setitem(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case SETITEMS:
|
|
|
|
if (load_setitems(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case STOP:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PERSID:
|
|
|
|
if (load_persid(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case BINPERSID:
|
|
|
|
if (load_binpersid(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case REDUCE:
|
|
|
|
if (noload_reduce(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
2003-02-02 12:09:05 -04:00
|
|
|
case PROTO:
|
|
|
|
if (load_proto(self) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
2003-02-02 13:59:11 -04:00
|
|
|
case NEWTRUE:
|
|
|
|
if (load_bool(self, Py_True) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case NEWFALSE:
|
|
|
|
if (load_bool(self, Py_False) < 0)
|
|
|
|
break;
|
|
|
|
continue;
|
2002-04-01 13:40:08 -04:00
|
|
|
default:
|
2003-02-01 02:24:36 -04:00
|
|
|
cPickle_ErrFormat(UnpicklingError,
|
2002-04-01 13:40:08 -04:00
|
|
|
"invalid load key, '%s'.",
|
|
|
|
"c", s[0]);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((err = PyErr_Occurred())) {
|
|
|
|
if (err == PyExc_EOFError) {
|
|
|
|
PyErr_SetNone(PyExc_EOFError);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PDATA_POP(self->stack, val);
|
|
|
|
return val;
|
1997-12-03 21:13:01 -04:00
|
|
|
}
|
2001-03-17 00:50:51 -04:00
|
|
|
|
1997-12-03 21:13:01 -04:00
|
|
|
|
1997-04-09 14:36:32 -03: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
|
|
|
Unpickler_load(Unpicklerobject *self, PyObject *unused)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
return load(self);
|
1997-04-09 14:36:32 -03:00
|
|
|
}
|
|
|
|
|
1997-12-03 21:13:01 -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
|
|
|
Unpickler_noload(Unpicklerobject *self, PyObject *unused)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
return noload(self);
|
1997-12-03 21:13:01 -04:00
|
|
|
}
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
|
|
|
|
static struct PyMethodDef Unpickler_methods[] = {
|
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
|
|
|
{"load", (PyCFunction)Unpickler_load, METH_NOARGS,
|
2002-08-13 19:20:41 -03:00
|
|
|
PyDoc_STR("load() -- Load a pickle")
|
1997-12-03 21:13:01 -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
|
|
|
{"noload", (PyCFunction)Unpickler_noload, METH_NOARGS,
|
2002-08-13 19:20:41 -03:00
|
|
|
PyDoc_STR(
|
1997-12-03 21:13:01 -04:00
|
|
|
"noload() -- not load a pickle, but go through most of the motions\n"
|
|
|
|
"\n"
|
|
|
|
"This function can be used to read past a pickle without instantiating\n"
|
|
|
|
"any objects or importing any modules. It can also be used to find all\n"
|
|
|
|
"persistent references without instantiating any objects or importing\n"
|
2002-08-13 19:20:41 -03:00
|
|
|
"any modules.\n")
|
1997-12-03 21:13:01 -04:00
|
|
|
},
|
1997-04-09 14:36:32 -03:00
|
|
|
{NULL, NULL} /* sentinel */
|
1997-01-06 18:59:08 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static Unpicklerobject *
|
2003-02-01 02:24:36 -04:00
|
|
|
newUnpicklerobject(PyObject *f)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
Unpicklerobject *self;
|
|
|
|
|
2003-04-09 18:25:30 -03:00
|
|
|
if (!( self = PyObject_GC_New(Unpicklerobject, &Unpicklertype)))
|
2002-04-01 13:40:08 -04:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
self->file = NULL;
|
|
|
|
self->arg = NULL;
|
|
|
|
self->stack = (Pdata*)Pdata_New();
|
|
|
|
self->pers_func = NULL;
|
|
|
|
self->last_string = NULL;
|
|
|
|
self->marks = NULL;
|
|
|
|
self->num_marks = 0;
|
|
|
|
self->marks_size = 0;
|
|
|
|
self->buf_size = 0;
|
|
|
|
self->read = NULL;
|
|
|
|
self->readline = NULL;
|
|
|
|
self->find_class = NULL;
|
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( self->memo = PyDict_New()))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
Py_INCREF(f);
|
|
|
|
self->file = f;
|
|
|
|
|
|
|
|
/* Set read, readline based on type of f */
|
|
|
|
if (PyFile_Check(f)) {
|
|
|
|
self->fp = PyFile_AsFile(f);
|
|
|
|
if (self->fp == NULL) {
|
2003-02-01 02:24:36 -04:00
|
|
|
PyErr_SetString(PyExc_ValueError,
|
2002-04-01 13:40:08 -04:00
|
|
|
"I/O operation on closed file");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
self->read_func = read_file;
|
|
|
|
self->readline_func = readline_file;
|
|
|
|
}
|
|
|
|
else if (PycStringIO_InputCheck(f)) {
|
|
|
|
self->fp = NULL;
|
|
|
|
self->read_func = read_cStringIO;
|
|
|
|
self->readline_func = readline_cStringIO;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
self->fp = NULL;
|
|
|
|
self->read_func = read_other;
|
|
|
|
self->readline_func = readline_other;
|
|
|
|
|
|
|
|
if (!( (self->readline = PyObject_GetAttr(f, readline_str)) &&
|
|
|
|
(self->read = PyObject_GetAttr(f, read_str)))) {
|
|
|
|
PyErr_Clear();
|
2003-02-01 02:24:36 -04:00
|
|
|
PyErr_SetString( PyExc_TypeError,
|
2002-04-01 13:40:08 -04:00
|
|
|
"argument must have 'read' and "
|
|
|
|
"'readline' attributes" );
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
2003-04-09 18:25:30 -03:00
|
|
|
PyObject_GC_Track(self);
|
2002-04-01 13:40:08 -04:00
|
|
|
|
|
|
|
return self;
|
|
|
|
|
|
|
|
err:
|
|
|
|
Py_DECREF((PyObject *)self);
|
|
|
|
return NULL;
|
1997-01-06 18:59:08 -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
|
|
|
get_Unpickler(PyObject *self, PyObject *file)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
return (PyObject *)newUnpicklerobject(file);
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2003-02-01 02:24:36 -04:00
|
|
|
Unpickler_dealloc(Unpicklerobject *self)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2003-04-09 18:25:30 -03:00
|
|
|
PyObject_GC_UnTrack((PyObject *)self);
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_XDECREF(self->readline);
|
|
|
|
Py_XDECREF(self->read);
|
|
|
|
Py_XDECREF(self->file);
|
|
|
|
Py_XDECREF(self->memo);
|
|
|
|
Py_XDECREF(self->stack);
|
|
|
|
Py_XDECREF(self->pers_func);
|
|
|
|
Py_XDECREF(self->arg);
|
|
|
|
Py_XDECREF(self->last_string);
|
2003-07-11 16:42:49 -03:00
|
|
|
Py_XDECREF(self->find_class);
|
2002-04-01 13:40:08 -04:00
|
|
|
|
|
|
|
if (self->marks) {
|
|
|
|
free(self->marks);
|
|
|
|
}
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (self->buf_size) {
|
|
|
|
free(self->buf);
|
|
|
|
}
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2003-05-21 18:29:48 -03:00
|
|
|
self->ob_type->tp_free((PyObject *)self);
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
2003-04-09 18:25:30 -03:00
|
|
|
static int
|
|
|
|
Unpickler_traverse(Unpicklerobject *self, visitproc visit, void *arg)
|
|
|
|
{
|
2006-04-21 07:40:58 -03:00
|
|
|
Py_VISIT(self->readline);
|
|
|
|
Py_VISIT(self->read);
|
|
|
|
Py_VISIT(self->file);
|
|
|
|
Py_VISIT(self->memo);
|
|
|
|
Py_VISIT(self->stack);
|
|
|
|
Py_VISIT(self->pers_func);
|
|
|
|
Py_VISIT(self->arg);
|
|
|
|
Py_VISIT(self->last_string);
|
|
|
|
Py_VISIT(self->find_class);
|
2003-04-09 18:25:30 -03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
Unpickler_clear(Unpicklerobject *self)
|
|
|
|
{
|
2006-04-21 07:40:58 -03:00
|
|
|
Py_CLEAR(self->readline);
|
|
|
|
Py_CLEAR(self->read);
|
|
|
|
Py_CLEAR(self->file);
|
|
|
|
Py_CLEAR(self->memo);
|
|
|
|
Py_CLEAR(self->stack);
|
|
|
|
Py_CLEAR(self->pers_func);
|
|
|
|
Py_CLEAR(self->arg);
|
|
|
|
Py_CLEAR(self->last_string);
|
|
|
|
Py_CLEAR(self->find_class);
|
2003-04-09 18:25:30 -03:00
|
|
|
return 0;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
|
|
|
static PyObject *
|
2003-02-01 02:24:36 -04:00
|
|
|
Unpickler_getattr(Unpicklerobject *self, char *name)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
if (!strcmp(name, "persistent_load")) {
|
|
|
|
if (!self->pers_func) {
|
|
|
|
PyErr_SetString(PyExc_AttributeError, name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Py_INCREF(self->pers_func);
|
|
|
|
return self->pers_func;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!strcmp(name, "find_global")) {
|
|
|
|
if (!self->find_class) {
|
|
|
|
PyErr_SetString(PyExc_AttributeError, name);
|
|
|
|
return NULL;
|
|
|
|
}
|
1999-04-19 14:58:18 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_INCREF(self->find_class);
|
|
|
|
return self->find_class;
|
|
|
|
}
|
1999-04-19 14:58:18 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!strcmp(name, "memo")) {
|
|
|
|
if (!self->memo) {
|
|
|
|
PyErr_SetString(PyExc_AttributeError, name);
|
|
|
|
return NULL;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_INCREF(self->memo);
|
|
|
|
return self->memo;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!strcmp(name, "UnpicklingError")) {
|
|
|
|
Py_INCREF(UnpicklingError);
|
|
|
|
return UnpicklingError;
|
|
|
|
}
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return Py_FindMethod(Unpickler_methods, (PyObject *)self, name);
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
Unpickler_setattr(Unpicklerobject *self, char *name, PyObject *value)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
if (!strcmp(name, "persistent_load")) {
|
|
|
|
Py_XDECREF(self->pers_func);
|
|
|
|
self->pers_func = value;
|
|
|
|
Py_XINCREF(value);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(name, "find_global")) {
|
|
|
|
Py_XDECREF(self->find_class);
|
|
|
|
self->find_class = value;
|
|
|
|
Py_XINCREF(value);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! value) {
|
|
|
|
PyErr_SetString(PyExc_TypeError,
|
|
|
|
"attribute deletion is not supported");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(name, "memo") == 0) {
|
|
|
|
if (!PyDict_Check(value)) {
|
2003-02-01 02:24:36 -04:00
|
|
|
PyErr_SetString(PyExc_TypeError,
|
2002-04-01 13:40:08 -04:00
|
|
|
"memo must be a dictionary");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
Py_XDECREF(self->memo);
|
|
|
|
self->memo = value;
|
|
|
|
Py_INCREF(value);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyErr_SetString(PyExc_AttributeError, name);
|
|
|
|
return -1;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
2003-02-01 12:45:06 -04:00
|
|
|
/* ---------------------------------------------------------------------------
|
|
|
|
* Module-level functions.
|
|
|
|
*/
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2004-07-27 02:22:33 -03:00
|
|
|
/* dump(obj, file, protocol=0). */
|
1997-01-06 18:59:08 -04:00
|
|
|
static PyObject *
|
2004-07-27 02:22:33 -03:00
|
|
|
cpm_dump(PyObject *self, PyObject *args, PyObject *kwds)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2006-02-27 12:46:16 -04:00
|
|
|
static char *kwlist[] = {"obj", "file", "protocol", NULL};
|
2002-04-01 13:40:08 -04:00
|
|
|
PyObject *ob, *file, *res = NULL;
|
|
|
|
Picklerobject *pickler = 0;
|
2003-02-01 12:45:06 -04:00
|
|
|
int proto = 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2004-07-27 02:22:33 -03:00
|
|
|
if (!( PyArg_ParseTupleAndKeywords(args, kwds, "OO|i", kwlist,
|
|
|
|
&ob, &file, &proto)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-01 12:45:06 -04:00
|
|
|
if (!( pickler = newPicklerobject(file, proto)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (dump(pickler, ob) < 0)
|
|
|
|
goto finally;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
res = Py_None;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
finally:
|
|
|
|
Py_XDECREF(pickler);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return res;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-27 02:22:33 -03:00
|
|
|
/* dumps(obj, protocol=0). */
|
1997-01-06 18:59:08 -04:00
|
|
|
static PyObject *
|
2004-07-27 02:22:33 -03:00
|
|
|
cpm_dumps(PyObject *self, PyObject *args, PyObject *kwds)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
2006-02-27 12:46:16 -04:00
|
|
|
static char *kwlist[] = {"obj", "protocol", NULL};
|
2002-04-01 13:40:08 -04:00
|
|
|
PyObject *ob, *file = 0, *res = NULL;
|
|
|
|
Picklerobject *pickler = 0;
|
2003-02-01 12:45:06 -04:00
|
|
|
int proto = 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2004-07-27 02:22:33 -03:00
|
|
|
if (!( PyArg_ParseTupleAndKeywords(args, kwds, "O|i:dumps", kwlist,
|
|
|
|
&ob, &proto)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( file = PycStringIO->NewOutput(128)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-01 12:45:06 -04:00
|
|
|
if (!( pickler = newPicklerobject(file, proto)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (dump(pickler, ob) < 0)
|
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
res = PycStringIO->cgetvalue(file);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
finally:
|
|
|
|
Py_XDECREF(pickler);
|
|
|
|
Py_XDECREF(file);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return res;
|
2001-03-17 00:50:51 -04:00
|
|
|
}
|
|
|
|
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-01 12:45:06 -04:00
|
|
|
/* load(fileobj). */
|
1997-01-06 18:59:08 -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
|
|
|
cpm_load(PyObject *self, PyObject *ob)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
Unpicklerobject *unpickler = 0;
|
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
|
|
|
PyObject *res = NULL;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( unpickler = newUnpicklerobject(ob)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
res = load(unpickler);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
finally:
|
|
|
|
Py_XDECREF(unpickler);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return res;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-01 12:45:06 -04:00
|
|
|
/* loads(string) */
|
1997-01-06 18:59:08 -04:00
|
|
|
static PyObject *
|
2003-02-01 02:24:36 -04:00
|
|
|
cpm_loads(PyObject *self, PyObject *args)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *ob, *file = 0, *res = NULL;
|
|
|
|
Unpicklerobject *unpickler = 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( PyArg_ParseTuple(args, "S:loads", &ob)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( file = PycStringIO->NewInput(ob)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
2001-03-17 00:50:51 -04:00
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( unpickler = newUnpicklerobject(file)))
|
2002-04-01 13:40:08 -04:00
|
|
|
goto finally;
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
res = load(unpickler);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
finally:
|
|
|
|
Py_XDECREF(file);
|
|
|
|
Py_XDECREF(unpickler);
|
1997-01-06 18:59:08 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return res;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(Unpicklertype__doc__,
|
|
|
|
"Objects that know how to unpickle");
|
1997-01-06 18:59:08 -04:00
|
|
|
|
1997-12-08 11:15:16 -04:00
|
|
|
static PyTypeObject Unpicklertype = {
|
|
|
|
PyObject_HEAD_INIT(NULL)
|
2003-04-09 18:25:30 -03:00
|
|
|
0, /*ob_size*/
|
|
|
|
"cPickle.Unpickler", /*tp_name*/
|
|
|
|
sizeof(Unpicklerobject), /*tp_basicsize*/
|
|
|
|
0,
|
|
|
|
(destructor)Unpickler_dealloc, /* tp_dealloc */
|
|
|
|
0, /* tp_print */
|
|
|
|
(getattrfunc)Unpickler_getattr, /* tp_getattr */
|
|
|
|
(setattrfunc)Unpickler_setattr, /* tp_setattr */
|
|
|
|
0, /* tp_compare */
|
|
|
|
0, /* tp_repr */
|
|
|
|
0, /* tp_as_number */
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
0, /* tp_hash */
|
|
|
|
0, /* tp_call */
|
|
|
|
0, /* tp_str */
|
|
|
|
0, /* tp_getattro */
|
|
|
|
0, /* tp_setattro */
|
|
|
|
0, /* tp_as_buffer */
|
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
|
|
|
|
Unpicklertype__doc__, /* tp_doc */
|
|
|
|
(traverseproc)Unpickler_traverse, /* tp_traverse */
|
|
|
|
(inquiry)Unpickler_clear, /* tp_clear */
|
1997-12-08 11:15:16 -04:00
|
|
|
};
|
1997-04-09 14:36:32 -03:00
|
|
|
|
|
|
|
static struct PyMethodDef cPickle_methods[] = {
|
2004-07-27 02:22:33 -03:00
|
|
|
{"dump", (PyCFunction)cpm_dump, METH_VARARGS | METH_KEYWORDS,
|
|
|
|
PyDoc_STR("dump(obj, file, protocol=0) -- "
|
2003-02-01 12:45:06 -04:00
|
|
|
"Write an object in pickle format to the given file.\n"
|
1997-12-03 21:13:01 -04:00
|
|
|
"\n"
|
2003-02-01 12:45:06 -04:00
|
|
|
"See the Pickler docstring for the meaning of optional argument proto.")
|
1997-12-03 21:13:01 -04:00
|
|
|
},
|
2003-02-01 12:45:06 -04:00
|
|
|
|
2004-07-27 02:22:33 -03:00
|
|
|
{"dumps", (PyCFunction)cpm_dumps, METH_VARARGS | METH_KEYWORDS,
|
|
|
|
PyDoc_STR("dumps(obj, protocol=0) -- "
|
2003-02-01 12:45:06 -04:00
|
|
|
"Return a string containing an object in pickle format.\n"
|
1997-12-03 21:13:01 -04:00
|
|
|
"\n"
|
2003-02-01 12:45:06 -04:00
|
|
|
"See the Pickler docstring for the meaning of optional argument proto.")
|
1997-12-03 21:13:01 -04:00
|
|
|
},
|
2003-02-01 12:45:06 -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
|
|
|
{"load", (PyCFunction)cpm_load, METH_O,
|
2002-08-13 19:20:41 -03:00
|
|
|
PyDoc_STR("load(file) -- Load a pickle from the given file")},
|
2003-02-01 12:45:06 -04:00
|
|
|
|
2002-03-31 10:44:22 -04:00
|
|
|
{"loads", (PyCFunction)cpm_loads, METH_VARARGS,
|
2002-08-13 19:20:41 -03:00
|
|
|
PyDoc_STR("loads(string) -- Load a pickle from the given string")},
|
2003-02-01 12:45:06 -04:00
|
|
|
|
2004-07-27 02:22:33 -03:00
|
|
|
{"Pickler", (PyCFunction)get_Pickler, METH_VARARGS | METH_KEYWORDS,
|
|
|
|
PyDoc_STR("Pickler(file, protocol=0) -- Create a pickler.\n"
|
2003-02-01 12:45:06 -04:00
|
|
|
"\n"
|
|
|
|
"This takes a file-like object for writing a pickle data stream.\n"
|
|
|
|
"The optional proto argument tells the pickler to use the given\n"
|
|
|
|
"protocol; supported protocols are 0, 1, 2. The default\n"
|
|
|
|
"protocol is 0, to be backwards compatible. (Protocol 0 is the\n"
|
|
|
|
"only protocol that can be written to a file opened in text\n"
|
|
|
|
"mode and read back successfully. When using a protocol higher\n"
|
|
|
|
"than 0, make sure the file is opened in binary mode, both when\n"
|
|
|
|
"pickling and unpickling.)\n"
|
|
|
|
"\n"
|
|
|
|
"Protocol 1 is more efficient than protocol 0; protocol 2 is\n"
|
|
|
|
"more efficient than protocol 1.\n"
|
|
|
|
"\n"
|
|
|
|
"Specifying a negative protocol version selects the highest\n"
|
|
|
|
"protocol version supported. The higher the protocol used, the\n"
|
|
|
|
"more recent the version of Python needed to read the pickle\n"
|
|
|
|
"produced.\n"
|
1997-12-03 21:13:01 -04:00
|
|
|
"\n"
|
2003-02-01 12:45:06 -04:00
|
|
|
"The file parameter must have a write() method that accepts a single\n"
|
|
|
|
"string argument. It can thus be an open file object, a StringIO\n"
|
|
|
|
"object, or any other custom object that meets this interface.\n")
|
1997-12-03 21:13:01 -04:00
|
|
|
},
|
2003-02-01 12:45:06 -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
|
|
|
{"Unpickler", (PyCFunction)get_Unpickler, METH_O,
|
2003-02-01 12:45:06 -04:00
|
|
|
PyDoc_STR("Unpickler(file) -- Create an unpickler.")},
|
|
|
|
|
1997-01-06 18:59:08 -04:00
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
1997-04-09 14:36:32 -03:00
|
|
|
static int
|
2003-02-01 02:24:36 -04:00
|
|
|
init_stuff(PyObject *module_dict)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *copy_reg, *t, *r;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2002-04-01 08:34:33 -04:00
|
|
|
#define INIT_STR(S) if (!( S ## _str=PyString_InternFromString(#S))) return -1;
|
1997-04-09 14:36:32 -03:00
|
|
|
|
2003-05-21 18:29:48 -03:00
|
|
|
if (PyType_Ready(&Unpicklertype) < 0)
|
|
|
|
return -1;
|
|
|
|
if (PyType_Ready(&Picklertype) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
INIT_STR(__class__);
|
|
|
|
INIT_STR(__getinitargs__);
|
|
|
|
INIT_STR(__dict__);
|
|
|
|
INIT_STR(__getstate__);
|
|
|
|
INIT_STR(__setstate__);
|
|
|
|
INIT_STR(__name__);
|
|
|
|
INIT_STR(__main__);
|
|
|
|
INIT_STR(__reduce__);
|
2003-02-18 21:45:13 -04:00
|
|
|
INIT_STR(__reduce_ex__);
|
2002-04-01 13:40:08 -04:00
|
|
|
INIT_STR(write);
|
|
|
|
INIT_STR(append);
|
|
|
|
INIT_STR(read);
|
|
|
|
INIT_STR(readline);
|
|
|
|
INIT_STR(copy_reg);
|
|
|
|
INIT_STR(dispatch_table);
|
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!( copy_reg = PyImport_ImportModule("copy_reg")))
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
|
2003-01-31 22:16:37 -04:00
|
|
|
/* This is special because we want to use a different
|
|
|
|
one in restricted mode. */
|
2002-04-01 13:40:08 -04:00
|
|
|
dispatch_table = PyObject_GetAttr(copy_reg, dispatch_table_str);
|
2003-02-03 20:21:07 -04:00
|
|
|
if (!dispatch_table) return -1;
|
|
|
|
|
|
|
|
extension_registry = PyObject_GetAttrString(copy_reg,
|
2003-02-03 21:54:49 -04:00
|
|
|
"_extension_registry");
|
2003-02-03 20:21:07 -04:00
|
|
|
if (!extension_registry) return -1;
|
|
|
|
|
|
|
|
inverted_registry = PyObject_GetAttrString(copy_reg,
|
2003-02-03 21:54:49 -04:00
|
|
|
"_inverted_registry");
|
2003-02-03 20:21:07 -04:00
|
|
|
if (!inverted_registry) return -1;
|
|
|
|
|
|
|
|
extension_cache = PyObject_GetAttrString(copy_reg,
|
2003-02-03 21:54:49 -04:00
|
|
|
"_extension_cache");
|
2003-02-03 20:21:07 -04:00
|
|
|
if (!extension_cache) return -1;
|
2002-04-01 13:40:08 -04:00
|
|
|
|
|
|
|
Py_DECREF(copy_reg);
|
|
|
|
|
2003-02-04 16:56:09 -04:00
|
|
|
if (!(empty_tuple = PyTuple_New(0)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
two_tuple = PyTuple_New(2);
|
|
|
|
if (two_tuple == NULL)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
2003-02-04 17:47:44 -04:00
|
|
|
/* We use this temp container with no regard to refcounts, or to
|
|
|
|
* keeping containees alive. Exempt from GC, because we don't
|
|
|
|
* want anything looking at two_tuple() by magic.
|
|
|
|
*/
|
|
|
|
PyObject_GC_UnTrack(two_tuple);
|
2002-04-01 13:40:08 -04:00
|
|
|
|
|
|
|
/* Ugh */
|
|
|
|
if (!( t=PyImport_ImportModule("__builtin__"))) return -1;
|
|
|
|
if (PyDict_SetItemString(module_dict, "__builtins__", t) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (!( t=PyDict_New())) return -1;
|
|
|
|
if (!( r=PyRun_String(
|
|
|
|
"def __str__(self):\n"
|
|
|
|
" return self.args and ('%s' % self.args[0]) or '(what)'\n",
|
|
|
|
Py_file_input,
|
|
|
|
module_dict, t) )) return -1;
|
|
|
|
Py_DECREF(r);
|
|
|
|
|
|
|
|
PickleError = PyErr_NewException("cPickle.PickleError", NULL, t);
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!PickleError)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
Py_DECREF(t);
|
|
|
|
|
2003-02-01 02:24:36 -04:00
|
|
|
PicklingError = PyErr_NewException("cPickle.PicklingError",
|
2002-04-01 13:40:08 -04:00
|
|
|
PickleError, NULL);
|
2003-02-01 02:24:36 -04:00
|
|
|
if (!PicklingError)
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (!( t=PyDict_New())) return -1;
|
|
|
|
if (!( r=PyRun_String(
|
|
|
|
"def __str__(self):\n"
|
|
|
|
" a=self.args\n"
|
|
|
|
" a=a and type(a[0]) or '(what)'\n"
|
|
|
|
" return 'Cannot pickle %s objects' % a\n"
|
|
|
|
, Py_file_input,
|
|
|
|
module_dict, t) )) return -1;
|
|
|
|
Py_DECREF(r);
|
|
|
|
|
|
|
|
if (!( UnpickleableError = PyErr_NewException(
|
2003-02-01 02:24:36 -04:00
|
|
|
"cPickle.UnpickleableError", PicklingError, t)))
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
Py_DECREF(t);
|
|
|
|
|
|
|
|
if (!( UnpicklingError = PyErr_NewException("cPickle.UnpicklingError",
|
2003-02-01 02:24:36 -04:00
|
|
|
PickleError, NULL)))
|
2002-04-01 13:40:08 -04:00
|
|
|
return -1;
|
|
|
|
|
2002-09-16 14:26:24 -03:00
|
|
|
if (!( BadPickleGet = PyErr_NewException("cPickle.BadPickleGet",
|
|
|
|
UnpicklingError, NULL)))
|
|
|
|
return -1;
|
2003-02-01 02:24:36 -04:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
if (PyDict_SetItemString(module_dict, "PickleError",
|
|
|
|
PickleError) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (PyDict_SetItemString(module_dict, "PicklingError",
|
|
|
|
PicklingError) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (PyDict_SetItemString(module_dict, "UnpicklingError",
|
|
|
|
UnpicklingError) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (PyDict_SetItemString(module_dict, "UnpickleableError",
|
|
|
|
UnpickleableError) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (PyDict_SetItemString(module_dict, "BadPickleGet",
|
|
|
|
BadPickleGet) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
PycString_IMPORT;
|
1999-06-09 12:23:31 -03:00
|
|
|
|
2002-04-01 13:40:08 -04:00
|
|
|
return 0;
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|
|
|
|
|
2002-08-01 23:27:13 -03:00
|
|
|
#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
|
|
|
|
#define PyMODINIT_FUNC void
|
1999-02-04 10:54:04 -04:00
|
|
|
#endif
|
2002-08-01 23:27:13 -03:00
|
|
|
PyMODINIT_FUNC
|
2003-02-01 02:24:36 -04:00
|
|
|
initcPickle(void)
|
2002-04-01 13:40:08 -04:00
|
|
|
{
|
|
|
|
PyObject *m, *d, *di, *v, *k;
|
2006-02-15 13:27:45 -04:00
|
|
|
Py_ssize_t i;
|
2003-02-03 20:21:07 -04:00
|
|
|
char *rev = "1.71"; /* XXX when does this change? */
|
2002-04-01 13:40:08 -04:00
|
|
|
PyObject *format_version;
|
|
|
|
PyObject *compatible_formats;
|
|
|
|
|
|
|
|
Picklertype.ob_type = &PyType_Type;
|
|
|
|
Unpicklertype.ob_type = &PyType_Type;
|
|
|
|
PdataType.ob_type = &PyType_Type;
|
|
|
|
|
|
|
|
/* Initialize some pieces. We need to do this before module creation,
|
2003-02-03 20:21:07 -04:00
|
|
|
* so we're forced to use a temporary dictionary. :(
|
|
|
|
*/
|
|
|
|
di = PyDict_New();
|
2002-04-01 13:40:08 -04:00
|
|
|
if (!di) return;
|
|
|
|
if (init_stuff(di) < 0) return;
|
|
|
|
|
|
|
|
/* Create the module and add the functions */
|
|
|
|
m = Py_InitModule4("cPickle", cPickle_methods,
|
|
|
|
cPickle_module_documentation,
|
|
|
|
(PyObject*)NULL,PYTHON_API_VERSION);
|
2006-01-19 02:09:39 -04:00
|
|
|
if (m == NULL)
|
|
|
|
return;
|
2002-04-01 13:40:08 -04:00
|
|
|
|
|
|
|
/* Add some symbolic constants to the module */
|
|
|
|
d = PyModule_GetDict(m);
|
2003-02-03 20:21:07 -04:00
|
|
|
v = PyString_FromString(rev);
|
|
|
|
PyDict_SetItemString(d, "__version__", v);
|
2002-04-01 13:40:08 -04:00
|
|
|
Py_XDECREF(v);
|
|
|
|
|
|
|
|
/* Copy data from di. Waaa. */
|
|
|
|
for (i=0; PyDict_Next(di, &i, &k, &v); ) {
|
|
|
|
if (PyObject_SetItem(d, k, v) < 0) {
|
|
|
|
Py_DECREF(di);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Py_DECREF(di);
|
|
|
|
|
2003-02-13 11:44:41 -04:00
|
|
|
i = PyModule_AddIntConstant(m, "HIGHEST_PROTOCOL", HIGHEST_PROTOCOL);
|
|
|
|
if (i < 0)
|
|
|
|
return;
|
|
|
|
|
2003-02-03 20:21:07 -04:00
|
|
|
/* These are purely informational; no code uses them. */
|
|
|
|
/* File format version we write. */
|
|
|
|
format_version = PyString_FromString("2.0");
|
|
|
|
/* Format versions we can read. */
|
|
|
|
compatible_formats = Py_BuildValue("[sssss]",
|
|
|
|
"1.0", /* Original protocol 0 */
|
|
|
|
"1.1", /* Protocol 0 + INST */
|
|
|
|
"1.2", /* Original protocol 1 */
|
|
|
|
"1.3", /* Protocol 1 + BINFLOAT */
|
2003-02-03 20:30:46 -04:00
|
|
|
"2.0"); /* Original protocol 2 */
|
2002-04-01 13:40:08 -04:00
|
|
|
PyDict_SetItemString(d, "format_version", format_version);
|
|
|
|
PyDict_SetItemString(d, "compatible_formats", compatible_formats);
|
|
|
|
Py_XDECREF(format_version);
|
|
|
|
Py_XDECREF(compatible_formats);
|
1997-01-06 18:59:08 -04:00
|
|
|
}
|