コード例 #1
0
ファイル: support.py プロジェクト: Southpaw-TACTIC/Team
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))
コード例 #2
0
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))
コード例 #3
0
ファイル: support.py プロジェクト: Southpaw-TACTIC/Team
 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)
コード例 #4
0
 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)
コード例 #5
0
ファイル: support.py プロジェクト: kowey/moses
 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
コード例 #6
0
 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
コード例 #7
0
ファイル: support.py プロジェクト: Southpaw-TACTIC/Team
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)
コード例 #8
0
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)