Skip to content

Commit b17742d

Browse files
committed
Fix py2 errors
1 parent dd52a7e commit b17742d

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

coconut/command/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ def prompt(self, msg):
760760
pygments.styles.get_style_by_name(self.style),
761761
),
762762
completer=self.get_completer(),
763-
auto_suggest=self.suggester,
763+
auto_suggest=self.suggester or None,
764764
)
765765

766766

coconut/compiler/header.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,14 @@ def recursive_iterator(*args, **kwargs):
458458
''',
459459
indent=1,
460460
),
461+
set_nt_match_args=pycondition(
462+
(3, 10),
463+
if_lt=r'''
464+
nt.__match_args__ = nt._fields
465+
''',
466+
indent=1,
467+
newline=True,
468+
),
461469
import_copyreg=pycondition(
462470
(3,),
463471
if_lt="import copy_reg as copyreg",

coconut/compiler/templates/header.py_template

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,8 +2024,10 @@ def _coconut_mk_anon_namedtuple(fields, types=None, of_kwargs=None):
20242024
NT = _coconut.typing.NamedTuple("_namedtuple_of", [(f, t) for f, t in _coconut.zip(fields, types)])
20252025
_coconut.copyreg.pickle(NT, lambda nt: (_coconut_mk_anon_namedtuple, (nt._fields, types, nt._asdict())))
20262026
if of_kwargs is None:
2027-
return NT
2028-
return NT(**of_kwargs)
2027+
nt = NT
2028+
else:
2029+
nt = NT(**of_kwargs)
2030+
{set_nt_match_args} return nt
20292031
def _coconut_ndim(arr):
20302032
arr_mod = _coconut_get_base_module(arr)
20312033
if (arr_mod in _coconut.numpy_modules or _coconut.hasattr(arr.__class__, "__matconcat__")) and _coconut.hasattr(arr, "ndim"):

coconut/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ def get_path_env_var(env_var, default):
666666
prompt_vi_mode = get_bool_env_var(vi_mode_env_var, False)
667667
prompt_wrap_lines = True
668668
prompt_history_search = True
669-
prompt_use_suggester = False
669+
prompt_use_suggester = not PY2
670670

671671
base_dir = os.path.dirname(os.path.abspath(fixpath(__file__)))
672672

0 commit comments

Comments
 (0)