The code below causes different behaviour for LOAD_GLOBAL and LOAD_NAME.
Which is correct?
Should exceptions raised in the equality test be converted to a NameError or just propogated?

Cheers,
Mark.

-------------------------------------
import sys

class S(str):
    pass

def eq_except(self, other):
    if isinstance(other, str):
        raise TypeError("Cannot compare S and str")

globals()[S("a")] = 0

S.__eq__ = eq_except

def f():
    print(a)

try:
    f()
except:
    print(sys.exc_info()[1])

try:
    print(a)
except:
    print(sys.exc_info()[1])
----------------------------------

Output:

TypeError('Cannot compare S and str',)
NameError("name 'a' is not defined",)

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to