|
|
|
|
|
by kofejnik
1366 days ago
|
|
Ran into this face-first, just yesterday. I'm converting a rather old, rather big API (~400 endpoints) from Python 2.7 into 3, and apparently in Python 2, _hasattr(something, someattribute)_ just returns False if attribute access throws an exception! Specifically, if you have class A():
@property
def a(self):
raise Exception('go away')
a = A()
then hasattr(a, 'a') will return False in Python 2.7 (and throw as expected in Python3)A true WTF moment, the tests and the API have been slightly broken for years, without anyone noticing. |
|