ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-dev
python-dev
Re: [Python-Dev] New PEP: Using ssize_t as the index type
by "Martin v. Löwis" other posts by this author
Dec 30 2005 1:49AM messages near this date
Re: [Python-Dev] New PEP: Using ssize_t as the index type | Re: [Python-Dev] New PEP: Using ssize_t as the index type
Fredrik Lundh wrote:
>  well, one thing seems to missing from your PEP: in several modules, you've
>  changed the cast used in the type table. e.g.
...
>  is this change backwards compatible ?

See the section "Conversion guidelines". I prefer the approach taken in
the patch below, i.e. remove the casts in initializing the type object.
Adding more typedefs for the function types would be the other option.

Regards,
Martin

Index: Modules/_elementtree.c
===================================================================
--- Modules/_elementtree.c	(Revision 41837)
+++ Modules/_elementtree.c	(Arbeitskopie)
@@ -92,6 +92,9 @@
 #endif

 /* compatibility macros */
+#if (PY_VERSION_HEX < 0x02050000)
+typedef int Py_ssize_t;
+#endif
 #if (PY_VERSION_HEX < 0x02040000)
 #define PyDict_CheckExact PyDict_Check
 #if (PY_VERSION_HEX < 0x02020000)
@@ -916,8 +919,9 @@
 }

 static PyObject*
-element_getitem(ElementObject* self, Py_ssize_t index)
+element_getitem(PyObject* _self, Py_ssize_t index)
 {
+    ElementObject* self = (ElementObject*)_self;
     if (!self-> extra || index < 0 || index >= self->extra->length) {
         PyErr_SetString(
             PyExc_IndexError,
@@ -931,8 +935,9 @@
 }

 static PyObject*
-element_getslice(ElementObject* self, Py_ssize_t start, Py_ssize_t end)
+element_getslice(PyObject* _self, Py_ssize_t start, Py_ssize_t end)
 {
+    ElementObject* self = (ElementObject*)_self;
     Py_ssize_t i;
     PyObject* list;

@@ -1158,8 +1163,9 @@
 }

 static int
-element_setslice(ElementObject* self, Py_ssize_t start, Py_ssize_t end,
PyObject* item)
+element_setslice(PyObject* _self, Py_ssize_t start, Py_ssize_t end,
PyObject* item)
 {
+    ElementObject* self = (ElementObject*)_self;
     int i, new, old;
     PyObject* recycle = NULL;

@@ -1228,8 +1234,9 @@
 }

 static int
-element_setitem(ElementObject* self, Py_ssize_t index, PyObject* item)
+element_setitem(PyObject* _self, Py_ssize_t index, PyObject* item)
 {
+    ElementObject* self = (ElementObject*)_self;
     int i;
     PyObject* old;

@@ -1371,10 +1378,10 @@
     (inquiry) element_length,
     0, /* sq_concat */
     0, /* sq_repeat */
-    (ssizeargfunc) element_getitem,
-    (ssizessizeargfunc) element_getslice,
-    (ssizeobjargproc) element_setitem,
-    (ssizessizeobjargproc) element_setslice,
+    element_getitem,
+    element_getslice,
+    element_setitem,
+    element_setslice,
 };

 statichere PyTypeObject Element_Type = {
_______________________________________________
Python-Dev mailing list
Python-Dev@[...].org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/python-dev-ml%40activestate.c
om
Thread:
"Martin v. Löwis"
Travis E. Oliphant
"Martin v. Löwis"
Brett Cannon
Fredrik Lundh
"Martin v. Löwis"
Tim Peters
"Martin v. Löwis"
Armin Rigo
"Martin v. Löwis"
Armin Rigo
"Martin v. Löwis"
M.-A. Lemburg
Neal Norwitz
"Martin v. Löwis"
M.-A. Lemburg
"Martin v. Löwis"
M.-A. Lemburg
"Martin v. Löwis"
M.-A. Lemburg
"Martin v. Löwis"
Tim Peters
"Martin v. Löwis"
Michael Urman
Neal Norwitz
Aahz
"Martin v. Löwis"
Guido van Rossum

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved