[Python-Dev] marshal and ssize_t (PEP 353)

Neal Norwitz nnorwitz at gmail.com
Tue May 15 23:05:21 CEST 2007


Martin,

I'm looking at Python/marshal.c and there are a lot of places that
don't support sequences that are larger than would fit into size(int).
 I looked for marshal referenced in the PEP and didn't find anything.
Was this an oversight or intentional?

To give you some examples of what I mean from the code:

(line 255)
                n = PyString_GET_SIZE(v);
                if (n > INT_MAX) {
                        /* huge strings are not supported */
                        p->depth--;
                        p->error = 1;
                        return;
                }
                w_long((long)n, p);
                w_string(PyString_AS_STRING(v), (int)n, p);

...
(line 717)
                n = r_long(p);
                if (n < 0 || n > INT_MAX) {
                        PyErr_SetString(PyExc_ValueError, "bad marshal data");
                        return NULL;
                }
                v = PyTuple_New((int)n);
                if (v == NULL)
                        return v;
                for (i = 0; i < n; i++) {
                        v2 = r_object(p);
                        if ( v2 == NULL ) {
                                if (!PyErr_Occurred())
                                        PyErr_SetString(PyExc_TypeError,
                                                "NULL object in marshal data");
                                Py_DECREF(v);
                                v = NULL;
                                break;
                        }
                        PyTuple_SET_ITEM(v, (int)i, v2);

Also, the PEP references the ssize_t branch which no longer exists.
Is it possible to reference the specific revision: 42382?

Thanks,
n


More information about the Python-Dev mailing list