mirror of
https://github.com/python/cpython.git
synced 2025-08-29 05:05:03 +00:00
ignore the coding cookie in compile(), exec(), and eval() if the source is a string #4626
This commit is contained in:
parent
0663a1ed79
commit
f5b52246ed
10 changed files with 63 additions and 14 deletions
|
@ -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 = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue