Ethan Furman added the comment:
Two issues still remain:
- custom behavior, as well as value and name, don't show in help
- value and name, if defined as enum members, show up as data
descriptors in help
Roundup Robot added the comment:
New changeset 353ced6ae182 by Ethan Furman in branch 'default':
Close #18693: Enum is now more help() friendly.
http://hg.python.org/cpython/rev/353ced6ae182
--
resolution: - fixed
stage: patch review - committed/rejected
status: open - closed
Ethan Furman added the comment:
Tracking inspect in issue19030.
Tracking help in issue19031.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18693
___
Ethan Furman added the comment:
Okay, here's the patch after the inspect portion was committed in #18929.
Summary:
- added __objclass__ to each enum member
- added __module__ to the class dir
- aded any extra methods defined to the instance dir
- changed _RouteClassAttributeToGetattr to
Ethan Furman added the comment:
Found it!
It was a combination of __objclass__ not being defined on the enum mmebers, and
the metatype not being searched in the __mro__ by inspect. Thanks, Ronald, for
the necessary clues.
Patch attached.
I'm not sure if I have the method wowser showing up
Eli Bendersky added the comment:
Great, Ethan.
I'd say the inspect fix has to be reviewed and committed separately. Maybe
#16938 is the right place to post the patch for it. Once that's in, we can
review/commit the enum parts.
--
___
Python
Ethan Furman added the comment:
help() won't really be fixed with the inspect patch. If no objections within a
few hours I'll open a new issue for it.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18693
Ronald Oussoren added the comment:
That help() is confused by __dir__ is documented in #16938.
AFAIK help is fairly fragile in its expectations of the attributes present on
classes and the correspondence between dir(cls) and list(cls.__dict__), and
that is something that could be fixed in
Eli Bendersky added the comment:
Do we have enough evidence to open a new bug vs. help() ?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18693
___
Ethan Furman added the comment:
I've done some more investigation today but I can't tell if the issue is solely
in help or if it's some wierd
interaction between help and _EnumMeta.
--
___
Python tracker rep...@bugs.python.org
Eli Bendersky added the comment:
On Sun, Sep 1, 2013 at 5:29 PM, Ethan Furman rep...@bugs.python.org wrote:
Ethan Furman added the comment:
I've done some more investigation today but I can't tell if the issue is
solely in help or if it's some wierd
interaction between help and _EnumMeta.
Ethan Furman added the comment:
Nope, not yet. And even a simple dummy metaclass with a custom __dir__ worked
fine.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18693
___
Ethan Furman added the comment:
What I know for sure:
1) if something is added to dir() that does not live in __dict__, help()
breaks.
2) if a certain something or some things are removed from dir(), help()
breaks. I'm not yet certain which somethings
apply here.
--
Ethan Furman added the comment:
Huh. I just checked `help(Color)` on my proposed __dir__ and got the two-line,
rather useless, response. Perhaps help() is broken with all custom __dir__s.
--
___
Python tracker rep...@bugs.python.org
Eli Bendersky added the comment:
Ethan, please revert your commit first. I liked the previous dir. The current
one is useless.
I think you may be right about help, but I didn't dig deep enough to be sure.
--
___
Python tracker
Changes by Ronald Oussoren ronaldousso...@mac.com:
--
nosy: +ronaldoussoren
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18693
___
___
Roundup Robot added the comment:
New changeset 39697dcd97e3 by Ethan Furman in branch 'default':
Issue 18693: Put custom __dir__ back in place. Will instead look at fixing
`help()`.
http://hg.python.org/cpython/rev/39697dcd97e3
--
___
Python
Ned Deily added the comment:
Ethan, http://www.python.org/dev/peps/pep-0429/#release-schedule
TL;DR - no new features after beta 1 (2013-11-24), no non-release-critical bug
fixes after rc1 (2014-01-19)
--
nosy: +ned.deily
___
Python tracker
Eli Bendersky added the comment:
Ethan, as Ned said (and I think you got this answer in the list before), the
real feature cutoff is Beta 1. So we have time until the end of November. Note
that even new PEPs (like the statistics one) can go in before that. Even after
beta, things that appear
Ethan Furman added the comment:
So what do we want Enum's __dir__ to report?
Normally we see things like __eq__, __dict__, __getnewargs__, etc.
For IntEnum there would be __abs__, __floor__, __div__, etc.
Do we want to worry about those kinds of differences? I think we do.
And if we do,
Roundup Robot added the comment:
New changeset 5d417257748e by Ethan Furman in branch 'default':
Close #18693: __dir__ removed from Enum; help() now helpful.
http://hg.python.org/cpython/rev/5d417257748e
--
nosy: +python-dev
resolution: - fixed
stage: - committed/rejected
status: open
Eli Bendersky added the comment:
Less than two days passed since this issue was opened. No waiting for feedback?
No patch? No code review?
Maybe there's another solution? Personally I find dir() often more useful than
help(). Maybe help() can be adapted to behave nicely for classes with
Ethan Furman added the comment:
Sorry, sorry.
Long week, felt like more than two days, mild sense of unease and stress due to
non-functioning Release Schedule on python.org, and wanting to get Enum used
/somewhere/ in the stdlib before 3.4 is locked down.
Making help() better would be a
New submission from Ethan Furman:
help(), when used on an enum member or class, returns almost nothing. I
suspect the custom __dir__ is at fault, but whatever is causing the problem
needs fixing.
--
assignee: ethan.furman
messages: 194714
nosy: barry, eli.bendersky, ethan.furman
Ethan Furman added the comment:
With custom __dir__:
Help on class Enum in module enum:
Enum = enum 'Enum'
Without custom __dir__:
Help on class Enum in module enum:
class Enum(builtins.object)
| Generic enumeration.
|
| Derive
25 matches
Mail list logo