[issue5827] os.path.normpath doesn't preserve unicode
Ezio Melotti ezio.melo...@gmail.com added the comment: Fixed in r77442 (trunk) and r77443 (release26-maint), thanks! -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5827 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5827] os.path.normpath doesn't preserve unicode
Changes by Ezio Melotti ezio.melo...@gmail.com: -- assignee: - ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5827 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5827] os.path.normpath doesn't preserve unicode
Ezio Melotti ezio.melo...@gmail.com added the comment: assertTrue() also accepts a 'msg' argument where to explain what went wrong in case of failure [1]. [1]: http://docs.python.org/library/unittest.html#unittest.TestCase.assertTrue -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5827 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5827] os.path.normpath doesn't preserve unicode
Erik Carstensen sandb...@virtutech.com added the comment: Also, assertTrue has an alias failUnless which I personally find more descriptive (I don't know if either form is preferred for inclusion in Python though). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5827 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5827] os.path.normpath doesn't preserve unicode
Ezio Melotti ezio.melo...@gmail.com added the comment: failUnless is deprecated in Python3.1 [1]. The assert* methods are preferred over the fail* ones that are now deprecated. [1]: http://docs.python.org/3.1/library/unittest.html#unittest.TestCase.failUnless -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5827 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5827] os.path.normpath doesn't preserve unicode
Matt Giuca matt.gi...@gmail.com added the comment: Thanks Ezio. I've updated the patch to incorporate your suggestions. Note that I too have only tested it on Linux, but I tested both posixpath and ntpath (and there is no OS-specific code, except for the filenames themselves). I'm not sure if using assertTrue(isinstance ...) is better than assertEqual(type ...), because the type equality checking produces this error: AssertionError: type 'str' != type 'unicode' while isinstance produces this unhelpful error: AssertionError: False is not True But oh well, I made the change anyway as most test cases use isinstance. -- Added file: http://bugs.python.org/file15362/normpath.2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5827 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5827] os.path.normpath doesn't preserve unicode
Ezio Melotti ezio.melo...@gmail.com added the comment: Thanks for the patch, I tried it on Linux and it seems to solve the problem. A few comments about it: 1) I'd change all the self.assertEqual(type(posixpath.normpath(u)), unicode) to self.assertTrue(isinstance(posixpath.normpath(u), unicode)); 2) a test for normpath(u'.') should probably be added; 3) in ntpath.py the 'slash' is actually a backslash, so the name of the var should be changed; -- nosy: +ezio.melotti, kcwu, loewis, sandberg priority: - normal stage: - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5827 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5827] os.path.normpath doesn't preserve unicode
New submission from Matt Giuca matt.gi...@gmail.com: 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. -- components: Library (Lib), Unicode files: normpath.patch keywords: patch messages: 86395 nosy: mgiuca severity: normal status: open title: os.path.normpath doesn't preserve unicode versions: Python 2.6, Python 2.7 Added file: http://bugs.python.org/file13757/normpath.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5827 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5827] os.path.normpath doesn't preserve unicode
Changes by Matt Giuca matt.gi...@gmail.com: -- type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5827 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com