Message234171
| Author |
Claudiu.Popa |
| Recipients |
Claudiu.Popa, eric.araujo, eric.snow, ncoghlan, yselivanov |
| Date |
2015年01月17日.15:19:58 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1421507998.94.0.569269484538.issue15582@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Yury, regarding your last message, is it actually possible to have a subclass which doesn't have a __doc__ attribute in its __dict__, except using slots? __doc__ seems to be set to None every time if it's not specified, so I don't know how could I detect the case where the client sets '__doc__ = None' himself.
The following example might be more explanatory:
>>> class A:
... __doc__ = "a"
...
>>> inspect.getdoc(A)
'a'
>>> inspect.getdoc(A())
'a'
>>> class B(A):
... __doc__ = None
...
>>> vars(B)
mappingproxy({'__doc__': None, '__module__': '__main__'})
>>> B.__dict__
mappingproxy({'__doc__': None, '__module__': '__main__'})
>>> class C(A): pass
...
>>> vars(C)
mappingproxy({'__doc__': None, '__module__': '__main__'})
>>>
Nevertheless, my patch ignores this case, since it operates only on methods. When trying to do inspect.getdoc(Child, parent=Parent), it will try to look for an attribute 'Child' in the mro of Parent and thus it will return None, since this doesn't exist (this can actually be a problem, if that attribute actually exist). |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2015年01月17日 15:19:58 | Claudiu.Popa | set | recipients:
+ Claudiu.Popa, ncoghlan, eric.araujo, eric.snow, yselivanov |
| 2015年01月17日 15:19:58 | Claudiu.Popa | set | messageid: <1421507998.94.0.569269484538.issue15582@psf.upfronthosting.co.za> |
| 2015年01月17日 15:19:58 | Claudiu.Popa | link | issue15582 messages |
| 2015年01月17日 15:19:58 | Claudiu.Popa | create |
|