[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-26 Thread Tal Einat
Tal Einat added the comment: Using the latest clinic.py from default branch, everything in itertools works like a charm :) -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20385

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-25 Thread Tal Einat
Tal Einat added the comment: I've found two bugs: 1) In the type check, a '' needs to be added before the type name. 2) Setting template_dict['self_type_object'] fails for module functions -- ___ Python tracker rep...@bugs.python.org

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-25 Thread Tal Einat
Tal Einat added the comment: Also, I believe the the type of the first argument passed to a method is a pointer to the typedef object, so a '*' needs to be added after the typedef name wherever it is used in such functions. -- ___ Python tracker

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-25 Thread Tal Einat
Tal Einat added the comment: My last comment was wrong. There is a bug regarding the first argument to new methods; It should just remain a PyTypeObject*. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20385

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-25 Thread Larry Hastings
Larry Hastings added the comment: 1) That's not a bug, that's the API. If you used the dynamic API to create a type it wouldn't take the . So I can't guess in advance what type it is, nor can I assume I always add the . 2) Will fix. -- ___

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-25 Thread Larry Hastings
Larry Hastings added the comment: The bug you cited is fixed in today's rollup patch, #20390. (I don't know how to denote the dependency between the two issues, maybe someone else can do that for me?) -- ___ Python tracker rep...@bugs.python.org

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-25 Thread Tal Einat
Tal Einat added the comment: I'm still seeing the first argument to a __new__ function as groupbyobject * instead of PyTypeObject *. This causes the following error (for example): ./Modules/itertoolsmodule.c:112:34: error: no member named 'tp_alloc' in 'groupbyobject' gbo = (groupbyobject

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-25 Thread Tal Einat
Tal Einat added the comment: To clarify my previous comment, I was referring to the first argument passed to the generated 'impl' function. Context: I'm attempting to convert 'itertools.groupby' in Modules/itertoolsmodule.c. -- ___ Python tracker

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-25 Thread Tal Einat
Tal Einat added the comment: Also, I'm seeing this in the generated code for __new__ methods: if (({self_name} == {self_type_object}) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20385

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-25 Thread Tal Einat
Tal Einat added the comment: To make reproducing these bugs easier, I'm attaching my partially converted version of Modules/itertoolsmodules.c, which has the buggy generated code inside. Partially converted means that I've only converted some of the functions requiring conversion. This file

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-25 Thread Larry Hastings
Larry Hastings added the comment: Can you try locally applying my patch for #20390 and seeing if you still have the problem? I tried applying it to the itertoolmodule.c you attached to the issue and it seemed to fix the problem. -- ___ Python

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-24 Thread Tal Einat
New submission from Tal Einat: To quote issue20294 where Larry Hastings added AC support for __new__ and __init__: * __init__ and __new__ always take kwargs. * if the function signature doesn't accept keyword arguments, it calls _PyArg_NoKeywords(). However, due to issue1486663, many

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-24 Thread Larry Hastings
Larry Hastings added the comment: How about I add the if type == our own type checks as per #1486663? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20385 ___

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-24 Thread Tal Einat
Tal Einat added the comment: In general, that sounds like a reasonable suggestion to me. A quick search shows that most classes that call _PyArg_NoKeywords check the type first. I think we should strive for uniformity in this respect, so I'm +1 for your suggestion. I do see some classes

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-24 Thread Larry Hastings
Larry Hastings added the comment: I think it's a bug that they don't do the subclass check. In practice, nobody subclasses range and itertools.tee. But they should probably still be fixed. -- ___ Python tracker rep...@bugs.python.org

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-24 Thread Tal Einat
Tal Einat added the comment: Great. Most of the classes in itertools could use this. BTW, you'll need to supply a way to supply the C name of the type, to use in the type check. -- ___ Python tracker rep...@bugs.python.org

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-24 Thread Larry Hastings
Larry Hastings added the comment: Way ahead of you. The class directive will have to change: class name typedef type_object On the other hand, this means that Argument Clinic can automatically give the right type to the default self converter. So most people won't have to write custom

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-24 Thread Tal Einat
Tal Einat added the comment: +1 for that as well, I've written quite a few self converters for that reason. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20385 ___

[issue20385] Argument Clinic: Support for __new__ not checking _PyArg_NoKeywords for sub-classes

2014-01-24 Thread Larry Hastings
Larry Hastings added the comment: How about this? I'm going to do a rollup patch today with three fixes: this, #20381, and changing the default filename for the file destination. -- Added file: http://bugs.python.org/file33693/larry.clinic.rollup.jan.24.diff.1.txt