Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.4k
[2.7] bpo-18533: Avoid RuntimeError from repr() of recursive dictview [GH-4823]#5357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
matrixise commentedJan 30, 2018
I have executed the tests with and there is no reference leaks. |
Objects/dictobject.c Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Py_DECREF(seq) could be called just afterPyObject_Repr(). This will simplify the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks for suggestion; that is indeed cleaner. I've just force-pushed a fresh commit including that change.
…on#4823)dictview_repr(): Use a Py_ReprEnter() / Py_ReprLeave() pair to checkfor recursion, and produce "..." if so.test_recursive_repr(): Check for a string rather than aRuntimeError. (Test cannot be any tighter as contents areimplementation-dependent.)test_deeply_nested_repr(): Add new test, replacing the originaltest_recursive_repr(). It checks that a RuntimeError is raised inthe case of a non-recursive but deeply nested structure.OrderedDictTests: Add new test case, to test behavior on OrderedDictinstances containing their own viewvalues() or viewitems(). This testpasses without the patch to dictview_repr(), but it failed in (atleast some versions of) Python 3, so including it here forcompleteness.(cherry picked from commitd7773d9)
5b4fdb5 toa27a0d4Comparebedevere-bot commentedFeb 26, 2018
@serhiy-storchaka: Please replace |
Uh oh!
There was an error while loading.Please reload this page.
As suggested ina message on BPO, this is a backport of#4823 to the 2.7 branch. Compared to the changes introduced in#4823, this PR:
seq_strindictview_repr().PyString...(instead ofPyUnicode...).viewvalues()andviewitems()(instead ofvalues()anditems()).RuntimeError(instead ofRecursionError).I kept the test on
OrderedDicteven though 2.7 behaves correctly already; please let me know if it would be cleaner to omit this part.https://bugs.python.org/issue18533