Merging the py3k-pep3137 branch back into the py3k branch.
No detailed change log; just check out the change log for the py3k-pep3137
branch. The most obvious changes:
- str8 renamed to bytes (PyString at the C level);
- bytes renamed to buffer (PyBytes at the C level);
- PyString and PyUnicode are no longer compatible.
I.e. we now have an immutable bytes type and a mutable bytes type.
The behavior of PyString was modified quite a bit, to make it more
bytes-like. Some changes are still on the to-do list.
diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c
index 6f13a85..6b2cd5a 100644
--- a/Modules/datetimemodule.c
+++ b/Modules/datetimemodule.c
@@ -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 */
@@ -3194,7 +3188,7 @@
PyObject *tuple;
static char *keywords[] = {"format", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kw, "S:strftime", keywords,
+ if (! PyArg_ParseTupleAndKeywords(args, kw, "U:strftime", keywords,
&format))
return NULL;