[issue23205] Unit test needed for IDLE's GrepDialog.py's findfiles()

Terry J. Reedy report at bugs.python.org
Sun Feb 24 01:07:08 EST 2019


Terry J. Reedy <tjreedy at udel.edu> added the comment:

Findfiles was more like os.walk than os.listdir.  os.walk now uses os.scandir instead of os.listdir.  From 3.7.2 doc:

"By default, errors from the scandir() call are ignored. If optional argument onerror is specified, it should be a function; it will be called with one argument, an OSError instance. It can report the error to continue with the walk, or raise the exception to abort the walk. Note that the filename is available as the filename attribute of the exception object."

We should delete the try: except: and pass in a function to print the name and error message.  This could be done after getting a working patch.

Defaults are not needed as findfiles is called with 3 positional args.  The calling method should do the replacement of '' with os.curdir().

The patch must be incomplete as generators do not have a sort method.  Replace the first 3 lines of grep_it with

        folder, filepat = os.path.split(path)
        if not folder:
            folder = os.curdir()
        filelist = sorted(findfiles(folder, filepat, self.recvar.get())

and replace 'list' with 'filelist' in the following code.

Cheryl, grab the issue if you want to do this.

----------
nosy: +cheryl.sabella
stage: patch review -> needs patch
versions: +Python 3.7, Python 3.8 -Python 2.7, Python 3.4, Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue23205>
_______________________________________


More information about the Python-bugs-list mailing list