Author scoder
Recipients scoder
Date 2013-08-31.10:56:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1377946586.23.0.205823706154.issue18893@psf.upfronthosting.co.za>
In-reply-to
Content
The exception handling clauses in framework_find() are weird.


def framework_find(fn, executable_path=None, env=None):
    """
    Find a framework using dyld semantics in a very loose manner.

    Will take input such as:
        Python
        Python.framework
        Python.framework/Versions/Current
    """
    try:
        return dyld_find(fn, executable_path=executable_path, env=env)
    except ValueError as e:
        pass
    fmwk_index = fn.rfind('.framework')
    if fmwk_index == -1:
        fmwk_index = len(fn)
        fn += '.framework'
    fn = os.path.join(fn, os.path.basename(fn[:fmwk_index]))
    try:
        return dyld_find(fn, executable_path=executable_path, env=env)
    except ValueError:
        raise e


My guess is that this is left-over code from Py2.x. Since it doesn't make sense to catch an exception in the second clause just to re-raise it, I think the intention was really to re-raise the original exception caught in the first clause, which no longer works that way in Py3.

The fix would then be to assign the exception to a new variable in the first except clause and re-raise that in the second.

I found this problem because Cython rejected the module with a compile error about "e" being undefined in the last line.
History
Date User Action Args
2013-08-31 10:56:26scodersetrecipients: + scoder
2013-08-31 10:56:26scodersetmessageid: <1377946586.23.0.205823706154.issue18893@psf.upfronthosting.co.za>
2013-08-31 10:56:26scoderlinkissue18893 messages
2013-08-31 10:56:25scodercreate