Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#9146 closed (invalid)

handlers/base.py relies on cpython-specific behavior

Reported by: Maciej Fijalkowski Owned by: jacobkm
Component: Core (Other) Version: 1.0
Severity: Keywords: pypy obscure
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Example of code:

import sys
try:
    raise 1/0
except:
    try:
        stuff
    finally:
        print sys.exc_info()

I think it should print NameError inside print. CPython behaves differently. Anyway, it's very confusing. The same logic is in
handlers/base.py around line 118, which indirectly calls sys.exc_info.

Change History (6)

comment:1 by Jacob, 16 years ago

milestone: 1.1
Summary: relying on cpython's bughandlers/base.py relies on cpython-specific behavior
Triage Stage: UnreviewedAccepted

comment:2 by Alex Gaynor, 16 years ago

Component: UncategorizedCore framework

comment:3 by Jacob, 16 years ago

There really isn't enough information here for me to figure out what to change. There's some pretty deeply nested exception handling there in the base handler, and I don't know which one's wrong, or what the wrong behavior looks like, or how to trigger it. Without more info -- and preferably a patch -- I don't know that I can intuit enough about this problem to fix it.

comment:4 by Malcolm Tredinnick, 16 years ago

I had a rummage through all the "finally" handlers in the request processing code last week and I couldn't find anything that called exc_info(). Thought I'd noted that here, but apparently I was distracted by a seagull before I got around to it. In any case, I'm in the same position as Jacob: need more info.

comment:5 by dc, 16 years ago

Resolution: invalid
Status: newclosed

I think it should print NameError? inside print.

No, it shouldn't. This is officially documented in the Python Language Reference: http://docs.python.org/reference/compound_stmts.html#try:
"The exception information is not available to the program during execution of the finally clause."

The same logic is in handlers/base.py

Could not find similar logic in that file. Please reopen if you can provide more information

comment:6 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top