Nick Coghlan added the comment:
Note that tp_new is a static method, not a class method (the type creation
machinery takes care of passing in the right class rather than the
descriptor machinery)
--
___
Python tracker rep...@bugs.python.org
Larry Hastings added the comment:
Note that tp_new is a static method, not a class method (the type
creation machinery takes care of passing in the right class rather
than the descriptor machinery)
I admit I didn't know that.
But from a practical perspective, surely you agree that tp_new
Nick Coghlan added the comment:
It doesn't act like a class method, though, it acts like a static method:
int.__new__()
Traceback (most recent call last):
File stdin, line 1, in module
TypeError: int.__new__(): not enough arguments
int.__new__(int)
0
You have to
Nick Coghlan added the comment:
(Also, I can't give you a solid reason for *why* it's like that - Guido just
wrote it that way, and the type machinery is hairy enough that I have no
intentions of second guessing him on that one)
--
___
Python
Nick Coghlan added the comment:
Oh, yes, now I remember - it *has* to be that way, otherwise upcalls from
subclass __new__ methods don't do the right thing (int.__new__(MyInt), etc),
just as you need to pass the current type in explicitly for cooperative super
calls. This is perhaps *the*
Larry Hastings added the comment:
Okay, one more diff. I have high hopes for this, but then I had high hopes
yesterday.
Nick, could you review the PyTypeObject changes in this patch? Obviously I'd
love a review of the whole thing, but if you can only make a little time, the
crucial part is
Nick Coghlan added the comment:
Scanned the whole patch, especially the type changes. This looks like a solid
approach to me.
For 3.5, PEP 457 might want to consider proposing a tp_sig slot and splitting
the signature out at type creation time rather than on attribute lookup. The
current
Larry Hastings added the comment:
Okay, I'm checking this beast in. Hooray! Thanks for your reviews, everybody!
--
I thought it was still possible to introduce objects into Python at runtime
without calling PyType_Ready on their type. If that's true,
then there wouldn't necessarily *be* a
Nick Coghlan added the comment:
There are probably still ways to do it, but we don't *support* doing it (and
I'm pretty sure we've fixed them all in the builtins and stdlib).
However, yes, that's another good reason to be conservative in only doing the
split into signature+doc at attribute
Larry Hastings added the comment:
I just realized, I forgot to fix the bug Zach reported, where help(bound_thing)
should still show the class or self parameter.
I'm going to check this in anyway, and file a fresh bug on myself to
address that.
--
Larry Hastings added the comment:
Phew! Thanks again, everybody!
--
resolution: - fixed
stage: needs patch - committed/rejected
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20189
Roundup Robot added the comment:
New changeset 85710aa396ef by Larry Hastings in branch 'default':
Issue #20189: Four additional builtin types (PyTypeObject,
http://hg.python.org/cpython/rev/85710aa396ef
--
nosy: +python-dev
___
Python tracker
Larry Hastings added the comment:
At last, my refreshed patch. Changes from the previous patch:
* Had another mildly bright idea. The name PyTypeObject *cls
is a holdover from Python 2.2 days, before the merging of classes
and types. Now they're both the same thing and the official name
Zachary Ware added the comment:
Ok, I found the source of the real issue alluded to in the misguided comment
about the 'cls' - 'type' change that I left on Rietveld.
I was under the impression that with that change, 'help(datetime.datetime.now)'
would show a signature of 'now(type, tz=None)'.
Larry Hastings added the comment:
I'm happy to resolve it before checking in the patch.
A small delta like that doesn't need a full-on review.
If people said eww then I'll back it out. Nobody said eww
to the PyModuleDef *module change (see below), and I'm not
here to pick a fight.
But let's
Larry Hastings added the comment:
A little more on consistency and inconsistency.
I count 109 tp_new callback functions in CPython, and they overwhelmingly call
the first parameter PyTypeObject *type (93 instances). In second place is
PyObject *self (9 instances), which is flat-out wrong.
I
Larry Hastings added the comment:
Argh. I lost 1.5 day's worth of work on revision 6 of this patch last
night, due to me being tired and over-aggressively cleaning my working
directories. I will have to reconstruct it from memory, hopefully
Tuesday. (I basically know what I did, and going
Larry Hastings added the comment:
Here is the hopefully-final patch for this issue. I incorporated the suggested
changes from Zachary Ware. Also I fixed some cls parameters that were
leaking into the signatures. I think this is ready for checkin!
--
Added file:
Zachary Ware added the comment:
Problems 1 (ValueError from help(os)) and 2 ('module' as first param) were
simple fixes:
The attached patch fixes problem 1 (and is probably worth doing anyway, since
inspect.signature has the ability to raise ValueError, and (IMO) help(module)
should never
Larry Hastings added the comment:
Your fixes for #1 and #2 were fine, I've incorporated them into the patch.
I'll update the diff after I've added the tests Nick suggested.
The assertion failure in #3 will also be gone, replaced with a failure:
You can't have two parameters named module!
Zachary Ware added the comment:
Larry Hastings added the comment:
Once I've done that, it'd be easy to make it also rename the secret self
converter name to _module or something. Anyway, long story short, let's
not try to fix #3 in this patch.
That sounds fine. _winapi is the only place
Guido van Rossum added the comment:
Now looking. Note that a few parts of the patch no longer cleanly apply:
hg import --no-c http://bugs.python.org/review/download/issue20189_10572.diff
applying http://bugs.python.org/review/download/issue20189_10572.diff
patching file Modules/_cursesmodule.c
Larry Hastings added the comment:
Updating / merging / resolving now, but it will take me a few minutes.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20189
___
Larry Hastings added the comment:
Here's a fresh patch against trunk. It applies cleanly against current tip
(725bc24f5492).
--
Added file:
http://bugs.python.org/file33517/larry.support.text_signature.on.more.types.diff.4.txt
___
Python tracker
Changes by Zachary Ware zachary.w...@gmail.com:
--
nosy: +zach.ware
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20189
___
___
Python-bugs-list
Guido van Rossum added the comment:
I limited myself to the four files you mentioned, and they look totally fine.
Together with Nick's view you should have enough core review now, right?
--
___
Python tracker rep...@bugs.python.org
Larry Hastings added the comment:
I do. Thanks for your time!
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20189
___
___
Python-bugs-list
Zachary Ware added the comment:
A few issues with this patch:
1) help(os) raises ValueError
Traceback (most recent call last):
File stdin, line 1, in module
File P:\ath\to\cpython\lib\_sitebuiltins.py, line 99, in __call__
return pydoc.help(*args, **kwds)
File
Larry Hastings added the comment:
Whoever does the review, could you post here? I feel bad enough asking y'all,
maybe we don't need multiple people doing it ;-)
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20189
Nick Coghlan added the comment:
Looking now.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20189
___
___
Python-bugs-list mailing list
Nick Coghlan added the comment:
Larry clarified that the signature(min) change in this patch was actually
restoring the Python 3.3 behaviour, so I think with the addition of some
relevant test cases to the test suite, go for it :)
--
___
Python
Larry Hastings added the comment:
Nick, could you maybe review this?
--
nosy: +ncoghlan
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20189
___
Larry Hastings added the comment:
Dang it, I forgot to add the second patch. Here it is.
--
Added file:
http://bugs.python.org/file33467/larry.support.text_signature.on.more.types.diff.2.txt
___
Python tracker rep...@bugs.python.org
Larry Hastings added the comment:
Updated the patch. (Diff #2 apparently didn't apply cleanly, so we didn't get
a review link.)
Old-guard core devs: I'm *really* desperate for a review of this patch. You
don't have to review everything thing, just these files:
* Include/object.h
*
Larry Hastings added the comment:
Okay, life has gotten even more complicated.
In another issue (#20172) Zachary Ware pointed out that Argument Clinic needs
to generate self parameters in the text string. But this complicates life
for inspect.Signature, which needs to not publish the self
Yury Selivanov added the comment:
But this complicates life for inspect.Signature, which needs to not publish
the self parameter when it's been bound.
That's already supported, isn't it?
str(inspect.signature(F.a))
'(self, a)'
str(inspect.signature(F().a))
'(a)'
--
Larry Hastings added the comment:
Not for builtins.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20189
___
___
Python-bugs-list mailing list
Stefan Krah added the comment:
Another issue is that with the patch applied help() is broken for certain forms
of docstrings:
from decimal import *
print(setcontext.__doc__)
setcontext(c) - Set a new default context.
help(setcontext)
Traceback (most recent call last):
File stdin, line 1,
Larry Hastings added the comment:
Here's an updated patch. I tried to do it right which wound up being a huge
amount of work in Clinic. The actual change to inspect.Signature was really
easy, once I understood everything.
The churn in the .c files is because Clinic now uses the self
Larry Hastings added the comment:
Another issue is that with the patch applied help() is broken for
certain forms of docstrings:
Yeah. We discussed this briefly in #19674. I wanted to use a marker that
wasn't The Convention That People Have Used For Decades but I felt overruled.
I want
Yury Selivanov added the comment:
Larry, just a small thing.. Could you please add something like Parameter =
cls._parameter_cls in the from_builtin method? (see the discussion in #17373)
--
___
Python tracker rep...@bugs.python.org
Yury Selivanov added the comment:
Larry,
Congrats on the amazing job you did with the arguments clinic.
And if you need any assistance with 'inspect.signature' I'd be glad to help.
--
nosy: +yselivanov
___
Python tracker rep...@bugs.python.org
Larry Hastings added the comment:
Yury: Thanks! I don't need any help right now though--just a review on this
patch ;-)
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20189
___
Stefan Krah added the comment:
Thanks, this is working here for the parameters. Is there a way to
specify the return annotation manually in the docstring?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20189
Larry Hastings added the comment:
Yes, it's just Python syntax, so you'd use -. However, you are not
permitted to according to PEP 8:
The Python standard library will not use function annotations as that would
result in a premature commitment to a particular annotation style.
--
Stefan Krah added the comment:
Yes, it's just Python syntax, so you'd use -.
I tried that, but it didn't filter through to inspect.signature().
However, you are not permitted to according to PEP 8:
Ah, too bad. Return annotations are nice.
--
New submission from Larry Hastings:
Stefan added some docstring text signatures by hand, only to discover that
inspect.Signature still didn't recognize them. Specifically,
decimal.Decimal.compare was unrecognized. This is a method_descriptor object,
which is a type that isn't even exposed
Larry Hastings added the comment:
Okay, learned some things.
1) inspect already has an ismethoddescriptor(). So I'll try to do this
properly by
2) The real problem is that method_descriptor doesn't have __text_signature__.
I only added that to PyCFunctionObject. I'll make the code
Changes by Meador Inge mead...@gmail.com:
--
nosy: +meador.inge
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20189
___
___
Python-bugs-list
Larry Hastings added the comment:
Here's a patch that adds __text_signature__ support for three more builtin
types:
method_descriptor
classmethod_descriptor
wrapper_descriptor
method-wrapper
The patch also modifies inspect.Signature so it recognizes these types.
--
Added file:
Changes by Larry Hastings la...@hastings.org:
--
nosy: +tim.peters
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20189
___
___
Python-bugs-list
51 matches
Mail list logo