|
From: <bc...@wo...> - 2001-07-24 20:32:38
|
[Ype Kingma]
>I investigated the problem of my previous post (below).
>It appears that os.path.dirname() is confused when
>using both backward and forward slashes, ...
Could you show an example of this confusion? I think the results is far
better than what I had feared:
Jython 2.1a2 on java1.4.0-beta (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.dirname('e:\\someDir\\packag/modul.py')
'e:\\someDir\\packag'
>>> os.path.dirname('e:\\someDir\\packag\\modul.py')
'e:\\someDir\\packag'
>>> os.path.dirname('e:\\someDir/packag/modul.py')
'e:\\someDir\\packag'
>>>
>in the directory of the main module not being on sys.path,
>(through my own code) resulting the import failure reported.
>Also os.path.normcase() and os.path.normpath() don't seem
>to be doing much (21a2, 1.1.8, OS2),
I think normcase a hard to do correctly on java. We could perhaps
improve the situation for a huge majority of users by testing for some
common case-ignoring OS'es. Windows and OS/2 spring to mind. Any others?
normpath() was missing a replace path.replace("/", sep) when sep is '\'
and I have added that. A part from that normpath seems to work
correctly.
>so I added my own
>normPath() function doing lower(), replacing backward by forward
>slashes and replacing multiple slashes by a single one.
>(It doesn't replace \.\ by \, as which is sometimes needed
>for the filenames of imported modules.)
>
>I had a look at the various os.path implementations, and
>the NT one seems quite close to what is needed under OS2.
>However, I could not find where os.path is defined and
>whether something else than javapath can be used in Jython.
>
>In Java path names are system dependent, so it might be
>worthwhile to have all os.path implementations available
>in jython, together with some indication of the underlying
>OS, so the program can decide for itself how to treat pathnames.
>
>Or is this already possible in Jython?
Only with something like jnios.
>Finally another thing (21a1): I renamed the directory of a package,
>and then changed all occurrences of the package name.
>Then I found out that the compiled modules contain a reference
>to the old package file name, even though they where loaded
>using the new package name. The fix was to remove the class files.
>Should this be added to the docs or is it a bug?
I suppose it depends on the situation. Note that CPython will write the
old packagename in stacktraces. Where is it you say the old package
names?
regards,
finn
|