Ben North added the comment: New patch including tests attached, against 3.3. Terry Reedy's example above now gives
>>> d = {} >>> d[1] = d.keys() >>> d[2] = d.values() >>> d {1: dict_keys([1, 2]), 2: dict_values([dict_keys([1, 2]), ...])} which I think is preferable. Summary of patch: dictobject.c: dictview_repr() now uses a Py_ReprEnter() / Py_ReprLeave() pair to check for recursion, and produces "..." if so. I think I've got the behaviour correct in the case that PySequence_List() fails, but couldn't find a way to trigger this in testing. test_dictviews.py: test_recursive_repr() checks for the correct string (containing "...") rather than a RuntimeError. test_deeply_nested_repr() is a new function, aiming to replace the original test_recursive_repr(). It checks that a RuntimeError is raised in the case of a non-recursive but deeply nested structure. Under --with-pydebug, ./python -m test.regrtest -R20:30 test_dictviews passes. ---------- Added file: http://bugs.python.org/file31022/non-error-recursive-dictview-3.3.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18533> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com