Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent PyCharm from showing builtin modules on KeyboardInterrupt and other occasions

In PyCharm when an Error occurs the IDE opens the module that produced the Error (this is especially annoying when the Error was produced by pressing Ctrl+C).

It also opens the module in which the program currently "is" when pausing in Debug mode. Is there a way to disable this behavior for built-in modules? (Preferably with a way of showing the exception anyway in case you want to see the source of the built-in module)

like image 691
0x539 Avatar asked Sep 16 '15 14:09

0x539


2 Answers

I accept the bounty as it pointed to the right direction:

applying the same trick to the file pydevd.py line 1793 finally solved it for me!!

        try:
          launch(file, globals, locals)  # execute the script
        except:
          import traceback; traceback.print_exc()
like image 152
Anona112 Avatar answered Nov 18 '22 00:11

Anona112


As I posted later here you can Edit PyDev's source to prevent parts of this from happening:

First, you have to find the source for the PyDev interactive interpreter (which is used by PyCharm). On my Windows machine it is located in C:\Program Files (x86)\PyCharm\helpers\PyDev (path my vary of course).

The problem can be fixed by editing the file _pydev_imps/_pydev_execfile.py (in the PyDev source directory). Line 18 reads

exec(compile(contents+"\n", file, 'exec'), glob, loc)

wrap it in a try ... except block with the following code as exception handler

import traceback; traceback.print_exc()
like image 33
0x539 Avatar answered Nov 18 '22 00:11

0x539