Author: guido.van.rossum
Date: Fri Nov  2 21:03:18 2007
New Revision: 58795

Modified:
   python/branches/py3k-pep3137/Modules/datetimemodule.c
Log:
Fix test_datetime.  The return type of make_Zreplacement is changed again.


Modified: python/branches/py3k-pep3137/Modules/datetimemodule.c
==============================================================================
--- python/branches/py3k-pep3137/Modules/datetimemodule.c       (original)
+++ python/branches/py3k-pep3137/Modules/datetimemodule.c       Fri Nov  2 
21:03:18 2007
@@ -1133,7 +1133,7 @@
 {
        PyObject *temp;
        PyObject *tzinfo = get_tzinfo_member(object);
-       PyObject *Zreplacement = PyBytes_FromStringAndSize("", 0);
+       PyObject *Zreplacement = PyUnicode_FromStringAndSize(NULL, 0);
        if (Zreplacement == NULL)
                return NULL;
        if (tzinfo == Py_None || tzinfo == NULL)
@@ -1158,14 +1158,7 @@
        Py_DECREF(temp);
        if (Zreplacement == NULL)
                return NULL;
-       if (PyUnicode_Check(Zreplacement)) {
-               PyObject *tmp = PyUnicode_AsUTF8String(Zreplacement);
-               Py_DECREF(Zreplacement);
-               if (tmp == NULL)
-                       return NULL;
-               Zreplacement = tmp;
-       }
-       if (!PyBytes_Check(Zreplacement)) {
+       if (!PyUnicode_Check(Zreplacement)) {
                PyErr_SetString(PyExc_TypeError,
                                "tzname.replace() did not return a string");
                goto Error;
@@ -1297,9 +1290,10 @@
                                        goto Done;
                        }
                        assert(Zreplacement != NULL);
-                       assert(PyBytes_Check(Zreplacement));
-                       ptoappend = PyBytes_AS_STRING(Zreplacement);
-                       ntoappend = PyBytes_GET_SIZE(Zreplacement);
+                       assert(PyUnicode_Check(Zreplacement));
+                       ptoappend = PyUnicode_AsStringAndSize(Zreplacement,
+                                                              &ntoappend);
+                       ntoappend = Py_Size(Zreplacement);
                }
                else {
                        /* percent followed by neither z nor Z */
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to