Message1480

Author hsk0
Recipients
Date 2007-05-17.02:52:27
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
I understand your concerns re: incomplete/broken platform-specific modules, and share them.

I've reviewed a good chunk of these differences. Here's what I see:
1. Most of the platform specific code looks good as-is
2. Some of the platform-specific code doesn't work as-is; for instance, the os.stat() calls in ntpath.py are a problem
3. The latest javapath.py has problems, explicit and implicit

I think #2 can be fixed with limited effort, or if not 100% then no worse than the current javapath.py. Certainly more complete and desired than #3.

So far, everything I've found in the platform-specific .py's that looks problematic seems fixable (derived in no small part from the work in javapath.py). I'm partially done and it looks promising so far. It looks like this update will entail:
* Adding or Modifying 6 .py files in CPythonLib (e.g. replacing os.stat() calls in ntpath.py)
* Modifying javaos.py
* Probably also modifying javapath.py (I have some thoughts, but haven't gotten there yet)
* Test cases

I'll post my patch shortly, once I get the bits a bit further along.

Besides os.stat, if you know any specific tips or gotchas to pay close attention to, do share.


I just have one question: In javapath.py, why is _tostr() used?

From what I can tell, it acts as a blocker only allowing strings past, typically used on parameters in javapath fuctions; non-string parameters kick a pretty exception message.

Why?

Reviewing the CPython platform-specific code, parameters are just used, expecting 'the right thing'. For instance, macpath.py's isabs(s) is a 1 liner:

    return ':' in s and s[0] != ':'

So the parameter has to support the 'in' and index operators or CPython would throw an exception, but they don't specifically require the parameter to be a basestring. Compare with the javapath.py implementation

def isabs(path):
    path = _tostr(path, "isabs")
    return File(path).isAbsolute()

It seems like javapath requires string parameters whereas the CPython bits accept any string-like type.

The latter seems more Pythonic to me, but I'm not clear on the history behind all this code so I'm wondering - why?

Is javapath's _tostr() behavior important for some subtle reason I'm not spotting?
Desirable for some reason I'm not picking up?
A historical necessity or accident, but which is now irrelevant (or even harmful)?

Wondering if, as I fixup the platform-specific *path.py's, if _tostr()-like behavior is something I need to worry about.
History
Date User Action Args
2008-02-20 17:17:44adminlinkissue1661700 messages
2008-02-20 17:17:44admincreate