I've noticed that if I run the exact same piece of Python 3 code in PyCharm, the "Run" tab sometimes will show the full traceback and error message, but other times will only show "Process finished with exit code 1".
1) Can someone explain why this happens?
2) Is there some way to force PyCharm to always show the full traceback and error message?
Edit: Here is an example that shows the behavior that I've been seeing. When I ran this 20 times, I got the traceback and error twice and the "exit code 1" message by itself 18 times. In order to see this behavior, the code seems to need to be busy printing something before the exception is raised. If I only raise the exception (without the calling callme()) I always get the traceback and error.
#!/usr/bin/python3
def callme():
print('doing some stuff!')
def main():
for i in range(1,100):
callme()
raise Exception('Something is went wrong!')
if __name__ == '__main__':
main()
Edit 2: I just realized that the answer to this probably has to be. The PyCharm Run display window only shows a certain number of lines. If the number of lines that it can print is less than the amount of stuff I am printing, then some of the lines won't show. So, actually the traceback lines are still there, but they just got printed way before some of the other output and so they aren't visible in the window. I found out that I can actually jump up to them (even if they aren't visible) by pressing the little up button next to the Run window.
Edit 3: Looks like I'm not the only person who has had this problem: PyCharm output error messages interspersed with console output. How to fix this?
According to that question, it got reported as a bug (https://youtrack.jetbrains.com/issue/PY-16143), but (as far as I can tell) it wasn't repaired. Any ideas on how to get around this?
For those who asked: I'm using PyCharm Community Edition 2016.3.2 and my operating system is CentOS 6.6.