Issue #26754: Undocumented support of general bytes-like objects

as path in compile() and similar functions is now deprecated.
This commit is contained in:
Serhiy Storchaka 2016-08-06 23:29:29 +03:00
parent d73c31899e
commit febc332056
7 changed files with 34 additions and 16 deletions

View file

@ -473,10 +473,13 @@ if 1:
self.assertEqual(d, {1: 2, 3: 4})
def test_compile_filename(self):
for filename in ('file.py', b'file.py',
bytearray(b'file.py'), memoryview(b'file.py')):
for filename in 'file.py', b'file.py':
code = compile('pass', filename, 'exec')
self.assertEqual(code.co_filename, 'file.py')
for filename in bytearray(b'file.py'), memoryview(b'file.py'):
with self.assertWarns(DeprecationWarning):
code = compile('pass', filename, 'exec')
self.assertEqual(code.co_filename, 'file.py')
self.assertRaises(TypeError, compile, 'pass', list(b'file.py'), 'exec')
@support.cpython_only