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

Skip to content

Commit bd072ae

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 2954e33 commit bd072ae

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
@@ -121,21 +133,9 @@
121133
import re
122134
import shutil
123135
import stat
124-
import sys
125136
import tempfile
126137
import warnings
127138

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

0 commit comments

Comments
 (0)