From f39b388a251b7c959f22f4a81751f8cbb3dff6e1 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Sat, 31 Oct 2015 09:33:44 +0000 Subject: [PATCH 1/8] Remove python2.6 backport in setupext --- setupext.py | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/setupext.py b/setupext.py index 4a31bd8f049b..6a8219d30e9e 100755 --- a/setupext.py +++ b/setupext.py @@ -9,6 +9,7 @@ import os import re import subprocess +from subprocess import check_output import sys import warnings from textwrap import fill @@ -19,32 +20,6 @@ PY3 = (sys.version_info[0] >= 3) -try: - from subprocess import check_output -except ImportError: - # check_output is not available in Python 2.6 - def check_output(*popenargs, **kwargs): - """ - Run command with arguments and return its output as a byte - string. - - Backported from Python 2.7 as it's implemented as pure python - on stdlib. - """ - process = subprocess.Popen( - stdout=subprocess.PIPE, *popenargs, **kwargs) - output, unused_err = process.communicate() - retcode = process.poll() - if retcode: - cmd = kwargs.get("args") - if cmd is None: - cmd = popenargs[0] - error = subprocess.CalledProcessError(retcode, cmd) - error.output = output - raise error - return output - - if sys.platform != 'win32': if sys.version_info[0] < 3: from commands import getstatusoutput From aad5ad71094f58740935d137d55ad1f82d94fc6e Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Sat, 31 Oct 2015 09:34:09 +0000 Subject: [PATCH 2/8] Remove 2.6 related workaround in cbook --- lib/matplotlib/cbook.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/lib/matplotlib/cbook.py b/lib/matplotlib/cbook.py index 58cb04dc960d..29e77316734c 100644 --- a/lib/matplotlib/cbook.py +++ b/lib/matplotlib/cbook.py @@ -191,20 +191,7 @@ def deprecate(func, message=message, name=name, alternative=alternative, import textwrap if isinstance(func, classmethod): - try: - func = func.__func__ - except AttributeError: - # classmethods in Python2.6 and below lack the __func__ - # attribute so we need to hack around to get it - method = func.__get__(None, object) - if hasattr(method, '__func__'): - func = method.__func__ - elif hasattr(method, 'im_func'): - func = method.im_func - else: - # Nothing we can do really... just return the original - # classmethod - return func + func = func.__func__ is_classmethod = True else: is_classmethod = False From 44cebb9503b8445036af7a40697f1327398aaeef Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Sat, 31 Oct 2015 09:43:45 +0000 Subject: [PATCH 3/8] Remove python 2.6 workaround in labeled data test --- .../tests/test_labeled_data_unpacking.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/matplotlib/tests/test_labeled_data_unpacking.py b/lib/matplotlib/tests/test_labeled_data_unpacking.py index e8baf8235e4f..fe5427304345 100644 --- a/lib/matplotlib/tests/test_labeled_data_unpacking.py +++ b/lib/matplotlib/tests/test_labeled_data_unpacking.py @@ -7,17 +7,10 @@ # 3.2+ versions from nose.tools import assert_regex, assert_not_regex except ImportError: - try: - # 2.7 versions - from nose.tools import assert_regexp_matches, assert_not_regexp_matches - assert_regex = assert_regexp_matches - assert_not_regex = assert_not_regexp_matches - except ImportError: - # 2.6 versions - def noop(txt, regex): - raise SkipTest("No assert for regex matching in py2.6") - assert_regex = noop - assert_not_regex = noop + # 2.7 versions + from nose.tools import assert_regexp_matches, assert_not_regexp_matches + assert_regex = assert_regexp_matches + assert_not_regex = assert_not_regexp_matches from ..testing import assert_produces_warning From f33c490bb7b49c28cc1e9721cdb9d06e74524342 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Sat, 31 Oct 2015 09:44:11 +0000 Subject: [PATCH 4/8] Remove pre python2.6 workaround in multiprocess example --- examples/misc/multiprocess.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/examples/misc/multiprocess.py b/examples/misc/multiprocess.py index febe6202b0d2..510e9001fa3e 100644 --- a/examples/misc/multiprocess.py +++ b/examples/misc/multiprocess.py @@ -1,15 +1,10 @@ # Demo of using multiprocessing for generating data in one process and plotting # in another. # Written by Robert Cimrman -# Requires >= Python 2.6 for the multiprocessing module or having the -# standalone processing module installed from __future__ import print_function import time -try: - from multiprocessing import Process, Pipe -except ImportError: - from processing import Process, Pipe +from multiprocessing import Process, Pipe import numpy as np import matplotlib From 020b08f16deb8715fe0f481f384e12dee5e4b335 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Sat, 31 Oct 2015 09:44:32 +0000 Subject: [PATCH 5/8] Correct supported versions in setupext --- setupext.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/setupext.py b/setupext.py index 6a8219d30e9e..2c3bd1fa8cc5 100755 --- a/setupext.py +++ b/setupext.py @@ -529,13 +529,13 @@ def check(self): if major < 2: raise CheckFailed( - "Requires Python 2.6 or later") - elif major == 2 and minor1 < 6: + "Requires Python 2.7 or later") + elif major == 2 and minor1 < 7: raise CheckFailed( - "Requires Python 2.6 or later (in the 2.x series)") - elif major == 3 and minor1 < 1: + "Requires Python 2.7 or later (in the 2.x series)") + elif major == 3 and minor1 < 4: raise CheckFailed( - "Requires Python 3.1 or later (in the 3.x series)") + "Requires Python 3.4 or later (in the 3.x series)") return sys.version From a88fc21186fcc258bd073a065e943e423ba6ba99 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Sat, 31 Oct 2015 10:11:19 +0000 Subject: [PATCH 6/8] Correct version check in __init__ a --- lib/matplotlib/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 1e88933c23bb..dbd2f56aa453 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -197,10 +197,11 @@ def _forward_ilshift(self, other): major, minor1, minor2, s, tmp = sys.version_info -_python26 = (major == 2 and minor1 >= 6) or major >= 3 +_python27 = (major == 2 and minor1 >= 7) +_python34 = (major == 3 and minor1 >= 4) -if not _python26: - raise ImportError('matplotlib requires Python 2.6 or later') +if not (_python27 or _python34): + raise ImportError('matplotlib requires Python 2.7 or 3.4 or later') if not compare_versions(numpy.__version__, __version__numpy__): From b8eb2d8d59bd0493aa1dd5ec53bc270867560861 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Sat, 31 Oct 2015 10:14:22 +0000 Subject: [PATCH 7/8] Remove 2.6 workaround for missing WeakSet --- lib/matplotlib/backends/backend_pgf.py | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/lib/matplotlib/backends/backend_pgf.py b/lib/matplotlib/backends/backend_pgf.py index 4f00ea0b43ab..3570b5380d9e 100644 --- a/lib/matplotlib/backends/backend_pgf.py +++ b/lib/matplotlib/backends/backend_pgf.py @@ -235,23 +235,6 @@ def get_latex_manager(): LatexManagerFactory.previous_instance = new_inst return new_inst -class WeakSet(object): - # TODO: Poor man's weakref.WeakSet. - # Remove this once python 2.6 support is dropped from matplotlib. - - def __init__(self): - self.weak_key_dict = weakref.WeakKeyDictionary() - - def add(self, item): - self.weak_key_dict[item] = None - - def discard(self, item): - if item in self.weak_key_dict: - del self.weak_key_dict[item] - - def __iter__(self): - return six.iterkeys(self.weak_key_dict) - class LatexManager(object): """ @@ -259,7 +242,7 @@ class LatexManager(object): determining the metrics of text elements. The LaTeX environment can be modified by setting fonts and/or a custem preamble in the rc parameters. """ - _unclean_instances = WeakSet() + _unclean_instances = weakref.WeakSet() @staticmethod def _build_latex_header(): From dc7debce0aeeee0b49caa906da9a5a374984d48e Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Sat, 31 Oct 2015 10:17:27 +0000 Subject: [PATCH 8/8] Remove missing assert_less workaround from spines test --- lib/matplotlib/tests/test_spines.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/tests/test_spines.py b/lib/matplotlib/tests/test_spines.py index d8688c586d42..2f6a9a3084cc 100644 --- a/lib/matplotlib/tests/test_spines.py +++ b/lib/matplotlib/tests/test_spines.py @@ -2,7 +2,7 @@ unicode_literals) import numpy as np -from nose.tools import assert_true +from nose.tools import assert_true, assert_less from matplotlib.externals import six import matplotlib @@ -71,13 +71,11 @@ def test_label_without_ticks(): spine = ax.spines['left'] spinebbox = spine.get_transform().transform_path( spine.get_path()).get_extents() - # replace with assert_less if >python2.6 - assert_true(ax.yaxis.label.get_position()[0] < spinebbox.xmin, + assert_less(ax.yaxis.label.get_position()[0], spinebbox.xmin, "Y-Axis label not left of the spine") spine = ax.spines['bottom'] spinebbox = spine.get_transform().transform_path( spine.get_path()).get_extents() - # replace with assert_less if >python2.6 - assert_true(ax.xaxis.label.get_position()[1] < spinebbox.ymin, + assert_less(ax.xaxis.label.get_position()[1], spinebbox.ymin, "X-Axis label not below the spine")