[issue21986] Idle: disable pickleability of user code objects

2014-10-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> PyShell imports non-idlelib modules, including re, before idlelib modules,
> such as rpc. So the re addition is there, though I strongly doubt that
> compiled regexs are every sent to the user process. 

But we can't guarantee that this alway will be so. Other stdlib modules can 
register picklers, and IDLE can import them in future. This code is not 
protected against future changes in other places of the code.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21986] Idle: disable pickleability of user code objects

2014-10-12 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I agree that a test for dumps would be a good idea.  Ditto for hundreds of 
other untested functions.  I don't see this one as a priority.

PyShell imports non-idlelib modules, including re, before idlelib modules, such 
as rpc.  So the re addition is there, though I strongly doubt that compiled 
regexs are every sent to the user process.  Since about 10 different messages 
of different types are sent as part of startup, the fact that Idle does start 
is strong evidence that dumps and much of the rest of rpc is ok.  I would start 
a test of rpc by documenting the protocol and listing the messages types so at 
least one of each could be tested.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21986] Idle: disable pickleability of user code objects

2014-10-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

It would be good to add a test of rpc.dumps().

Current code copies copyreg.dispatch_table at the moment of rpc import. But it 
can be changed later and these change will not affect private copy. For example 
the re module adds pickleability of compiled regex patterns. I think the use 
of ChainMap is more safe solution.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21986] Idle: disable pickleability of user code objects

2014-10-10 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Code objects get wrapped in 3 tuple layers before being 'pickled', so a private 
dispatch is the easiet solution.  Since copyreg.dispatch_table has only two 
items to copy, I pushed a version of the first patch.  Since private dispatch 
tables are new in 3.3 and not in 2.7, I withdraw the idea of patching 2.7.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions:  -Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21986] Idle: disable pickleability of user code objects

2014-10-10 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
assignee:  -> terry.reedy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21986] Idle: disable pickleability of user code objects

2014-10-10 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 90c62e1f3658 by Terry Jan Reedy in branch '3.4':
Issue #21986: Idle now matches interpreter in not pickling user code objects.
https://hg.python.org/cpython/rev/90c62e1f3658

New changeset cb94764bf8be by Terry Jan Reedy in branch 'default':
Merge with 3.4: #21986, don't pickle user code objects.
https://hg.python.org/cpython/rev/cb94764bf8be

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21986] Idle: disable pickleability of user code objects

2014-10-09 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Wanting to make sure that a patch does not break Idle makes perfect sense to 
me.  As it turns out, running *any* code from the editor (even empty) works for 
these patches.  Idle compiles the code to a code object *in the Idle process* 
and if no compile errors, ships the code object to the user process via rpc to 
be executed in the user process.  I comfirmed this with a print inside 
pickle_code.  With this clear, I have downloaded both patches to test on 2.7 
and 3.4.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21986] Idle: disable pickleability of user code objects

2014-10-09 Thread Claudiu Popa

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21986] Idle: disable pickleability of user code objects

2014-10-09 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
title: Pickleability of code objects is inconsistent -> Idle: disable 
pickleability of user code objects

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21986] Idle: disable pickleability of user code objects

2014-10-09 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
title: Pickleability of code objects is inconsistent -> Idle: disable 
pickleability of user code objects

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com