ignore the coding cookie in compile(), exec(), and eval() if the source is a string #4626

This commit is contained in:
Benjamin Peterson 2009-03-02 23:31:26 +00:00
parent 0663a1ed79
commit f5b52246ed
10 changed files with 63 additions and 14 deletions

View file

@ -17,10 +17,10 @@ class CodingTest(unittest.TestCase):
path = os.path.dirname(__file__)
filename = os.path.join(path, module_name + '.py')
fp = open(filename, encoding='utf-8')
text = fp.read()
fp = open(filename, "rb")
bytes = fp.read()
fp.close()
self.assertRaises(SyntaxError, compile, text, filename, 'exec')
self.assertRaises(SyntaxError, compile, bytes, filename, 'exec')
def test_exec_valid_coding(self):
d = {}