Skip to content

Commit c59478c

Browse files
type is always PyUnicode_Type?
1 parent 311aa3c commit c59478c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Objects/unicodeobject.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14671,14 +14671,16 @@ static PyObject *
1467114671
unicode_vectorcall(PyObject *type, PyObject *const *args,
1467214672
size_t nargsf, PyObject *kwnames)
1467314673
{
14674+
assert(Py_Is(_PyType_CAST(type), &PyUnicode_Type));
14675+
1467414676
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
1467514677
Py_ssize_t nkwargs = (kwnames) ? PyTuple_GET_SIZE(kwnames) : 0;
1467614678
if (nargs == 0 && nkwargs == 0) {
14677-
return unicode_new_impl(_PyType_CAST(type), NULL, NULL, NULL);
14679+
return unicode_get_empty();
1467814680
}
1467914681
PyObject *object = args[0];
1468014682
if (nargs == 1 && nkwargs == 0) {
14681-
return unicode_new_impl(_PyType_CAST(type), object, NULL, NULL);
14683+
return PyObject_Str(object);
1468214684
}
1468314685
if (nargs + nkwargs == 2) {
1468414686
const char *encoding;
@@ -14712,7 +14714,7 @@ unicode_vectorcall(PyObject *type, PyObject *const *args,
1471214714
else {
1471314715
return fallback_to_tp_call(type, nargs, nkwargs, args, kwnames);
1471414716
}
14715-
return unicode_new_impl(_PyType_CAST(type), object, encoding, errors);
14717+
return PyUnicode_FromEncodedObject(object, encoding, errors);
1471614718
}
1471714719
if (nargs + nkwargs == 3) {
1471814720
if (nkwargs == 1) {
@@ -14734,7 +14736,7 @@ unicode_vectorcall(PyObject *type, PyObject *const *args,
1473414736
if (errors == NULL) {
1473514737
return NULL;
1473614738
}
14737-
return unicode_new_impl(_PyType_CAST(type), object, encoding, errors);
14739+
return PyUnicode_FromEncodedObject(object, encoding, errors);
1473814740
}
1473914741
if (nargs > 3) {
1474014742
PyErr_Format(PyExc_TypeError,

0 commit comments

Comments
 (0)