[Python-checkins] r86989 - in python/branches/pep-0384: Include/structseq.h Include/unicodeobject.h Modules/_ctypes/cfield.c Modules/_testcapimodule.c Objects/rangeobject.c Objects/structseq.c Objects/unicodeobject.c
martin.v.loewis
python-checkins at python.org
Fri Dec 3 20:24:39 CET 2010
Author: martin.v.loewis
Date: Fri Dec 3 20:24:39 2010
New Revision: 86989
Log:
Fix merging glitches.
Expose version of structseq under limited API.
Modified:
python/branches/pep-0384/Include/structseq.h
python/branches/pep-0384/Include/unicodeobject.h
python/branches/pep-0384/Modules/_ctypes/cfield.c
python/branches/pep-0384/Modules/_testcapimodule.c
python/branches/pep-0384/Objects/rangeobject.c
python/branches/pep-0384/Objects/structseq.c
python/branches/pep-0384/Objects/unicodeobject.c
Modified: python/branches/pep-0384/Include/structseq.h
==============================================================================
--- python/branches/pep-0384/Include/structseq.h (original)
+++ python/branches/pep-0384/Include/structseq.h Fri Dec 3 20:24:39 2010
@@ -21,18 +21,25 @@
extern char* PyStructSequence_UnnamedField;
+#ifndef Py_LIMITED_API
PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type,
PyStructSequence_Desc *desc);
+#endif
+PyAPI_FUNC(PyTypeObject*) PyStructSequence_NewType(PyStructSequence_Desc *desc);
PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type);
+#ifndef Py_LIMITED_API
typedef PyTupleObject PyStructSequence;
/* Macro, *only* to be used to fill in brand new objects */
#define PyStructSequence_SET_ITEM(op, i, v) PyTuple_SET_ITEM(op, i, v)
#define PyStructSequence_GET_ITEM(op, i) PyTuple_GET_ITEM(op, i)
+#endif
+PyAPI_FUNC(void) PyStructSequence_SetItem(PyObject*, Py_ssize_t, PyObject*);
+PyAPI_FUNC(PyObject*) PyStructSequence_GetItem(PyObject*, Py_ssize_t);
#ifdef __cplusplus
}
Modified: python/branches/pep-0384/Include/unicodeobject.h
==============================================================================
--- python/branches/pep-0384/Include/unicodeobject.h (original)
+++ python/branches/pep-0384/Include/unicodeobject.h Fri Dec 3 20:24:39 2010
@@ -320,6 +320,7 @@
_Py_ascii_whitespace (see below) with an inlined check.
*/
+#ifndef Py_LIMITED_API
#define Py_UNICODE_ISSPACE(ch) \
((ch) < 128U ? _Py_ascii_whitespace[(ch)] : _PyUnicode_IsWhitespace(ch))
@@ -1644,7 +1645,6 @@
const Py_UNICODE *s,
Py_UNICODE c
);
-#endif /* Py_LIMITED_API */
/* Create a copy of a unicode string ending with a nul character. Return NULL
and raise a MemoryError exception on memory allocation failure, otherwise
@@ -1653,6 +1653,7 @@
PyAPI_FUNC(Py_UNICODE*) PyUnicode_AsUnicodeCopy(
PyObject *unicode
);
+#endif /* Py_LIMITED_API */
#ifdef __cplusplus
}
Modified: python/branches/pep-0384/Modules/_ctypes/cfield.c
==============================================================================
--- python/branches/pep-0384/Modules/_ctypes/cfield.c (original)
+++ python/branches/pep-0384/Modules/_ctypes/cfield.c Fri Dec 3 20:24:39 2010
@@ -1214,7 +1214,7 @@
} else
Py_INCREF(value);
- len = PyUnicode_AsWideChar((PyUnicodeObject *)value, chars, 2);
+ len = PyUnicode_AsWideChar(value, chars, 2);
if (len != 1) {
Py_DECREF(value);
PyErr_SetString(PyExc_TypeError,
Modified: python/branches/pep-0384/Modules/_testcapimodule.c
==============================================================================
--- python/branches/pep-0384/Modules/_testcapimodule.c (original)
+++ python/branches/pep-0384/Modules/_testcapimodule.c Fri Dec 3 20:24:39 2010
@@ -1398,7 +1398,7 @@
if (buffer == NULL)
return PyErr_NoMemory();
- size = PyUnicode_AsWideChar((PyUnicodeObject*)unicode, buffer, buflen);
+ size = PyUnicode_AsWideChar(unicode, buffer, buflen);
if (size == -1) {
PyMem_Free(buffer);
return NULL;
Modified: python/branches/pep-0384/Objects/rangeobject.c
==============================================================================
--- python/branches/pep-0384/Objects/rangeobject.c (original)
+++ python/branches/pep-0384/Objects/rangeobject.c Fri Dec 3 20:24:39 2010
@@ -431,7 +431,6 @@
return range_item(self, i);
}
if (PySlice_Check(item)) {
- PySliceObject *slice = (PySliceObject*)item;
Py_ssize_t start, stop, step, len, rlen;
rangeobject *result;
PyObject *substart = NULL, *substep = NULL, *substop = NULL;
@@ -441,7 +440,7 @@
return NULL;
}
- if (PySlice_GetIndicesEx(slice, rlen,
+ if (PySlice_GetIndicesEx(item, rlen,
&start, &stop, &step, &len) < 0) {
return NULL;
}
@@ -450,7 +449,7 @@
Py_INCREF(substep);
} else {
/* NB: slice step != Py_None here */
- substep = PyNumber_Multiply(self->step, slice->step);
+ substep = PyNumber_Multiply(self->step, ((PySliceObject*)item)->step);
if (substep == NULL)
goto fail;
}
Modified: python/branches/pep-0384/Objects/structseq.c
==============================================================================
--- python/branches/pep-0384/Objects/structseq.c (original)
+++ python/branches/pep-0384/Objects/structseq.c Fri Dec 3 20:24:39 2010
@@ -43,6 +43,18 @@
return (PyObject*)obj;
}
+void
+PyStructSequence_SetItem(PyObject* op, Py_ssize_t i, PyObject* v)
+{
+ PyStructSequence_SET_ITEM(op, i, v);
+}
+
+PyObject*
+PyStructSequence_GetItem(PyObject* op, Py_ssize_t i)
+{
+ return PyStructSequence_GET_ITEM(op, i);
+}
+
static void
structseq_dealloc(PyStructSequence *obj)
{
@@ -365,3 +377,11 @@
SET_DICT_FROM_INT(real_length_key, n_members);
SET_DICT_FROM_INT(unnamed_fields_key, n_unnamed_members);
}
+
+PyTypeObject*
+PyStructSequence_NewType(PyStructSequence_Desc *desc)
+{
+ PyTypeObject *result = (PyTypeObject*)PyType_GenericAlloc(&PyType_Type, 0);
+ PyStructSequence_InitType(result, desc);
+ return result;
+}
Modified: python/branches/pep-0384/Objects/unicodeobject.c
==============================================================================
--- python/branches/pep-0384/Objects/unicodeobject.c (original)
+++ python/branches/pep-0384/Objects/unicodeobject.c Fri Dec 3 20:24:39 2010
@@ -9222,7 +9222,7 @@
Py_UNICODE* result_buf;
PyObject* result;
- if (PySlice_GetIndicesEx((PySliceObject*)item, PyUnicode_GET_SIZE(self),
+ if (PySlice_GetIndicesEx(item, PyUnicode_GET_SIZE(self),
&start, &stop, &step, &slicelength) < 0) {
return NULL;
}
More information about the Python-checkins
mailing list