diff options
author | Walter Dörwald <walter@livinglogic.de> | 2007-06-13 16:57:12 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2007-06-13 16:57:12 (GMT) |
commit | 84a3efec37bb97877f247b3e462bc48432e09b9f (patch) | |
tree | 6f8a907588dcfa23f0805233895c3502e674f4f1 /Python | |
parent | 22000cbd6b1a2ddf5f1c4e3c3a6db78ad9f908db (diff) | |
download | cpython-84a3efec37bb97877f247b3e462bc48432e09b9f.zip cpython-84a3efec37bb97877f247b3e462bc48432e09b9f.tar.gz cpython-84a3efec37bb97877f247b3e462bc48432e09b9f.tar.bz2 |
Add T_PYSSIZET in structmember.h: This can be used for
Py_ssize_t members.
Simplify the implementation of UnicodeError objects:
start and end attributes are now stored directly as
Py_ssize_t members, which simplifies various get and
set functions.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/structmember.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Python/structmember.c b/Python/structmember.c index 17422d0..4da0c78 100644 --- a/Python/structmember.c +++ b/Python/structmember.c @@ -85,6 +85,9 @@ PyMember_GetOne(const char *addr, PyMemberDef *l) case T_ULONG: v = PyLong_FromUnsignedLong(*(unsigned long*)addr); break; + case T_PYSSIZET: + v = PyInt_FromSsize_t(*(Py_ssize_t*)addr); + break; case T_FLOAT: v = PyFloat_FromDouble((double)*(float*)addr); break; @@ -263,6 +266,13 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) } break; } + case T_PYSSIZET:{ + *(Py_ssize_t*)addr = PyInt_AsSsize_t(v); + if ((*(Py_ssize_t*)addr == (Py_ssize_t)-1) + && PyErr_Occurred()) + return -1; + break; + } case T_FLOAT:{ double double_val; double_val = PyFloat_AsDouble(v); |