Issue1534547

classification
Title: os.path.curdir, os.path.sep, ... missing from Jython 2.2a1
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fwierzbicki Nosy List: cgroves, fwierzbicki, pekka.klarck
Priority: normal Keywords:

Created on 2006-08-04.13:46:49 by anonymous, last changed 2007-01-31.05:17:19 by cgroves.

Messages
msg1192 (view) Author: Nobody/Anonymous (nobody) Date: 2006-08-04.13:46:49
I noticed that following attributes are missing from
'os.path' module in Jython 2.2a1 but they are available
at least on Python 2.4. 

altsep
curdir
extsep
pardir
pathsep
sep

Having these attributes would make it easier to write
code that works both in Python and Jython. Fortunately
'sep' and 'pathsep' are available in 'os' module and
others are not that important because, AFAIK, they have
same values at least on Windows, Linux and modern Macs.

msg1193 (view) Author: Pekka Klärck (pekka.klarck) Date: 2006-10-17.20:08:02
Logged In: YES 
user_id=1379331

When writing code for both Jython and Python it is not that
problematic that these attributes are missing because you'll
notice it pretty soon. A much bigger problem is that people
writing code to Python are unlikely to know that and it's
not possible to use code where these attrs are used in
Jython without tweaking.
msg1194 (view) Author: Pekka Klärck (pekka.klarck) Date: 2006-12-11.11:34:27
Noticed two more os.path related bugs that may cause interoperability issues with CPython and Jython.

1) os.path.realpath is missing. According to http://docs.python.org/lib/module-os.path.html it is in Python starting from 2.2.

2) os.path.normcase doesn't normalize the path in Windows as it should. See the doc mentioned above and examples below.

C:\>python
Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os.path
>>> os.path.normcase('C:\\Temp')
'c:\\temp'
>>>

C:\>jython
Jython 2.2a2952 on java1.5.0_06 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> import os.path
>>> os.path.normcase('C:\\Temp')
'C:\\Temp'
>>>
msg1195 (view) Author: Pekka Klärck (pekka.klarck) Date: 2007-01-22.17:09:47
An example of problems caused by this issue is http://wiki.python.org/jython/JythonMonthly/Articles/January2007/1 where missing os.path.sep requires following patch. (Changing os.path.sep to os.sep would've probably been a better solution in this case because os.name is 'java' in Jython.) 


####################

debugerror.py:

16a17
> from utils import fdict
20c21,27
< whereami = os.path.sep.join(whereami.split(os.path.sep)[:-1])
---
> #whereami = os.path.sep.join(whereami.split(os.path.sep)[:-1])
> #sep attribute doesn't seem to exist in jython, hence:
> if os.name == 'nt':
>     whereami = '\\'.join(whereami.split('\\')[:-1]) 
> else:
>     whereami = '/'.join(whereami.split('/')[:-1]) 
> 
msg1196 (view) Author: Charlie Groves (cgroves) Date: 2007-01-31.05:17:19
Partially fixed in r3068.  

I just copied the existing values for the attributes in os to path to fix the initial problem.  

For realpath, I'm just using File(path).getCanonicalPath() which I think does the same thing from reading the docs.  

I haven't done anything to fix the normcase method.  The existing implementation uses File(path).getPath() on the passed in path, but that does nothing to handle the case changes.  I'm not sure how to detect if a filesystem is case sensitive in java, so I opened a new bug(#1648449) for normpath.
History
Date User Action Args
2006-08-04 13:46:49anonymouscreate