Lysandros Nikolaou <lisandros...@gmail.com> added the comment:

> Note that although we could just exit if the length of the line is smaller 
> than the column offset before calling 
> https://github.com/python/cpython/blob/master/Parser/pegen.c#L148 (I assume 
> that is the problem) is more important to understand how are we reaching that 
> situation.

That's because of 
https://github.com/python/cpython/blob/e2fb8a2c42ee60c72a40d93da69e9efc4e359023/Parser/pegen.c#L404,
 which decreases the size of the string to be decoded by 1 if the last 
character is a newline (or, equivalently, if the error offset points past the 
end of the line). Thus, PyUnicode_DecodeUTF8 returns an object that is one 
character shorter than the col_offset and that's how we get to the situation 
you mentioned.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40958>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to