Skip to content

Commit eaef0b2

Browse files
authored
Merge pull request #2282 from mgxd/fix/cp
fix: ensure encoding when opening commit info
2 parents 69575bc + a2d28b6 commit eaef0b2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

nipype/pkg_info.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33

44
from future import standard_library
55
standard_library.install_aliases()
6+
from builtins import open
67
import configparser
78

89
import os
910
import sys
1011
import subprocess
1112

12-
from .info import VERSION
13-
1413
COMMIT_INFO_FNAME = 'COMMIT_INFO.txt'
1514
PY3 = sys.version_info[0] >= 3
1615

@@ -52,7 +51,8 @@ def pkg_commit_hash(pkg_path):
5251
cfg_parser = configparser.RawConfigParser()
5352
else:
5453
cfg_parser = configparser.ConfigParser()
55-
cfg_parser.read(pth)
54+
with open(pth, encoding='utf-8') as fp:
55+
cfg_parser.readfp(fp)
5656
archive_subst = cfg_parser.get('commit hash', 'archive_subst_hash')
5757
if not archive_subst.startswith('$Format'): # it has been substituted
5858
return 'archive substitution', archive_subst
@@ -86,6 +86,9 @@ def get_pkg_info(pkg_path):
8686
with named parameters of interest
8787
'''
8888
src, hsh = pkg_commit_hash(pkg_path)
89+
from .info import VERSION
90+
if not PY3:
91+
src, hsh, VERSION = src.encode(), hsh.encode(), VERSION.encode()
8992
import networkx
9093
import nibabel
9194
import numpy

0 commit comments

Comments
 (0)