[Bug #19743] All but EOF can be read again after push-back

This commit is contained in:
Nobuyoshi Nakada 2023-06-22 20:10:13 +09:00
parent 8142728b5a
commit 1344de5621
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
2 changed files with 4 additions and 0 deletions

View File

@ -7121,6 +7121,7 @@ static void
pushback(struct parser_params *p, int c)
{
if (c == -1) return;
p->eofp = 0;
p->lex.pcur--;
if (p->lex.pcur > p->lex.pbeg && p->lex.pcur[0] == '\n' && p->lex.pcur[-1] == '\r') {
p->lex.pcur--;
@ -9164,6 +9165,7 @@ parse_numeric(struct parser_params *p, int c)
c = nextc(p);
if (c != '-' && c != '+' && !ISDIGIT(c)) {
pushback(p, c);
c = nondigit;
nondigit = 0;
goto decode_num;
}

View File

@ -1138,6 +1138,8 @@ x = __ENCODING__
assert_syntax_error('0000xyz', /^ \^~~\Z/)
assert_syntax_error('1.2i1.1', /^ \^~~\Z/)
assert_syntax_error('1.2.3', /^ \^~\Z/)
assert_syntax_error('1.', /unexpected end-of-input/)
assert_syntax_error('1e', /expecting end-of-input/)
end
def test_truncated_source_line