diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-06-07 19:57:46 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-06-07 19:57:46 (GMT) |
commit | 7eeb5b5e5017cf1354b084327b49390044946069 (patch) | |
tree | 6105fb6e6fa76d1d0e3c4d6e987b91aa623f7fc3 | |
parent | fa68a6188a16562c1b4ba8cf879ce49decba5546 (diff) | |
download | cpython-7eeb5b5e5017cf1354b084327b49390044946069.zip cpython-7eeb5b5e5017cf1354b084327b49390044946069.tar.gz cpython-7eeb5b5e5017cf1354b084327b49390044946069.tar.bz2 |
Issue #8848: U / U# formats of Py_BuildValue() are just alias to s / s#
-rw-r--r-- | Doc/c-api/arg.rst | 6 | ||||
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 2 | ||||
-rw-r--r-- | Objects/exceptions.c | 4 | ||||
-rw-r--r-- | Python/Python-ast.c | 2 | ||||
-rw-r--r-- | Python/errors.c | 2 | ||||
-rw-r--r-- | Python/modsupport.c | 34 | ||||
-rw-r--r-- | Python/sysmodule.c | 2 |
7 files changed, 9 insertions, 43 deletions
diff --git a/Doc/c-api/arg.rst b/Doc/c-api/arg.rst index bf6ef5c..84e27c2 100644 --- a/Doc/c-api/arg.rst +++ b/Doc/c-api/arg.rst @@ -530,12 +530,10 @@ Building values 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. diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index c1b3093..e84bb8a 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -4467,7 +4467,7 @@ PyCArrayType_from_ctype(PyObject *itemtype, Py_ssize_t length) #endif result = PyObject_CallFunction((PyObject *)&PyCArrayType_Type, - "U(O){s:n,s:O}", + "s(O){s:n,s:O}", name, &PyCArray_Type, "_length_", diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 8200d4d..3d5b1ea 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -1510,7 +1510,7 @@ PyUnicodeEncodeError_Create( 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 @@ PyUnicodeDecodeError_Create( 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); } diff --git a/Python/Python-ast.c b/Python/Python-ast.c index 05fa541..bedd7d7 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -527,7 +527,7 @@ static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int } 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; diff --git a/Python/errors.c b/Python/errors.c index 3766973..4ae661a 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -679,7 +679,7 @@ PyErr_NewException(const char *name, PyObject *base, PyObject *dict) 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); diff --git a/Python/modsupport.c b/Python/modsupport.c index a68e10b..5f5d842 100644 --- a/Python/modsupport.c +++ b/Python/modsupport.c @@ -302,39 +302,7 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags) 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 *); diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 4c87d54..f1da9730c 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1510,7 +1510,7 @@ _PySys_Init(void) 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)); |