method: path.local.getpycodeobj

*Not documented*
    def getpycodeobj(self):

origin: path.local

where:

exceptions that might appear during execution:

function source:

def getpycodeobj(self):
    dotpy = self.check(ext='.py')
    if dotpy:
        my_magic     = py.std.imp.get_magic()
        my_timestamp = int(self.mtime())
        if __debug__:
            pycfile = self + 'c'
        else:
            pycfile = self + 'o'
        try:
            f = pycfile.open('rb')
            try:
                header = f.read(8)
                if len(header) == 8:
                    magic, timestamp = py.std.struct.unpack('<4si', header)
                    if magic == my_magic and timestamp == my_timestamp:
                        co = py.std.marshal.load(f)
                        path1 = co.co_filename
                        path2 = str(self)
                        if path1 == path2:
                            return co
                        try:
                            if os.path.samefile(path1, path2):
                                return co
                        except (OSError,          # probably path1 not found
                                AttributeError):  # samefile() not available
                            pass
            finally:
                f.close()
        except py.error.Error:
            pass
    s = self.read(mode='rU') + '\n'
    codeobj = compile(s, str(self), 'exec', generators.compiler_flag)
    if dotpy:
        try:
            f = pycfile.open('wb')
            f.write(py.std.struct.pack('<4si', 'TEMP', -1))  # fixed below
            py.std.marshal.dump(codeobj, f)
            f.flush()
            f.seek(0)
            f.write(py.std.struct.pack('<4si', my_magic, my_timestamp))
            f.close()
        except py.error.Error:
            pass
    return codeobj

call sites:

called in /home/johnny/projects/merlinux/py/dist/py/path/common.py

traceback path.local.getpycodeobj.0

called in /home/johnny/projects/merlinux/py/dist/py/path/common.py

traceback path.local.getpycodeobj.1

called in /home/johnny/projects/merlinux/py/dist/py/path/common.py

traceback path.local.getpycodeobj.2

called in /home/johnny/projects/merlinux/py/dist/py/path/common.py

traceback path.local.getpycodeobj.3

called in /home/johnny/projects/merlinux/py/dist/py/path/common.py

traceback path.local.getpycodeobj.4

called in /home/johnny/projects/merlinux/py/dist/py/path/common.py

traceback path.local.getpycodeobj.5

called in /home/johnny/projects/merlinux/py/dist/py/path/common.py

traceback path.local.getpycodeobj.6

called in /home/johnny/projects/merlinux/py/dist/py/path/common.py

traceback path.local.getpycodeobj.7

called in /home/johnny/projects/merlinux/py/dist/py/path/common.py

traceback path.local.getpycodeobj.8

called in /home/johnny/projects/merlinux/py/dist/py/path/common.py

traceback path.local.getpycodeobj.9