You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
skipitem() in getargs.c still supports 'w' and 'w#', and shouldn't #68114
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='https://github.com/larryhastings'closed_at=Nonecreated_at=<Date2015-04-13.02:44:00.845>labels= ['interpreter-core', '3.8', 'type-bug', '3.7']
title="skipitem() in getargs.c still supports 'w' and 'w#', and shouldn't"updated_at=<Date2018-07-09.16:05:58.680>user='https://github.com/larryhastings'
tl;dr: skipitem() in Python 3 still supports "w" and "w#", which were abandoned. They should be removed.
--
If:
you have an extension that parses its arguments with
PyArg_ParseTupleAndKeywords (or its cousins),
you have optional positional parameters, and
you run out of positional arguments
CPython will call skipitem() to skip over the remaining positional parameters so it can process keyword arguments. It does this by knowing all the format units, and iterating over them and throwing away the various varargs pointers until it hits the keyword arguments part of the format string.
PyArg_ParseTuple() etc. in Python 2 supported "w" and "w#" for parsing "objects with the read-write buffer interface". These were removed in Python 3.
skipitem() in Python 3 still supports both skipping "w" and "w#". But in fact the only legal format unit starting with a 'w' in Python 3 is 'w*'. So a function with a 'w*' as an optional parameter that got skipped would be misinterpreted; skipitem would see the 'w', not recognize the following '*' and leave it there, then the next function that read a character from the format string (either skipitem() or convertsimple()) would see the '*' and throw an "impossible <bad format char>" exception.
here is a patch and test case.
I added an entry to Misc/NEWS. I tried to follow the format; however, let me know if I have done this incorrectly.
llllllllll commented on Jul 15, 2015
llllllllllmannequin
Mannequin
More actions
Sorry it took so long to get back to this. I didn't realize this was still open. I have provided the update to the docs and moved it to the 3.6 section. I also made sure the patch still applies and the tests all pass.
Activity
larryhastings commentedon Apr 13, 2015
tl;dr: skipitem() in Python 3 still supports "w" and "w#", which were abandoned. They should be removed.
--
If:
PyArg_ParseTupleAndKeywords (or its cousins),
CPython will call skipitem() to skip over the remaining positional parameters so it can process keyword arguments. It does this by knowing all the format units, and iterating over them and throwing away the various varargs pointers until it hits the keyword arguments part of the format string.
PyArg_ParseTuple() etc. in Python 2 supported "w" and "w#" for parsing "objects with the read-write buffer interface". These were removed in Python 3.
skipitem() in Python 3 still supports both skipping "w" and "w#". But in fact the only legal format unit starting with a 'w' in Python 3 is 'w*'. So a function with a 'w*' as an optional parameter that got skipped would be misinterpreted; skipitem would see the 'w', not recognize the following '*' and leave it there, then the next function that read a character from the format string (either skipitem() or convertsimple()) would see the '*' and throw an "impossible <bad format char>" exception.
llllllllll commentedon Apr 13, 2015
here is a patch and test case.
I added an entry to Misc/NEWS. I tried to follow the format; however, let me know if I have done this incorrectly.
llllllllll commentedon Jul 15, 2015
Sorry it took so long to get back to this. I didn't realize this was still open. I have provided the update to the docs and moved it to the 3.6 section. I also made sure the patch still applies and the tests all pass.
llllllllll commentedon Jul 25, 2015
bumping so that we don't forget about this.
llllllllll commentedon Oct 20, 2015
bumping this issue
llllllllll commentedon Apr 19, 2016
bump
vstinner commentedon Apr 19, 2016
I reviewed skipitems.patch.
serhiy-storchaka commentedon Jul 9, 2018
Do you mind to convert your patch into a pull request Joe?
gh-68114: Fix handling for removed PyArg_ParseTuple 'w' formatters (G…