mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
Issue #26754: Undocumented support of general bytes-like objects
as path in compile() and similar functions is now deprecated.
This commit is contained in:
parent
d73c31899e
commit
febc332056
7 changed files with 34 additions and 16 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue