Repository navigation
Closed
Labels
3.7 (EOL)end of lifeend of lifeextension-modulesC modules in the Modules dirC modules in the Modules dirtopic-argument-clinictype-featureA feature request or enhancementA feature request or enhancement
Description
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:
assignee = None
closed_at = <Date 2019-05-07.14:09:44.504>
created_at = <Date 2014-01-08.00:22:19.535>
labels = ['extension-modules', 'type-feature', '3.7', 'expert-argument-clinic']
title = 'Derby #17: Convert 49 sites to Argument Clinic across 13 files'
updated_at = <Date 2022-02-25.15:13:53.923>
user = 'https://github.com/larryhastings'bugs.python.org fields:
activity = <Date 2022-02-25.15:13:53.923>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2019-05-07.14:09:44.504>
closer = 'mdk'
components = ['Extension Modules', 'Argument Clinic']
creation = <Date 2014-01-08.00:22:19.535>
creator = 'larry'
dependencies = ['28754']
files = ['33943', '33988', '33989', '46392', '46449', '46495', '46526', '46527', '46528', '46529', '46530']
hgrepos = []
issue_num = 20185
keywords = ['patch']
message_count = 65.0
messages = ['207643', '208124', '208140', '208150', '208154', '208246', '208247', '208269', '208271', '208529', '208632', '208762', '208768', '208774', '208877', '208883', '208884', '209048', '209419', '209432', '209516', '209517', '209520', '209548', '209570', '210142', '210168', '210235', '210326', '210327', '210330', '210350', '210388', '210389', '210393', '210434', '210441', '210594', '210595', '224766', '282110', '282790', '282893', '282894', '282906', '283579', '285963', '285980', '286093', '286436', '286698', '286817', '286936', '286942', '287064', '290164', '290205', '290215', '290227', '290228', '295725', '341729', '413954', '413998', '414006']
nosy_count = 11.0
nosy_names = ['terry.reedy', 'vstinner', 'larry', 'nadeem.vawda', 'python-dev', 'martin.panter', 'zach.ware', 'serhiy.storchaka', 'vajrasky', 'josh.r', 'mdk']
pr_nums = ['541', '542', '543', '544', '545', '2116', '31558', '31578', '31581']
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue20185'
versions = ['Python 3.7']Metadata
Metadata
Assignees
Labels
3.7 (EOL)end of lifeend of lifeextension-modulesC modules in the Modules dirC modules in the Modules dirtopic-argument-clinictype-featureA feature request or enhancementA feature request or enhancement
Activity
larryhastings commentedon Jan 8, 2014
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
larryhastings commentedon Jan 14, 2014
Antoine Pitrou took care of cryptmodule.c.
[-]Derby #17: Convert 50 sites to Argument Clinic across 14 files[/-][+]Derby #17: Convert 49 sites to Argument Clinic across 13 files[/+]vajrasky commentedon Jan 15, 2014
Here is the patch for Modules/resource.c.
However, I can not convert this method signature:
_Py_PARSE_PID can be 'i' or 'l' or 'L'.
vajrasky commentedon Jan 15, 2014
Here is the patch for Modules/gcmodule.c.
vajrasky commentedon Jan 15, 2014
Here is the patch for Python/marshal.c.
A couple of issues:
I can not have bytes as argument.
bytes: Py_buffer -> not possible
So I changed it to byte.
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
larryhastings commentedon Jan 16, 2014
Someone else came up with this hack using a custom converter:
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
larryhastings commentedon Jan 16, 2014
Keep track of bpo-20226, that's the issue where I'm adding improved support for simple expressions like "version".
vajrasky commentedon Jan 16, 2014
With little modification:
It works. Thanks! But I got unnecessary empty string:
It should be:
Anyway, that is trivial problem. Now I hit a hard one. How do you convert this signature?
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?
serhiy-storchaka commentedon Jan 16, 2014
This is known bug in prlimit (bpo-20191).
vajrasky commentedon Jan 20, 2014
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));
vajrasky commentedon Jan 21, 2014
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.
vajrasky commentedon Jan 22, 2014
Here is the patch for listobject. A couple of thoughts:
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.
"__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.
42 remaining items
python-dev commentedon Feb 4, 2017
New changeset 50958e13c833 by Serhiy Storchaka in branch 'default':
Issue bpo-20185: Converted the gc module to Argument Clinic.
https://hg.python.org/cpython/rev/50958e13c833
python-dev commentedon Feb 4, 2017
New changeset 725c112c941ca6ac7fb995449f85501ea100647e by Serhiy Storchaka in branch 'master':
Issue bpo-20185: Converted the gc module to Argument Clinic.
725c112
serhiy-storchaka commentedon Feb 5, 2017
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.
serhiy-storchaka commentedon Mar 24, 2017
New changeset 5c643a0 by Serhiy Storchaka in branch 'master':
bpo-20185: Convert typeobject.c to Argument Clinic. (#544)
5c643a0
serhiy-storchaka commentedon Mar 24, 2017
New changeset 1989763 by Serhiy Storchaka in branch 'master':
bpo-20185: Convert the resource moduel to Argument Clinic. (#545)
1989763
serhiy-storchaka commentedon Mar 24, 2017
New changeset 0767ad4 by Serhiy Storchaka in branch 'master':
bpo-20185: Convert the marshal module to Argument Clinic. (#541)
0767ad4
serhiy-storchaka commentedon Mar 24, 2017
New changeset fdd42c4 by Serhiy Storchaka in branch 'master':
bpo-20185: Convert list object implementation to Argument Clinic. (#542)
fdd42c4
serhiy-storchaka commentedon Mar 24, 2017
New changeset b5c51d3 by Serhiy Storchaka in branch 'master':
bpo-20185: Convert float object implementation to Argument Clinic. (#543)
b5c51d3
terryjreedy commentedon Jun 11, 2017
New changeset 57d8de8 by terryjreedy in branch '3.6':
[3.6]bpo-20185: Adjust IDLE test to 3.7 Clinic change [GH-542] (bpo-2116)
57d8de8
JulienPalard commentedon May 7, 2019
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.
vstinner commentedon Feb 25, 2022
New changeset 7d03c8b by Victor Stinner in branch 'main':
bpo-46852: Rename float.__set_format__() to float.__setformat__() (GH-31558)
7d03c8b
vstinner commentedon Feb 25, 2022
New changeset 0848da1 by Victor Stinner in branch '3.10':
bpo-46852: Rename float.__set_format__() to float.__setformat__() (GH-31558) (GH-31578)
0848da1
vstinner commentedon Feb 25, 2022
New changeset a549cd1 by Victor Stinner in branch '3.9':
bpo-46852: Rename float.__set_format__() to float.__setformat__() (GH-31558) (GH-31581)
a549cd1