This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Derby #17: Convert 49 sites to Argument Clinic across 13 files
Type: enhancement Stage: resolved
Components: Argument Clinic, Extension Modules Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: 28754 Superseder:
Assigned To: Nosy List: josh.r, larry, martin.panter, mdk, nadeem.vawda, python-dev, serhiy.storchaka, terry.reedy, vajrasky, vstinner, zach.ware
Priority: normal Keywords: patch

Created on 2014-01-08 00:22 by larry, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue20185_conglomerate_v4.diff vajrasky, 2014-02-06 14:37 review
clinic_gc_v4.patch vajrasky, 2014-02-08 08:26 review
clinic_longobject_v3.patch vajrasky, 2014-02-08 09:12 review
clinic_longobject_v4.patch serhiy.storchaka, 2017-01-23 16:17 review
clinic_longobject_v5.patch serhiy.storchaka, 2017-01-29 09:28 review
clinic_gc_v5.patch serhiy.storchaka, 2017-02-02 19:51 review
clinic_float_v5.diff serhiy.storchaka, 2017-02-05 22:13 review
clinic_list_v5.diff serhiy.storchaka, 2017-02-05 22:13 review
clinic_type_v5.diff serhiy.storchaka, 2017-02-05 22:13 review
clinic_marshal_v5.diff serhiy.storchaka, 2017-02-05 22:14 review
clinic_resource_v5.diff serhiy.storchaka, 2017-02-05 22:14 review
Pull Requests
URL Status Linked Edit
PR 541 merged serhiy.storchaka, 2017-03-07 09:35
PR 542 merged serhiy.storchaka, 2017-03-07 09:36
PR 543 merged serhiy.storchaka, 2017-03-07 09:37
PR 544 merged serhiy.storchaka, 2017-03-07 09:38
PR 545 merged serhiy.storchaka, 2017-03-07 09:38
PR 2116 merged terry.reedy, 2017-06-11 18:05
PR 31558 merged vstinner, 2022-02-25 01:06
PR 31578 merged vstinner, 2022-02-25 14:26
PR 31581 merged vstinner, 2022-02-25 14:51
Messages (65)
msg207643 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2014-01-08 00:22
This issue is part of the Great Argument Clinic Conversion Derby,
where we're trying to convert as much of Python 3.4 to use
Argument Clinic as we can before Release Candidate 1 on January 19.

This issue asks you to change the following bundle of files:
    Objects/typeobject.c: 5 sites
    Objects/longobject.c: 5 sites
    Objects/listobject.c: 5 sites
    Objects/floatobject.c: 4 sites
    Modules/resource.c: 4 sites
    Modules/_threadmodule.c: 4 sites
    Modules/_bz2module.c: 4 sites
    Modules/_bisectmodule.c: 4 sites
    Python/marshal.c: 3 sites
    Objects/exceptions.c: 3 sites
    Modules/nismodule.c: 3 sites
    Modules/gcmodule.c: 3 sites
    Python/_warnings.c: 2 sites
    Modules/_cryptmodule.c: 1 sites

Talk to me (larry) if you only want to attack part of a bundle.

For instructions on how to convert a function to work with Argument
Clinic, read the "howto":
    http://docs.python.org/dev/howto/clinic.html
msg208124 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2014-01-14 23:35
Antoine Pitrou took care of cryptmodule.c.
msg208140 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-15 04:25
Here is the patch for Modules/resource.c.

However, I can not convert this method signature:

if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i|(OO):prlimit",
                          &pid, &resource, &curobj, &maxobj))

_Py_PARSE_PID can be 'i' or 'l' or 'L'.
msg208150 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-15 07:11
Here is the patch for Modules/gcmodule.c.
msg208154 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-15 10:51
Here is the patch for Python/marshal.c.

A couple of issues:
1. I can not have bytes as argument.

    bytes: Py_buffer -> not possible

So I changed it to byte.

2. I can not give default value, marshal.version, to argument.

version: int(c_default="Py_MARSHAL_VERSION") = marshal.version -> not possible (unless I put "import marshal" in Tools/clinic/clinic.py).

So I gave it a raw value, 2.

version: int(c_default="Py_MARSHAL_VERSION") = 2
msg208246 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2014-01-16 07:37
Someone else came up with this hack using a custom converter:

class PID_converter(int_converter):
  format_unit = '" _Py_PARSE_PID "'

Also, for marshal.version, soon you will be able to.  This syntax won't work now but it will soon:

version: int(c_default="Py_MARSHAL_VERSION") = version
msg208247 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2014-01-16 07:41
Keep track of #20226, that's the issue where I'm adding improved support for simple expressions like "version".
msg208269 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-16 09:44
With little modification:

class PID_converter(int_converter):
  type = 'pid_t'
  format_unit = '" _Py_PARSE_PID "'

It works. Thanks! But I got unnecessary empty string:

if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "i:prlimit", &pid, &resource))

It should be:

if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i:prlimit", &pid, &resource))

Anyway, that is trivial problem. Now I hit a hard one. How do you convert this signature?

-    if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i|(OO):prlimit",
-                          &pid, &resource, &curobj, &maxobj))

I create custom converters:

+class TupleOpen_converter(object_converter):
+  format_unit = '(O'
+class TupleClose_converter(object_converter):
+  format_unit = 'O)'

and

+/*[clinic input]
+resource.prlimit
+
+    pid: PID
+    resource: int
+    [
+    curobj: TupleOpen
+    maxobj: TupleClose
+    ]
+    /
+[clinic start generated code]*/

But I got invalid argument size in the generated code.

+        case 2:
+            if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "i:prlimit", &pid, &resource))
+                return NULL;
+            break;
+        case 4:   ========> should be "case 3:"
+            if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "i(OO):prlimit", &pid, &resource, &curobj, &maxobj))
+                return NULL;
+            group_right_1 = 1;
+            break;
+        default:
+            PyErr_SetString(PyExc_TypeError, "resource.prlimit requires 2 to 4 arguments"); =======> should be "2 to 3 arguments"
+            return NULL;

Any idea, Larry?
msg208271 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-01-16 10:55
This is known bug in prlimit (issue20191).
msg208529 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-20 08:47
Here is the patch for typeobject. I didn't convert the new method. It's so complicated. It counts whether how many arguments or keywords you pass. It asserts the args before parsing the args. I don't think clinic supports this.

This is the code:
    assert(args != NULL && PyTuple_Check(args));
    assert(kwds == NULL || PyDict_Check(kwds));

    /* Special case: type(x) should return x->ob_type */
    {
        const Py_ssize_t nargs = PyTuple_GET_SIZE(args);
        const Py_ssize_t nkwds = kwds == NULL ? 0 : PyDict_Size(kwds);

        if (PyType_CheckExact(metatype) && nargs == 1 && nkwds == 0) {
            PyObject *x = PyTuple_GET_ITEM(args, 0);
            Py_INCREF(Py_TYPE(x));
            return (PyObject *) Py_TYPE(x);
        }

        /* SF bug 475327 -- if that didn't trigger, we need 3
           arguments. but PyArg_ParseTupleAndKeywords below may give
           a msg saying type() needs exactly 3. */
        if (nargs + nkwds != 3) {
            PyErr_SetString(PyExc_TypeError,
                            "type() takes 1 or 3 arguments");
            return NULL;
        }
    }

    /* Check arguments: (name, bases, dict) */
    if (!PyArg_ParseTupleAndKeywords(args, kwds, "UO!O!:type", kwlist,
                                     &name,
                                     &PyTuple_Type, &bases,
                                     &PyDict_Type, &orig_dict))
        return NULL;
msg208632 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-21 08:52
Here is the patch for longobject. There are two sites which I couldn't convert. The first is the constructor which is complicated. The other one is __round__ which clinic explicitly does not support.
msg208762 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-22 09:32
Here is the patch for listobject. A couple of thoughts:

1. I can not convert this signature:

    if (!PyArg_ParseTuple(args, "O|O&O&:index", &v,
                                _PyEval_SliceIndex, &start,
                                _PyEval_SliceIndex, &stop))
        return NULL;

It's bloody difficult. If I make start (and stop) as PyObject, I get a lot of pointer warning conversion. The closest I can get is making start (and stop) as Py_ssize_t but it changes the behaviour. a.index(0, -4*sys.maxsize, 4*sys.maxsize) will throw OverflowError.

2. for tp_init, it forces me to give wrong return signature.
"__init__([sequence=None])\n"

This is the clinic input:

list.__init__

  self: PyListObject
  [
  sequence: object(c_default="NULL") = None
  ]
  /

Without None, it will be an error in clinic process.

3. The init function returns integer but in error case, it returns NULL which will throws pointer warning conversion.

static int
list___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
    int return_value = -1;
    int group_right_1 = 0;
    PyObject *sequence = NULL;

    if (!_PyArg_NoKeywords("__init__", kwargs))
        goto exit;
    switch (PyTuple_GET_SIZE(args)) {
        case 0:
            break;
        case 1:
            if (!PyArg_ParseTuple(args, "O:__init__", &sequence))
                return NULL;
            group_right_1 = 1;
            break;
....
msg208768 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-01-22 10:13
1. In list.index use custom converter.

/*[python input]

class slice_index_converter(CConverter):
    type = 'Py_ssize_t'
    converter = '_PyEval_SliceIndex'

[python start generated code]*/

2. In list.__init__ use either "unspecified" default value or optional group without default value.

3. This looks as Argument Clinic bug.
msg208774 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2014-01-22 10:51
I'll fix the "return NULL" problem.  However, you are using optional groups in the list __init__.  The original doesn't use them.  Please stop using optional groups in functions that don't require them.
msg208877 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-23 03:25
Thanks, Serhiy, for the pointer. Now, I am able to convert the method using _PyEval_SliceIndex function.

Sorry, Larry. I used optional groups in __init__ because I didn't know about unspecified.

Here is the updated patch for listobject. One thought, for list.index method, I use this:

stop: slice_index(c_default="Py_SIZE(self)") = unspecified

Then the signature will be:

"index(value, [start=0, [stop=unspecified]])\n"

Somehow I prefer more explanatory signature:

"index(value, [start=0, [stop=size of list]])\n"

Anyway, this is a trivial thing.
msg208883 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-23 07:50
Here is the patch for floatobject. I did not convert 2 sites. The first is the round method which clinic explicitly does not support. The second one is the new method. This is the snippet of new method:

float_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
    PyObject *x = Py_False; /* Integer zero */
    static char *kwlist[] = {"x", 0};

    if (type != &PyFloat_Type)
        return float_subtype_new(type, args, kwds); /* Wimp out */
    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:float", kwlist, &x))
        return NULL;
    /* If it's a string, but not a string subclass, use
       PyFloat_FromString. */
    if (PyUnicode_CheckExact(x))
        return PyFloat_FromString(x);
....

If I clinic this method, I could not put custom code before parsing arguments code anymore. This could affect the performance or may not be correct at all.
msg208884 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-23 08:15
This is updated patch for marshal incorporating the fixes from clinic. Now, I can use 'bytes' named argument and default value of marshal.version instead of hardcoded number.
msg209048 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-24 08:53
Updated marshal patch. I just learned we don't need to release pybuffer (y*) manually.
msg209419 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-27 09:08
Here is the updated patch for resource module based on Zachary's comment.
msg209432 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-27 10:36
Here is the updated patch for type module based on Zachary's comment.

However, I can not convert this method.

{"__subclasshook__", object_subclasshook, METH_CLASS | METH_VARARGS,
     object_subclasshook_doc},

static PyObject *
object_subclasshook(PyObject *cls, PyObject *args)
{
    Py_RETURN_NOTIMPLEMENTED;
}

>>> type.__subclasshook__()
NotImplemented
>>> type.__subclasshook__('cutecat')
NotImplemented
>>> type.__subclasshook__('cutecat', 1, [])
NotImplemented
msg209516 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-28 09:09
Here is the updated patch for list module based on Zachary and Serhiy's reviews.
msg209517 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-28 09:12
Forgot to say that, in list module, anything is convertable except __getitem__.
msg209520 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-28 09:31
Here is the updated patch for marshal module based on Zachary's review.
msg209548 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-01-28 14:12
Here is the updated patch for float object based on Zachary and Serhiy's reviews. Some methods that can not be converted are:

__getnewargs__, __round__, float_new.


So these files are ready for Python 3.4: resource, typeobject, listobject, and floatobject.

These files are not ready yet: gc, longobject.
msg209570 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-01-28 18:03
Attaching a conglomerate patch consisting of clinic_resource_v2.patch, clinic_typeobject_v2.patch, clinic_listobject_v3.patch, clinic_marshal_v4.patch, and clinic_floatobject_v2.patch, with updated (post-#20326) clinic output, for easier review.
msg210142 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-02-03 15:40
Here is the updated patch addressing Zachary's reviews (Thanks!). However, there are some reviews that I could not implement.

1. "This is a good candidate for a custom return converter."

I can not synchronize struct rlimit and NULL return values.

2. "Should be 'class float "PyFloatObject *" "&PyFloat_Type"'.  Using PyFloatObject
* instead of PyObject * may require some casts to PyObject * in some places, but
it's better to use the real name."

I tried it but it was like opening pandora box. It's too much effort to surpress compile errors and warnings. And casting PyFloatObject to PyObject in many places, such as functions, macros, makes me nervous. I think this one deserves a dedicated ticket.
msg210168 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-02-03 22:26
Vajrasky Kok wrote:
> However, there are some reviews that I could not implement.
>
> 1. "This is a good candidate for a custom return converter."
>
> I can not synchronize struct rlimit and NULL return values.

Looking again, that one is non-trivial, but still doable.  You just need a "this means an error happened" value to initialize rl to, and return that value instead of NULL.

> 2. "Should be 'class float "PyFloatObject *" "&PyFloat_Type"'.  Using
> PyFloatObject * instead of PyObject * may require some casts to
> PyObject * in some places, but it's better to use the real name."
>
> I tried it but it was like opening pandora box. It's too much effort
> to surpress compile errors and warnings. And casting PyFloatObject
> to PyObject in many places, such as functions, macros, makes me
> nervous. I think this one deserves a dedicated ticket.

It didn't look too bad to me.  There are already several places where a value is cast back and forth between PyObject and PyFloatObject.  Giving 'self' the right type allows a couple of casts to be removed, and the ones that have to be added are almost exclusively in calls to PyFloat_AsDouble or the CONVERT_TO_DOUBLE macro (which looks like it can just do the casts itself without much issue).  I would vote for making PyFloat_AsDouble expect PyFloatObject instead of PyObject, but since (I think?) it looks like it's part of the stable ABI, I'm not sure if that would fly.

See http://hg.python.org/sandbox/zware/rev/51473d8c23f8 for a patch on your patch that uses PyFloatObject, compiles cleanly (on win32, at least), and passes relevant tests (though I haven't run the full test suite on this yet; it takes forever on this PC).

I have a few more review comments that I hope to get posted later this evening.

The patch is looking pretty good overall, though!
msg210235 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-02-04 14:45
Ok, so my changes to CONVERT_TO_DOUBLE don't fly with gcc, so that's out.  In the two cases where convert_to_double wants a PyObject *, we could declare "PyObject *objself = (PyObject *)self;", but that's not particularly appealing.  I'll leave the whole PyObject vs. PyFloatObject issue to someone with more C experience.
msg210326 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-02-05 15:25
Here is the patch addressing Zachary's review (Thanks!). There are some Zachary's suggestions that I could not implement:

1. float_conjugate_impl,            /* nb_float */
I think this should still be the real function (the parser), not the impl.  The
impl function is really just an implementation detail.

It has to be that way. If I change it to float_conjugate, the compiler will complain. But on other places, we can use the real function.

2. v = list_sort_impl((PyListObject *)v, Py_None, 0);
Considering what I said about not using impl functions at the end of
floatobject.c, it would be nice to avoid it here, but I think that would be a
lot more trouble than it would be worth.

I can not use the real function here, otherwise the compiler will throw error.
msg210327 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-02-05 15:31
Zachary, "Looking again, that one is non-trivial, but still doable.  You just need a "this means an error happened" value to initialize rl to, and return that value instead of NULL."

How do you give "this means an error happened" value to struct rlimit?

struct rlimit {
               rlim_t rlim_cur;  /* Soft limit */
               rlim_t rlim_max;  /* Hard limit (ceiling for rlim_cur) */
};

This is what prevents me to use custom converter.
msg210330 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-02-05 16:16
Vajrasky: Note that you can reply to individual review comments within Rietveld; this way context is kept and replies are easier :).  The same people get the message either way.

Anyhow, for float point 1: you can use I believe you can use (unaryfunc) for nb_int and nb_float, just like nb_positive above.

list point 2: I agree, it's not worth it to try to not use the impl function.

rlimit: I'm not sure what value to give, and I'm not where I can play with it until my PC catches fire, either.  Is there some value that makes no sense as a legitimate value?  Is it legal for rlim_cur to be greater than rlim_max?  Or is there a value that is just exceedingly uncommon?  Or you could simply pick some random value; your converter should be written to render with self.err_occurred_if("_return_value == RLIMIT_ERROR_VALUE").
msg210350 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-02-05 22:27
Ok, current status of this issue as I see it:

  Objects/typeobject.c:    part of conglomerate patch, LGTM
  Objects/longobject.c:    awaiting revision based on review
  Objects/listobject.c:    part of conglomerate patch, LGTM
  Objects/floatobject.c:   part of conglomerate patch, two minor issues, otherwise LGTM
  Modules/resource.c:      part of conglomerate patch, LGTM (could use return converter, not essential)
  Modules/_threadmodule.c: untouched, held til 3.5
  Modules/_bz2module.c:    untouched, held til 3.5
  Modules/_bisectmodule.c: untouched, held til 3.5
  Python/marshal.c:        part of conglomerate patch, LGTM
  Objects/exceptions.c:    untouched, held til 3.5
  Modules/nismodule.c:     untouched, held til 3.5
  Modules/gcmodule.c:      awaiting revision based on review
  Python/_warnings.c:      untouched, held til 3.5
  Modules/_cryptmodule.c:  done in another issue

I'd like someone with more C experience to have a look at typeobject, floatobject, listobject, resource, and marshal to make sure I haven't missed anything (or led Vajrasky astray).  If someone else can ok them, I can get them committed.

Vajrasky: What's the status on gcmodule and longobject?
msg210388 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-02-06 14:37
Here is the updated patch. I missed the 'unaryfunc' part. :) Yeah, it's weird. I run clinic again and the dump buffer was getting smaller again.
msg210389 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-02-06 14:43
Here is the updated patch for gc module.

Some functions that can not be converted:
- set_threshold(threshold0, [threshold1, threshold2])
Don't know what default value to give to threshold1, threshold2.

static struct gc_generation generations[NUM_GENERATIONS] = {
    /* PyGC_Head,                               threshold,      count */
    {{{GEN_HEAD(0), GEN_HEAD(0), 0}},           700,            0},
    {{{GEN_HEAD(1), GEN_HEAD(1), 0}},           10,             0},
    {{{GEN_HEAD(2), GEN_HEAD(2), 0}},           10,             0},
};

- collect([generation])
Don't know what default value to give to generation.

int genarg = NUM_GENERATIONS - 1;

I don't think we can use expression in signature.

- get_referrers and get_referents
Don't know what signature to use for functions that can accept any number of arguments.
msg210393 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-02-06 14:50
About rlimit, I think we can use negative number for any member of the struct. But the thing is I am not really sure whether it's okay or not. So it's better on the safe side.

I'll finish longobject in one or two days.
msg210434 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-02-07 03:42
Here is the updated patch for gc module based on Zachary's review.
msg210441 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-02-07 08:26
Here is the updated patch for long object. A couple of functions that can not be converted:

- long_new
It has custom processing before parsing arguments part.

- long_round
Not supported by clinic.

_ __trunc__, __floor__, __ceil__ all are mapped to long_long. Not sure how to handle this case.
msg210594 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-02-08 08:26
Here is the updated patch for gc module based on Zachary's review.
msg210595 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-02-08 09:12
Here is the updated patch for long object based on Zachary's review.
msg224766 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2014-08-04 20:14
All the Derby patches should only go into trunk at this point.
msg282110 - (view) Author: Julien Palard (mdk) * (Python committer) Date: 2016-11-30 22:44
Look like this has never been applied, any reason for this?

Tip has probably highly diverged, but I may try to rebase it, should I?
msg282790 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-12-09 17:20
New changeset c62352ec21bc by Victor Stinner in branch 'default':
Issue #20185: Convert _warnings.warn() to Argument Clinic
https://hg.python.org/cpython/rev/c62352ec21bc
msg282893 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-12-11 01:05
Julien, to help push these changes forward, I suggest start by rebasing and reviewing the conglomerate patch, since it seems that was almost ready.

Reading through the thread, it seems the current status is:

1. _crypt module handled elsewhere by Antoine

2. type, list, and float objects, the resource module, and Python/marshal.c are done by Vajrasky, in part of the conglomerate v4 patch. Zach said they look good, but wanted a second opinion from someone with good C knowledge. Check if Zach’s minor comments for float object and resource module were dealt with.

3. long object and gc module were updated by Vajrasky since last review, so probably need to check if there are any outstanding problems with them.

4. _bisect module by Julien via Issue 28754

5. Victor made a change to Python/_warnings.c, but there may be more to do

6. Not yet handled: Objects/exceptions.c, _thread, _bz2, nis modules.
msg282894 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-12-11 02:13
Zach’s comments on float seem to have been addressed (https://bugs.python.org/review/20185/diff2/10940:10949/Objects/floatobject.c). The comments on the resource module were about return converters: <http://bugs.python.org/review/20185/diff2/10817:10949/Modules/resource.c>. One has been addressed.

The other was about the rlimit2py() function, used in two places. One of these is resource.prlimit(), which is not converted to Arg Clinic in the patch. If we don’t convert it, I agree that leaving rlimit2py() as it is is simplest.

Given that the current prlimit() arg parsing is buggy (Issue 20191), it would be good to convert it to Arg Clinic in the process of solving the bug, but that could be done as a separate step.

Tangentially, the rlimit2py() function has special HAVE_LONG_LONG handling. This is no longer needed in 3.6; see Issue 27961. But again, I think it is better to review and commit the existing patch than to keep perfecting it :)
msg282906 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-12-11 06:19
Victor, you perhaps could just use NULL as default:

+    source: object = NULL
msg283579 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-12-19 04:45
I finished reviewing the most recent patches and left some comments. Perhaps it is worth splitting the conglomerate patch up. I don’t see any point holding back some modules while things are tweaked in unrelated files.

My biggest concern is casting function pointers, especially when the number of parameters is different than expected. It would be good to fix or discuss that more before going ahead with floatobject.c.
msg285963 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-01-21 16:56
Martin, you are the one who looked at these patches for last three years. Do you want to take this issue to you and update Vajrasky's patches?

Now there is good performance argument for converting builtins to Argument Clinic.
msg285980 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2017-01-22 01:37
Will keep this in mind, but my time is rather limited, so I may not get to it (and I wouldn’t want to discourage other people from working on it)
msg286093 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-01-23 16:17
Updated patch for longobject.c addresses Martin's comments.
msg286436 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2017-01-29 09:44
longobject_v5 looks good to me
msg286698 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2017-02-01 21:12
New changeset aa7ac93d23b2 by Serhiy Storchaka in branch 'default':
Issue #20185: Converted the int class to Argument Clinic.
https://hg.python.org/cpython/rev/aa7ac93d23b2
msg286817 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-02-02 19:51
Updated patch for the gc module is synchronized with current sources and addresses Martin's comments.

The only problem with this patch is that it exposes the default value for gc.collect() argument as constant 2 in Python instead of actual NUM_GENERATIONS-1. The latter value can't be exposed in Python.

On other side it is 2 in the documentation, and it is not so easy to change the value of NUM_GENERATIONS.
msg286936 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2017-02-04 09:20
New changeset 50958e13c833 by Serhiy Storchaka in branch 'default':
Issue #20185: Converted the gc module to Argument Clinic.
https://hg.python.org/cpython/rev/50958e13c833
msg286942 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2017-02-04 10:00
New changeset 725c112c941ca6ac7fb995449f85501ea100647e by Serhiy Storchaka in branch 'master':
Issue #20185: Converted the gc module to Argument Clinic.
https://github.com/python/cpython/commit/725c112c941ca6ac7fb995449f85501ea100647e
msg287064 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-02-05 22:13
Here is a set of patches based on issue20185_conglomerate_v4.diff. They are synchronized with current sources. Addressed Martin's comments,converted list.index(), float.__round__() and resource.prlimit() and made other minor changes.
msg290164 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-24 22:08
New changeset 5c643a028ee86c613d7168ca5bcb8fc94477a09e by Serhiy Storchaka in branch 'master':
bpo-20185: Convert typeobject.c to Argument Clinic. (#544)
https://github.com/python/cpython/commit/5c643a028ee86c613d7168ca5bcb8fc94477a09e
msg290205 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-24 22:23
New changeset 1989763f0d0858ce6274f5e1d725b5b8da91a780 by Serhiy Storchaka in branch 'master':
bpo-20185: Convert the resource moduel to Argument Clinic. (#545)
https://github.com/python/cpython/commit/1989763f0d0858ce6274f5e1d725b5b8da91a780
msg290215 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-24 22:25
New changeset 0767ad40bfe83525d2ba290cc6eb7c97ce01cdd6 by Serhiy Storchaka in branch 'master':
bpo-20185: Convert the marshal module to Argument Clinic. (#541)
https://github.com/python/cpython/commit/0767ad40bfe83525d2ba290cc6eb7c97ce01cdd6
msg290227 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-24 22:27
New changeset fdd42c481edba4261f861fc1dfe24bbd79b5a17a by Serhiy Storchaka in branch 'master':
bpo-20185: Convert list object implementation to Argument Clinic. (#542)
https://github.com/python/cpython/commit/fdd42c481edba4261f861fc1dfe24bbd79b5a17a
msg290228 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-24 22:27
New changeset b5c51d3dd95bbfde533655fb86ac0f96f771ba7b by Serhiy Storchaka in branch 'master':
bpo-20185: Convert float object implementation to Argument Clinic. (#543)
https://github.com/python/cpython/commit/b5c51d3dd95bbfde533655fb86ac0f96f771ba7b
msg295725 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-06-11 18:29
New changeset 57d8de80313c536d409d6a104ae577af8ffc57fb by terryjreedy in branch '3.6':
[3.6]bpo-20185: Adjust IDLE test to 3.7 Clinic change [GH-542] (#2116)
https://github.com/python/cpython/commit/57d8de80313c536d409d6a104ae577af8ffc57fb
msg341729 - (view) Author: Julien Palard (mdk) * (Python committer) Date: 2019-05-07 14:09
I rebased the conglomerate patch onto current master, and there's only  three methods left, in floatobject.c, it's three methods inside a #if 0, it does not looks interesting to merge it (30 insertions, 12 deletions), so I'm closing this issue.
msg413954 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-02-25 02:05
New changeset 7d03c8be5af2f1559dbc35b775b3116dfd63cfb6 by Victor Stinner in branch 'main':
bpo-46852: Rename float.__set_format__() to float.__setformat__() (GH-31558)
https://github.com/python/cpython/commit/7d03c8be5af2f1559dbc35b775b3116dfd63cfb6
msg413998 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-02-25 14:47
New changeset 0848da19ce8ea037ab1cfc569778e94bf8e3b24a by Victor Stinner in branch '3.10':
bpo-46852: Rename float.__set_format__() to float.__setformat__() (GH-31558) (GH-31578)
https://github.com/python/cpython/commit/0848da19ce8ea037ab1cfc569778e94bf8e3b24a
msg414006 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-02-25 15:13
New changeset a549cd1fc55888e2e287714b25e2cb2251913909 by Victor Stinner in branch '3.9':
bpo-46852: Rename float.__set_format__() to float.__setformat__() (GH-31558) (GH-31581)
https://github.com/python/cpython/commit/a549cd1fc55888e2e287714b25e2cb2251913909
History
Date User Action Args
2022-04-11 14:57:56adminsetgithub: 64384
2022-02-25 15:13:53vstinnersetmessages: + msg414006
2022-02-25 14:51:09vstinnersetpull_requests: + pull_request29705
2022-02-25 14:47:15vstinnersetmessages: + msg413998
2022-02-25 14:26:29vstinnersetpull_requests: + pull_request29701
2022-02-25 02:05:45vstinnersetmessages: + msg413954
2022-02-25 01:06:11vstinnersetnosy: + vstinner

pull_requests: + pull_request29681
2019-05-07 14:09:44mdksetstatus: open -> closed
resolution: fixed
messages: + msg341729

stage: needs patch -> resolved
2017-06-11 18:29:40terry.reedysetnosy: + terry.reedy
messages: + msg295725
2017-06-11 18:05:01terry.reedysetpull_requests: + pull_request2169
2017-03-24 22:27:39serhiy.storchakasetmessages: + msg290228
2017-03-24 22:27:31serhiy.storchakasetmessages: + msg290227
2017-03-24 22:25:08serhiy.storchakasetmessages: + msg290215
2017-03-24 22:23:46serhiy.storchakasetmessages: + msg290205
2017-03-24 22:08:59serhiy.storchakasetmessages: + msg290164
2017-03-07 09:38:41serhiy.storchakasetpull_requests: + pull_request447
2017-03-07 09:38:02serhiy.storchakasetpull_requests: + pull_request446
2017-03-07 09:37:15serhiy.storchakasetpull_requests: + pull_request445
2017-03-07 09:36:28serhiy.storchakasetpull_requests: + pull_request444
2017-03-07 09:35:41serhiy.storchakasetpull_requests: + pull_request443
2017-02-05 22:14:21serhiy.storchakasetfiles: + clinic_resource_v5.diff
2017-02-05 22:14:06serhiy.storchakasetfiles: + clinic_marshal_v5.diff
2017-02-05 22:13:49serhiy.storchakasetfiles: + clinic_type_v5.diff
2017-02-05 22:13:32serhiy.storchakasetfiles: + clinic_list_v5.diff
2017-02-05 22:13:10serhiy.storchakasetfiles: + clinic_float_v5.diff

messages: + msg287064
2017-02-04 10:00:31python-devsetmessages: + msg286942
2017-02-04 09:20:26python-devsetmessages: + msg286936
2017-02-02 19:51:01serhiy.storchakasetfiles: + clinic_gc_v5.patch

messages: + msg286817
2017-02-01 21:12:44python-devsetmessages: + msg286698
2017-01-29 09:44:49martin.pantersetmessages: + msg286436
2017-01-29 09:28:15serhiy.storchakasetfiles: + clinic_longobject_v5.patch
2017-01-23 16:17:26serhiy.storchakasetfiles: + clinic_longobject_v4.patch

messages: + msg286093
2017-01-22 01:37:59martin.pantersetmessages: + msg285980
2017-01-21 16:56:21serhiy.storchakasetmessages: + msg285963
2016-12-19 04:45:08martin.pantersetmessages: + msg283579
stage: patch review -> needs patch
2016-12-11 06:19:38serhiy.storchakasetmessages: + msg282906
2016-12-11 02:13:06martin.pantersetmessages: + msg282894
2016-12-11 01:06:00martin.pantersetversions: + Python 3.7, - Python 3.5
nosy: + martin.panter

messages: + msg282893

stage: needs patch -> patch review
2016-12-09 17:20:34python-devsetnosy: + python-dev
messages: + msg282790
2016-11-30 22:44:38mdksetnosy: + mdk
messages: + msg282110
2016-11-24 21:37:27martin.pantersetdependencies: + Argument Clinic for bisect.bisect_left
2015-02-25 15:29:41serhiy.storchakasetcomponents: + Argument Clinic
2014-10-23 00:32:04josh.rsetnosy: + josh.r
2014-08-04 20:14:54larrysetmessages: + msg224766
versions: + Python 3.5, - Python 3.4
2014-02-08 09:13:15vajraskysetfiles: - clinic_gc_v3.patch
2014-02-08 09:13:02vajraskysetfiles: - clinic_longobject_v2.patch
2014-02-08 09:12:29vajraskysetfiles: + clinic_longobject_v3.patch

messages: + msg210595
2014-02-08 08:26:22vajraskysetfiles: + clinic_gc_v4.patch

messages: + msg210594
2014-02-07 08:27:12vajraskysetfiles: - clinic_longobject.patch
2014-02-07 08:26:58vajraskysetfiles: + clinic_longobject_v2.patch

messages: + msg210441
2014-02-07 03:47:51vajraskysetfiles: - clinic_gc_v2.patch
2014-02-07 03:42:46vajraskysetfiles: + clinic_gc_v3.patch

messages: + msg210434
2014-02-06 14:50:19vajraskysetmessages: + msg210393
2014-02-06 14:43:56vajraskysetfiles: - clinic_gc.patch
2014-02-06 14:43:43vajraskysetfiles: + clinic_gc_v2.patch

messages: + msg210389
2014-02-06 14:43:41vajraskysetfiles: - issue20185_conglomerate_v3.diff
2014-02-06 14:37:32vajraskysetfiles: + issue20185_conglomerate_v4.diff

messages: + msg210388
2014-02-05 22:27:07zach.waresetmessages: + msg210350
2014-02-05 19:27:08zach.waresetmessages: - msg210340
2014-02-05 19:26:58zach.waresetfiles: - clinic_typeobject.patch
2014-02-05 19:22:38zach.waresetnosy: + larry, nadeem.vawda, serhiy.storchaka, vajrasky
2014-02-05 19:22:02zach.waresetfiles: - clinic_resource.patch
2014-02-05 19:22:00zach.waresetfiles: - clinic_marshal.patch
2014-02-05 19:21:57zach.waresetfiles: - clinic_listobject.patch
2014-02-05 19:21:55zach.waresetfiles: - clinic_listobject_v2.patch
2014-02-05 19:21:53zach.waresetfiles: - clinic_floatobject.patch
2014-02-05 19:21:52zach.waresetfiles: - clinic_marshal_v2.patch
2014-02-05 19:21:50zach.waresetfiles: - clinic_marshal_v3.patch
2014-02-05 19:21:48zach.waresetfiles: - clinic_resource_v2.patch
2014-02-05 19:21:46zach.waresetfiles: - clinic_typeobject_v2.patch
2014-02-05 19:21:44zach.waresetfiles: - clinic_listobject_v3.patch
2014-02-05 19:21:41zach.waresetfiles: - clinic_marshal_v4.patch
2014-02-05 19:21:39zach.waresetfiles: - clinic_floatobject_v2.patch
2014-02-05 19:21:36zach.waresetfiles: - issue20185_conglomerate.diff
2014-02-05 19:21:34zach.waresetfiles: - issue20185_conglomerate_v2.diff
2014-02-05 19:21:28zach.waresetnosy: - larry, nadeem.vawda, serhiy.storchaka, vajrasky
messages: + msg210340
2014-02-05 16:16:49zach.waresetmessages: + msg210330
2014-02-05 15:31:55vajraskysetmessages: + msg210327
2014-02-05 15:26:04vajraskysetfiles: + issue20185_conglomerate_v3.diff

messages: + msg210326
2014-02-04 14:45:59zach.waresetmessages: + msg210235
2014-02-03 22:26:35zach.waresetmessages: + msg210168
2014-02-03 15:40:34vajraskysetfiles: + issue20185_conglomerate_v2.diff

messages: + msg210142
2014-01-28 18:03:58zach.waresetfiles: + issue20185_conglomerate.diff

messages: + msg209570
2014-01-28 16:12:43zach.waresetnosy: + zach.ware
2014-01-28 14:12:32vajraskysetfiles: + clinic_floatobject_v2.patch

messages: + msg209548
2014-01-28 09:32:00vajraskysetfiles: + clinic_marshal_v4.patch

messages: + msg209520
2014-01-28 09:12:10vajraskysetmessages: + msg209517
2014-01-28 09:09:10vajraskysetfiles: + clinic_listobject_v3.patch

messages: + msg209516
2014-01-27 10:36:51vajraskysetfiles: + clinic_typeobject_v2.patch

messages: + msg209432
2014-01-27 09:08:54vajraskysetfiles: + clinic_resource_v2.patch

messages: + msg209419
2014-01-24 08:53:28vajraskysetfiles: + clinic_marshal_v3.patch

messages: + msg209048
2014-01-23 08:15:41vajraskysetfiles: + clinic_marshal_v2.patch

messages: + msg208884
2014-01-23 07:50:30vajraskysetfiles: + clinic_floatobject.patch

messages: + msg208883
2014-01-23 03:25:55vajraskysetfiles: + clinic_listobject_v2.patch

messages: + msg208877
2014-01-22 10:51:16larrysetmessages: + msg208774
2014-01-22 10:13:59serhiy.storchakasetmessages: + msg208768
2014-01-22 09:32:31vajraskysetfiles: + clinic_listobject.patch

messages: + msg208762
2014-01-21 08:52:13vajraskysetfiles: + clinic_longobject.patch

messages: + msg208632
2014-01-20 09:13:24vajraskysetfiles: + clinic_typeobject.patch
2014-01-20 09:13:14vajraskysetfiles: - clinic_typeobject.patch
2014-01-20 08:47:53vajraskysetfiles: + clinic_typeobject.patch

messages: + msg208529
2014-01-16 10:55:05serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg208271
2014-01-16 09:44:25vajraskysetmessages: + msg208269
2014-01-16 07:41:02larrysetmessages: + msg208247
2014-01-16 07:37:37larrysetmessages: + msg208246
2014-01-15 10:51:14vajraskysetfiles: + clinic_marshal.patch

messages: + msg208154
2014-01-15 07:11:42vajraskysetfiles: + clinic_gc.patch

messages: + msg208150
2014-01-15 04:26:25vajraskysetfiles: + clinic_resource.patch
2014-01-15 04:26:08vajraskysetfiles: - clinic_codecsmodule.patch
2014-01-15 04:26:00vajraskysetfiles: + clinic_codecsmodule.patch

nosy: + vajrasky
messages: + msg208140

keywords: + patch
2014-01-14 23:35:28larrysetmessages: + msg208124
title: Derby #17: Convert 50 sites to Argument Clinic across 14 files -> Derby #17: Convert 49 sites to Argument Clinic across 13 files
2014-01-08 11:32:31nadeem.vawdasetnosy: + nadeem.vawda
2014-01-08 01:36:37r.david.murraylinkissue20187 dependencies
2014-01-08 00:22:19larrycreate