From 04c5bf3d560795f33705a89c4ebd77aff4670a2e Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Wed, 6 Nov 2019 11:18:18 +1000 Subject: [PATCH] Fix bug caused by change in collections.UserList. - Collections.UserList changed betweeen python 3.7.3 and 3.7.5, requiring the constructor of Entry to be a like that for a list. - Solved by not using UserList and defining __getitem__ and __len__. --- TODO | 3 ++- eris/__main__.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 008c148..40ee979 100644 --- a/TODO +++ b/TODO @@ -264,7 +264,6 @@ Ideas - Let the mouse click on the actions in the status bar? - Let the mouse click the filenames. Try to show a result from the same type of tool. -- Check if class Entry is really working correctly as a collections.UserList. - Docstrings - Add ESC as an alternative to 'q' for quit. If looking at Help, ESC should just exit the help screen. @@ -439,3 +438,5 @@ Shelved - Not necessary since git_diff was removed. - Cache tools._python_version. - Not supporting python2 anymore. +- Check if class Entry is really working correctly as a collections.UserList. + - Entry is no longer a UserList. \ No newline at end of file diff --git a/eris/__main__.py b/eris/__main__.py index 67a0bec..740f9b2 100755 --- a/eris/__main__.py +++ b/eris/__main__.py @@ -80,15 +80,14 @@ KEYS_DOC = """Keys: """ -class Entry(collections.UserList): +class Entry: def __init__(self, path, results, summary, highlighted=None, set_results=True): - collections.UserList.__init__(self, results) self.path = path self.summary = summary self.highlighted = highlighted - self.widgets = self.data + self.widgets = results if set_results: # FIX: this is missed for entries appended later for result in results: @@ -96,6 +95,12 @@ class Entry(collections.UserList): self.widget = fill3.Row(results) self.appearance_cache = None + def __len__(self): + return len(self.widgets) + + def __getitem__(self, index): + return self.widgets.__getitem__(index) + def _get_cursor(self): result_selected = self.widget[self.highlighted] status_color = tools._STATUS_COLORS.get(