New submission from Ted Shaneyfelt:
def f():
try: return 0
except: return 1,2
x = f() # x is 0
x,y = f() # proposal: x,y should be 1,2 instead of uncaught TypeError
It would make sense to be able to catch [TypeError: 'int' object is not
iterable] and return the correct number of values. Yes, the way it's done now,
the function is no longer running when it is caught - but is it possible and
practical to determine if parameters match before the function returns instead
of afterward, allowing the called function to catch the error attempting to
return?
----------
components: Interpreter Core
messages: 287173
nosy: Ted Shaneyfelt
priority: normal
severity: normal
status: open
title: Allow return mismatch to be caught by function
type: enhancement
versions: Python 3.5
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue29467>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com