New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Argument Clinic: add support for __init__ #64493
Comments
Currently Argument Clinic doesn't support the __init__ methods, mainly because the C implementation of this method should return int, not PyObject *. In some cases it is possible to wrap a function generated by Argument Clinic (as in Modules/_pickle.c). But not always, because the __init__ method is called with the self, args, and kwargs arguments, while Argument Clinic can generate function without kwargs. |
Oh! I thought it worked fine, because I've seen people convert both an __init__ and a __new__. But I guess they wrapped them. It's an easy change, I can try to do that today. |
I should have a fix in for __init__ and __call__ later today. (Issue bpo-20294.)
In the next few days I'm going to add support for "*args" and "**kwargs", and
You'll be able to do this soon: parameter: object(c_default='pysqlite_PrepareProtocolType') = ProtocolType This feature isn't checked in yet, I'm waiting for a review. It's part of
You can't. How about you use a default of -1 and then: if (maxrows == -1)
I'd prefer it if you converted them anyway. Converting them means they'll
Once I add the ability to pass in *args and **kwargs, you'll be able to I think I responded to all your other comments when I reviewed the patch. Thanks! |
Oops, sorry, that last comment was intended for a different issue. Please ignore, and sorry for the spam! |
Here's a patch. Wasn't as easy as I thought, it kind of took all day. Changes include:
Pre-exiting behavior:
|
Rietveld doesn't like the patch and I'm having a hard time finding a changeset on which I can get it to apply cleanly. May I suggest avoiding |
Whoops, that doesn't apply cleanly. Here's an updated patch. |
Output looks good and I didn't see anything that scared me in the patch, though I can't pretend to fully understand 100% of it. Builds on Windows, pickle tests pass, and nothing else is affected (that's checked in so far). Looks good to me, as far as I can see. |
I have reviewed this as best I am able. I'll be honest that a lot of clinic.py makes my eyes cross; I'm used to webdev templating, which is inverted from AC (flow control inside the template). Not complaining, it's a complicated subject. I do like the centralization of the templates. I didn't see anything that jumped out at me. I tried out the new conversions on socketmodule and like the output, and none of the existing conversions mutated. So LGTM! It took me a while to figure out how to make __new__ a class method though, decorator support should probably be documented (or else a hint like '__new__ must be a @classmethod!') |
New changeset 2e32462e4832 by Larry Hastings in branch 'default': |
Checked in. Thanks for bringing the problem to my attention, Serhiy, and thanks for the reviews you two! rmsr: If I had a stronger background in templating, maybe Argument Clinic would be cleaner inside. As it is I'm beating the problem to death with sheer force of will. |
Thank you Larry, now I can use Argument Clinic in the __init__ methods. But there is one problem. Docstring generated for the __init__ method contains the "__init__" name in the signature. Therefore it can't be used as class docstring. On other hand, the compiler complains of not used __init__ docstring. |
That problem will be irrelevant, once builtin classes support signatures (bpo-20189). |
…__ and __init__ functions. GitHub-Issue-Link: python/cpython#64493
…__ and __init__ functions. GitHub-Issue-Link: python/cpython#64493
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: