tests/readlink.py
author Martin von Zweigbergk <martinvonz@google.com>
Sun, 31 Jan 2016 00:31:55 -0800
branchstable
changeset 27964 ac5057d5fc37
parent 25660 328739ea70c3
child 29175 7bcfb9090c86
permissions -rwxr-xr-x
verify: recover lost freeing of memory In df8973e1fb45 (verify: move file cross checking to its own function, 2016-01-05), "mflinkrevs = None" was moved into function, so the reference was cleared there, but the calling function now held on to the variable. The point of clearing it was presumably to free up memory, so let's move the clearing to the calling function where it makes a difference. Also change "mflinkrevs = None" to "del mflinkrevs", since the comment about scope now surely is obsolete.

#!/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)