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.

Author Oren Milman
Recipients Oren Milman
Date 2017-08-21.08:33:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1503304389.01.0.083549043961.issue31243@psf.upfronthosting.co.za>
In-reply-to
Content
according to the docs (https://docs.python.org/3.7/c-api/arg.html?highlight=pyarg_parsetuple#c.PyArg_ParseTuple), PyArg_ParseTuple
returns true for success or false for failure. I also looked at the
implementation in Python/getargs.c, and it seems that indeed PyArg_ParseTuple
can return only 0 or 1.

however, in some places in the codebase, there are checks whether
PyArg_ParseTuple returned a negative int.
I found a bunch in Modules/_testcapimodule.c, and one in Modules/_io/textio.c
in textiowrapper_read_chunk. (hopefully i haven't missed other places.)

this code crashes because of the check in textiowrapper_read_chunk:
import codecs
import _io
class MyDec():
    def getstate(self):
        return 420
class MyDecWrapper():
    def __call__(self, blabla):
        return MyDec()
quopri = codecs.lookup("quopri")
quopri._is_text_encoding = True
quopri.incrementaldecoder = MyDecWrapper()
t = _io.TextIOWrapper(_io.BytesIO(b'aaaaaa'),
                      newline='\n', encoding="quopri")
t.read(42)


I guess all of these checks should be changed to check whether PyArg_ParseTuple
returned 0.

also, before this specific call to PyArg_ParseTuple in textiowrapper_read_chunk,
we should check whether 'state' is a tuple.
Moreover, this call shouldn't produce a wrong error message, as explained in
#28261.
History
Date User Action Args
2017-08-21 08:33:09Oren Milmansetrecipients: + Oren Milman
2017-08-21 08:33:09Oren Milmansetmessageid: <1503304389.01.0.083549043961.issue31243@psf.upfronthosting.co.za>
2017-08-21 08:33:08Oren Milmanlinkissue31243 messages
2017-08-21 08:33:08Oren Milmancreate