Skip to content

False positive "no-member" for Python 3 subprocess.Popen().communicate() #64

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

Closed
pylint-bot opened this issue Sep 4, 2013 · 3 comments
Closed
Labels

Comments

@pylint-bot
Copy link

Originally reported by: Anonymous


Pylint assumes that Popen().communicate() returns a tuple of 2 "str" instance, but this is incorrect in Python 3 where it returns a tuple of 2 "bytes" instances, unless universal_newlines=True is passed to Popen, in which case it returns a tuple of 2 "str" instances again.

$ cat subprocess_test.py
from subprocess import Popen, PIPE
stdout, stderr = Popen('/bin/ls', stdout=PIPE).communicate()
print(stdout.decode("ascii"))

$ pylint -d C -r n subprocess_test.py
************* Module subprocess_test
E: 3, 6: Instance of 'str' has no 'decode' member (no-member)

Python 3 runs the code fine.

I wonder if this is related to the "brain" package included in asteroid, as in the asteroid package:

$ grep -A 12 Popen brain/py2stdlib.py
class Popen(object):
returncode = pid = 0
stdin = stdout = stderr = file()

def __init__(self, args, bufsize=0, executable=None,
             stdin=None, stdout=None, stderr=None,
             preexec_fn=None, close_fds=False, shell=False,
             cwd=None, env=None, universal_newlines=False,
             startupinfo=None, creationflags=0):
    pass

def communicate(self, input=None):
    return ('string', 'string')

@pylint-bot
Copy link
Author

Original comment by Sylvain Thénault (BitBucket: sthenault, GitHub: @sthenault?):


this should indeed be fixed in the pylint-brain project

@pylint-bot
Copy link
Author

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


This is already fixed in pylint-brain and the fix will be included in the next astroid version.

@pylint-bot
Copy link
Author

Original comment by Sylvain Thénault (BitBucket: sthenault, GitHub: @sthenault?):


Removing version: 1.0 (automated comment)

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

1 participant