Kaydet (Commit) 84a3efec authored tarafından Walter Dörwald's avatar Walter Dörwald

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.
üst 22000cbd
......@@ -34,8 +34,8 @@ typedef struct {
PyObject *message;
PyObject *encoding;
PyObject *object;
PyObject *start;
PyObject *end;
Py_ssize_t start;
Py_ssize_t end;
PyObject *reason;
} PyUnicodeErrorObject;
#endif
......
......@@ -68,6 +68,7 @@ typedef struct PyMemberDef {
#ifdef HAVE_LONG_LONG
#define T_LONGLONG 17
#define T_ULONGLONG 18
#define T_PYSSIZET 19 /* Py_ssize_t */
#endif /* HAVE_LONG_LONG */
/* Flags */
......
......@@ -14,6 +14,8 @@ Core and builtins
- Patch #1733960: Allow T_LONGLONG to accept ints.
- T_PYSSIZET can now be used in PyMemberDef lists for Py_ssize_t members.
- Prevent expandtabs() on string and unicode objects from causing a segfault
when a large width is passed on 32-bit platforms.
......@@ -687,6 +689,9 @@ Library
- Fix utf-8-sig incremental decoder, which didn't recognise a BOM when the
first chunk fed to the decoder started with a BOM, but was longer than 3 bytes.
- The implementation of UnicodeError objects has been simplified (start and end
attributes are now stored directly as Py_ssize_t members).
Extension Modules
-----------------
......
This diff is collapsed.
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment