This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bennorth
Recipients bennorth, terry.reedy, vstinner, zuo
Date 2013-07-23.23:20:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1374621606.7.0.56189778969.issue18533@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-07-23 23:20:06bennorthsetrecipients: + bennorth, terry.reedy, vstinner, zuo
2013-07-23 23:20:06bennorthsetmessageid: <1374621606.7.0.56189778969.issue18533@psf.upfronthosting.co.za>
2013-07-23 23:20:06bennorthlinkissue18533 messages
2013-07-23 23:20:06bennorthcreate