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

Unexpected regression from standard library: AttributeError is thrown when command is a list rather than a string #5

Open
klardotsh opened this issue Mar 13, 2018 · 0 comments

Comments

@klardotsh
Copy link

While my example below is with Python 3.6 (from Homebrew), I was also able to repro on Python 3.7 (also from Homebrew).

 subprocess.run  » python3
Python 3.6.4 (default, Mar  1 2018, 18:36:50)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

# First, let's look at the standard library's behavior
>>> import subprocess
>>> subprocess.run('clang')
clang: error: no input files
CompletedProcess(args='clang', returncode=1)
>>> subprocess.run(['clang'])
clang: error: no input files
CompletedProcess(args=['clang'], returncode=1)

# And now for the behavior of this library
>>> import run
>>> run.run('clang')
clang
>>> run.run(['clang'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/joshklar/src/subprocess.run/run/__init__.py", line 146, in __new__
    command, stdin, cwd=cwd, env=env, shell=shell)
  File "/Users/joshklar/src/subprocess.run/run/__init__.py", line 121, in create_process
    shlex.split(command),
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/shlex.py", line 305, in split
    return list(lex)
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/shlex.py", line 295, in __next__
    token = self.get_token()
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/shlex.py", line 105, in get_token
    raw = self.read_token()
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/shlex.py", line 136, in read_token
    nextchar = self.instream.read(1)
AttributeError: 'list' object has no attribute 'read'
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant