[Pythonmac-SIG] CFURL Pain

Bob Ippolito bob at redivi.com
Mon Feb 28 19:56:08 CET 2005


On Feb 28, 2005, at 1:41 PM, has wrote:

> I'm not really up on these APIs nor their Python wrappers, but I  
> suspect this stuff is broke:
>
> First try:
>
> import Carbon.CF as CF
> f =  
> CF.CFURLCreateFromFileSystemRepresentation('file://localhost/Users/ 
> has/', True)
> print f # <CFURL object at 0x000c10e0 for 0x000de810>
> print `f.CFURLGetString().toPython()` #  
> u'./file://localhost/Users/has' (Where did './' come from?)
> print f.toPython() # MacOS.Error: (-192, 'Resource not found')
> print f.CFURLGetFSRef() # crashes
> print f.CFURLGetFSRef()[1].as_pathname() # MacOS.Error: (-35, 'no such  
> volume')
>
> Second try:
>
> import Carbon.CF as CF
> f = CF.toCF('file://localhost/Users/has/').CFURLCreateWithString(None)
> print f # <CFURL object at 0x000c10f0 for 0x0004fec0>
> print `f.CFURLGetString().toPython()` # u'file://localhost/Users/has/'
> print f.toPython() # MacOS.Error: (-192, 'Resource not found')
> print f.CFURLGetFSRef() # crashes
> print f.CFURLGetFSRef()[1].as_pathname() # crashes
>
>
> Anyone want to confirm/correct me? (OS10.2.8, MacPython 2.3.3)

I wouldn't be surprised if it's broken, use PyObjC and NSURL instead,  
those work.  Why haven't you upgraded to 2.3.5 (not that I think it  
would help)?

-bob



More information about the Pythonmac-SIG mailing list