New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

traceback bug with closures #132

Closed
sqlalchemy-bot opened this Issue Apr 17, 2010 · 4 comments

Comments

Projects
None yet
1 participant
@sqlalchemy-bot

sqlalchemy-bot commented Apr 17, 2010

Migrated issue, originally created by Michael Bayer (@zzzeek)

When it lists the backtrace, like:

 ('/home/wacky/build/Vigilia/env/lib/python2.6/site-packages/pylons/controllers/core.py',
  105,
  '_inspect_call',
  'result = self._perform_call(func, args)'),
 ('/home/wacky/build/Vigilia/env/lib/python2.6/site-packages/pylons/controllers/core.py',
  57,
  '_perform_call',
  'return func(**args)'),
 ('<string>', 2, 'edit_album', None),
 ('/home/wacky/build/Vigilia/vigilia/lib/base.py',
  88,
  'wrapper',
  'return func(self, *args, **kwargs)'),


notice the <string>, 'edit_album', and None object.  This None object is the cause. It should be converted to string, or Mako should know how to deal with it.

We get a None there when the function is a closure, or a returned function that dynamically generated, which is the case with most decorators.

The solution is a two-liner:

diff -r 6cf6461d778243d8a8986c658eb2246e5939bdce mako/exceptions.py
--- a/mako/exceptions.py	Tue Apr 13 10:07:04 2010 -0400
+++ b/mako/exceptions.py	Sat Apr 17 16:28:52 2010 -0400
@@ -152,6 +152,8 @@
         rawrecords = traceback.extract_tb(trcback)
         new_trcback = []
         for filename, lineno, function, line in rawrecords:
+            if not line:
+                line = ''
             try:
                 (line_map, template_lines) = mods[filename]
             except KeyError:
}}
@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Apr 17, 2010

Michael Bayer (@zzzeek) wrote:

we suspect this is the bug:

    def test_format_closures(self):
        try:
            exec "def foo():"\
                 "    raise RuntimeError('test')"\
                 in locals()
            foo()
        except:
            html_error = exceptions.html_error_template().render()
            print html_error
@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Apr 17, 2010

Michael Bayer (@zzzeek) wrote:

the fix + test is in 68c7229 . reopen if further issues

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Apr 17, 2010

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Apr 17, 2010

Anonymous wrote:

Here's a demo Pylons application (create -t pylons) with Pylons 1.0b1

http://f.abourget.net/dump/makobug2-0.1dev.tar.gz

it does crash.. and shows what's required to make it crash, just go to http://localhost:5000/bug/index

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment