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 zegreek
Recipients HWJ, amaury.forgeotdarc, benjamin.peterson, dlitz, gvanrossum, pitrou, vstinner, zegreek
Date 2008-09-04.12:03:24
SpamBayes Score 6.522599e-07
Marked as misclassified No
Message-id <1220529807.24.0.817838616803.issue3187@psf.upfronthosting.co.za>
In-reply-to
Content
If, as I understand, it is the application's job to call listdir with
bytes or unicode depending on the platform, it might be useful to have a
function in the os module telling whether the filesystem is bytes of
unicode-native. 

That way, the idiom for doing something to all files in a given
directory would read:

>>> directory="my_direcory"
... if not os.is_filesystem_unicode():
...     directory=directory.encode(sys.stdin.encoding)
... for name in os.listdir(directory):
...     f=open(name)
... # do something
...     f.close()

and it would work on all platforms, even if one of the filenames is not
in the locale's normal encoding.

If this idiom is correct, it could also be useful to include it in the
module documentation so that application authors know what they are
supposed to do.
History
Date User Action Args
2008-09-04 12:03:27zegreeksetrecipients: + zegreek, gvanrossum, amaury.forgeotdarc, pitrou, vstinner, benjamin.peterson, HWJ, dlitz
2008-09-04 12:03:27zegreeksetmessageid: <1220529807.24.0.817838616803.issue3187@psf.upfronthosting.co.za>
2008-09-04 12:03:25zegreeklinkissue3187 messages
2008-09-04 12:03:24zegreekcreate