Author: guido.van.rossum
Date: Fri Nov  2 22:32:46 2007
New Revision: 58808

Modified:
   python/branches/py3k-pep3137/Lib/uuid.py
   python/branches/py3k-pep3137/Objects/stringobject.c
Log:
Fix test_uuid.py.
This meant restoring reversed(b"...") functionality,
by putting back string_item().


Modified: python/branches/py3k-pep3137/Lib/uuid.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/uuid.py    (original)
+++ python/branches/py3k-pep3137/Lib/uuid.py    Fri Nov  2 22:32:46 2007
@@ -234,7 +234,7 @@
 
     @property
     def bytes(self):
-        bytes = b''
+        bytes = buffer()
         for shift in range(0, 128, 8):
             bytes.insert(0, (self.int >> shift) & 0xff)
         return bytes

Modified: python/branches/py3k-pep3137/Objects/stringobject.c
==============================================================================
--- python/branches/py3k-pep3137/Objects/stringobject.c (original)
+++ python/branches/py3k-pep3137/Objects/stringobject.c Fri Nov  2 22:32:46 2007
@@ -810,6 +810,16 @@
     return memchr(PyString_AS_STRING(self), ival, Py_Size(self)) != NULL;
 }
 
+static PyObject *
+string_item(PyStringObject *a, register Py_ssize_t i)
+{
+       if (i < 0 || i >= Py_Size(a)) {
+               PyErr_SetString(PyExc_IndexError, "string index out of range");
+               return NULL;
+       }
+       return PyInt_FromLong((unsigned char)a->ob_sval[i]);
+}
+
 static PyObject*
 string_richcompare(PyStringObject *a, PyStringObject *b, int op)
 {
@@ -981,7 +991,7 @@
        (lenfunc)string_length, /*sq_length*/
        (binaryfunc)string_concat, /*sq_concat*/
        (ssizeargfunc)string_repeat, /*sq_repeat*/
-       0,              /*sq_item*/
+       (ssizeargfunc)string_item, /*sq_item*/
        0,              /*sq_slice*/
        0,              /*sq_ass_item*/
        0,              /*sq_ass_slice*/
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to