From: <pj...@us...> - 2009-06-08 06:41:39
|
Revision: 6468 http://jython.svn.sourceforge.net/jython/?rev=6468&view=rev Author: pjenvey Date: 2009-06-08 06:41:36 +0000 (Mon, 08 Jun 2009) Log Message: ----------- also special case paths with a single leading '/' (e.g. '/Jython25') as absolute on Windows. add test case for this and leading r'\' (r6413) fixes #1372 Modified Paths: -------------- trunk/jython/NEWS trunk/jython/src/org/python/core/PySystemState.java Added Paths: ----------- trunk/jython/Lib/test/test_nt_paths.py Added: trunk/jython/Lib/test/test_nt_paths.py =================================================================== --- trunk/jython/Lib/test/test_nt_paths.py (rev 0) +++ trunk/jython/Lib/test/test_nt_paths.py 2009-06-08 06:41:36 UTC (rev 6468) @@ -0,0 +1,40 @@ +"""Test path handling on Windows + +Made for Jython. +""" +from __future__ import with_statement +import os +import unittest +from test import test_support + +class NTAbspathTestCase(unittest.TestCase): + + def setUp(self): + with open(test_support.TESTFN, 'w') as fp: + fp.write('foo') + + # Move to the same drive as TESTFN + drive, self.path = os.path.splitdrive(os.path.abspath( + test_support.TESTFN)) + self.orig_cwd = os.getcwd() + os.chdir(os.path.join(drive, os.sep)) + + def tearDown(self): + os.chdir(self.orig_cwd) + os.remove(test_support.TESTFN) + + def test_abspaths(self): + # Ensure r'\TESTFN' and '/TESTFN' are handled as absolute + for path in self.path, self.path.replace('\\', '/'): + with open(path) as fp: + self.assertEqual(fp.read(), 'foo') + + +def test_main(): + if (os._name if test_support.is_jython else os.name) != 'nt': + raise test_support.TestSkipped('NT specific test') + test_support.run_unittest(NTAbspathTestCase) + + +if __name__ == '__main__': + test_main() Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2009-06-08 00:30:12 UTC (rev 6467) +++ trunk/jython/NEWS 2009-06-08 06:41:36 UTC (rev 6468) @@ -11,6 +11,7 @@ - [ 1364 ] SimpleHTTPServer.py contains call to missing os.fstat - [ 1367 ] PIpes (popen2) do not flush their buffer - [ 1368 ] '\xe4'.decode('utf-8') does not raise UnicodeDecodeError but returns u'' + - [ 1372 ] No default drive in Windows file paths - Fix file's repr with Windows paths - Fix urllib and urllib2 path handling on Windows - Fix r'\Jython25' not considered an abspath on Windows Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2009-06-08 00:30:12 UTC (rev 6467) +++ trunk/jython/src/org/python/core/PySystemState.java 2009-06-08 06:41:36 UTC (rev 6468) @@ -508,8 +508,10 @@ } File file = new File(path); - // Python considers r'\Jython25' an abspath on Windows, unlike java.io.File - if (!file.isAbsolute() && (!Platform.IS_WINDOWS || !path.startsWith("\\"))) { + // Python considers r'\Jython25' and '/Jython25' abspaths on Windows, unlike + // java.io.File + if (!file.isAbsolute() && (!Platform.IS_WINDOWS + || !(path.startsWith("\\") || path.startsWith("/")))) { if (sys == null) { sys = Py.getSystemState(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |