Code

Opened 6 years ago

Closed 5 years ago

Last modified 3 years ago

#9146 closed (invalid)

handlers/base.py relies on cpython-specific behavior

Reported by: fijal 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: UI/UX:

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.

Attachments (0)

Change History (6)

comment:1 Changed 5 years ago by jacob

  • milestone set to 1.1
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from relying on cpython's bug to handlers/base.py relies on cpython-specific behavior
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 5 years ago by Alex

  • Component changed from Uncategorized to Core framework

comment:3 Changed 5 years ago by jacob

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 Changed 5 years ago by mtredinnick

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 Changed 5 years ago by dc

  • Resolution set to invalid
  • Status changed from new to closed

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 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.