def _getframe(depth=0): """Return a frame object from the call stack. This is a replacement for sys._getframe() which is aware of Psyco frames. The returned objects are instances of either PythonFrame or PsycoFrame instead of being real Python-level frame object, so that they can emulate the common attributes of frame objects. The original sys._getframe() ignoring Psyco frames altogether is stored in psyco._getrealframe(). See also psyco._getemulframe().""" # 'depth+1' to account for this _getframe() Python function return embedframe(_psyco.getframe(depth+1))
def __getattr__(self, attr): if attr == 'f_back': try: result = embedframe(_psyco.getframe(self._frame)) except ValueError: result = None except error: warn("f_back is skipping dead Psyco frames") result = self._frame.f_back self.__dict__['f_back'] = result return result else: return getattr(self._frame, attr)
def __getattr__(self, attr): if attr == "f_back": try: result = embedframe(_psyco.getframe(self._tag)) except ValueError: result = None elif attr == "f_lineno": result = self.f_code.co_firstlineno # better than nothing elif attr == "f_builtins": result = self.f_globals["__builtins__"] elif attr == "f_restricted": result = self.f_builtins is not __builtins__ elif attr == "f_locals": raise AttributeError, ("local variables of functions run by Psyco " "cannot be accessed in any way, sorry") else: raise AttributeError, ("emulated Psyco frames have " "no '%s' attribute" % attr) self.__dict__[attr] = result return result
def __getattr__(self, attr): if attr == 'f_back': try: result = embedframe(_psyco.getframe(self._tag)) except ValueError: result = None elif attr == 'f_lineno': result = self.f_code.co_firstlineno # better than nothing elif attr == 'f_builtins': result = self.f_globals['__builtins__'] elif attr == 'f_restricted': result = self.f_builtins is not __builtins__ elif attr == 'f_locals': raise AttributeError, ("local variables of functions run by Psyco " "cannot be accessed in any way, sorry") else: raise AttributeError, ("emulated Psyco frames have " "no '%s' attribute" % attr) self.__dict__[attr] = result return result
def _getemulframe(depth=0): """As _getframe(), but the returned objects are real Python frame objects emulating Psyco frames. Some of their attributes can be wrong or missing, however.""" # 'depth+1' to account for this _getemulframe() Python function return _psyco.getframe(depth+1, 1)