Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I believe the error is caused by a misuse of <code>sys.exc_clear()</code> and exceptions. The actual problem is that you're calling it after handling another exception. This is the exception that actually gets cleared, not the one in the you recorded.</p> <p>A solution to your problem would be to create a different method for tracking exceptions and call it in the except clause and call it only in the except clause -- that way the exception will always be the right one.</p> <p>Problems I can see in the code above:</p> <ol> <li>You're calling <code>exc.clear_exc()</code> after another exception has been handled, clearing it not the one you want.</li> <li>You want to call <code>exc.clear_exc()</code> to clear someone else's exceptions - this is wrong and it can break the program (e.g. if a bare <code>raise</code> is called after the call to a fixed version <code>track</code>, it will fail). Whoever is handling the exception likes to use those values, clearing them like this can do no good. </li> <li>You're expecting that if there was no error, <code>sys.exc_info()</code> will not be set as long as you clear it each time. That is not true -- there might be data for a previous exception there in a completely unrelated call to <code>track</code>. Don't rely on that.</li> </ol> <p>All of those are fixed by using separate methods and never using <code>sys.clear_exc()</code>. </p> <p>Oh, another thing, if those <code>except:</code> clauses without an exceptions are not just examples, it's advisable to handle only exceptions that you know about, and not all of them like that.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload