Repository navigation
gh-146056: Fix repr() for lists and tuples containing NULLs - #146129
Conversation
|
If you change |
|
Please add a test on tuple as well: diff --git a/Lib/test/test_capi/test_tuple.py b/Lib/test/test_capi/test_tuple.py
index 0c27e81168f..51d26640865 100644
--- a/Lib/test/test_capi/test_tuple.py
+++ b/Lib/test/test_capi/test_tuple.py
@@ -73,6 +73,11 @@ def test_tuple_new(self):
self.assertRaises(SystemError, tuple_new, PY_SSIZE_T_MIN)
self.assertRaises(MemoryError, tuple_new, PY_SSIZE_T_MAX)
+
+ def test_uninitialized_tuple_repr(self):
+ tup = _testlimitedcapi.tuple_new(3)
+ self.assertEqual(repr(tup), '(<NULL>, <NULL>, <NULL>)')
+
def test_tuple_fromarray(self):
# Test PyTuple_FromArray()
tuple_fromarray = _testcapi.tuple_fromarray |
Co-authored-by: Victor Stinner <vstinner@python.org>
99a95d7 to
a75c4c1
Compare
vstinner
left a comment
There was a problem hiding this comment.
LGTM. I was against this before knowing that PyObject_Repr() and Python 3.12 repr(list) already support NULL, then I changed my mind.
IMO we should fix repr(list) in Python 3.13 and 3.14. But I don't think that we should backport the PyUnicodeWriter_WriteRepr() change.
Co-authored-by: Victor Stinner <vstinner@python.org>
|
I think this was a bug in the PyUnicodeWriter C API. When the user rewrite they code to using it, they can reasonably assume that I have found few other bugs in the PyUnicodeWriter C API, working on them. |
|
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
|
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
|
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
pythonGH-146129) (cherry picked from commit 0f2246b) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
|
GH-146155 is a backport of this pull request to the 3.14 branch. |
|
FYI I updated |
pythonGH-146129) (cherry picked from commit 0f2246b) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
|
GH-146204 is a backport of this pull request to the 3.14 branch. |
1 similar comment
|
GH-146204 is a backport of this pull request to the 3.14 branch. |
|
GH-146155 is a backport of this pull request to the 3.14 branch. |
|
GH-146204 is a backport of this pull request to the 3.14 branch. |
…LLs (pythonGH-146129) (pythonGH-146155) (cherry picked from commit 0f2246b) (cherry picked from commit 7965133) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
…GH-146129) (pythonGH-146155) (cherry picked from commit 0f2246b) (cherry picked from commit 7965133) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
…onGH-146129) Co-authored-by: Victor Stinner <vstinner@python.org>
Uh oh!
There was an error while loading. Please reload this page.