Problem with copy the Variable with sys.stdout
See original GitHub issueDescription
What steps will reproduce the problem?
import sys
Temp = sys.stdout
I try to copy the variable “Temp”
Traceback
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1037, in copy
obj = self.delegate.get_value(idx)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1386, in get_value
return self.parent().get_value(name)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 1439, in get_value
value = self.shellwidget.get_value(name)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\ipythonconsole\widgets\namespacebrowser.py", line 99, in get_value
timeout=CALL_KERNEL_TIMEOUT).get_value(name)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\comms\commbase.py", line 542, in __call__
call_dict, call_data, self._comm_id)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\ipythonconsole\comms\kernelcomm.py", line 114, in _get_call_return_value
call_dict, call_data, comm_id)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\comms\commbase.py", line 420, in _get_call_return_value
return self._sync_error(reply['value'])
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\comms\commbase.py", line 480, in _sync_error
error_wrapper.raise_error()
File "C:\ProgramData\Anaconda3\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:\ProgramData\Anaconda3\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:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\comms\commbase.py", line 376, in _set_call_return_value
comm_id=self.calling_comm_id)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\comms\commbase.py", line 245, in _send_message
data, protocol=self._comms[comm_id]['pickle_protocol'])]
File "C:\ProgramData\Anaconda3\lib\site-packages\cloudpickle\cloudpickle.py", line 1148, in dumps
cp.dump(obj)
File "C:\ProgramData\Anaconda3\lib\site-packages\cloudpickle\cloudpickle.py", line 491, in dump
return Pickler.dump(self, obj)
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 437, in dump
self.save(obj)
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 549, in save
self.save_reduce(obj=obj, *rv)
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 662, in save_reduce
save(state)
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 504, in save
f(self, obj) # Call unbound method with explicit self
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 859, in save_dict
self._batch_setitems(obj.items())
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 885, in _batch_setitems
save(v)
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 549, in save
self.save_reduce(obj=obj, *rv)
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 662, in save_reduce
save(state)
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 504, in save
f(self, obj) # Call unbound method with explicit self
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 859, in save_dict
self._batch_setitems(obj.items())
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 885, in _batch_setitems
save(v)
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 504, in save
f(self, obj) # Call unbound method with explicit self
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 859, in save_dict
self._batch_setitems(obj.items())
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 885, in _batch_setitems
save(v)
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 549, in save
self.save_reduce(obj=obj, *rv)
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 662, in save_reduce
save(state)
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 504, in save
f(self, obj) # Call unbound method with explicit self
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 859, in save_dict
self._batch_setitems(obj.items())
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 885, in _batch_setitems
save(v)
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 504, in save
f(self, obj) # Call unbound method with explicit self
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 859, in save_dict
self._batch_setitems(obj.items())
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 885, in _batch_setitems
save(v)
File "C:\ProgramData\Anaconda3\lib\pickle.py", line 524, in save
rv = reduce(self.proto)
File "stringsource", line 2, in zmq.backend.cython.context.Context.__reduce_cython__
TypeError: no default __reduce__ due to non-trivial __cinit__
Versions
- Spyder version: 4.0.1
- Python version: 3.7.6
- Qt version: 5.9.6
- PyQt5 version: 5.9.2
- 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.3.0 (OK)
diff_match_patch >=20181111 : 20181111 (OK)
intervaltree : None (OK)
IPython >=4.0 : 7.12.0 (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.8.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.8 (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.4.0 (OK)
spyder_kernels >=1.8.1;<2.0.0: 1.8.1 (OK)
watchdog : None (OK)
cython >=0.21 : 0.29.15 (OK)
matplotlib >=2.0.0 : 3.1.3 (OK)
numpy >=1.7 : 1.18.1 (OK)
pandas >=0.13.1 : 1.0.1 (OK)
scipy >=0.17.0 : 1.4.1 (OK)
sympy >=0.7.3 : 1.5.1 (OK)
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Problems with deepcopying sys.stdout in python
I have the following problem with copy.deepcopy. It is to do with deepcopying sys.stdout import sys, copy class Example: def __init__(self, ...
Read more >How to print to stderr and stdout in Python?
Method 1: Using Python stderr. It is comparable to stdout in that it likewise prints straight to the console, but the key distinction...
Read more >Store standard output on a variable in Python
This is a great, hacky trick to get the standard output ( and others like standard error and standard input) in Python.
Read more >Write Python stdout to file immediately
This is happening because normally when process STDOUT is redirected to something other than a terminal, then the output is buffered into some ......
Read more >why sys.stdout returned null · Issue #370 · pythonnet ...
Howerver, Exception is throw when assigning sys.stdout because variable output is not of type PyObject. Make the Output class inherit from ...
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
Yes, I think you are right and in this case the stdout is a stream and not a String so I think it we can pass the error and inform the user that Spyder is not able to copy this variable
Great advice @steff456! I also agree with that solution.