Fix problem when exec'ing a string with a coding
This commit is contained in:
parent
7ac971243b
commit
f7f28fc46b
@ -21,6 +21,11 @@ class CodingTest(unittest.TestCase):
|
|||||||
fp.close()
|
fp.close()
|
||||||
self.assertRaises(SyntaxError, compile, text, filename, 'exec')
|
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():
|
def test_main():
|
||||||
test.test_support.run_unittest(CodingTest)
|
test.test_support.run_unittest(CodingTest)
|
||||||
|
|
||||||
|
@ -632,7 +632,7 @@ decode_str(const char *str, struct tok_state *tok)
|
|||||||
"unknown encoding: %s", tok->enc);
|
"unknown encoding: %s", tok->enc);
|
||||||
return error_ret(tok);
|
return error_ret(tok);
|
||||||
}
|
}
|
||||||
str = PyString_AsString(utf8);
|
str = PyBytes_AsString(utf8);
|
||||||
}
|
}
|
||||||
assert(tok->decoding_buffer == NULL);
|
assert(tok->decoding_buffer == NULL);
|
||||||
tok->decoding_buffer = utf8; /* CAUTION */
|
tok->decoding_buffer = utf8; /* CAUTION */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user