changeset 6183:bb198596f85c

Fix __repr__ of hyperdb.Class If a error occurs during schema parsing, classname isn't known yet, account for this case in __repr__.
author Ralf Schlatterbeck <rsc@runtux.com>
date Wed, 20 May 2020 10:21:12 +0200
parents acb9841bb4fd
children c757a6a14c8d
files roundup/hyperdb.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/hyperdb.py	Wed May 20 00:14:50 2020 -0400
+++ b/roundup/hyperdb.py	Wed May 20 10:21:12 2020 +0200
@@ -1076,8 +1076,12 @@
 
     def __repr__(self):
         """Slightly more useful representation
+           Note that an error message can be raised at a point
+           where self.classname isn't known yet if the error
+           occurs during schema parsing.
         """
-        return '<hyperdb.Class "%s">' % self.classname
+        cn = getattr (self, 'classname', 'Unknown')
+        return '<hyperdb.Class "%s">' % cn
 
     # Editing nodes:
 

Roundup Issue Tracker: http://roundup-tracker.org/