[Python-3000-checkins] r58992 - in python/branches/py3k: Include/object.h Modules/_csv.c Modules/_ctypes/callproc.c Modules/_testcapimodule.c Modules/cjkcodecs/multibytecodec.c Modules/datetimemodule.c Modules/grpmodule.c Objects/exceptions.c Objects/stringlib/string_format.h Objects/stringlib/unicodedefs.h Objects/typeobject.c Objects/unicodeobject.c Python/pythonrun.c

thomas.heller python-3000-checkins at python.org
Thu Nov 15 21:48:55 CET 2007


Author: thomas.heller
Date: Thu Nov 15 21:48:54 2007
New Revision: 58992

Modified:
   python/branches/py3k/Include/object.h
   python/branches/py3k/Modules/_csv.c
   python/branches/py3k/Modules/_ctypes/callproc.c
   python/branches/py3k/Modules/_testcapimodule.c
   python/branches/py3k/Modules/cjkcodecs/multibytecodec.c
   python/branches/py3k/Modules/datetimemodule.c
   python/branches/py3k/Modules/grpmodule.c
   python/branches/py3k/Objects/exceptions.c
   python/branches/py3k/Objects/stringlib/string_format.h
   python/branches/py3k/Objects/stringlib/unicodedefs.h
   python/branches/py3k/Objects/typeobject.c
   python/branches/py3k/Objects/unicodeobject.c
   python/branches/py3k/Python/pythonrun.c
Log:
Replace PyObject_Unicode with PyObject_Str everywhere, and remove the
#define for PyObject_Unicode in object.h.


Modified: python/branches/py3k/Include/object.h
==============================================================================
--- python/branches/py3k/Include/object.h	(original)
+++ python/branches/py3k/Include/object.h	Thu Nov 15 21:48:54 2007
@@ -432,7 +432,6 @@
 PyAPI_FUNC(void) _PyObject_Dump(PyObject *);
 PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *);
 PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *);
-#define PyObject_Unicode PyObject_Str /* Compatibility */
 PyAPI_FUNC(int) PyObject_Compare(PyObject *, PyObject *);
 PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int);
 PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int);

Modified: python/branches/py3k/Modules/_csv.c
==============================================================================
--- python/branches/py3k/Modules/_csv.c	(original)
+++ python/branches/py3k/Modules/_csv.c	Thu Nov 15 21:48:54 2007
@@ -1185,7 +1185,7 @@
 		else {
 			PyObject *str;
 
-			str = PyObject_Unicode(field);
+			str = PyObject_Str(field);
  			Py_DECREF(field);
 			if (str == NULL)
 				return NULL;

Modified: python/branches/py3k/Modules/_ctypes/callproc.c
==============================================================================
--- python/branches/py3k/Modules/_ctypes/callproc.c	(original)
+++ python/branches/py3k/Modules/_ctypes/callproc.c	Thu Nov 15 21:48:54 2007
@@ -785,7 +785,7 @@
 			goto error;
 	} else
 		PyErr_Clear();
-	msg_str = PyObject_Unicode(v);
+	msg_str = PyObject_Str(v);
 	if (msg_str)
 		PyUnicode_AppendAndDel(&s, msg_str);
 	else {

Modified: python/branches/py3k/Modules/_testcapimodule.c
==============================================================================
--- python/branches/py3k/Modules/_testcapimodule.c	(original)
+++ python/branches/py3k/Modules/_testcapimodule.c	Thu Nov 15 21:48:54 2007
@@ -615,12 +615,12 @@
 	return Py_None;
 }
 
-/* Example passing NULLs to PyObject_Str(NULL) and PyObject_Unicode(NULL). */
+/* Example passing NULLs to PyObject_Str(NULL). */
 
 static PyObject *
 test_null_strings(PyObject *self)
 {
-	PyObject *o1 = PyObject_Str(NULL), *o2 = PyObject_Unicode(NULL);
+	PyObject *o1 = PyObject_Str(NULL), *o2 = PyObject_Str(NULL);
 	PyObject *tuple = PyTuple_Pack(2, o1, o2);
 	Py_XDECREF(o1);
 	Py_XDECREF(o2);

Modified: python/branches/py3k/Modules/cjkcodecs/multibytecodec.c
==============================================================================
--- python/branches/py3k/Modules/cjkcodecs/multibytecodec.c	(original)
+++ python/branches/py3k/Modules/cjkcodecs/multibytecodec.c	Thu Nov 15 21:48:54 2007
@@ -552,7 +552,7 @@
 	if (PyUnicode_Check(arg))
 		ucvt = NULL;
 	else {
-		arg = ucvt = PyObject_Unicode(arg);
+		arg = ucvt = PyObject_Str(arg);
 		if (arg == NULL)
 			return NULL;
 		else if (!PyUnicode_Check(arg)) {
@@ -728,7 +728,7 @@
 	if (PyUnicode_Check(unistr))
 		ucvt = NULL;
 	else {
-		unistr = ucvt = PyObject_Unicode(unistr);
+		unistr = ucvt = PyObject_Str(unistr);
 		if (unistr == NULL)
 			return NULL;
 		else if (!PyUnicode_Check(unistr)) {

Modified: python/branches/py3k/Modules/datetimemodule.c
==============================================================================
--- python/branches/py3k/Modules/datetimemodule.c	(original)
+++ python/branches/py3k/Modules/datetimemodule.c	Thu Nov 15 21:48:54 2007
@@ -2444,7 +2444,7 @@
 
 	/* if the format is zero length, return str(self) */
 	if (PyUnicode_GetSize(format) == 0)
-                return PyObject_Unicode((PyObject *)self);
+                return PyObject_Str((PyObject *)self);
 
         return PyObject_CallMethod((PyObject *)self, "strftime", "O", format);
 }
@@ -3220,7 +3220,7 @@
 
 	/* if the format is zero length, return str(self) */
 	if (PyUnicode_GetSize(format) == 0)
-                return PyObject_Unicode((PyObject *)self);
+                return PyObject_Str((PyObject *)self);
 
         return PyObject_CallMethod((PyObject *)self, "strftime", "O", format);
 }

Modified: python/branches/py3k/Modules/grpmodule.c
==============================================================================
--- python/branches/py3k/Modules/grpmodule.c	(original)
+++ python/branches/py3k/Modules/grpmodule.c	Thu Nov 15 21:48:54 2007
@@ -110,7 +110,7 @@
     char *name;
     struct group *p;
 
-    py_str_name = PyObject_Unicode(pyo_name);
+    py_str_name = PyObject_Str(pyo_name);
     if (!py_str_name)
 	    return NULL;
     name = PyUnicode_AsString(py_str_name);

Modified: python/branches/py3k/Objects/exceptions.c
==============================================================================
--- python/branches/py3k/Objects/exceptions.c	(original)
+++ python/branches/py3k/Objects/exceptions.c	Thu Nov 15 21:48:54 2007
@@ -89,9 +89,9 @@
     case 0:
         return PyUnicode_FromString("");
     case 1:
-        return PyObject_Unicode(PyTuple_GET_ITEM(self->args, 0));
+        return PyObject_Str(PyTuple_GET_ITEM(self->args, 0));
     default:
-        return PyObject_Unicode(self->args);
+        return PyObject_Str(self->args);
     }
 }
 
@@ -939,7 +939,7 @@
     have_lineno = (self->lineno != NULL) && PyInt_CheckExact(self->lineno);
 
     if (!filename && !have_lineno)
-        return PyObject_Unicode(self->msg ? self->msg : Py_None);
+        return PyObject_Str(self->msg ? self->msg : Py_None);
 
     if (filename && have_lineno)
         return PyUnicode_FromFormat("%S (%s, line %ld)",

Modified: python/branches/py3k/Objects/stringlib/string_format.h
==============================================================================
--- python/branches/py3k/Objects/stringlib/string_format.h	(original)
+++ python/branches/py3k/Objects/stringlib/string_format.h	Thu Nov 15 21:48:54 2007
@@ -770,7 +770,7 @@
     case 'r':
         return PyObject_Repr(obj);
     case 's':
-        return PyObject_Unicode(obj);
+        return PyObject_Str(obj);
     default:
         PyErr_Format(PyExc_ValueError,
                      "Unknown converion specifier %c",

Modified: python/branches/py3k/Objects/stringlib/unicodedefs.h
==============================================================================
--- python/branches/py3k/Objects/stringlib/unicodedefs.h	(original)
+++ python/branches/py3k/Objects/stringlib/unicodedefs.h	Thu Nov 15 21:48:54 2007
@@ -20,7 +20,7 @@
 #define STRINGLIB_NEW            PyUnicode_FromUnicode
 #define STRINGLIB_RESIZE         PyUnicode_Resize
 #define STRINGLIB_CHECK          PyUnicode_Check
-#define STRINGLIB_TOSTR          PyObject_Unicode
+#define STRINGLIB_TOSTR          PyObject_Str
 
 #define STRINGLIB_WANT_CONTAINS_OBJ 1
 

Modified: python/branches/py3k/Objects/typeobject.c
==============================================================================
--- python/branches/py3k/Objects/typeobject.c	(original)
+++ python/branches/py3k/Objects/typeobject.c	Thu Nov 15 21:48:54 2007
@@ -2954,7 +2954,7 @@
                 return NULL;
         }
 
-        self_as_str = PyObject_Unicode(self);
+        self_as_str = PyObject_Str(self);
         if (self_as_str != NULL) {
                 /* find the format function */
                 format_meth = PyObject_GetAttrString(self_as_str, "__format__");

Modified: python/branches/py3k/Objects/unicodeobject.c
==============================================================================
--- python/branches/py3k/Objects/unicodeobject.c	(original)
+++ python/branches/py3k/Objects/unicodeobject.c	Thu Nov 15 21:48:54 2007
@@ -572,14 +572,14 @@
 #endif
 #endif
 	/* step 1: count the number of %S/%R format specifications
-	 * (we call PyObject_Unicode()/PyObject_Repr() for these objects
+	 * (we call PyObject_Str()/PyObject_Repr() for these objects
 	 * once during step 3 and put the result in an array) */
 	for (f = format; *f; f++) {
 		if (*f == '%' && (*(f+1)=='S' || *(f+1)=='R'))
 			++callcount;
 	}
 	/* step 2: allocate memory for the results of
-	 * PyObject_Unicode()/PyObject_Repr() calls */
+	 * PyObject_Str()/PyObject_Repr() calls */
 	if (callcount) {
 		callresults = PyMem_Malloc(sizeof(PyObject *)*callcount);
 		if (!callresults) {
@@ -683,7 +683,7 @@
 				PyObject *obj = va_arg(count, PyObject *);
 				PyObject *str;
 				assert(obj);
-				str = PyObject_Unicode(obj);
+				str = PyObject_Str(obj);
 				if (!str)
 					goto fail;
 				n += PyUnicode_GET_SIZE(str);
@@ -987,7 +987,7 @@
 PyObject *PyUnicode_FromObject(register PyObject *obj)
 {
     /* XXX Perhaps we should make this API an alias of
-           PyObject_Unicode() instead ?! */
+           PyObject_Str() instead ?! */
     if (PyUnicode_CheckExact(obj)) {
 	Py_INCREF(obj);
 	return obj;
@@ -8671,7 +8671,7 @@
 		else {
 		    PyObject *unicode;
 		    if (c == 's')
-			temp = PyObject_Unicode(v);
+			temp = PyObject_Str(v);
 		    else
 			temp = PyObject_Repr(v);
 		    if (temp == NULL)
@@ -8889,7 +8889,7 @@
 	if (x == NULL)
 		return (PyObject *)_PyUnicode_New(0);
 	if (encoding == NULL && errors == NULL)
-	    return PyObject_Unicode(x);
+	    return PyObject_Str(x);
 	else
 	return PyUnicode_FromEncodedObject(x, encoding, errors);
 }

Modified: python/branches/py3k/Python/pythonrun.c
==============================================================================
--- python/branches/py3k/Python/pythonrun.c	(original)
+++ python/branches/py3k/Python/pythonrun.c	Thu Nov 15 21:48:54 2007
@@ -911,7 +911,7 @@
 	}
 	v = PySys_GetObject("ps1");
 	if (v != NULL) {
-		v = PyObject_Unicode(v);
+		v = PyObject_Str(v);
 		if (v == NULL)
 			PyErr_Clear();
 		else if (PyUnicode_Check(v))
@@ -919,7 +919,7 @@
 	}
 	w = PySys_GetObject("ps2");
 	if (w != NULL) {
-		w = PyObject_Unicode(w);
+		w = PyObject_Str(w);
 		if (w == NULL)
 			PyErr_Clear();
 		else if (PyUnicode_Check(w))
@@ -1373,7 +1373,7 @@
 		else
 			err = PyFile_WriteObject(exception, f, Py_PRINT_RAW);
 		if (err == 0 && (value != Py_None)) {
-			PyObject *s = PyObject_Unicode(value);
+			PyObject *s = PyObject_Str(value);
 			/* only print colon if the str() of the
 			   object is not the empty string
 			*/
@@ -1687,7 +1687,7 @@
 		PyObject *type, *value, *tb;
 		PyErr_Fetch(&type, &value, &tb);
 		if (value != NULL) {
-			u = PyObject_Unicode(value);
+			u = PyObject_Str(value);
 			if (u != NULL) {
 				msg = PyUnicode_AsString(u);
 			}


More information about the Python-3000-checkins mailing list