From d5b0bb4d324a314f72c6f8c57f060fbd4d7b36b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Sat, 2 Jun 2018 11:25:48 +0200 Subject: [PATCH] Avoid potential TypeErrors using LazyInitialise --- lib/tfw/decorators/lazy_initialise.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tfw/decorators/lazy_initialise.py b/lib/tfw/decorators/lazy_initialise.py index 615721b..4fdd3a3 100644 --- a/lib/tfw/decorators/lazy_initialise.py +++ b/lib/tfw/decorators/lazy_initialise.py @@ -13,7 +13,7 @@ class LazyInitialise: def __get__(self, instance, owner): if instance is None: - raise TypeError('Cannot get object property from class!') + return self # avoids potential __new__ TypeError value = self.func(instance) setattr(instance, self.func.__name__, value) return value