➜

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.

作者 vstinner
收信人 HWJ, amaury.forgeotdarc, benjamin.peterson, pitrou, vstinner
日期 2008-08-21.10:59:26
SpamBayes Score 1.0547119e-15
Marked as misclassified 否
Message-id <1219316369.16.0.371557599728.issue3187@psf.upfronthosting.co.za>
In-reply-to
内容
I wrote a Filename class. I tries different methods:
 * no parent class "class Filename: ..." -> I don't know how to make 
bytes(filename) works!? But it's the best option to avoid strange bugs 
(mix bytes/str, remember Python 2.x...)
 * str parent class "class Filename(str): ..." -> doesn't work because 
os functions uses the fake unicode filename before testing the bytes 
(real) filename
 * bytes parent class "class Filename(bytes): ..." -> that's the 
current implementation

The idea is to encode str -> bytes (and not bytes -> str because we 
want to avoid problems with such conversions). So I reimplemented most 
bytes methods: __addr__, __raddr__, __contains__, startswith, endswith 
and index. index method has no start/end arguments since the behaviour 
would be different than a real unicode string :-/

I added an example of fixed os.listdir(): create Filename() object if 
we get bytes. Should we always create Filename objects? I don't think 
so.
历史
日期 用户 动作 参数
2008-08-21 10:59:29vstinner修改recipients: + vstinner, amaury.forgeotdarc, pitrou, benjamin.peterson, HWJ
2008-08-21 10:59:29vstinner修改messageid: <1219316369.16.0.371557599728.issue3187@psf.upfronthosting.co.za>
2008-08-21 10:59:28vstinner链接issue3187 messages
2008-08-21 10:59:27vstinner创建