Fix build issues on OSX 10.6 (issue 6802)
diff --git a/Lib/plat-mac/macresource.py b/Lib/plat-mac/macresource.py
index f02453b..d693c87 100644
--- a/Lib/plat-mac/macresource.py
+++ b/Lib/plat-mac/macresource.py
@@ -77,52 +77,38 @@
def open_pathname(pathname, verbose=0):
"""Open a resource file given by pathname, possibly decoding an
AppleSingle file"""
+ # 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.FSpOpenResFile(pathname, 1)
+ refno = Res.FSOpenResourceFile(pathname, u'', 1)
except Res.Error, arg:
- if arg[0] in (-37, -39):
- # 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:
- return refno
- # Finally try decoding an AppleSingle file
- pathname = _decode(pathname, verbose=verbose)
- refno = Res.FSOpenResourceFile(pathname, u'', 1)
- else:
+ if arg[0] != -199:
+ # -199 is "bad resource map"
raise
- return refno
+ else:
+ return refno
+ # Finally try decoding an AppleSingle file
+ pathname = _decode(pathname, verbose=verbose)
+ refno = Res.FSOpenResourceFile(pathname, u'', 1)
def resource_pathname(pathname, verbose=0):
"""Return the pathname for a resource file (either DF or RF based).
If the pathname given already refers to such a file simply return it,
otherwise first decode it."""
+ # 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.FSpOpenResFile(pathname, 1)
- Res.CloseResFile(refno)
+ refno = Res.FSOpenResourceFile(pathname, u'', 1)
except Res.Error, arg:
- if arg[0] in (-37, -39):
- # 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:
- return refno
- # Finally try decoding an AppleSingle file
- pathname = _decode(pathname, verbose=verbose)
- else:
+ if arg[0] != -199:
+ # -199 is "bad resource map"
raise
+ else:
+ return refno
+ # Finally try decoding an AppleSingle file
+ pathname = _decode(pathname, verbose=verbose)
return pathname
def open_error_resource():