[issue33323] inconsistent stack trace for exceptions thrown in generators passed to min/max
New submission from Naris R : if a generator passed to min/max throws an exception, the stack trace is normally shown on the line that caused the exception, but if the exception is a StopIteration, the trace only shows the line where the max/min function was called. I was writing a minimax and alphabeta search with generator expression and list comprehension and accidentally passed an empty iterator to the next function while computing states for minimax and it took a very long time to find out where the error was actually caused. -- messages: 315561 nosy: Naris R priority: normal severity: normal status: open title: inconsistent stack trace for exceptions thrown in generators passed to min/max type: behavior versions: Python 2.7, Python 3.6 ___ Python tracker <https://bugs.python.org/issue33323> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33323] inconsistent stack trace for exceptions thrown in generators passed to min/max
Naris R 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 <https://bugs.python.org/issue33323> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34427] calling MutableSequence.extend on self produces infinite loop
New submission from Naris R : Example: ``` from typing import MutableSequence, TypeVar CliffordGate = TypeVar('CliffordGate') class QCircuit(MutableSequence[CliffordGate]): def __init__(self, gates): self.gates = list(gates) def __repr__(self): return f'{self.__class__.__name__}({self.gates})' def __getitem__(self, key): return self.gates[key] def __setitem__(self, key, item): self.gates[key] = item def __delitem__(self, key): del self.gates[key] def insert(self, key, item): self.gates.insert(key, item) a = QCircuit(['H0', 'S2']) a += a ``` -- components: Library (Lib) messages: 323696 nosy: Naris R priority: normal severity: normal status: open title: calling MutableSequence.extend on self produces infinite loop type: behavior versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue34427> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34427] calling MutableSequence.extend on self produces infinite loop
Naris R added the comment: I forgot to copy over __len__ in the example -- ___ Python tracker <https://bugs.python.org/issue34427> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34427] calling MutableSequence.extend on self produces infinite loop
Change by Naris R : -- nosy: +rhettinger, stutzbach ___ Python tracker <https://bugs.python.org/issue34427> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34427] calling MutableSequence.extend on self produces infinite loop
Change by Naris R : -- keywords: +patch pull_requests: +8291 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue34427> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com