[Python-checkins] r81807 - in python/branches/py3k: Doc/c-api/arg.rst Modules/_ctypes/_ctypes.c Objects/exceptions.c Python/Python-ast.c Python/errors.c Python/modsupport.c Python/sysmodule.c

victor.stinner python-checkins at python.org
Mon Jun 7 21:57:46 CEST 2010


Author: victor.stinner
Date: Mon Jun  7 21:57:46 2010
New Revision: 81807

Log:
Issue #8848: U / U# formats of Py_BuildValue() are just alias to s / s#


Modified:
   python/branches/py3k/Doc/c-api/arg.rst
   python/branches/py3k/Modules/_ctypes/_ctypes.c
   python/branches/py3k/Objects/exceptions.c
   python/branches/py3k/Python/Python-ast.c
   python/branches/py3k/Python/errors.c
   python/branches/py3k/Python/modsupport.c
   python/branches/py3k/Python/sysmodule.c

Modified: python/branches/py3k/Doc/c-api/arg.rst
==============================================================================
--- python/branches/py3k/Doc/c-api/arg.rst	(original)
+++ python/branches/py3k/Doc/c-api/arg.rst	Mon Jun  7 21:57:46 2010
@@ -530,12 +530,10 @@
       and ``None`` is returned.
 
    ``U`` (string) [char \*]
-      Convert a null-terminated C string to a Python unicode object. If the C string
-      pointer is *NULL*, ``None`` is used.
+      Same as ``s``.
 
    ``U#`` (string) [char \*, int]
-      Convert a C string and its length to a Python unicode object. If the C string
-      pointer is *NULL*, the length is ignored and ``None`` is returned.
+      Same as ``s#``.
 
    ``i`` (integer) [int]
       Convert a plain C :ctype:`int` to a Python integer object.

Modified: python/branches/py3k/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/branches/py3k/Modules/_ctypes/_ctypes.c	(original)
+++ python/branches/py3k/Modules/_ctypes/_ctypes.c	Mon Jun  7 21:57:46 2010
@@ -4467,7 +4467,7 @@
 #endif
 
     result = PyObject_CallFunction((PyObject *)&PyCArrayType_Type,
-                                   "U(O){s:n,s:O}",
+                                   "s(O){s:n,s:O}",
                                    name,
                                    &PyCArray_Type,
                                    "_length_",

Modified: python/branches/py3k/Objects/exceptions.c
==============================================================================
--- python/branches/py3k/Objects/exceptions.c	(original)
+++ python/branches/py3k/Objects/exceptions.c	Mon Jun  7 21:57:46 2010
@@ -1510,7 +1510,7 @@
     const char *encoding, const Py_UNICODE *object, Py_ssize_t length,
     Py_ssize_t start, Py_ssize_t end, const char *reason)
 {
-    return PyObject_CallFunction(PyExc_UnicodeEncodeError, "Uu#nnU",
+    return PyObject_CallFunction(PyExc_UnicodeEncodeError, "su#nns",
                                  encoding, object, length, start, end, reason);
 }
 
@@ -1625,7 +1625,7 @@
     assert(length < INT_MAX);
     assert(start < INT_MAX);
     assert(end < INT_MAX);
-    return PyObject_CallFunction(PyExc_UnicodeDecodeError, "Uy#nnU",
+    return PyObject_CallFunction(PyExc_UnicodeDecodeError, "sy#nns",
                                  encoding, object, length, start, end, reason);
 }
 

Modified: python/branches/py3k/Python/Python-ast.c
==============================================================================
--- python/branches/py3k/Python/Python-ast.c	(original)
+++ python/branches/py3k/Python/Python-ast.c	Mon Jun  7 21:57:46 2010
@@ -527,7 +527,7 @@
         }
         PyTuple_SET_ITEM(fnames, i, field);
     }
-    result = PyObject_CallFunction((PyObject*)&PyType_Type, "U(O){sOss}",
+    result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}",
                     type, base, "_fields", fnames, "__module__", "_ast");
     Py_DECREF(fnames);
     return (PyTypeObject*)result;

Modified: python/branches/py3k/Python/errors.c
==============================================================================
--- python/branches/py3k/Python/errors.c	(original)
+++ python/branches/py3k/Python/errors.c	Mon Jun  7 21:57:46 2010
@@ -679,7 +679,7 @@
             goto failure;
     }
     /* Create a real new-style class. */
-    result = PyObject_CallFunction((PyObject *)&PyType_Type, "UOO",
+    result = PyObject_CallFunction((PyObject *)&PyType_Type, "sOO",
                                    dot+1, bases, dict);
   failure:
     Py_XDECREF(bases);

Modified: python/branches/py3k/Python/modsupport.c
==============================================================================
--- python/branches/py3k/Python/modsupport.c	(original)
+++ python/branches/py3k/Python/modsupport.c	Mon Jun  7 21:57:46 2010
@@ -302,39 +302,7 @@
 
         case 's':
         case 'z':
-        {
-            PyObject *v;
-            char *str = va_arg(*p_va, char *);
-            Py_ssize_t n;
-            if (**p_format == '#') {
-                ++*p_format;
-                if (flags & FLAG_SIZE_T)
-                    n = va_arg(*p_va, Py_ssize_t);
-                else
-                    n = va_arg(*p_va, int);
-            }
-            else
-                n = -1;
-            if (str == NULL) {
-                v = Py_None;
-                Py_INCREF(v);
-            }
-            else {
-                if (n < 0) {
-                    size_t m = strlen(str);
-                    if (m > PY_SSIZE_T_MAX) {
-                        PyErr_SetString(PyExc_OverflowError,
-                            "string too long for Python string");
-                        return NULL;
-                    }
-                    n = (Py_ssize_t)m;
-                }
-                v = PyUnicode_FromStringAndSize(str, n);
-            }
-            return v;
-        }
-
-        case 'U':
+        case 'U':   /* XXX deprecated alias */
         {
             PyObject *v;
             char *str = va_arg(*p_va, char *);

Modified: python/branches/py3k/Python/sysmodule.c
==============================================================================
--- python/branches/py3k/Python/sysmodule.c	(original)
+++ python/branches/py3k/Python/sysmodule.c	Mon Jun  7 21:57:46 2010
@@ -1510,7 +1510,7 @@
                          PyLong_FromLong(PY_VERSION_HEX));
     svnversion_init();
     SET_SYS_FROM_STRING("subversion",
-                        Py_BuildValue("(UUU)", "CPython", branch,
+                        Py_BuildValue("(sss)", "CPython", branch,
                                       svn_revision));
     SET_SYS_FROM_STRING("dont_write_bytecode",
                          PyBool_FromLong(Py_DontWriteBytecodeFlag));


More information about the Python-checkins mailing list