Message401204
What I missed before is that duplicating the effect of the first two interactive entries (no exception) requires escaping the backslash so that the source argument for the explicit compile does not have a null.
compile("'\\0'", '', 'exec')
<code object <module> at 0x00000214431CAA20, file "", line 1>
compile("#\\0", '', 'exec')
<code object <module> at 0x00000214431CAC30, file "", line 1>
So I did not actually see an exception to the rule.
---
*On Win 10*, I experimented with a version of Armin and Irit's example, without and with b'...' and 'wb'.
s = '#\x00\na\nb\n'
print(len(s)) # 7
with open("f:/Python/a/nulltest.py", 'w') as f:
f.write(s)
import nulltest
When I ran a local repository build of 3.9, 3.10, or 3.11 with
f:\dev\3x>python f:/Python/a/nulltest.py
I got Irit's strange NameError instead of the proper ValueError.
When I ran with installed 3.9 or 3.10 with
py -3.10 -m a.nulltest
I got the null-byte ValueError.
When I ran from IDLE's editor running on either installed or repository python, the import gave the null-byte ValueError. |
|
Date |
User |
Action |
Args |
2021-09-07 03:02:20 | terry.reedy | set | recipients:
+ terry.reedy, gvanrossum, arigo, georg.brandl, benjamin.peterson, jwilk, Arfrever, alex, ita1024, serhiy.storchaka, iritkatriel |
2021-09-07 03:02:20 | terry.reedy | set | messageid: <1630983740.92.0.574822018738.issue20115@roundup.psfhosted.org> |
2021-09-07 03:02:20 | terry.reedy | link | issue20115 messages |
2021-09-07 03:02:20 | terry.reedy | create | |
|