bug in os.path.samefile (Python 1.5.1)?

Gordon McMillan gmcm at hypernet.com
Mon Jun 7 15:22:49 CEST 1999


Matej Cepl writes:
/snip/
> Now, I need to check whether the processed file is in the "current"
> directory or I should make steps to make recursive calling on
> another directory. I guess, that the best way how to do it, is by
> calling os.path.samefile(os.path.dirname(full_name),base) {see below
> for context). However, Python 1.5.1 (I cannot use 1.5.2 not having
> administrator's rights on WinNT 4.0 WK) complains by following
> report: 

No, ntpath.samefile was broken in 1.5.1 and does not exist in 1.5.2. 
Can't compare inodes of things that don't have inodes.

You don't say how the name of the "processed file" was gathered. You 
could get tripped up by case, forward vs backward slashes and the 
presence or absence of a drive letter. If it was done in a "sane" 
way, then os.path.normpath on both operands will probably let a 
string compare work properly.


- Gordon




More information about the Python-list mailing list