# Python started to don't show errors and don't stop in errors

**URL:** <https://discuss.python.org/t/python-started-to-dont-show-errors-and-dont-stop-in-errors/9301>\
**Category:** Python Help\
**Created:** [June 16, 2021, 6:36pm UTC](https://discuss.python.org/t/python-started-to-dont-show-errors-and-dont-stop-in-errors/9301 "2021-06-16T18:36:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![renatoseres](https://avatars.discourse-cdn.com/v4/letter/r/4491bb/32.png) [@renatoseres](https://discuss.python.org/u/renatoseres)\
**Post date:** [June 16, 2021, 6:36pm UTC](https://discuss.python.org/t/python-started-to-dont-show-errors-and-dont-stop-in-errors/9301/1 "2021-06-16T18:36:10Z")

</div>

First example - Ok - In this xample it’s displaying errors - OK:

def test():  
print(‘function test - line 1’)  
msg=MIMEMultipart(‘alternative’)  
print(‘function test - line 3’)  
print(‘function test - line 4’)

print(‘main code - hi’)  
test()  
print(‘main code - yeh’)

* * *

In the example above, python correctly throw a error - “NameError: name ‘MIMEMultipart’ is not defined” (because in the example I don’t put the import commands in the code)

* * *

BUT I have another python code (a bigger code), in which I have built in the same code above , and Python it’s not giving error message.  
Python executes just the following lines / output:  
‘main code - hi’  
‘function test - line 1’  
‘main code - yeh’

Until some days ago I could get all Python errors in the screen, but now I have this problem above.

(evertyhing else it’s working in my bigger code)

I am using Python 3.9.4  
I tested in another machine, with Python 3.7.4 - the same problem occurs  
And tested in a third machine, with python 3.5.9 - the same problem occurs

---

<div class="post-metadata">

**Author:** ![steven.daprano](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/steven.daprano/32/1083_2.png) [@steven.daprano](https://discuss.python.org/u/steven.daprano)\
**Post date:** [June 16, 2021, 9:34pm UTC](https://discuss.python.org/t/python-started-to-dont-show-errors-and-dont-stop-in-errors/9301/2 "2021-06-16T21:34:42Z")

</div>

Your second Python code will be catching and suppressing exceptions.  
This is _nearly always a bad idea_.

It probably looks something like this:

```
try:
    code goes here
except:
    pass

```

> **[The Most Diabolical Python Antipattern – Real Python](https://realpython.com/the-most-diabolical-python-antipattern/)**
>
> There are plenty of ways to write bad code. But in Python, one in particular reigns as king...

Possibly it does this instead:

```
# could be called *anything*
def hide_exceptions(type, value, traceback):
    # could contain anything
    pass

sys.excepthook = hide_exceptions

```

You need to search the second code for anything that hides errors. I  
suggest you search for:

- “except:”
- “except Exception”
- “sys.excepthook”

(without the quotes obviously) and hope it is easy to find.

Or find the person who wrote this code and ask them to solve the  
problem.

---

<div class="post-metadata">

**Author:** ![renatoseres](https://avatars.discourse-cdn.com/v4/letter/r/4491bb/32.png) [@renatoseres](https://discuss.python.org/u/renatoseres)\
**Post date:** [June 17, 2021, 5:14pm UTC](https://discuss.python.org/t/python-started-to-dont-show-errors-and-dont-stop-in-errors/9301/3 "2021-06-17T17:14:37Z")

</div>

Steven,

THANK YOU ! VERY MUCH !

Problem Solved !

My code was:

try:  
resultmail=myfunctionsendmail(xxxx,xxx,xxx,xxx);  
except:  
print(’\nERROR IN MAIL SEND’)

What I’ve learned with your post:

1- Never Call a function with several lines inside a Try  
2- Must use the try except in the lines of function

THANK YOU AGAIN
