8000 Merge pull request #3235 from jenshnielsen/more_warnings · matplotlib/matplotlib@9e51dba · GitHub
[go: up one dir, main page]

Skip to content

Commit 9e51dba

Browse files
committed
Merge pull request #3235 from jenshnielsen/more_warnings
Silence some more warnings
1 parent c26e08e commit 9e51dba

File tree

4 files changed

+31
-20
lines changed
  • tests
  • 4 files changed

    +31
    -20
    lines changed

    lib/matplotlib/__init__.py

    Lines changed: 20 additions & 12 deletions
    Original file line numberDiff line numberDiff line change
    @@ -343,8 +343,9 @@ def checkdep_dvipng():
    343343
    try:
    344344
    s = subprocess.Popen(['dvipng','-version'], stdout=subprocess.PIPE,
    345345
    stderr=subprocess.PIPE)
    346-
    line = s.stdout.readlines()[1]
    347-
    v = line.split()[-1].decode('ascii')
    346+
    stdout, stderr = s.communicate()
    347+
    line = stdout.decode('ascii').split('\n')[1]
    348+
    v = line.split()[-1]
    348349
    return v
    349350
    except (IndexError, ValueError, OSError):
    350351
    return None
    @@ -371,7 +372,8 @@ def checkdep_tex():
    371372
    try:
    372373
    s = subprocess.Popen(['tex','-version'], stdout=subprocess.PIPE,
    373374
    stderr=subprocess.PIPE)
    374-
    line = s.stdout.readlines()[0].decode('ascii')
    375+
    stdout, stderr = s.communicate()
    376+
    line = stdout.decode('ascii').split('\n')[0]
    375377
    pattern = '3\.1\d+'
    376378
    match = re.search(pattern, line)
    377379
    v = match.group(0)
    @@ -383,9 +385,11 @@ def checkdep_pdftops():
    383385
    try:
    384386
    s = subprocess.Popen(['pdftops','-v'], stdout=subprocess.PIPE,
    385387
    stderr=subprocess.PIPE)
    386-
    for line in s.stderr:
    387-
    if b'version' in line:
    388-
    v = line.split()[-1].decode('ascii')
    388+
    stdout, stderr = s.communicate()
    389+
    lines = stderr.decode('ascii').split('\n')
    390+
    for line in lines:
    391+
    if 'version' in line:
    392+
    v = line.split()[-1]
    389393
    return v
    390394
    except (IndexError, ValueError, UnboundLocalError, OSError):
    391395
    return None
    @@ -394,9 +398,11 @@ def checkdep_inkscape():
    394398
    try:
    395399
    s = subprocess.Popen(['inkscape','-V'], stdout=subprocess.PIPE,
    396400
    stderr=subprocess.PIPE)
    397-
    for line in s.stdout:
    398-
    if b'Inkscape' in line:
    399-
    v = line.split()[1].decode('ascii')
    401+
    stdout, stderr = s.communicate()
    402+
    lines = stdout.decode('ascii').split('\n')
    403+
    for line in lines:
    404+
    if 'Inkscape' in line:
    405+
    v = line.split()[1]
    400406
    break
    401407
    return v
    402408
    except (IndexError, ValueError, UnboundLocalError, OSError):
    @@ -406,9 +412,11 @@ def checkdep_xmllint():
    406412
    try:
    407413
    s = subprocess.Popen(['xmllint','--version'], stdout=subprocess.PIPE,
    408414
    stderr=subprocess.PIPE)
    409-
    for line in s.stderr:
    410-
    if b'version' in line:
    411-
    v = line.split()[-1].decode('ascii')
    415+
    stdout, stderr = s.communicate()
    416+
    lines = stderr.decode('ascii').split('\n')
    417+
    for line in lines:
    418+
    if 'version' in line:
    419+
    v = line.split()[-1]
    412420
    break
    413421
    return v
    414422
    except (IndexError, ValueError, UnboundLocalError, OSError):

    lib/matplotlib/backends/backend_ps.py

    Lines changed: 5 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -90,12 +90,13 @@ def gs_version(self):
    9090
    pass
    9191

    9292
    from matplotlib.compat.subprocess import Popen, PIPE
    93-
    pipe = Popen(self.gs_exe + " --version",
    94-
    shell=True, stdout=PIPE).stdout
    93+
    s = Popen(self.gs_exe + " --version",
    94+
    shell=True, stdout=PIPE)
    95+
    pipe, stderr = s.communicate()
    9596
    if six.PY3:
    96-
    ver = pipe.read().decode('ascii')
    97+
    ver = pipe.decode('ascii')
    9798
    else:
    98-
    ver = pipe.read()
    99+
    ver = pipe
    99100
    gs_version = tuple(map(int, ver.strip().split(".")))
    100101

    101102
    self._cached["gs_version"] = gs_version

    lib/matplotlib/tests/test_backend_ps.py

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -40,6 +40,8 @@ def _test_savefig_to_stringio(format='ps'):
    4040

    4141
    assert values[0] == values[1]
    4242
    assert values[1] == values[2].replace(b'\r\n', b'\n')
    43+
    for buffer in buffers:
    44+
    buffer.close()
    4345

    4446

    4547
    @cleanup

    lib/matplotlib/texmanager.py

    Lines changed: 4 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -70,16 +70,16 @@ def dvipng_hack_alpha():
    7070
    try:
    7171
    p = Popen(['dvipng', '-version'], stdin=PIPE, stdout=PIPE,
    7272
    stderr=STDOUT, close_fds=(sys.platform != 'win32'))
    73+
    stdout, stderr = p.communicate()
    7374
    except OSError:
    7475
    mpl.verbose.report('No dvipng was found', 'helpful')
    7576
    return False
    76-
    stdin, stdout = p.stdin, p.stdout
    77-
    for line in stdout:
    78-
    if line.startswith(b'dvipng '):
    77+
    lines = stdout.decode('ascii').split('\n')
    78+
    for line in lines:
    79+
    if line.startswith('dvipng '):
    7980
    version = line.split()[-1]
    8081
    mpl.verbose.report('Found dvipng version %s' % version,
    8182
    'helpful')
    82-
    version = version.decode('ascii')
    8383
    version = distutils.version.LooseVersion(version)
    8484
    return version < distutils.version.LooseVersion('1.6')
    8585
    mpl.verbose.report('Unexpected response from dvipng -version', 'helpful')

    0 commit comments

    Comments
     (0)
    0