Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 24e459b

Browse files
committed
Move __init__ Python version check earlier.
This will allow us to import anything new things from the standard library without breaking Python 2.
1 parent ff9273c commit 24e459b

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib/matplotlib/__init__.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,18 @@
105105

106106
import six
107107

108+
import sys
109+
if sys.version_info < (3, 5): # noqa: E402
110+
raise ImportError("""
111+
Matplotlib 3.0+ does not support Python 2.x, 3.0, 3.1, 3.2, 3.3, or 3.4.
112+
Beginning with Matplotlib 3.0, Python 3.5 and above is required.
113+
114+
See Matplotlib `INSTALL.rst` file for more information:
115+
116+
https://github.com/matplotlib/matplotlib/blob/master/INSTALL.rst
117+
118+
""")
119+
108120
import atexit
109121
from collections import MutableMapping
110122
import contextlib
@@ -120,21 +132,9 @@
120132
import re
121133
import shutil
122134
import stat
123-
import sys
124135
import tempfile
125136
import warnings
126137

127-
if sys.version_info < (3, 5): # noqa: E402
128-
raise ImportError("""
129-
Matplotlib 3.0+ does not support Python 2.x, 3.0, 3.1, 3.2, 3.3, or 3.4.
130-
Beginning with Matplotlib 3.0, Python 3.5 and above is required.
131-
132-
See Matplotlib `INSTALL.rst` file for more information:
133-
134-
https://github.com/matplotlib/matplotlib/blob/master/INSTALL.rst
135-
136-
""")
137-
138138
# cbook must import matplotlib only within function
139139
# definitions, so it is safe to import from it here.
140140
from . import cbook

0 commit comments

Comments
 (0)