New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os.path.normcase documentation/behaviour unclear on Mac OS X #47735
Comments
$ python
Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from os.path import normcase
>>> normcase ('aB')
'aB'
>>> From http://docs.python.org/lib/module-os.path.html: "On Unix, this |
"Of course, Mac OS X is both Unix and case-insensitive" Not so. Case-{in|}sensitivity is an attribute of HFS+ file systems that is |
Ok, good point. Perhaps the documentation should be updated to clarify |
On Windows, case-insensitivity is part of the API, not of the file I believe FAT is inherently case-insensitive. |
The following patch explicitly mentions that os.path.normcase treats OSX I'm in favor of applying this. |
I've committed a fix for this in r70746 and ported this to 3.1 and 2.6 as |
I'm reopening this because now the normcase implementation of posixpath has a todo that says "on Mac OS X, this should really return s.lower()." (see r66743). |
The comment is wrong, os.path.normcase should not return s.lower(), as the other issue notes the case sensitivity is filesystem dependent. Returning s.lower() will break code when dealing with paths that refer to an NFS share on a Linux server, or to a path on a local case sensitive file system. IMHO The comment in posixpath should be changed to something like this: # On MacOS X most but not all filesystems are case sensitive, which The current comment gives the impression that a trivial should be applied, which isn't true. |
Changing the function is better than changing the comment. |
Note that this does not just affect MacOSX, this even affects Linux (although the behaviour on the default filesystems is different). On Linux the default is case-sensitive filesystems, but you can use network filesystems that have case-insensitive behavior, for example by using a CIFS share. This means that /mnt/myserver-share/foo/bar and /mnt/myserver-share/FOO/BAR may or may not refer to the same "object": there aren't the same if /mnt/myserver-share is a regular Linux filesystem but will be when /mnt/myserver-share is a mount from a CIFS server. In short: os.path.normcase is hopelessly naive in its assumptions about system behavior. |
Is this or could this be addressed via the new pathlib module? |
New changeset a854d23305de by Ned Deily in branch '3.4': New changeset 3edda677119e by Ned Deily in branch 'default': |
The misleading "TODO" comment has been removed. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: