tests/readlink.py
author Augie Fackler <augie@google.com>
Tue, 11 Aug 2015 14:53:47 -0400
changeset 26010 2c03e521a0c5
parent 25660 328739ea70c3
child 29175 7bcfb9090c86
permissions -rwxr-xr-x
reachableroots: return NULL if we're throwing an exception Based on my reading of [0] and surrounding sections, if we want an exception to be properly raised when something goes wrong in the C code, we need to make sure we return NULL here. Do so. https://docs.python.org/2/extending/extending.html#back-to-the-example

#!/usr/bin/env python

import errno, os, sys

for f in sys.argv[1:]:
    try:
        print f, '->', os.readlink(f)
    except OSError as err:
        if err.errno != errno.EINVAL:
            raise
        print f, 'not a symlink'

sys.exit(0)