mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
More on SF bug [#460020] bug or feature: unicode() and subclasses.
tuple(i) repaired to return a true tuple when i is an instance of a tuple subclass. Added PyTuple_CheckExact macro. PySequence_Tuple(): if a tuple-like object isn't exactly a tuple, it's not safe to return the object as-is -- make a new tuple of it instead.
This commit is contained in:
parent
caaff8d95d
commit
4c3a0a35cd
3 changed files with 7 additions and 2 deletions
|
@ -1235,7 +1235,11 @@ PySequence_Tuple(PyObject *v)
|
|||
return null_error();
|
||||
|
||||
/* Special-case the common tuple and list cases, for efficiency. */
|
||||
if (PyTuple_Check(v)) {
|
||||
if (PyTuple_CheckExact(v)) {
|
||||
/* Note that we can't know whether it's safe to return
|
||||
a tuple *subclass* instance as-is, hence the restriction
|
||||
to exact tuples here. In contrasts, lists always make
|
||||
a copy, so there's need for exactness below. */
|
||||
Py_INCREF(v);
|
||||
return v;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue