Ticket #4045: f_locals.patch

File f_locals.patch, 2.0 KB (added by alanfranzoni, 6 years ago)
  • twisted/python/failure.py

    diff --git a/twisted/python/failure.py b/twisted/python/failure.py
    index bf928e0..d8bb078 100644
    a b class _Traceback(object): 
    102102class _Frame(object):
    103103    """
    104104    A fake frame object, used by L{_Traceback}.
     105
     106    @ivar f_code: fake L{code<types.CodeType>} object
     107    @ivar f_globals: fake f_globals dictionary (usually empty)
     108    @ivar f_locals: fake f_locals dictionary (usually empty)
    105109    """
    106110
    107111    def __init__(self, name, filename):
     112        """
     113        @param name: method/function name for this frame.
     114        @type name: C{str}
     115        @param filename: filename for this frame.
     116        @type name: C{str}
     117        """
     118
    108119        self.f_code = _Code(name, filename)
    109120        self.f_globals = {}
     121        self.f_locals = {}
    110122
    111123
    112124class _Code(object):
  • twisted/test/test_failure.py

    diff --git a/twisted/test/test_failure.py b/twisted/test/test_failure.py
    index 7dc0ab1..c623bac 100644
    a b class TestFormattableTraceback(unittest.TestCase): 
    314314                          ('filename.py', 235, 'method2', None)])
    315315
    316316
     317class TestFrameAttributes(unittest.TestCase):
     318    """
     319    _Frame objects should possess some basic attributes that qualify them as
     320    fake python Frame objects.
     321    """
     322
     323    def test_fakeFrameAttributes(self):
     324        """
     325        basic _Frame attributes faking.
     326        """
     327        frame = failure._Frame("dummyname", "dummyfilename")
     328        self.assert_(isinstance(frame.f_globals, dict))
     329        self.assert_(isinstance(frame.f_locals, dict))
     330        self.assert_(isinstance(frame.f_code, failure._Code))
     331
     332
    317333if sys.version_info[:2] >= (2, 5):
    318334    from twisted.test.generator_failure_tests import TwoPointFiveFailureTests
  • new file twisted/topfiles/4045.feature

    diff --git a/twisted/topfiles/4045.feature b/twisted/topfiles/4045.feature
    new file mode 100644
    index 0000000..bcbe81e
    - +  
     1twisted.python.failure._Frame objects now support fake f_locals attribute.