[New-bugs-announce] [issue29467] Allow return mismatch to be caught by function

Ted Shaneyfelt report at bugs.python.org
Mon Feb 6 16:11:31 EST 2017


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 <report at bugs.python.org>
<http://bugs.python.org/issue29467>
_______________________________________


More information about the New-bugs-announce mailing list