[Pythonmac-SIG] Serious bug with FSSpecs (and GUSI, and MacPython) on OSX

Jack Jansen jack@oratrix.com
Mon, 28 Jan 2002 11:45:35 +0100


On Monday, January 28, 2002, at 07:26 , Alexandre Parenteau wrote:

> Jack,
>
> I think it is difficult to get a FSRef support in GUSI : plus I think we
> need to get rid of GUSI ASAP.
>
> Now I failed to understand the exact problem : isn't GUSI supposed to 
> fail
> to create a FSSpec with a name >= 32 ? May be it is not, I remember I 
> had to
> do something special in MacCvs.

The problem is easily demonstrated. Create a folder with a file 
'file56789-123456789-123456789.py' in it, and go there in Python. Do the 
following:

 >>> os.listdir(':')
['file56789-123456789-12#66608.py']
 >>> macfs.FSSpec('file56789-123456789-123456789.py')
FSSpec((-100, 419338, 'file56789-123456789-12#66608.py'))
 >>> macfs.FSSpec('file56789-123456789-123456789.pyc')
Traceback (most recent call last):
   File "<input>", line 1, in ?
MacOS.Error: (-37, 'there may be no bad names in the final system!')
 >>> macfs.FSSpec('file56789-123456789-12#66608.pyc')  # XXXX
FSSpec((-100, 419338, 'file56789-123456789-12#66608.py'))
 >>> os.remove('file56789-123456789-12#66608.pyc') # XXXX
 >>> os.listdir(':')
[]
 >>>

As you can see, if you mangled the original filename (I changed .py to 
.pyc here) things work fine, i.e. the system knows that the .pyc file 
doesn't exist. However, if you mangle the filename as it appears when it 
has been processed as an FSSpec at some point you're hosed.

What I'm now thinking of is a bit of code in the pathname->fsspec code 
(both for MacPython and for GUSI) that tries to detect this situation, 
i.e. something like (in pseudo-Python here, but should be C)

      fss = FSSpec(pathname)
      if '#' in fss.name:
		p1 = strrchr('#', pathname)
		p2 = strrchr('#', fss.name)
		if p1 and strcmp(p1, p2) != 0:
			raise 'FSSpec for non-existing file would point to existing file'
--
- Jack Jansen        <Jack.Jansen@oratrix.com>        
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- Emma 
Goldman -