Claudiu Popa added the comment:

Thank you for your feedback, Terry.

1. IDLE is behaving differently than the builtin interpreter. It should be 
higher priority, because it
leads beginners into believing that code objects are picklable.

2. No, wrapping code objects in a CodePickler with __getstate__ et al will not 
work. What is important in my implementation of CodePickler is that the 
dispatch_table is private, so it will not leak private reduction function, as 
it happens right now.

3. That doesn't make sense. What works now is pickling of code objects, 
removing the copyreg call, without my patch, will break the rpc as well. To 
test this, comment the copyreg.pickle call in idlelib.rpc and just define a 
function in IDLE, you'll get a PicklingError. I added a small test file, which 
can be used to test what happens now and what happens after my patch.

4. Better, here's a traceback which can explain from where codes are sent. The 
traceback is from inside pickle_code, using code.InteractiveInterpreter.

 File "C:\Python34\lib\idlelib\PyShell.py", line 1602, in main
   root.mainloop()
 File "C:\Python34\lib\tkinter\__init__.py", line 1069, in mainloop
   self.tk.mainloop(n)
 File "C:\Python34\lib\tkinter\__init__.py", line 1487, in __call__
   return self.func(*args)
 File "C:\Python34\lib\idlelib\MultiCall.py", line 179, in handler
   r = l[i](event)
 File "C:\Python34\lib\idlelib\PyShell.py", line 1188, in enter_callback
   self.runit()
 File "C:\Python34\lib\idlelib\PyShell.py", line 1229, in runit
   more = self.interp.runsource(line)
 File "C:\Python34\lib\idlelib\PyShell.py", line 671, in runsource
   return InteractiveInterpreter.runsource(self, source, filename)
 File "C:\Python34\lib\code.py", line 74, in runsource
   self.runcode(code)
 File "C:\Python34\lib\idlelib\PyShell.py", line 762, in runcode
   (code,), {})
 File "C:\Python34\lib\idlelib\rpc.py", line 256, in asyncqueue
   self.putmessage((seq, request))
 File "C:\Python34\lib\idlelib\rpc.py", line 348, in putmessage
   s = pickle.dumps(message)

----------
Added file: http://bugs.python.org/file36855/test.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21986>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to