Author mgiuca
Recipients mgiuca
Date 2009-04-24.04:23:56
SpamBayes Score 6.66134e-16
Marked as misclassified No
Message-id <1240547039.35.0.461990786151.issue5827@psf.upfronthosting.co.za>
In-reply-to
Content
In the Python 2.x branch, os.path.normpath will sometimes return a str
even if given a unicode. This is not an issue in the Python 3.0 branch.

This happens specifically when it throws away all string data and
constructs its own:

>>> os.path.normpath(u'')
'.'
>>> os.path.normpath(u'.')
'.'
>>> os.path.normpath(u'/')
'/'

This is a problem if working with code which expects all strings to be
unicode strings (sometimes, functions raise exceptions if given a str,
when expecting a unicode).

I have attached patches (with test cases) for posixpath and ntpath which
correctly preserve the unicode-ness of the input string, such that the
new behaviour is:

>>> os.path.normpath(u'')
u'.'
>>> os.path.normpath(u'.')
u'.'
>>> os.path.normpath(u'/')
u'/'

I tried it on os2emxpath and plat-riscos/riscospath (the other two
OS-specific path modules), and it already worked fine for them.
Therefore, this patch fixes all necessary OS-specific versions of os.path.
History
Date User Action Args
2009-04-24 04:23:59mgiucasetrecipients: + mgiuca
2009-04-24 04:23:59mgiucasetmessageid: <1240547039.35.0.461990786151.issue5827@psf.upfronthosting.co.za>
2009-04-24 04:23:57mgiucalinkissue5827 messages
2009-04-24 04:23:57mgiucacreate