mgedmin / objgraph

Visually explore Python object graphs
http://mg.pov.lt/objgraph/
MIT License
768 stars 72 forks source link

`test_edge_label_frame_locals` fails on Python 3.13 #80

Open mgorny opened 3 months ago

mgorny commented 3 months ago

When running the test suite against Python 3.13.0b2, I'm getting the following failure:

$ tox -e py313
.pkg: _optional_hooks> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: get_requires_for_build_sdist> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: get_requires_for_build_wheel> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: prepare_metadata_for_build_wheel> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: build_sdist> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
py313: install_package> python -I -m pip install --force-reinstall --no-deps /tmp/objgraph/.tox/.tmp/package/3/objgraph-3.6.2.dev0.tar.gz
py313: commands[0]> python tests.py
..........................F.s..............s....ss.....s....
======================================================================
FAIL: test_edge_label_frame_locals (__main__.StringRepresentationTest.test_edge_label_frame_locals)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/objgraph/tests.py", line 470, in test_edge_label_frame_locals
    self.assertEqual(' [label="f_locals",weight=10]',
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                     objgraph._edge_label(frame, frame.f_locals))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: ' [label="f_locals",weight=10]' != ''
-  [label="f_locals",weight=10]

----------------------------------------------------------------------
Ran 60 tests in 1.750s

FAILED (failures=1, skipped=5)
py313: exit 1 (1.88 seconds) /tmp/objgraph> python tests.py pid=139558
  py313: FAIL code 1 (7.76=setup[5.89]+cmd[1.88] seconds)
  evaluation failed :( (7.88 seconds)
mgedmin commented 3 months ago

I'm aware of the issue. The What's New In Python 3.13 document says

To ensure debuggers and similar tools can reliably update local variables in scopes affected by this change, FrameType.f_locals now returns a write-through proxy to the frame’s local and locally referenced nonlocal variables in these scopes, rather than returning an inconsistently updated shared dict instance with undefined runtime semantics.

which seems very relevant.

I don't yet have a clear idea of what to do about this.