Message71748
I implemented the "invalid filename" class feature:
- by default, os.listdir() raise an error (UnicodeDecodeError) on
invalid filename. The previous behaviour was to return bytes object
instead of str.
- if invalid_filename=True: create an InvalidFilename class instance
InvalidFilename is not a bytes string, it's not a str string, it's a
new class. It has three attributes:
- bytes: the real filename
- charset: charset (type str)
- str: fake filename (type str) used by __str__() method
My patch also fixes os.path.join() to accept InvalidFilename: if at
last one argument is an InvalidFilename, use InvalidFilename.join()
(class method).
os.listdir() and os.unlink() are patched to accept InvalidFilename.
unlink always accept InvalidFilename whereas listdir() only produces
InvalidFilename is os.listdir(path, invalid_filename=True) is used.
I added an optional argument "invalid_filename" to shutil.rmtree(),
default value is *True*.
To sum up, visible changes:
- os.listdir() raise an error on invalid filename instead of return a
mixed list of str and bytes
- shutil.rmtree() manipulate str and InvalidFilename instead of str
and bytes |
|
Date |
User |
Action |
Args |
2008-08-22 14:21:44 | vstinner | set | recipients:
+ vstinner, gvanrossum, amaury.forgeotdarc, pitrou, benjamin.peterson, HWJ |
2008-08-22 14:21:44 | vstinner | set | messageid: <1219414904.04.0.609279694414.issue3187@psf.upfronthosting.co.za> |
2008-08-22 14:21:43 | vstinner | link | issue3187 messages |
2008-08-22 14:21:42 | vstinner | create | |
|