Skip to content

Commit

Permalink
Fix problem when exec'ing a string with a coding
Browse files Browse the repository at this point in the history
  • Loading branch information
nnorwitz committed Aug 11, 2007
1 parent 7ac9712 commit f7f28fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Lib/test/test_coding.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def verify_bad_module(self, module_name):
fp.close()
self.assertRaises(SyntaxError, compile, text, filename, 'exec')

def test_exec_valid_coding(self):
d = {}
exec('# coding: cp949\na = 5\n', d)
self.assertEqual(d['a'], 5)

def test_main():
test.test_support.run_unittest(CodingTest)

Expand Down
2 changes: 1 addition & 1 deletion Parser/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ decode_str(const char *str, struct tok_state *tok)
"unknown encoding: %s", tok->enc);
return error_ret(tok);
}
str = PyString_AsString(utf8);
str = PyBytes_AsString(utf8);
}
assert(tok->decoding_buffer == NULL);
tok->decoding_buffer = utf8; /* CAUTION */
Expand Down

0 comments on commit f7f28fc

Please sign in to comment.