Skip to content

Commit cc20e28

Browse files
committed
PY3: Drop Python 2 guards, use runpy instead of exec
1 parent 0ecbf8d commit cc20e28

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

doc/source/conf.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121

2222
import sys
2323
import os
24-
try:
25-
from configparser import ConfigParser
26-
except ImportError:
27-
from ConfigParser import ConfigParser # PY2
24+
from runpy import run_path
25+
from configparser import ConfigParser
2826

2927
# Check for external Sphinx extensions we depend on
3028
try:
@@ -51,9 +49,7 @@
5149
# -- General configuration ----------------------------------------------------
5250

5351
# We load the nibabel release info into a dict by explicit execution
54-
rel = {}
55-
with open(os.path.join('..', '..', 'nibabel', 'info.py'), 'r') as fobj:
56-
exec(fobj.read(), rel)
52+
rel = run_path(os.path.join('..', '..', 'nibabel', 'info.py'))
5753

5854
# Write long description from info
5955
with open('_long_description.inc', 'wt') as fobj:
@@ -62,10 +58,7 @@
6258
# Load metadata from setup.cfg
6359
config = ConfigParser()
6460
config.read(os.path.join('..', '..', 'setup.cfg'))
65-
try:
66-
metadata = config['metadata']
67-
except AttributeError:
68-
metadata = dict(config.items('metadata')) # PY2
61+
metadata = config['metadata']
6962

7063
# Add any Sphinx extension module names here, as strings. They can be
7164
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.

0 commit comments

Comments
 (0)