Remove useless argument of _PyUnicode_AsDefaultEncodedString()

This commit is contained in:
Victor Stinner 2011-03-02 01:03:11 +00:00
parent 6f58b6b504
commit f3fd733f92
8 changed files with 9 additions and 13 deletions

View File

@ -668,8 +668,7 @@ PyAPI_FUNC(int) PyUnicode_ClearFreeList(void);
#ifndef Py_LIMITED_API #ifndef Py_LIMITED_API
PyAPI_FUNC(PyObject *) _PyUnicode_AsDefaultEncodedString( PyAPI_FUNC(PyObject *) _PyUnicode_AsDefaultEncodedString(
PyObject *unicode, PyObject *unicode);
const char *errors);
#endif #endif
/* Returns a pointer to the default encoding (UTF-8) of the /* Returns a pointer to the default encoding (UTF-8) of the

View File

@ -1826,7 +1826,7 @@ PyCSimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL; return NULL;
} }
if (PyUnicode_Check(proto)) { if (PyUnicode_Check(proto)) {
PyObject *v = _PyUnicode_AsDefaultEncodedString(proto, NULL); PyObject *v = _PyUnicode_AsDefaultEncodedString(proto);
if (!v) if (!v)
goto error; goto error;
proto_str = PyBytes_AS_STRING(v); proto_str = PyBytes_AS_STRING(v);

View File

@ -219,7 +219,7 @@ dbm_contains(PyObject *self, PyObject *arg)
return -1; return -1;
} }
if (PyUnicode_Check(arg)) { if (PyUnicode_Check(arg)) {
arg = _PyUnicode_AsDefaultEncodedString(arg, NULL); arg = _PyUnicode_AsDefaultEncodedString(arg);
if (arg == NULL) if (arg == NULL)
return -1; return -1;
} }

View File

@ -4975,7 +4975,7 @@ slot_tp_str(PyObject *self)
res = slot_tp_repr(self); res = slot_tp_repr(self);
if (!res) if (!res)
return NULL; return NULL;
ress = _PyUnicode_AsDefaultEncodedString(res, NULL); ress = _PyUnicode_AsDefaultEncodedString(res);
Py_DECREF(res); Py_DECREF(res);
return ress; return ress;
} }

View File

@ -1806,14 +1806,11 @@ PyUnicode_AsEncodedUnicode(PyObject *unicode,
} }
PyObject * PyObject *
_PyUnicode_AsDefaultEncodedString(PyObject *unicode, _PyUnicode_AsDefaultEncodedString(PyObject *unicode)
const char *errors)
{ {
PyObject *v = ((PyUnicodeObject *)unicode)->defenc; PyObject *v = ((PyUnicodeObject *)unicode)->defenc;
if (v) if (v)
return v; return v;
if (errors != NULL)
Py_FatalError("non-NULL encoding in _PyUnicode_AsDefaultEncodedString");
v = PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(unicode), v = PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(unicode),
PyUnicode_GET_SIZE(unicode), PyUnicode_GET_SIZE(unicode),
NULL); NULL);
@ -1959,7 +1956,7 @@ _PyUnicode_AsStringAndSize(PyObject *unicode, Py_ssize_t *psize)
PyErr_BadArgument(); PyErr_BadArgument();
return NULL; return NULL;
} }
bytes = _PyUnicode_AsDefaultEncodedString(unicode, NULL); bytes = _PyUnicode_AsDefaultEncodedString(unicode);
if (bytes == NULL) if (bytes == NULL)
return NULL; return NULL;
if (psize != NULL) if (psize != NULL)

View File

@ -511,7 +511,7 @@ source_as_string(PyObject *cmd, char *funcname, char *what, PyCompilerFlags *cf)
if (PyUnicode_Check(cmd)) { if (PyUnicode_Check(cmd)) {
cf->cf_flags |= PyCF_IGNORE_COOKIE; cf->cf_flags |= PyCF_IGNORE_COOKIE;
cmd = _PyUnicode_AsDefaultEncodedString(cmd, NULL); cmd = _PyUnicode_AsDefaultEncodedString(cmd);
if (cmd == NULL) if (cmd == NULL)
return NULL; return NULL;
} }

View File

@ -3026,7 +3026,7 @@ expr_constant(struct compiler *c, expr_ty e)
case Name_kind: case Name_kind:
/* optimize away names that can't be reassigned */ /* optimize away names that can't be reassigned */
id = PyBytes_AS_STRING( id = PyBytes_AS_STRING(
_PyUnicode_AsDefaultEncodedString(e->v.Name.id, NULL)); _PyUnicode_AsDefaultEncodedString(e->v.Name.id));
if (strcmp(id, "True") == 0) return 1; if (strcmp(id, "True") == 0) return 1;
if (strcmp(id, "False") == 0) return 0; if (strcmp(id, "False") == 0) return 0;
if (strcmp(id, "None") == 0) return 0; if (strcmp(id, "None") == 0) return 0;

View File

@ -551,7 +551,7 @@ convertitem(PyObject *arg, const char **p_format, va_list *p_va, int flags,
#define UNICODE_DEFAULT_ENCODING(arg) \ #define UNICODE_DEFAULT_ENCODING(arg) \
_PyUnicode_AsDefaultEncodedString(arg, NULL) _PyUnicode_AsDefaultEncodedString(arg)
/* Format an error message generated by convertsimple(). */ /* Format an error message generated by convertsimple(). */