From cc9a4f4324ba40527351ee21898a716b733334ad Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Sat, 30 Aug 2014 11:58:34 +0200 Subject: [PATCH] Fixed TypeError when running ponysay --onelist. Traceback (most recent call last): File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 170, in _run_module_as_main "__main__", mod_spec) File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 85, in _run_code exec(code, run_globals) File "venv/bin/ponysay/__main__.py", line 154, in File "venv/bin/ponysay/ponysay.py", line 248, in run File "venv/bin/ponysay/ponysay.py", line 765, in onelist File "venv/bin/ponysay/lists.py", line 210, in onelist File "venv/bin/ponysay/lists.py", line 210, in File "venv/bin/ponysay/lists.py", line 104, in _get_file_list TypeError: listdir: illegal type for path parameter This bug was introduced in this commit: list.py: Extracted duplicate code for listing files in a directory into a utility function. I fixed the problem by removing the requirement for lists.onelist() to accept None for directory lists that should not be searched. --- src/lists.py | 13 ++++++------- src/ponysay.py | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/lists.py b/src/lists.py index 298a45ad..dd7b7fa7 100755 --- a/src/lists.py +++ b/src/lists.py @@ -198,20 +198,19 @@ def linklist(ponydirs = None, quoters = [], ucsiser = None): _print_columnised(list(ponies)) -def onelist(standarddirs, extradirs = None, ucsiser = None): +def onelist(standarddirs, extradirs, ucsiser): ''' Lists the available ponies on one column without anything bold or otherwise formated - @param standard:itr? Include standard ponies - @param extra:itr? Include extra ponies - @param ucsiser:(list)?→void Function used to UCS:ise names + @param standard:itr Include standard ponies + @param extra:itr Include extra ponies + @param ucsiser:(list)→void Function used to UCS:ise names ''' ## Get all pony files - ponies = [j for i in [standarddirs, extradirs] for j in _get_file_list(i, '.pony')] + ponies = [name for dir_list in [standarddirs, extradirs] for dir in dir_list for name in _get_file_list(dir, '.pony')] ## UCS:ise and sort - if ucsiser is not None: - ucsiser(ponies) + ucsiser(ponies) ponies.sort() ## Print each one on a seperate line, but skip duplicates diff --git a/src/ponysay.py b/src/ponysay.py index f9560f5b..cea7a668 100755 --- a/src/ponysay.py +++ b/src/ponysay.py @@ -760,9 +760,9 @@ class Ponysay(): @param standard:bool Include standard ponies @param extra:bool Include extra ponies ''' - lists.onelist(self.ponydirs if standard else None, - self.extraponydirs if extra else None, - lambda x : self.__ucsise(x)) + lists.onelist(self.ponydirs if standard else [], + self.extraponydirs if extra else [], + self.__ucsise) def quoters(self, standard = True, extra = False):