This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients alex, hynek, pitrou
Date 2012-01-27.09:28:29
SpamBayes Score 3.8857806e-16
Marked as misclassified No
Message-id <1327656510.59.0.15052161836.issue13848@psf.upfronthosting.co.za>
In-reply-to
Content
Indeed, there seems to be no mechanism available to forbid NUL chars under Windows (for Python 3.x):

>>> open("LICENSE\x00foobar")
<_io.TextIOWrapper name='LICENSE\x00foobar' mode='r' encoding='cp1252'>
>>> os.stat("LICENSE\x00foobar")
nt.stat_result(st_mode=33206, st_ino=2251799813779714, st_dev=0, st_nlink=1, st_uid=0, st_gid=0, st_size=15132, st_atime=8589934592, st_mtime=8589934592, st_ctime=1301169903)

I think PyUnicode_AsUnicode should grow a NUL char check in Python 3.3, since it doesn't return the size anyway. I don't think we can do that in previous versions, though, so we need an alternate strategy. Scanning the unicode string for NUL characters is enough. That should be easy by using PyUnicode_AsUnicodeAndSize.

As for the patch:
- the test should be in test_io; you may also add a separate in test_fileio
- conv_name is never decref'ed, and so there will be a memory leak
History
Date User Action Args
2012-01-27 09:28:30pitrousetrecipients: + pitrou, alex, hynek
2012-01-27 09:28:30pitrousetmessageid: <1327656510.59.0.15052161836.issue13848@psf.upfronthosting.co.za>
2012-01-27 09:28:30pitroulinkissue13848 messages
2012-01-27 09:28:29pitroucreate