Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glob monkey patch missing recursive argument in Python 3.5 #341

Closed
ScriptingSquirrel opened this issue Dec 1, 2016 · 0 comments
Closed
Labels

Comments

@ScriptingSquirrel
Copy link

ScriptingSquirrel commented Dec 1, 2016

Hi, in your newest release the "monkey patch" of glob.glob breaks user code, if one tries to set the recursive argument that the original glob.glob implementation provides in Python 3.5 (see Python 3.5 docs).

Demonstration:

#> python3.5
>>> import glob
>>> glob.glob('.', recursive=True)
['.']
>>> import sh
>>> glob.glob('.', recursive=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: glob() got an unexpected keyword argument 'recursive'

I guess adding args and kwargs to your glob wrapper might fix this and makes you independent of the function signature of the actual glob implementation. Suggested diff on sh.py:

377,378c377,378
< def glob(path):
<     expanded = GlobResults(path, _old_glob(path))
---
> def glob(path, *args, **kwargs):
>     expanded = GlobResults(path, _old_glob(path, *args, **kwargs))

Many thanks for your great work! ;)

edit: fixed order in the diff

@amoffat amoffat added the bug label Dec 16, 2016
0-wiz-0 added a commit to NetBSD/pkgsrc-wip that referenced this issue Jan 18, 2017
Test status:
FAILED (failures=1, errors=7, skipped=2)

*   added `_bg_exc` for silencing exceptions in background threads [#350](amoffat/sh#350)

*   bugfix for patched glob.glob on python3.5 [#341](amoffat/sh#341)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants