Fix Variable Explorer PicklingError for deeply nested objects#25706
Open
d-kavinraja wants to merge 2 commits intospyder-ide:masterfrom
Open
Fix Variable Explorer PicklingError for deeply nested objects#25706d-kavinraja wants to merge 2 commits intospyder-ide:masterfrom
d-kavinraja wants to merge 2 commits intospyder-ide:masterfrom
Conversation
c0e68c3 to
fa14491
Compare
…-ide#25699) Root cause: When cloudpickle.dumps() raises pickle.PicklingError in the kernel for deeply nested lists/dicts/DataFrames, the comm layer reconstructs the error as a dynamic Exception subclass (not pickle.PicklingError), so the frontend's except handler misses it and shows an unhelpful 'unknown error' message. Changes: - commbase.py: Resolve exception types from well-known modules (pickle, _pickle) in from_json() before falling back to builtins, so PicklingError is properly reconstructed as pickle.PicklingError. - kernel.py: Catch PicklingError/RecursionError in get_value() and retry with a temporarily increased recursion limit (10x) before giving up. - namespacebrowser.py: Add safety net in the generic except handler to detect PicklingError by class name and show a proper error message. Fixes spyder-ide#25699
The test_goto_uri[params15] test case hardcoded 'spyder-ide#123' as the expected URL for the 'spyder-idegh-123' shorthand. However, go_to_uri_from_cursor() computes this URL dynamically from the repo's git remotes (preferring 'upstream' over 'origin'). When running on a fork, origin points to the fork, causing a mismatch. Fix: compute the expected URL at module level using the same get_git_remotes + remote_to_url logic so the test works on any fork.
Member
|
Hey @d-kavinraja, thanks for your contribution. Could you clarify if you used AI to create this pull request? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #25699 — Variable Explorer throws "An unknown error occurred, sorry" when clicking on lists, dictionaries, or Pandas DataFrames that require deep recursion to pickle.
Root Cause
A 3-layer failure in the error handling chain:
kernel.py):cloudpickle.dumps(value)raisespickle.PicklingErrorfor deeply nested structures with no fallback.commbase.py):from_json()reconstructs the error type usinggetattr(builtins, "PicklingError", ...). SincePicklingErroris NOT inbuiltins, a dynamically-created class inheriting fromException(notpickle.PicklingError) is created.namespacebrowser.py):except (PicklingError, ...)catchespickle.PicklingError, but the dynamically-created class doesn't match, so the error falls through to the genericexcept Exceptionhandler showing the unhelpful message.Changes
1.
commbase.py— Fix exception type reconstructionfrom_json()now resolves exception types from well-known modules (pickle,_pickle) before falling back tobuiltins/dynamic creation. This ensurespickle.PicklingErrorraised in the kernel is properly reconstructed on the Spyder side.2.
kernel.py— Add recursion limit fallbackget_value()now catchesPicklingError/RecursionErroron the first pickle attempt and retries with a temporarily increased recursion limit (10x), allowing most normal objects (lists, dicts, DataFrames) that happen to be moderately deep to succeed.3.
namespacebrowser.py— Safety net in generic handlerThe final
except Exceptionblock now checks the exception's class name. If it'sPicklingErrororUnpicklingError(even from a dynamically-created class), it shows the proper "not picklable" message instead of "unknown error."