by the8472 · 9y ago · 0 comments
Is that a C-string? Does it crash if one forgets the null byte?
open(b'test-\xd8\x01.txt', 'w').close()
Makes the same point.Note that
b'test-\xd8\x00.txt'
is totally valid. You just can't use that as a file name.It's a Python bytestring.
> Does it crash if one forgets the null byte?
No. But in that case it will crash when you use it as CPython (and most FS APIs, and most FS) don't allow NUL in filenames.
>>> open(b'test-\xd8\x00.txt', 'w').close()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: embedded NUL character
So yeah, TypeErrorEdit: Formatting