This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: IDLE incorrectly labeling error as internal
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: IDLE removes elements from tracebacks.
View: 24252
Assigned To: terry.reedy Nosy List: Tadhg McDonald-Jensen, kbk, ppperry, roger.serwy, terry.reedy
Priority: normal Keywords:

Created on 2016-03-23 18:00 by Tadhg McDonald-Jensen, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
run.py Tadhg McDonald-Jensen, 2016-03-23 18:00 raise ValueError #this and the file name get internal error message
Messages (4)
msg262293 - (view) Author: Tadhg McDonald-Jensen (Tadhg McDonald-Jensen) * Date: 2016-03-23 18:00
(I apologize if I'm doing something wrong)

When using a file named run.py in idle, any errors raised from the module makes IDLE show a traceback like this:

Traceback (most recent call last):
** IDLE Internal Exception: 
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/idlelib/run.py", line 351, in runcode
    exec(code, self.locals)
  File "/Users/Tadhg/Documents/run.py", line 1, in <module>
    raise ValueError
ValueError

I looked into idlelib.run and think the culprit is the way print_exception tries to exclude internal files, specifically line 180 in vs 2.7 and line 206 in vs3.5

            exclude = ("run.py", "rpc.py", "threading.py", "queue.py",
                       "RemoteDebugger.py", "bdb.py")

this excludes paths with these names anywhere in the path (later in cleanup_traceback) instead of getting the absolute paths of these modules.
msg262322 - (view) Author: Tadhg McDonald-Jensen (Tadhg McDonald-Jensen) * Date: 2016-03-24 02:50
other then bdb.py all of the excluded modules are imported into idlelib.run so that line could be replaced with:

import bdb
exclude = (__file__, rpc.__file__, threading.__file__, 
           queue.__file__, RemoteDebugger.__file__, bdb.__file__)

although it is really only necessary for run, rpc and RemoteDebugger since they are imported through `idlelib.__` so it could also use a notation like this:


exclude = ("idlelib/run.py", "idlelib/rpc.py", "threading.py", "queue.py",
           "idlelib/RemoteDebugger.py", "bdb.py")

although this would need to make use of os.path.join or equivalent to be cross compatible.
msg262457 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-03-25 22:24
The goal is to match the traceback that Python itself produces with the same code, but it is perhaps an impossible process. The current list goes back to 2003 without tracker issue numbers, so I don't know the reason for each.  I worry a bit about the suppression of lines from threading and queue.

I wondered why the idlelib.run lines were here until I read this (3.5.2, run.py, line 233-236.

    if len(tb) == 0:
        # exception was in IDLE internals, don't prune!
        tb[:] = orig_tb[:]
        print("** IDLE Internal Exception: ", file=sys.stderr)

So both lines were deleted and then restored.

Prepending idlelib as appropriate, seems like a good idea.

    exclude = ['bdb.py', 'queue.py', 'threading.py']
    for name in ('RemoteDebugger.py', 'rpc.py', 'run.py'):
        exclude.append(os.path.join('idlelib', name))
msg263622 - (view) Author: (ppperry) Date: 2016-04-17 18:29
Duplicate issue24252, although the consequences are slightly different.
History
Date User Action Args
2022-04-11 14:58:28adminsetgithub: 70814
2017-06-23 04:23:17terry.reedysetstatus: open -> closed
assignee: terry.reedy
superseder: IDLE removes elements from tracebacks.
resolution: duplicate
stage: test needed -> resolved
2016-04-17 18:29:27ppperrysetnosy: + ppperry
messages: + msg263622
2016-03-25 22:24:37terry.reedysetmessages: + msg262457
stage: test needed
2016-03-24 02:50:09Tadhg McDonald-Jensensetmessages: + msg262322
2016-03-23 18:13:25serhiy.storchakasetnosy: + terry.reedy, kbk, roger.serwy

versions: + Python 3.6
2016-03-23 18:00:45Tadhg McDonald-Jensencreate