Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
BLD: fix configparser.InterpolationSyntaxError
Closes #7572 inability to install in virtualenvs with percent in their path.
  • Loading branch information
Sorin Sbarnea committed Apr 28, 2016
1 parent 1b6831b commit d73e877
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
10 changes: 3 additions & 7 deletions numpy/distutils/npy_pkg_config.py
Expand Up @@ -5,9 +5,9 @@
import os

if sys.version_info[0] < 3:
from ConfigParser import SafeConfigParser, NoOptionError
from ConfigParser import RawConfigParser, NoOptionError
else:
from configparser import ConfigParser, SafeConfigParser, NoOptionError
from configparser import RawConfigParser, NoOptionError

__all__ = ['FormatError', 'PkgNotFound', 'LibraryInfo', 'VariableSet',
'read_config', 'parse_flags']
Expand Down Expand Up @@ -259,11 +259,7 @@ def parse_config(filename, dirs=None):
else:
filenames = [filename]

if sys.version[:3] > '3.1':
# SafeConfigParser is deprecated in py-3.2 and renamed to ConfigParser
config = ConfigParser()
else:
config = SafeConfigParser()
config = RawConfigParser()

n = config.read(filenames)
if not len(n) >= 1:
Expand Down
10 changes: 8 additions & 2 deletions numpy/distutils/system_info.py
Expand Up @@ -129,9 +129,15 @@
from glob import glob
from functools import reduce
if sys.version_info[0] < 3:
from ConfigParser import NoOptionError, ConfigParser
from ConfigParser import NoOptionError
from ConfigParser import RawConfigParser as ConfigParser
else:
from configparser import NoOptionError, ConfigParser
from configparser import NoOptionError
from configparser import RawConfigParser as ConfigParser
# It seems that some people are importing ConfigParser from here so is
# good to keep its class name. Use of RawConfigParser is needed in
# order to be able to load path names with percent in them, like
# `feature%2Fcool` which is common on git flow branch names.

from distutils.errors import DistutilsError
from distutils.dist import Distribution
Expand Down
1 change: 1 addition & 0 deletions site.cfg.example
Expand Up @@ -8,6 +8,7 @@
# will also be checked for the file ~/.numpy-site.cfg .

# The format of the file is that of the standard library's ConfigParser module.
# No interpolation is allowed, RawConfigParser class being used to load it.
#
# http://docs.python.org/3/library/configparser.html
#
Expand Down

0 comments on commit d73e877

Please sign in to comment.