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)
|
if (cache == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#if (PY_VERSION_HEX < 0x02050000)
|
||||||
|
key = Py_BuildValue("(Oi)", itemtype, length);
|
||||||
|
#else
|
||||||
key = Py_BuildValue("(On)", itemtype, length);
|
key = Py_BuildValue("(On)", itemtype, length);
|
||||||
|
#endif
|
||||||
if (!key)
|
if (!key)
|
||||||
return NULL;
|
return NULL;
|
||||||
result = PyDict_GetItem(cache, key);
|
result = PyDict_GetItem(cache, key);
|
||||||
|
@ -3698,7 +3702,11 @@ CreateArrayType(PyObject *itemtype, Py_ssize_t length)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
result = PyObject_CallFunction((PyObject *)&ArrayType_Type,
|
result = PyObject_CallFunction((PyObject *)&ArrayType_Type,
|
||||||
|
#if (PY_VERSION_HEX < 0x02050000)
|
||||||
|
"s(O){s:i,s:O}",
|
||||||
|
#else
|
||||||
"s(O){s:n,s:O}",
|
"s(O){s:n,s:O}",
|
||||||
|
#endif
|
||||||
name,
|
name,
|
||||||
&Array_Type,
|
&Array_Type,
|
||||||
"_length_",
|
"_length_",
|
||||||
|
|
|
@ -250,11 +250,21 @@ CField_repr(CFieldObject *self)
|
||||||
name = ((PyTypeObject *)self->proto)->tp_name;
|
name = ((PyTypeObject *)self->proto)->tp_name;
|
||||||
|
|
||||||
if (bits)
|
if (bits)
|
||||||
result = PyString_FromFormat("<Field type=%s, ofs=%d:%d, bits=%d>",
|
result = PyString_FromFormat(
|
||||||
name, (int)self->offset, size, bits);
|
#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
|
else
|
||||||
result = PyString_FromFormat("<Field type=%s, ofs=%d, size=%d>",
|
result = PyString_FromFormat(
|
||||||
name, (int)self->offset, size);
|
#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;
|
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
|
#ifndef MS_WIN32
|
||||||
#define max(a, b) ((a) > (b) ? (a) : (b))
|
#define max(a, b) ((a) > (b) ? (a) : (b))
|
||||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||||
|
|
Loading…
Reference in New Issue