incorrect input for cmd subprocess.check_ouput() in distro.py
See original GitHub issueEnvironment
- pip version: 10.0.1
- Python version: 3.5
- OS: ubuntu 16.04
Description
The input cmd = ('lsb_release', '-a')
on line 997 of distro.py is not a correct input for stdout = subprocess.check_output(cmd, stderr=devnull)
on the line right after. It should instead be cmd = 'lsb_release; -a'
.
See https://docs.python.org/3.5/library/subprocess.html#subprocess.check_output
Expected behavior
Pip does not install or uninstall.
How to Reproduce
I can’t with 100% give a way to reproduce as it only occurred when I upgraded pip. I changed that line myself and it worked.
I’ve cloned the distro repo and ran the tests. The tests resulted in 132 failures, and 34 passes. Most of the failures seem to be caused from that same issue. After making the change to that line mentioned in the description, that particular test passed.
Test results can be found here: https://pastebin.com/3UCfA2Au
Output
This is the output when it failed to install the bcrypt package
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/basecommand.py", line 228, in main
status = self.run(options, args)
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/commands/uninstall.py", line 46, in run
with self._build_session(options) as session:
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/basecommand.py", line 81, in _build_session
insecure_hosts=options.trusted_hosts,
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/download.py", line 338, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/download.py", line 101, in user_agent
zip(["name", "version", "id"], distro.linux_distribution()),
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/distro.py", line 120, in linux_distribution
return _distro.linux_distribution(full_distribution_name)
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/distro.py", line 634, in linux_distribution
self.version(),
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/distro.py", line 688, in version
self.lsb_release_attr('release'),
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/distro.py", line 836, in lsb_release_attr
return self._lsb_release_info.get(attribute, '')
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/distro.py", line 522, in __get__
ret = obj.__dict__[self._fname] = self._f(obj)
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/distro.py", line 933, in _lsb_release_info
stdout = subprocess.check_output(cmd, stderr=devnull)
File "/usr/lib/python3.5/subprocess.py", line 626, in check_output
**kwargs).stdout
File "/usr/local/lib/python3.5/dist-packages/run/__init__.py", line 145, in __new__
process = cls.create_process(command, stdin, cwd=cwd, env=env, shell=shell)
File "/usr/local/lib/python3.5/dist-packages/run/__init__.py", line 121, in create_process
shlex.split(command),
File "/usr/lib/python3.5/shlex.py", line 273, in split
return list(lex)
File "/usr/lib/python3.5/shlex.py", line 263, in __next__
token = self.get_token()
File "/usr/lib/python3.5/shlex.py", line 90, in get_token
raw = self.read_token()
File "/usr/lib/python3.5/shlex.py", line 118, in read_token
nextchar = self.instream.read(1)
AttributeError: 'tuple' object has no attribute 'read'
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.5/dist-packages/pip/__main__.py", line 19, in <module>
sys.exit(_main())
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/__init__.py", line 246, in main
return command.main(cmd_args)
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/basecommand.py", line 264, in main
timeout=min(5, options.timeout)) as session:
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/basecommand.py", line 81, in _build_session
insecure_hosts=options.trusted_hosts,
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/download.py", line 338, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/download.py", line 101, in user_agent
zip(["name", "version", "id"], distro.linux_distribution()),
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/distro.py", line 120, in linux_distribution
return _distro.linux_distribution(full_distribution_name)
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/distro.py", line 634, in linux_distribution
self.version(),
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/distro.py", line 688, in version
self.lsb_release_attr('release'),
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/distro.py", line 836, in lsb_release_attr
return self._lsb_release_info.get(attribute, '')
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/distro.py", line 522, in __get__
ret = obj.__dict__[self._fname] = self._f(obj)
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/distro.py", line 933, in _lsb_release_info
stdout = subprocess.check_output(cmd, stderr=devnull)
File "/usr/lib/python3.5/subprocess.py", line 626, in check_output
**kwargs).stdout
File "/usr/local/lib/python3.5/dist-packages/run/__init__.py", line 145, in __new__
process = cls.create_process(command, stdin, cwd=cwd, env=env, shell=shell)
File "/usr/local/lib/python3.5/dist-packages/run/__init__.py", line 121, in create_process
shlex.split(command),
File "/usr/lib/python3.5/shlex.py", line 273, in split
return list(lex)
File "/usr/lib/python3.5/shlex.py", line 263, in __next__
token = self.get_token()
File "/usr/lib/python3.5/shlex.py", line 90, in get_token
raw = self.read_token()
File "/usr/lib/python3.5/shlex.py", line 118, in read_token
nextchar = self.instream.read(1)
AttributeError: 'tuple' object has no attribute 'read'
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (6 by maintainers)
Top GitHub Comments
@HarshitRuwali uninstall subprocess.run
Gonna close this issue also ✌️
there should be no need to install subprocess, it is part of the python standard library