Author martin.panter
Recipients BreamoreBoy, ezio.melotti, kunkku, lemburg, loewis, martin.panter, serhiy.storchaka, vstinner
Date 2016-05-25.07:43:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1464162182.27.0.163744997738.issue16182@psf.upfronthosting.co.za>
In-reply-to
Content
I’m a bit worried about flex_complete() covering up errors. If I add calls to PyErr_WriteUnraisable(), I can see both the s1 and s2 decodes failing. Input the following line:

>>> "©"; import x;

and then move the cursor back one place, so it is directly after the “x”, but not after the semicolon (;). Then press Tab. Both errors are:

ValueError: embedded null byte

It looks like the reason is that PyUnicode_DecodeLocaleAndSize() requires that str[len] is a null character (the error message is misleading). It seems the len parameter is mainly there to verify that there are no embedded null characters, i.e. you cannot use it to give a truncated string.

It looks like Py_DecodeLocale() is used underneath; maybe it is simpler to call that directly. But it does not solve the string truncating problem.

A test case (perhaps using a pseudo-terminal) might also help pick this kind of thing up, if we can’t report errors any other way.
History
Date User Action Args
2016-05-25 07:43:02martin.pantersetrecipients: + martin.panter, lemburg, loewis, vstinner, ezio.melotti, BreamoreBoy, serhiy.storchaka, kunkku
2016-05-25 07:43:02martin.pantersetmessageid: <1464162182.27.0.163744997738.issue16182@psf.upfronthosting.co.za>
2016-05-25 07:43:02martin.panterlinkissue16182 messages
2016-05-25 07:43:01martin.pantercreate