You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running a simple roundtripper on every python file in the cpython repo's Lib dir found this interesting case. Aside: this is the only new case I found in my follow-up investigation from #1095.
Attempting to roundtrip this file in my scratch env produces a huge trace of the form:
long trace (with sections snipped)
Traceback (most recent call last):
File "/home/sirosen/_scratch/.venv/lib/python3.11/site-packages/libcst/_nodes/base.py", line 358, in deep_clone
cloned_fields[key] = tuple(_clone(v) for v in val)
^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'Dict' object is not iterable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/sirosen/_scratch/.venv/lib/python3.11/site-packages/libcst/_nodes/base.py", line 358, in deep_clone
cloned_fields[key] = tuple(_clone(v) for v in val)
^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'ConcatenatedString' object is not iterable
During handling of the above exception, another exception occurred:
... repeats many times ...
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/sirosen/_scratch/.venv/lib/python3.11/site-packages/libcst/_nodes/base.py", line 358, in deep_clone
cloned_fields[key] = tuple(_clone(v) for v in val)
^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'ConcatenatedString' object is not iterable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/sirosen/_scratch/.venv/lib/python3.11/site-packages/libcst/_nodes/base.py", line 358, in deep_clone
cloned_fields[key] = tuple(_clone(v) for v in val)
^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'SimpleString' object is not iterable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/sirosen/_scratch/rt.py", line 21, in <module>
_roundtrip_data(content)
File "/home/sirosen/_scratch/rt.py", line 12, in _roundtrip_data
wrapped_tree = libcst.MetadataWrapper(raw_tree)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sirosen/_scratch/.venv/lib/python3.11/site-packages/libcst/metadata/wrapper.py", line 146, in __init__
module = module.deep_clone()
^^^^^^^^^^^^^^^^^^^
File "/home/sirosen/_scratch/.venv/lib/python3.11/site-packages/libcst/_nodes/base.py", line 358, in deep_clone
cloned_fields[key] = tuple(_clone(v) for v in val)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sirosen/_scratch/.venv/lib/python3.11/site-packages/libcst/_nodes/base.py", line 358, in <genexpr>
cloned_fields[key] = tuple(_clone(v) for v in val)
^^^^^^^^^
File "/home/sirosen/_scratch/.venv/lib/python3.11/site-packages/libcst/_nodes/base.py", line 105, in _clone
return val.deep_clone()
^^^^^^^^^^^^^^^^
File "/home/sirosen/_scratch/.venv/lib/python3.11/site-packages/libcst/_nodes/base.py", line 358, in deep_clone
cloned_fields[key] = tuple(_clone(v) for v in val)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... repeats many times ...
File "/home/sirosen/_scratch/.venv/lib/python3.11/site-packages/libcst/_nodes/base.py", line 362, in deep_clone
return type(self)(**cloned_fields)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<string>", line 6, in __init__
File "/home/sirosen/_scratch/.venv/lib/python3.11/site-packages/libcst/_nodes/base.py", line 117, in __post_init__
self._validate()
File "/home/sirosen/_scratch/.venv/lib/python3.11/site-packages/libcst/_nodes/expression.py", line 592, in _validate
super(SimpleString, self)._validate()
RecursionError: maximum recursion depth exceeded
In case it's relevant, my no-op transformer is this body of code:
My guess would be that this is hard to solve because it probably requires unwinding a complex recursive construction into something non-recursive. Given that cpython can support this, I thought it was interesting enough to be worth reporting.
The text was updated successfully, but these errors were encountered:
zsol
added
bug
Something isn't working
parsing
Converting source code into CST nodes
machinery
Internal plumbing for visitor, transformer, matcher APIs
and removed
parsing
Converting source code into CST nodes
labels
Jul 30, 2024
That probably works if my goal is to make this work by hook or by crook. I opened this primarily because it was an interesting discovery I felt was worth sharing with the libcst maintainers. It's not really blocking me from any work.
(I would not be bothered if libcst declares this a non-issue and closes.)
Running a simple roundtripper on every python file in the cpython repo's
Lib
dir found this interesting case.Aside: this is the only new case I found in my follow-up investigation from #1095.
Here's a permalink to the current version of
pydoc_data/topics.py
Attempting to roundtrip this file in my scratch env produces a huge trace of the form:
long trace (with sections snipped)
In case it's relevant, my no-op transformer is this body of code:
rt.py
My guess would be that this is hard to solve because it probably requires unwinding a complex recursive construction into something non-recursive. Given that cpython can support this, I thought it was interesting enough to be worth reporting.
The text was updated successfully, but these errors were encountered: