Skip to content

Commit 0f821c4

Browse files
committed
Convert pari_share() to str
1 parent d593d2c commit 0f821c4

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

autogen/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
def rebuild(force=False):
1212
pari_module_path = 'cypari2'
13-
src_files = [join(pari_share(), b'pari.desc')] + \
13+
src_files = [join(pari_share(), 'pari.desc')] + \
1414
glob.glob(join('autogen', '*.py'))
1515
gen_files = [join(pari_module_path, 'auto_paridecl.pxd'),
1616
join(pari_module_path, 'auto_gen.pxi')]

autogen/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def read_pari_desc():
4444
... 'section': 'transcendental'}
4545
True
4646
"""
47-
pari_desc = os.path.join(pari_share(), b'pari.desc')
47+
pari_desc = os.path.join(pari_share(), 'pari.desc')
4848
with io.open(pari_desc, encoding="utf-8") as f:
4949
lines = f.readlines()
5050

autogen/paths.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121

2222
# find_executable() returns None if nothing was found
23-
gppath = find_executable("gp") or ""
23+
gppath = find_executable("gp")
2424
if gppath is None:
2525
# This almost certainly won't work, but we need to put something here
2626
prefix = "."
@@ -36,14 +36,18 @@ def pari_share():
3636
EXAMPLES::
3737
3838
>>> from autogen.parser import pari_share
39-
>>> pari_share().endswith(b'/share/pari')
39+
>>> pari_share().endswith('/share/pari')
4040
True
4141
"""
4242
from subprocess import Popen, PIPE
4343
if not gppath:
4444
raise EnvironmentError("cannot find an installation of PARI/GP: make sure that the 'gp' program is in your $PATH")
4545
gp = Popen([gppath, "-f", "-q"], stdin=PIPE, stdout=PIPE)
4646
out = gp.communicate(b"print(default(datadir))")[0]
47+
# Convert out to str if needed
48+
if not isinstance(out, str):
49+
from sys import getfilesystemencoding
50+
out = out.decode(getfilesystemencoding(), "surrogateescape")
4751
datadir = out.strip()
4852
if not os.path.isdir(datadir):
4953
# As a fallback, try a path relative to the prefix

0 commit comments

Comments
 (0)