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

executing local command leads to AttributeError at python 3.6 #302

Closed
ponimas opened this issue Dec 27, 2016 · 4 comments
Closed

executing local command leads to AttributeError at python 3.6 #302

ponimas opened this issue Dec 27, 2016 · 4 comments

Comments

@ponimas
Copy link

ponimas commented Dec 27, 2016

In [0]: from plumbum import local

In [1]: local["ls"]()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-20-ada3f6b44880> in <module>()
----> 1 local["ls"]()

/usr/local/lib/python3.6/site-packages/plumbum/commands/base.py in __call__(self, *args, **kwargs)
     88     def __call__(self, *args, **kwargs):
     89         """A shortcut for `run(args)`, returning only the process' stdout"""
---> 90         return self.run(args, **kwargs)[1]
     91
     92     def _get_encoding(self):

/usr/local/lib/python3.6/site-packages/plumbum/commands/base.py in run(self, args, **kwargs)
    218         """
    219         with self.bgrun(args, **kwargs) as p:
--> 220             return p.run()
    221
    222

/usr/local/lib/python3.6/site-packages/plumbum/commands/base.py in runner()
    180             was_run[0] = True
    181             try:
--> 182                 return run_proc(p, retcode, timeout)
    183             finally:
    184                 del p.run  # to break cyclic reference p -> cell -> p

/usr/local/lib/python3.6/site-packages/plumbum/commands/processes.py in run_proc(proc, retcode, timeout)
    194     """
    195     _register_proc_timeout(proc, timeout)
--> 196     stdout, stderr = proc.communicate()
    197     proc._end_time = time.time()
    198     if not stdout:

/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py in communicate(self, input, timeout)
    834
    835             try:
--> 836                 stdout, stderr = self._communicate(input, endtime, timeout)
    837             finally:
    838                 self._communication_started = True

/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py in _communicate(self, input, endtime, orig_timeout)
   1530                 if stdout is not None:
   1531                     stdout = self._translate_newlines(stdout,
-> 1532                                                       self.stdout.encoding,
   1533                                                       self.stdout.errors)
   1534                 if stderr is not None:

AttributeError: '_io.BufferedReader' object has no attribute 'encoding'
@ponimas ponimas changed the title executing local command leads to AttributeError in python 3.6 executing local command leads to AttributeError at python 3.6 Dec 27, 2016
@henryiii
Copy link
Collaborator

Thanks for catching this! I believe it happens because 3.6 adds an 'encoding' parameter to popen, and plumbum subclasses it, adding an "encoding" parameter as well, causing a clash. I'll look into fixing it for 1.6.3, which I hope will have full 3.6 support.

@henryiii henryiii mentioned this issue Dec 27, 2016
@henryiii
Copy link
Collaborator

Does that work for you? I've merged into master, so master should be fine.

@ponimas
Copy link
Author

ponimas commented Dec 28, 2016

It works now! Thanks!

@henryiii
Copy link
Collaborator

Great, hoping for a release soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants