Copy file reference in variable explorer generates PicklingError
See original GitHub issueDescription
What steps will reproduce the problem?
on attempt to copy from “Variable viewer” cell corresponding to closed file reference (“TextIOWrapper object of _io module”)
Traceback
File "C:\Anaconda\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1037, in copy
obj = self.delegate.get_value(idx)
File "C:\Anaconda\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1386, in get_value
return self.parent().get_value(name)
File "C:\Anaconda\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1439, in get_value
value = self.shellwidget.get_value(name)
File "C:\Anaconda\lib\site-packages\spyder\plugins\ipythonconsole\widgets\namespacebrowser.py", line 99, in get_value
timeout=CALL_KERNEL_TIMEOUT).get_value(name)
File "C:\Anaconda\lib\site-packages\spyder_kernels\comms\commbase.py", line 542, in __call__
call_dict, call_data, self._comm_id)
File "C:\Anaconda\lib\site-packages\spyder\plugins\ipythonconsole\comms\kernelcomm.py", line 114, in _get_call_return_value
call_dict, call_data, comm_id)
File "C:\Anaconda\lib\site-packages\spyder_kernels\comms\commbase.py", line 420, in _get_call_return_value
return self._sync_error(reply['value'])
File "C:\Anaconda\lib\site-packages\spyder_kernels\comms\commbase.py", line 480, in _sync_error
error_wrapper.raise_error()
File "C:\Anaconda\lib\site-packages\spyder_kernels\comms\commbase.py", line 90, in raise_error
raise self.etype(self)
Exception in comms call get_value:
File "C:\Anaconda\lib\site-packages\spyder_kernels\comms\commbase.py", line 343, in _handle_remote_call
self._set_call_return_value(msg_dict, return_value)
File "C:\Anaconda\lib\site-packages\spyder_kernels\comms\commbase.py", line 376, in _set_call_return_value
comm_id=self.calling_comm_id)
File "C:\Anaconda\lib\site-packages\spyder_kernels\comms\commbase.py", line 245, in _send_message
data, protocol=self._comms[comm_id]['pickle_protocol'])]
File "C:\Anaconda\lib\site-packages\cloudpickle\cloudpickle.py", line 1125, in dumps
cp.dump(obj)
File "C:\Anaconda\lib\site-packages\cloudpickle\cloudpickle.py", line 482, in dump
return Pickler.dump(self, obj)
File "C:\Anaconda\lib\pickle.py", line 409, in dump
self.save(obj)
File "C:\Anaconda\lib\pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Anaconda\lib\site-packages\cloudpickle\cloudpickle.py", line 1010, in save_file
raise pickle.PicklingError("Cannot pickle closed files")
_pickle.PicklingError: Cannot pickle closed files
Versions
- Spyder version: 4.0.1
- Python version: 3.6.7
- Qt version: 5.12.5
- PyQt5 version: 5.12.3
- Operating System: Windows 10
Dependencies
atomicwrites >=1.2.0 : 1.3.0 (OK)
chardet >=2.0.0 : 3.0.4 (OK)
cloudpickle >=0.5.0 : 1.2.2 (OK)
diff_match_patch >=20181111 : 20181111 (OK)
intervaltree : None (OK)
IPython >=4.0 : 7.11.1 (OK)
jedi =0.14.1 : 0.14.1 (OK)
nbconvert >=4.0 : 5.6.1 (OK)
numpydoc >=0.6.0 : 0.9.2 (OK)
pexpect >=4.4.0 : 4.7.0 (OK)
pickleshare >=0.4 : 0.7.5 (OK)
psutil >=0.3 : 5.6.7 (OK)
pygments >=2.0 : 2.5.2 (OK)
pylint >=0.25 : 2.4.4 (OK)
pyls >=0.31.2;<0.32.0 : 0.31.7 (OK)
zmq >=17 : 18.1.1 (OK)
qdarkstyle >=2.7 : 2.7 (OK)
qtawesome >=0.5.7 : 0.6.1 (OK)
qtconsole >=4.6.0 : 4.6.0 (OK)
qtpy >=1.5.0 : 1.9.0 (OK)
rtree >=0.8.3 : 0.9.3 (OK)
sphinx >=0.6.6 : 2.3.1 (OK)
spyder_kernels >=1.8.1;<2.0.0: 1.8.1 (OK)
watchdog : None (OK)
cython >=0.21 : 0.29.14 (OK)
matplotlib >=2.0.0 : 3.1.2 (OK)
numpy >=1.7 : 1.18.1 (OK)
pandas >=0.13.1 : 0.25.3 (OK)
scipy >=0.17.0 : 1.3.1 (OK)
sympy >=0.7.3 : 1.5.1 (OK)
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Spyder v4.1.0 release notes (2020-03-19) | LibHunt
Disable code folding and indent guides when files have more than 2000 ... Copy file reference in variable explorer generates PicklingError ...
Read more >OverflowError in Spyder variable explorer - Stack Overflow
I want to view a pandas dataframe in Spyder's Variable Explorer. When I click on the dataframe 'Name' in the Variable Explorer window,...
Read more >Changelog — Python 3.11.1 documentation
open_connection() raises, break reference cycles generated by local exception and future instances (which has exception instance as its member var). Patch by ...
Read more >A file copy operation fails when files or folders have long paths ...
You use Windows Explorer to try to copy files or folders in order to paste ... and generates a message that states that...
Read more >Variable Explorer — Spyder 5 documentation
The Variable Explorer allows you to interactively browse and manage the objects generated running your code. Spyder Variable Explorer execution with a ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@dalthviz, please solve this one by adding
PicklingError
on line102
of the file that appears below:https://github.com/spyder-ide/spyder/blob/cb9e8c1ad135ee65f1c62268c0a2ce2aab7e2514/spyder/plugins/ipythonconsole/widgets/namespacebrowser.py#L95-L103
So,
UnpicklingError
can be generated when Spyder is unable to deserialize the value that comes from the kernel; andPicklingError
when the kernel is unable to serialize the value Spyder is asking for.Good point - or remove copy option from context menu (for this data type)