15

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)

bad_coder
  • 11,289
  • 20
  • 44
  • 72
0x539
  • 1,489
  • 1
  • 13
  • 30

2 Answers2

1

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()
Community
  • 1
  • 1
0x539
  • 1,489
  • 1
  • 13
  • 30
  • thanks for the suggestion but it now breaks into : File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd_file_utils.py", line 341, in GetFilenameAndBase – Anona112 Dec 20 '15 at 16:11
  • @Anona112 I haven't experienced this behaviour; I probably changed some other setting. but I don't remember anymore – 0x539 Dec 21 '15 at 17:11
1

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()
Anona112
  • 3,724
  • 4
  • 21
  • 30