[issue29902] copy breaks staticmethod

2017-08-02 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you Benjamin.

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

___
Python tracker 

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



[issue29902] copy breaks staticmethod

2017-08-02 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 3dd1ccbb0950b2b83713a495958c35d60b453fa9 by Serhiy Storchaka in 
branch '2.7':
bpo-29902: Emit a Py3k deprecation warning when pickling or copying (#2823)
https://github.com/python/cpython/commit/3dd1ccbb0950b2b83713a495958c35d60b453fa9


--

___
Python tracker 

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



[issue29902] copy breaks staticmethod

2017-08-01 Thread Benjamin Peterson

Benjamin Peterson added the comment:

I don't think it's too important, though most py3k warnings have been
DeprecationWarning. You can think of it as deprecating a misfeature.

--

___
Python tracker 

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



[issue29902] copy breaks staticmethod

2017-08-01 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you Benjamin for your review!

But I have a design question. Is DeprecationWarning a correct warning type? 
DeprecationWarning is used when some feature less or more works in the current 
version, but will be removed in future releases. But pickling memoryview and 
staticmethod don't work and never worked correctly. A warning here is a sign 
that the code can not work as expected. Wouldn't RuntimeWarning be more 
appropriate warning type?

--

___
Python tracker 

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



[issue29902] copy breaks staticmethod

2017-07-27 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> benjamin.peterson
nosy: +benjamin.peterson

___
Python tracker 

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



[issue29902] copy breaks staticmethod

2017-07-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

But I think it is worth to add a check and emit a deprecation warning in Py3k 
mode in 2.7. 2.7 has longer support term than 3.5. And since it is less 
compatible with 3.6, it is harder to use 3.6 for testing 2.7 programs.

--
stage:  -> patch review

___
Python tracker 

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



[issue29902] copy breaks staticmethod

2017-07-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +2875

___
Python tracker 

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



[issue29902] copy breaks staticmethod

2017-07-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I have decided to not merge these changes in 3.5. They help to avoid 
programmatic errors, but have a non-zero chance of breaking programs that work 
by accidence. Since this is the last non-secure bugfix we will not have a 
chance to rollback these changes.

An alternative to these changes is testing a program with Python 3.6.

--
versions:  -Python 3.5

___
Python tracker 

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



[issue29902] copy breaks staticmethod

2017-04-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

If add just warnings we are free to add any warnings in 2.7 in Py3k compatible 
mode (option -3).

--

___
Python tracker 

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



[issue29902] copy breaks staticmethod

2017-04-16 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

I'd be very hesitant to add anything to 2.7 that changes (even broken) behavior 
here.  It might make more sense to backport the more strict checks to 3.5.  
OTOH, we can save people from all programming errors, and if warnings are 
basically ignored (plus, adding warnings *can* break things), then perhaps we 
should only document the limitations.

There's already some description of copy()'s limitations, so either add another 
warning there, or in the static method objects description in section 3.2

--

___
Python tracker 

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



[issue29902] copy breaks staticmethod

2017-04-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

What are your thoughts Barry? staticmethod, classmethod and property objects 
are incorrectly pickled in 2.7 and 3.5 (they are not pickleable in 3.6+). 
Making them not pickleable in 2.7 and 3.5 can help to catch programming errors.

But this can break the code that "just works" (actually works incorrectly) if 
it pickles or deepcopies complex objects containing staticmethod, classmethod 
or property objects, but never use it. Similar situation happened in issue22995 
with Cython objects.

Maybe emitting a warning rather than an exception would be safer? But 
deprecation warnings are ignored by default.

--

___
Python tracker 

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



[issue29902] copy breaks staticmethod

2017-03-31 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This issue was fixed by issue22995 in 3.6. But for some reasons the general 
solution was not applied to 3.5 and 2.7. Proposed patch makes staticmethod, 
classmethod and property descriptors explicitly non-pickleable (as was made 
explicitly non-pickleable file-like object) in 3.5. Only tests will be 
foreported to 3.6 and 3.7.

--

___
Python tracker 

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



[issue29902] copy breaks staticmethod

2017-03-31 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +822

___
Python tracker 

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



[issue29902] copy breaks staticmethod

2017-03-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Copying and pickling of staticmethod objects are not supported. Starting from 
3.6 this raises an exception (see issue22995).

>>> bar.y = copy(staticmethod(foo))
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/serhiy/py/cpython3.6/Lib/copy.py", line 96, in copy
rv = reductor(4)
TypeError: can't pickle staticmethod objects

--
components: +Interpreter Core
nosy: +alexandre.vassalotti, barry, serhiy.storchaka
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



[issue29902] copy breaks staticmethod

2017-03-25 Thread Bruce Frederiksen

New submission from Bruce Frederiksen:

Doing a copy on a staticmethod breaks it:

Python 3.5.2 (default, Nov 17 2016, 17:05:23) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from copy import copy
>>> def foo(): pass
... 
>>> class bar: pass
... 
>>> bar.x = staticmethod(foo)
>>> bar.x.__name__
'foo'
>>> bar.y = copy(staticmethod(foo))
>>> bar.y.__name__
Traceback (most recent call last):
  File "", line 1, in 
RuntimeError: uninitialized staticmethod object

--
components: Library (Lib)
messages: 290481
nosy: dangyogi
priority: normal
severity: normal
status: open
title: copy breaks staticmethod
type: behavior
versions: Python 3.5

___
Python tracker 

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