Skip to contentSkip to conversation

Slightly broken exception handling in bb.utils.movefile()

DISCUSSION Phil Blundell 1 participant 1 message Oct 12, 2016

lore
Share & tools
lore
#0 lore raw

This code:

        except Exception as e:
            if e[0] != errno.EXDEV:
                # Some random error.
                print("movefile: Failed to move", src, "to", dest, e) return None

doesn't seem to work any more (presumably since Python 3).  If you end up with a PermissionDeniedError here then you get a runtime crash because PermissionDeniedErrors aren't subscriptable.

In fact I'm not sure the above was ever quite correct even with Python
2.  I assume that it ought to be a bit more like:

        except OSError as e:
            if e.errno != errno.EXDEV:

p.