[issue9018] os.path.normcase(None) does not raise an error on linux and should

2010-06-25 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

Fixed in r82214. Now os.path.normcase() raises a TypeError if the arg is not 
str or bytes.

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9018
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9018] os.path.normcase(None) does not raise an error on linux and should

2010-06-22 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

My understanding is that there is a deep problem here, in that file system case 
(and in some cases encoding) is not OS/platform dependent, but is rather *file 
system* dependent.

Adding lower to normcase on OS X is probably not going to break much code (he 
says with no evidence to back it up), but someday it would be nice to address 
the various file system type dependencies in the os module :(

In any case, it is probably better to address the 'lower' issue in a separate 
issue/patch.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9018
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9018] os.path.normcase(None) does not raise an error on linux and should

2010-06-22 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Ah, I see my lack of knowledge of OS X has betrayed me.  Apparently you can set 
the case sensitivity of OS X file systemsso the deep problem is even deeper 
than I thought :(

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9018
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9018] os.path.normcase(None) does not raise an error on linux and should

2010-06-22 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

This problem should be addressed in another issue though.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9018
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9018] os.path.normcase(None) does not raise an error on linux and should

2010-06-21 Thread Senthil Kumaran

Senthil Kumaran orsent...@gmail.com added the comment:

On Sat, Jun 19, 2010 at 08:00:55PM +, Shashwat Anand wrote:
 Why on Mac OS X, it should return s.lower() ?

That is is because some file systems on Mac OS X are case-sensitive.

 def normcase(s):
 Normalize case of pathname.  Has no effect under Posix
 if s is None:  
 raise AttributeError
 return s

It should be a TypeError, not AttributeError. (Attached Test cases
checks it properly)

--
nosy: +orsenthil

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9018
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9018] os.path.normcase(None) does not raise an error on linux and should

2010-06-21 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

ntpath and macpath raise an AttributeError, so we could:
1) change them all to accept only bytes/str and raise a TypeError for other 
wrong types (correct, consistent, non-backward-compatible);
2) change only posixpath to raise a TypeError for wrong types (partially 
correct, inconsistent, backward-compatible);
3) change only posixpath to raise an AttributeError for wrong types (wrong, 
consistent, backward-compatible);

The option 2 is still an improvement over the current situation, but it would 
be better to find a backward-compatible way to also obtain option 1 (assuming 
that backward compatibility is a concern here -- and I think it is (even though 
people could just change the code to catch (AttributeError, TypeError) and 
eventually get rid of the AttributeError)).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9018
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9018] os.path.normcase(None) does not raise an error on linux and should

2010-06-21 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

 ntpath and macpath raise an AttributeError, so we could:
 1) change them all to accept only bytes/str and raise a TypeError for
 other wrong types (correct, consistent, non-backward-compatible);

Sounds like the best thing to do.

 The option 2 is still an improvement over the current situation, but
 it would be better to find a backward-compatible way to also obtain
 option 1 (assuming that backward compatibility is a concern here --
 and I think it is (even though people could just change the code to
 catch (AttributeError, TypeError) and eventually get rid of the
 AttributeError)).

This isn't an exception you catch at runtime. It's an exception you get
when your code is wrong, and then you fix your code. Therefore I don't
think backwards compatibility is important.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9018
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9018] os.path.normcase(None) does not raise an error on linux and should

2010-06-21 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

Here is the patch.

--
assignee:  - ezio.melotti
components: +Library (Lib)
keywords: +patch
stage: needs patch - patch review
Added file: http://bugs.python.org/file17735/issue9018-2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9018
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9018] os.path.normcase(None) does not raise an error on linux and should

2010-06-21 Thread Senthil Kumaran

Senthil Kumaran orsent...@gmail.com added the comment:

Nice patch. I like the use of new string formating. It can be applied.
 
BTW, do you think that TODO of s.lower() for MAC OS X should be addressed along 
with this. It might require some research as how much of a desirable behavior 
it would be.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9018
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9018] os.path.normcase(None) does not raise an error on linux and should

2010-06-19 Thread Shashwat Anand

Shashwat Anand anand.shash...@gmail.com added the comment:

Following the documentation,
os.path.normcase(path)
Normalize the case of a pathname. On Unix and Mac OS X, this returns the path 
unchanged; on case-insensitive filesystems, it converts the path to lowercase. 
On Windows, it also converts forward slashes to backward slashes.

on Mac OS X,
 import os
 os.name
'posix'

Checking through, Lib/posixpath.py,

# Normalize the case of a pathname.  Trivial in Posix, string.lower on Mac.
# On MS-DOS this may also turn slashes into backslashes; however, other
# normalizations (such as optimizing '../' away) are not allowed
# (another function should be defined to do that).

def normcase(s):
Normalize case of pathname.  Has no effect under Posix
# TODO: on Mac OS X, this should really return s.lower().
return s

Why on Mac OS X, it should return s.lower() ?
Also to raise Error for None case we can probably change normcase() in 
Lib/posixpath.py as,

def normcase(s):
Normalize case of pathname.  Has no effect under Posix
if s is None:  
raise AttributeError
return s

--
nosy: +l0nwlf

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9018
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9018] os.path.normcase(None) does not raise an error on linux and should

2010-06-17 Thread R. David Murray

New submission from R. David Murray rdmur...@bitdance.com:

os.path.normcase(None) raises an error on Windows but returns None on linux.  
os.path.abspath(None) raises an error in both cases.  os.path.normcase(None) 
should raise an error on linux.

I've only marked this for 3.2 because I suspect there may be linux code out 
there that this will break, so the fix should probably only be applied to 3.2.  
(I discovered this because a unit test someone else wrote passed on linux but 
failed on windows.)

--
keywords: easy
messages: 108016
nosy: r.david.murray
priority: normal
severity: normal
stage: unit test needed
status: open
title: os.path.normcase(None) does not raise an error on linux and should
type: behavior
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9018
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9018] os.path.normcase(None) does not raise an error on linux and should

2010-06-17 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9018
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9018] os.path.normcase(None) does not raise an error on linux and should

2010-06-17 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' g.rod...@gmail.com:


--
nosy: +giampaolo.rodola

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9018
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9018] os.path.normcase(None) does not raise an error on linux and should

2010-06-17 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

Right now posixpath returns the argument unchanged, ntpath performs a 
.replace(), and macpath a .lower(), so when non-string (or non-bytes) are 
passed to normcase the results are:
posixpath: arg returned as-is;
ntpath: AttributeError (object has no attribute 'replace');
macpath: AttributeError (object has no attribute 'lower');

In posixpath we could reject all the non-string (and non-bytes) args, raising a 
TypeError. For consistency, the other functions should raise a TypeError too, 
but I'm not sure it's worth changing it.

Attached a simple testcase that checks that normcase raises a TypeError for 
invalid values with all the three implementations.

--
keywords: +patch
stage: unit test needed - needs patch
Added file: http://bugs.python.org/file17700/issue9018.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9018
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9018] os.path.normcase(None) does not raise an error on linux and should

2010-06-17 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
keywords:  -patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9018
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9018] os.path.normcase(None) does not raise an error on linux and should

2010-06-17 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

 I've only marked this for 3.2 because I suspect there may be linux code 
 out there that this will break,

It should be noticed that Linux-only code has absolutely no point in using 
normcase(), since it's a no-op there.

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9018
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com