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.

作者 pitrou
收信人 alex, hynek, pitrou
日期 2012-01-27.09:28:29
SpamBayes Score 3.8857806e-16
Marked as misclassified
Message-id <1327656510.59.0.15052161836.issue13848@psf.upfronthosting.co.za>
In-reply-to
内容
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
历史
日期 用户 动作 参数
2012-01-27 09:28:30pitrou修改recipients: + pitrou, alex, hynek
2012-01-27 09:28:30pitrou修改messageid: <1327656510.59.0.15052161836.issue13848@psf.upfronthosting.co.za>
2012-01-27 09:28:30pitrou链接issue13848 messages
2012-01-27 09:28:29pitrou创建