[issue33323] inconsistent stack trace for exceptions thrown in generators passed to min/max

Naris R report at bugs.python.org
Sat Apr 21 09:19:47 EDT 2018


Naris R <nariscatboy at gmail.com> added the comment:

This is a little bit contrived but it demonstrates the problem.

```
def good_exception():
    raise Exception('something bad happened')

def bad_exception():
    return next(iter([]))

def good(n):
    return good_exception() + n

def bad(n):
    return n - bad_exception()

import traceback

try:
    max(good(i) for i in range(4)) # desirable behaviour
except:
    traceback.print_exc()

try:
    min(bad(i) for i in range(7)) # unhelpful error message
except:
    traceback.print_exc()
```

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33323>
_______________________________________


More information about the Python-bugs-list mailing list