[issue25757] Subclasses of property lose docstring

2016-05-02 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the patch, Torsten. This is a duplicate of issue 24766. Your patch 
is almost identical (except the behavior change) to the patch in issue 24766. I 
will adapt your test and attribute your name in commit message.

--
resolution:  -> duplicate
stage: patch review -> resolved
status: open -> closed
superseder:  -> Subclass of property doesn't preserve instance __doc__ when 
using doc= argument

___
Python tracker 

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



[issue25757] Subclasses of property lose docstring

2015-12-11 Thread Berker Peksag

Berker Peksag added the comment:

fix_repetitions.diff was unrelated to this issue so subprop_doc_r2.diff still 
needs to be reviewed.

--

___
Python tracker 

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



[issue25757] Subclasses of property lose docstring

2015-12-11 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Can this be closed now or is there work left to be done?

--
nosy: +rhettinger

___
Python tracker 

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



[issue25757] Subclasses of property lose docstring

2015-12-11 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for fix_repetitions.diff, Torsten. The test_property failure was 
discussed in issue 25755.

--
nosy: +berker.peksag

___
Python tracker 

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



[issue25757] Subclasses of property lose docstring

2015-12-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset cc1aa0e88626 by Berker Peksag in branch '3.5':
Issue #25755: Move PropertyWritableDoc into the test case
https://hg.python.org/cpython/rev/cc1aa0e88626

New changeset 8f52c9d72d9f by Berker Peksag in branch 'default':
Issue #25755: Move PropertyWritableDoc into the test case
https://hg.python.org/cpython/rev/8f52c9d72d9f

--
nosy: +python-dev

___
Python tracker 

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



[issue25757] Subclasses of property lose docstring

2015-11-28 Thread Emanuel Barry

Emanuel Barry added the comment:

Looking at it again, it appears you didn't have to decref it; my bad.

Both patches LGTM.

--

___
Python tracker 

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



[issue25757] Subclasses of property lose docstring

2015-11-28 Thread Torsten Landschoff

Torsten Landschoff added the comment:

Prompted by Emanuel's comment I ran the test with repetitions. This does not 
actually test his assertion that I missed a decref since he referred to the 
error case when setting the __doc__ key of the instance dict fails. But I was 
curious none the less.

I was shocked that this failed with

```
torsten@defiant:~/mirror/cpython$ make test TESTOPTS="-R 3:2 test_property"
...
test test_property failed -- Traceback (most recent call last):
  File "/home/torsten/mirror/cpython/Lib/test/test_property.py", line 172, in 
test_property_decorator_doc_writable
self.assertEqual(sub.__class__.spam.__doc__, 'Eggs')
AssertionError: 'Spam' != 'Eggs'
```

But this was not introduced by my changes, rather it is an existing bug in the 
tests: test_property_decorator_doc_writable modifies a class created on module 
level so the second repetition sees the already updated class.

fix_repetitions.diff contains a fix for this problem (by defining the class 
locally in the test method).

While at it I introduced a refleak on purpose and this is correctly reported by 
the tests. Good to know how to test for this :-)

--
Added file: http://bugs.python.org/file41183/fix_repetitions.diff

___
Python tracker 

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



[issue25757] Subclasses of property lose docstring

2015-11-28 Thread Torsten Landschoff

Changes by Torsten Landschoff :


Added file: http://bugs.python.org/file41181/subprop_doc_r2.diff

___
Python tracker 

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



[issue25757] Subclasses of property lose docstring

2015-11-27 Thread Emanuel Barry

Emanuel Barry added the comment:

Pointed out a refleak and a small nit.

--
nosy: +ebarry
stage:  -> patch review

___
Python tracker 

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



[issue25757] Subclasses of property lose docstring

2015-11-27 Thread Torsten Landschoff

Torsten Landschoff added the comment:

Just a note about the patch: I changed the behaviour a bit in that the code 
does not ignore random exceptions while getting getter.__doc__.

I think that would be surprising for most users and it also does not match the 
application of the doc field to the subclass, where exceptions are propagated.

--

___
Python tracker 

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



[issue25757] Subclasses of property lose docstring

2015-11-27 Thread Torsten Landschoff

Torsten Landschoff added the comment:

Here is a proposed patch to correct this including regression tests.

--
keywords: +patch
Added file: http://bugs.python.org/file41176/subprop_doc.diff

___
Python tracker 

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



[issue25757] Subclasses of property lose docstring

2015-11-27 Thread Torsten Landschoff

New submission from Torsten Landschoff:

I actually found this in Python2, but it is still unchanged in Python 3.6 dev. 
Namely, creating an instance of a class derived from property will drop the 
docstring passed explicitly to the constructor: 

torsten@defiant:~$ python3.6
Python 3.6.0a0 (default:9fcfdb53e8af, Nov 27 2015, 23:11:09) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> property(doc="Hello world").__doc__
'Hello world'
>>> class SubProp(property): pass
... 
>>> SubProp(doc="Hello world").__doc__
>>>

This war surprising to me. I actually used a subclass of property to describe 
fields of configuration classes with extensive documentation, which disappeared 
during runtime.

In Python2 I work around this by assigning to __doc__ as the last thing in the 
constructor of my SubProp class.

--
components: Interpreter Core
messages: 255511
nosy: torsten
priority: normal
severity: normal
status: open
title: Subclasses of property lose docstring
type: behavior
versions: Python 3.6

___
Python tracker 

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