[Python-Dev] Can Python implementations reject semantically invalid expressions? (original) (raw)

Terry Reedy tjreedy at udel.edu
Fri Jul 2 22:44:55 CEST 2010


On 7/2/2010 12:43 AM, Glyph Lefkowitz wrote:

def f(): return 1 + "1"

instead of compiling something which can't fail to raise an exception, would that still be a legal Python implementation? I'd say "no". Python has defined semantics in this situation: a TypeError is raised.

The manuals are rather inconsistent about defining the exception semantics. Some parts define the exception returned. Other, equivalent parts, do not. I should start a separate thread on this when I find the examples I once had.

-- Terry Jan Reedy



More information about the Python-Dev mailing list