8000 * complex_subtype_from_string: L860, L871-L874 (the function called i… · python/cpython@72b349d · GitHub
[go: up one dir, main page]

Skip to content

Commit 72b349d

Browse files
committed
* complex_subtype_from_string: L860, L871-L874 (the function called in L926)
1 parent ffd088a commit 72b349d

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

Objects/complexobject.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -856,22 +856,15 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
856856
PyObject *s_buffer = NULL, *result = NULL;
857857
Py_ssize_t len;
858858

859-
if (PyUnicode_Check(v)) {
860-
s_buffer = _PyUnicode_TransformDecimalAndSpaceToASCII(v);
861-
if (s_buffer == NULL) {
862-
return NULL;
863-
}
864-
assert(PyUnicode_IS_ASCII(s_buffer));
865-
/* Simply get a pointer to existing ASCII characters. */
866-
s = PyUnicode_AsUTF8AndSize(s_buffer, &len);
867-
assert(s != NULL);
868-
}
869-
else {
870-
PyErr_Format(PyExc_TypeError,
871-
"complex() argument must be a string or a number, not '%.200s'",
872-
Py_TYPE(v)->tp_name);
859+
assert(PyUnicode_Check(v));
860+
s_buffer = _PyUnicode_TransformDecimalAndSpaceToASCII(v);
861+
if (s_buffer == NULL) {
873862
return NULL;
874863
}
864+
assert(PyUnicode_IS_ASCII(s_buffer));
865+
/* Simply get a pointer to existing ASCII characters. */
866+
s = PyUnicode_AsUTF8AndSize(s_buffer, &len);
867+
assert(s != NULL);
875868

876869
result = _Py_string_to_number_with_underscores(s, len, "complex", v, type,
877870
complex_from_string_inner);

0 commit comments

Comments
 (0)
0