[Patches] [ python-Patches-1520294 ] Support for PyGetSetDefs in pydoc, inspect, and types

SourceForge.net noreply at sourceforge.net
Thu Jul 20 05:18:19 CEST 2006


Patches item #1520294, was opened at 2006-07-10 18:45
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1520294&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Barry A. Warsaw (bwarsaw)
Assigned to: Barry A. Warsaw (bwarsaw)
Summary: Support for PyGetSetDefs in pydoc, inspect, and types

Initial Comment:
Attributes defined in extension modules via PyGetSetDef
aren't instances of property and aren't really handled
correctly in the above three modules.

This patch adds a types.GetSetterType an
inspect.isgetsetter() function, and support for
getsetters in pydoc, along with test cases and doc changes.

This patch should go into Python 2.5 and part of it
should get backported to Python 2.4.  Specifically the
support for PyGetSetDef in pydoc should be backported,
but it should be done in such a way as to not add
isgetsetter() or GetSetterType (fairly easy to do as
module globals in pydoc.py).

Mostly I'm looking for another set of eyes to proof my
changes.

----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2006-07-19 20:18

Message:
Logged In: YES 
user_id=33168

I know that Anthony has been busy.

I'm -0 on the patch moreso because of the added _types.c. 
It's not the code that I have a problem with, but the
direction we are going.  At various points, we've talked
about doing away with types.py.  This makes that a bit
messier.  it's a little like the idea of adding
__module_name__ at the last minute.  Once this is in, it's
next to impossible to remove if incorrect.  Also, I'm a
little concerned about how this affects other impls (PyPy,
IronPython, Jython).

Would you mind posting more of the impl details on py-dev
and see if anyone still has an opinion?  I don't recall any
support pro or con.  I suspect most don't really care and
few people have read the patch.  If you mention the impl
details, I don't know if that would change anything.

What is the impact of waiting?  These features have been in
since 2.2, right?  Also, unlike Tim's threading changes,
these can be exposed with a third party extension module
can't they?

----------------------------------------------------------------------

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2006-07-19 05:21

Message:
Logged In: YES 
user_id=12800

Thanks for the comments.

- I've changed it to GetSetDescriptorType
- 'data descriptor' is just what Python itself prints for
the type(getset_descriptor) so that's what I chose, but the
test should still be with isgetsetdescriptor().  Although
it's inconsistent with type(), I changed inspect.py's text
to read 'getset descriptor' since I think that's more accurate.
- I've changed false to \code{False} in the docs, but
libinspect.text uses "true" all over the place.  I am not
changing that. :)
- updated the test and tried to make it pass in other
implementations.

Since no one else has really commented either for or
against, and the RM hasn't pronounced, I'm going to take
silence as approval and commit these changes later today.

----------------------------------------------------------------------

Comment By: Georg Brandl (gbrandl)
Date: 2006-07-17 06:17

Message:
Logged In: YES 
user_id=849994

Looks fine, I noticed a few things:
- perhaps GetSet should be named GetSetDescriptor for
consistency with DataDescriptor and MemberDescriptor
- in pydoc, shouldn't "data descriptor" be tested with
"inspectisdatadescriptor"?
- in the docs, false should be False
- test_twelve should now be called test_thirteen ;) and the
comment in it should be adapted
- is the test suite expected to pass in implementations
without the newly tested descriptor types?

----------------------------------------------------------------------

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2006-07-13 09:05

Message:
Logged In: YES 
user_id=12800

Here's an updated patch with several improvements.  First,
the name is now GetSetType and isgetset().  Also, I've added
support for member descriptors with MemberDescriptorType and
ismemberdescriptor().  I've also added pydoc help for member
descriptors.  The appropriate things are done for
implementations other than CPython that don't have such
extension types.

This patch includes the usual docs and tests updates.

The other improvement is that rather than relying on
accidents of implementation in the C Python interpreter,
I've added a built-in _types module which implements
specifically the types that are needed.  This seems like the
best way to ensure that we have accurate types without tying
down future development of obscure other modules.

This may make it more difficult to backport to Python 2.4,
but that's a different concern.  Better to DTRT for Python
2.5 first.

Assigning back to Georg for another quick review, but feel
free to assign it back to me for final checkin (assuming
Anthony okays it).

----------------------------------------------------------------------

Comment By: Georg Brandl (gbrandl)
Date: 2006-07-11 00:04

Message:
Logged In: YES 
user_id=849994

Why not GetSet? Apart from that, the patch looks fine.

----------------------------------------------------------------------

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2006-07-10 20:07

Message:
Logged In: YES 
user_id=12800

Yeah, I went back and forth on that a few times.  GetSetter
was a poor compromise between GetSet and GetterSetter :)

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-07-10 19:57

Message:
Logged In: YES 
user_id=33168

I haven't looked at the patch, but the name seems a little
funny to me due to the lack of parallel names.  GetterSetter
makes more sense or the current GetSet.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1520294&group_id=5470


More information about the Patches mailing list