[issue16938] pydoc confused by __dir__

2013-10-18 Thread koobs
koobs added the comment: Some test failures have cropped, I have attached buildbot logs and referenced them in #19030 -- nosy: +koobs ___ Python tracker ___

[issue16938] pydoc confused by __dir__

2013-10-18 Thread Ethan Furman
Ethan Furman added the comment: This has been fixed in #19030: every good object will have a home class; non-good objects (the result of buggy __dir__, __getattribute__, or __getattr__ methods) will not be returned and so cannot confuse pydoc. -- resolution: -> fixed stage: -> commit

[issue16938] pydoc confused by __dir__

2013-10-14 Thread Ethan Furman
Ethan Furman added the comment: Ronald, if you get a chance could you try your descriptor, without the __objclass__ work around, with the latest patch in #19030? -- ___ Python tracker _

[issue16938] pydoc confused by __dir__

2013-10-14 Thread Ethan Furman
Ethan Furman added the comment: Discovered a problem with one of the tests, moved back to issue19030. The __class__/__objclass__ is gone, the code is simpler. When issue19030 is committed I think we can make a doc change to include __objclass__ somewhere and close this one. -- stage:

[issue16938] pydoc confused by __dir__

2013-10-13 Thread Ethan Furman
Ethan Furman added the comment: That portion of classify_class_attrs now reads: else: homecls = getattr(get_obj, "__objclass__", None) if homecls not in possible_bases: # if the resulting object does not live somewhere in the # mro, drop it and go with

[issue16938] pydoc confused by __dir__

2013-10-13 Thread Nick Coghlan
Nick Coghlan added the comment: I want to kill the dance in inspect completely. Just use __objclass__ and document it appropriately. -- ___ Python tracker ___ ___

[issue16938] pydoc confused by __dir__

2013-10-13 Thread Ethan Furman
Ethan Furman added the comment: Nick Couphlan added the comment: > > No, __class__ on a descriptor has *NOTHING* to do with how it was > looked up. It's the class of the *result*. Which is why in most cases it's discarded as the home class. (I could easily be saying this wrong, which is why I

[issue16938] pydoc confused by __dir__

2013-10-13 Thread Nick Coghlan
Nick Coghlan added the comment: That means __objclass__ can have its meaning broadened to say "this is where this particular instance of this kind of object was defined", and that and __class__ are just coincidentally the same for Enum objects. We should *not* need to have any Enum specific co

[issue16938] pydoc confused by __dir__

2013-10-13 Thread Nick Coghlan
Nick Coghlan added the comment: However, setting __objclass__ on Enum members would be a perfectly reasonable thing to do. -- ___ Python tracker ___

[issue16938] pydoc confused by __dir__

2013-10-13 Thread Nick Coghlan
Nick Coghlan added the comment: No, __class__ on a descriptor has *NOTHING* to do with how it was looked up. It's the class of the *result*. >> property.__class__ >>> staticmethod.__class__ >>> classmethod.__class__ It's completely irrelevant to determining *where the attribute came from*.

[issue16938] pydoc confused by __dir__

2013-10-13 Thread Ethan Furman
Ethan Furman added the comment: 'None' is not an appropriate response to the "Where does this attribute come from" question. For one, it's wrong. For two, it breaks help. The current patch fixes that particular problem (as a last resort it walks the mro looking for the last class that report

[issue16938] pydoc confused by __dir__

2013-10-13 Thread Nick Coghlan
Nick Coghlan added the comment: Part of the issue 19030 patch was incorrect and we missed it in the review. Specifically, the else clause in this bit: try: get_obj = getattr(cls, name) except Exception as exc: pass else:

[issue16938] pydoc confused by __dir__

2013-10-10 Thread Ronald Oussoren
Ronald Oussoren added the comment: A problem with __objclass__ is that it is undocumented other than in PEP 252. That why I called it a workaround, at the time I created this issue I had just found the problem and workaround and as far as I knew __objclass__ was an undocumented feature of CPy

[issue16938] pydoc confused by __dir__

2013-10-06 Thread Ethan Furman
Ethan Furman added the comment: = class Boom: def __dir__(self): return ['BOOM'] def __getattr__(self, name): if name =='BOOM': return 42 return super().__getattr(name) help(Boom)

[issue16938] pydoc confused by __dir__

2013-09-06 Thread Ethan Furman
Ethan Furman added the comment: dir(obj) is only confused if it returns attributes that are not found in obj.__dict__ (aka virtual attributes). For these virtual attributes, setting __objclass__ solves the problem. Armin, when you say it's a workaround do you mean __objclass__ itself, or the

[issue16938] pydoc confused by __dir__

2013-09-06 Thread Ethan Furman
Ethan Furman added the comment: Ronald said: > One possible workaround: assume that the class is the inspected > class when a name returned by dir(cls) cannot be found in one of > the classes on the mro. At some point will this cause help to display an attribute on the wrong class? --

[issue16938] pydoc confused by __dir__

2013-09-06 Thread Armin Rigo
Armin Rigo added the comment: The __objclass__ is a workaround. I don't understand your point. I think the original poster is saying that simply putting a __dir__() method on a class can confuse help() more than would be necessary, and if he's correct I agree with him. -- _

[issue16938] pydoc confused by __dir__

2013-09-06 Thread Ethan Furman
Ethan Furman added the comment: "Crash" is probably too strong. help() runs, but doesn't return anything useful. Metaclasses aside, I think the real issue here is objects that don't have __objclass__ defined. __objclass__ has been around for over a decade (see PEP-0252), and with that `insp

[issue16938] pydoc confused by __dir__

2013-09-06 Thread Armin Rigo
Armin Rigo added the comment: I believe that this describes a problem more general than the problem of Enums from Issue18693: help(x) shouldn't crash in the presence of a __dir__() method that returns unexpected names. -- nosy: +arigo ___ Python tra

[issue16938] pydoc confused by __dir__

2013-09-04 Thread Ethan Furman
Ethan Furman added the comment: Issue18693 has a patch to `inspect` so that classify_class_attrs will also look in the metaclass. If that is accepted I think PyDoc is okay as is. -- ___ Python tracker ___

[issue16938] pydoc confused by __dir__

2013-09-03 Thread Ethan Furman
Ethan Furman added the comment: I wonder if it would be better to have inspect.classify_class_attrs be improved instead? -- ___ Python tracker ___ __

[issue16938] pydoc confused by __dir__

2013-09-02 Thread Ethan Furman
Changes by Ethan Furman : -- nosy: +eli.bendersky, ethan.furman ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue16938] pydoc confused by __dir__

2013-08-21 Thread Eric Snow
Changes by Eric Snow : -- nosy: +eric.snow ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.o

[issue16938] pydoc confused by __dir__

2013-01-11 Thread Ronald Oussoren
New submission from Ronald Oussoren: If a class implements __dir__ to also return a number of attributes that aren't present in the class __dict__ inspect.classify_class_attrs gets confused and assumes the home class is None. This in turn confused pydoc, docclass in pydoc assumes that the 'cla