Commit cff9237d authored by Benjamin Peterson's avatar Benjamin Peterson

check after comments, too (#13832)

parent 6a7b855a
...@@ -470,6 +470,8 @@ if 1: ...@@ -470,6 +470,8 @@ if 1:
self.assertInvalidSingle('a = 13\nb = 187') self.assertInvalidSingle('a = 13\nb = 187')
self.assertInvalidSingle('del x\ndel y') self.assertInvalidSingle('del x\ndel y')
self.assertInvalidSingle('f()\ng()') self.assertInvalidSingle('f()\ng()')
self.assertInvalidSingle('f()\n# blah\nblah()')
self.assertInvalidSingle('f()\nxy # blah\nblah()')
def test_main(): def test_main():
support.run_unittest(TestSpecifics) support.run_unittest(TestSpecifics)
......
...@@ -234,13 +234,23 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, ...@@ -234,13 +234,23 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
char *cur = tok->cur; char *cur = tok->cur;
char c = *tok->cur; char c = *tok->cur;
for (;;) {
while (c == ' ' || c == '\t' || c == '\n' || c == '\014') while (c == ' ' || c == '\t' || c == '\n' || c == '\014')
c = *++cur; c = *++cur;
if (c && c != '#') { if (!c)
break;
if (c != '#') {
err_ret->error = E_BADSINGLE; err_ret->error = E_BADSINGLE;
PyNode_Free(n); PyNode_Free(n);
n = NULL; n = NULL;
break;
}
/* Suck up comment. */
while (c && c != '\n')
c = *++cur;
} }
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment