Opened 5 years ago

Closed 4 years ago

#4045 enhancement closed fixed (fixed)

Twisted's Failure fake '_Frame' object lacks f_locals

Reported by: sidnei Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:
Author: Launchpad Bug:

Description

Upon updating Twisted and zope.testing on a known Zope 3-based project, a new failure showed up on a test that was exercising the behavior of trial-based unittests as run by zope.testing's testrunner.

Turns out that a failure wasn't properly being reported due to zope.testing's custom format_traceback function trying to access the 'f_locals' attribute of a frame object (twisted.python.failure._Frame) from the handed over traceback object (an instance of twisted.python.failure._Traceback).

Of course the code from zope.testing is brittle enough to fall over on its back due to this missing attribute, but there's no apparent reason for Twisted's fake Frame object not provide the said 'f_locals' attribute other than perhaps memory issues (http://bugs.python.org/issue6116).

Attachments (1)

f_locals.patch (2.0 KB) - added by alanfranzoni 4 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 4 years ago by alanfranzoni

  • Keywords review added
  • Owner glyph deleted
  • Type changed from defect to enhancement

I realize that probably _Frame objects, and other fake objects created by twisted failure infrastructure for exception delivery, will NEVER support the full python sync exception API; most objects got ton of attributes.

By the way zc.buildout and its test runner is gaining momentum in the community, with a point; it's getting increasingly easy to have quickly reproducibile builds and separate work environments in python, something that Java got from years. Hence I think that this small patch (which I would call a feature) deserves its place in twisted trunk.

Changed 4 years ago by alanfranzoni

comment:2 Changed 4 years ago by exarkun

... but zope.testing works without f_locals now right?

comment:3 Changed 4 years ago by exarkun

  • Author set to exarkun
  • Branch set to branches/fakeframe-f_locals-4045

(In [29478]) Branching to 'fakeframe-f_locals-4045'

comment:4 Changed 4 years ago by exarkun

(In [29479]) Apply f_locals.patch

refs #4045

comment:5 Changed 4 years ago by exarkun

  • Author exarkun deleted
  • Branch branches/fakeframe-f_locals-4045 deleted
  • Keywords review removed
  • Owner set to exarkun
  • Status changed from new to assigned

Alright, well, I have no idea if this will actually help zope.testing or not, but it still sorta makes sense, particularly since f_globals is already there.

This basically looks fine. There are a couple coding standard issues that I'll fix up, then I'll merge the branch.

comment:6 Changed 4 years ago by exarkun

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [29494]) Merge fakeframe-f_locals-4045

Author: alanfranzoni
Reviewer: exarkun
Fixes: #4045

Add an f_locals attribute to the fake frame instances used by
twisted.python.failure when real frames aren't available.

This doesn't convey any information about locals, but it might
help tools expecting real frames not break.

comment:7 Changed 3 years ago by <automation>

  • Owner exarkun deleted
Note: See TracTickets for help on using tickets.