Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit eae6aae

Browse files
author
Anselm Kruis
committed
Merge 3.5-slp (Stackless #127, use C-Python pickling)
2 parents 79de128 + 1a49b66 commit eae6aae

File tree

3 files changed

+7
-110
lines changed

3 files changed

+7
-110
lines changed

Stackless/changelog.txt

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ What's New in Stackless 3.X.X?
1010
*Release date: 20XX-XX-XX*
1111

1212
- https://bitbucket.org/stackless-dev/stackless/issues/127
13-
Fix pickling of 'callable-iterator' and 'method-wrapper' objects.
14-
Fix copy.copy() for 'callable-iterator', 'method', 'dict_keys', 'dict_values'
15-
and 'dict_items' objects.
13+
Disable the Stackless specific code for pickling 'iterator' and
14+
'callable_iterator' objects. C-Python 3.3 already pickles them. Stackless-3.5
15+
can't read pickles of 'iterator' or 'callable_iterator' objects created with
16+
Stackless 3.4.2 or older versions.
17+
Fix pickling of 'method-wrapper' objects.
18+
Fix copy.copy() for 'method', 'dict_keys', 'dict_values' and 'dict_items'
19+
objects.
1620

1721
- https://bitbucket.org/stackless-dev/stackless/issues/126
1822
Load the module stackless early in all C-Python tests. This ensures a defined

Stackless/pickling/prickelpit.c

-99
Original file line numberDiff line numberDiff line change
@@ -1427,105 +1427,6 @@ static int init_moduletype(void)
14271427
#define initchain init_moduletype
14281428

14291429

1430-
/******************************************************
1431-
1432-
pickling of iterators
1433-
1434-
******************************************************/
1435-
1436-
/* XXX make sure this copy is always up to date */
1437-
typedef struct {
1438-
PyObject_HEAD
1439-
long it_index;
1440-
PyObject *it_seq;
1441-
} seqiterobject;
1442-
1443-
static PyTypeObject wrap_PySeqIter_Type;
1444-
1445-
static PyObject *
1446-
iter_reduce(seqiterobject *iterator)
1447-
{
1448-
PyObject *tup;
1449-
tup = Py_BuildValue("(O(Ol)())",
1450-
&wrap_PySeqIter_Type,
1451-
iterator->it_seq,
1452-
iterator->it_index);
1453-
return tup;
1454-
}
1455-
1456-
static PyObject *
1457-
iter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1458-
{
1459-
PyObject *iter, *seq;
1460-
long index;
1461-
1462-
if (is_wrong_type(type)) return NULL;
1463-
if (!PyArg_ParseTuple(args, "Ol:iter", &seq, &index)) return NULL;
1464-
iter = PySeqIter_New(seq);
1465-
if (iter != NULL) {
1466-
((seqiterobject *) iter)->it_index = index;
1467-
iter->ob_type = type;
1468-
}
1469-
return iter;
1470-
}
1471-
1472-
MAKE_WRAPPERTYPE(PySeqIter_Type, iter, "iterator", iter_reduce, iter_new,
1473-
generic_setstate)
1474-
1475-
/* XXX make sure this copy is always up to date */
1476-
typedef struct {
1477-
PyObject_HEAD
1478-
PyObject *it_callable; /* Set to NULL when iterator is exhausted */
1479-
PyObject *it_sentinel; /* Set to NULL when iterator is exhausted */
1480-
} calliterobject;
1481-
1482-
static PyTypeObject wrap_PyCallIter_Type;
1483-
static PyObject *
1484-
calliter_reduce(calliterobject *iterator)
1485-
{
1486-
PyObject *tup;
1487-
tup = Py_BuildValue("(O(OO)" NO_STATE_FORMAT ")",
1488-
&wrap_PyCallIter_Type,
1489-
iterator->it_callable ? iterator->it_callable : Py_None,
1490-
iterator->it_sentinel ? iterator->it_sentinel : Py_None
1491-
NO_STATE_ARG);
1492-
return tup;
1493-
}
1494-
1495-
static
1496-
PyObject *
1497-
calliter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
1498-
{
1499-
calliterobject *it;
1500-
PyObject *it_callable;
1501-
PyObject *it_sentinel;
1502-
1503-
if (is_wrong_type(type)) return NULL;
1504-
if (!PyArg_ParseTuple(args, "OO:calliter", &it_callable,
1505-
&it_sentinel))
1506-
return NULL;
1507-
1508-
if (it_callable == Py_None) it_callable = NULL;
1509-
if (it_sentinel == Py_None) it_sentinel = NULL;
1510-
1511-
it = (calliterobject *) PyCallIter_New(it_callable, it_sentinel);
1512-
if (it != NULL)
1513-
Py_TYPE(it) = type;
1514-
return (PyObject *) it;
1515-
}
1516-
1517-
MAKE_WRAPPERTYPE(PyCallIter_Type, calliter, "callable_iterator",
1518-
calliter_reduce, calliter_new, generic_setstate)
1519-
1520-
static int init_itertype(void)
1521-
{
1522-
return init_type(&wrap_PySeqIter_Type, NULL)
1523-
|| init_type(&wrap_PyCallIter_Type, initchain);
1524-
}
1525-
#undef initchain
1526-
#define initchain init_itertype
1527-
1528-
15291430
/******************************************************
15301431
15311432
pickling of class/instance methods (PyMethod)

Stackless/unittests/test_pickle.py

-8
Original file line numberDiff line numberDiff line change
@@ -690,14 +690,6 @@ def test_module(self):
690690
import tabnanny as obj
691691
self._test(obj, '__name__', '__dict__')
692692

693-
def test_iterator(self):
694-
obj = iter("abc")
695-
self._test(obj)
696-
697-
def test_callable_iterator(self):
698-
obj = iter(lambda: None, None)
699-
self._test(obj)
700-
701693
def test_method(self):
702694
obj = self.id
703695
self._test(obj, '__func__', '__self__')

0 commit comments

Comments
 (0)