py/builtinevex: Support passing in a bytearray/buffer to eval/exec.

CPython allows this and it's a simple generalisation of the existing code
which just supported str/bytes.

Fixes issue #5704.
This commit is contained in:
Damien George
2020-02-28 12:45:36 +11:00
parent 54a54f5872
commit 1993c8cf9a
3 changed files with 29 additions and 4 deletions

View File

@@ -0,0 +1,12 @@
# test builtin eval with a buffer (bytearray/memoryview) input
try:
eval
bytearray
memoryview
except:
print("SKIP")
raise SystemExit
print(eval(bytearray(b'1 + 1')))
print(eval(memoryview(b'2 + 2')))