mirror of https://github.com/python/cpython
Backport from upstream version: compatibility with older Python
versions.
This commit is contained in:
parent
f99b8162a2
commit
9998f78d6d
|
@ -3674,7 +3674,11 @@ CreateArrayType(PyObject *itemtype, Py_ssize_t length)
|
|||
if (cache == NULL)
|
||||
return NULL;
|
||||
}
|
||||
#if (PY_VERSION_HEX < 0x02050000)
|
||||
key = Py_BuildValue("(Oi)", itemtype, length);
|
||||
#else
|
||||
key = Py_BuildValue("(On)", itemtype, length);
|
||||
#endif
|
||||
if (!key)
|
||||
return NULL;
|
||||
result = PyDict_GetItem(cache, key);
|
||||
|
@ -3698,7 +3702,11 @@ CreateArrayType(PyObject *itemtype, Py_ssize_t length)
|
|||
#endif
|
||||
|
||||
result = PyObject_CallFunction((PyObject *)&ArrayType_Type,
|
||||
#if (PY_VERSION_HEX < 0x02050000)
|
||||
"s(O){s:i,s:O}",
|
||||
#else
|
||||
"s(O){s:n,s:O}",
|
||||
#endif
|
||||
name,
|
||||
&Array_Type,
|
||||
"_length_",
|
||||
|
|
|
@ -250,11 +250,21 @@ CField_repr(CFieldObject *self)
|
|||
name = ((PyTypeObject *)self->proto)->tp_name;
|
||||
|
||||
if (bits)
|
||||
result = PyString_FromFormat("<Field type=%s, ofs=%d:%d, bits=%d>",
|
||||
name, (int)self->offset, size, bits);
|
||||
result = PyString_FromFormat(
|
||||
#if (PY_VERSION_HEX < 0x02050000)
|
||||
"<Field type=%s, ofs=%d:%d, bits=%d>",
|
||||
#else
|
||||
"<Field type=%s, ofs=%zd:%d, bits=%d>",
|
||||
#endif
|
||||
name, self->offset, size, bits);
|
||||
else
|
||||
result = PyString_FromFormat("<Field type=%s, ofs=%d, size=%d>",
|
||||
name, (int)self->offset, size);
|
||||
result = PyString_FromFormat(
|
||||
#if (PY_VERSION_HEX < 0x02050000)
|
||||
"<Field type=%s, ofs=%d, size=%d>",
|
||||
#else
|
||||
"<Field type=%s, ofs=%zd, size=%d>",
|
||||
#endif
|
||||
name, self->offset, size);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
/******************************************************************/
|
||||
|
||||
#if (PY_VERSION_HEX < 0x02050000)
|
||||
typedef int Py_ssize_t;
|
||||
#define lenfunc inquiry
|
||||
#define readbufferproc getreadbufferproc
|
||||
#define writebufferproc getwritebufferproc
|
||||
#define segcountproc getsegcountproc
|
||||
#define charbufferproc getcharbufferproc
|
||||
#define ssizeargfunc intargfunc
|
||||
#define ssizessizeargfunc intintargfunc
|
||||
#define ssizeobjargproc intobjargproc
|
||||
#define ssizessizeobjargproc intintobjargproc
|
||||
#endif
|
||||
|
||||
#ifndef MS_WIN32
|
||||
#define max(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
|
Loading…
Reference in New Issue