Skip to content
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
Closed

traceback bug with closures #132

sqlalchemy-bot opened this issue Apr 17, 2010 · 4 comments
Labels
bug Something isn't working low priority runtime

Comments

@sqlalchemy-bot
Copy link

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
Copy link
Author

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
Copy link
Author

Michael Bayer (@zzzeek) wrote:

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

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot
Copy link
Author

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
Labels
bug Something isn't working low priority runtime
Projects
None yet
Development

No branches or pull requests

1 participant