summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2002-03-29 14:29:35 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2002-03-29 14:29:35 (GMT)
commit5053b70da013a338a3a710875d94e811c95dee9d (patch)
tree32c9d9520c75a4337c5cf422f8258ac4a3bae884 /Mac
parent695b33b02a0288819c2b0e61f5b1e28bcd5ac966 (diff)
downloadcpython-5053b70da013a338a3a710875d94e811c95dee9d.zip
cpython-5053b70da013a338a3a710875d94e811c95dee9d.tar.gz
cpython-5053b70da013a338a3a710875d94e811c95dee9d.tar.bz2
If the file has no resource fork first check to see whether it's a
datafork-based resource file before trying to decode it as AppleSingle.
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Lib/macresource.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/Mac/Lib/macresource.py b/Mac/Lib/macresource.py
index 4bd40bc..4eaf076 100644
--- a/Mac/Lib/macresource.py
+++ b/Mac/Lib/macresource.py
@@ -77,13 +77,20 @@ def open_pathname(pathname):
refno = Res.FSpOpenResFile(pathname, 1)
except Res.Error, arg:
if arg[0] in (-37, -39):
- # No resource fork. We may be on OSX, try to decode
- # the applesingle file.
- pathname = _decode(pathname)
- if pathname:
+ # No resource fork. We may be on OSX, and this may be either
+ # a data-fork based resource file or a AppleSingle file
+ # from the CVS repository.
+ try:
refno = Res.FSOpenResourceFile(pathname, u'', 1)
+ except Res.Error, arg:
+ if arg[0] != -199:
+ # -199 is "bad resource map"
+ raise
else:
- raise
+ return refno
+ # Finally try decoding an AppleSingle file
+ pathname = _decode(pathname)
+ refno = Res.FSOpenResourceFile(pathname, u'', 1)
return refno
def _decode(pathname):