diff --git a/gdx/__init__.py b/gdx/__init__.py index 7f67fb7..1ee50ed 100644 --- a/gdx/__init__.py +++ b/gdx/__init__.py @@ -11,7 +11,7 @@ import pandas import xarray as xr -from .pycompat import install_aliases, filter, range, super, zip +from .pycompat import install_aliases, filter, raise_from, range, super, zip install_aliases() from .api import GDX, gdxcc, type_str, vartype_str @@ -408,7 +408,7 @@ def info(self, name): """Informal string representation of the Symbol with *name*.""" if isinstance(self._state[name], dict): attrs = self._state[name]['attrs'] - return '{} {}({}) — {} records: {}'.format( + return '{} {}({}), {} records: {}'.format( attrs['type_str'], name, ','.join(attrs['domain']), attrs['records'], attrs['description']) else: @@ -474,4 +474,4 @@ def __getitem__(self, key): self._load_symbol_data(key) return super(File, self).__getitem__(key) else: - raise KeyError(key) from e + raise raise_from(KeyError(key), e) diff --git a/gdx/pycompat.py b/gdx/pycompat.py index 776046f..601acfa 100644 --- a/gdx/pycompat.py +++ b/gdx/pycompat.py @@ -2,6 +2,7 @@ from builtins import filter, range, object, super, zip from future.standard_library import install_aliases +from future.utils import raise_from PY3 = sys.version_info[0] >= 3 diff --git a/gdx/test/test_gdx.py b/gdx/test/test_gdx.py index cc0ec43..807aa84 100644 --- a/gdx/test/test_gdx.py +++ b/gdx/test/test_gdx.py @@ -133,7 +133,7 @@ def test_info1(self, gdxfile): def test_info2(self, rawgdx): # Use a File where p1 is guaranteed to not have been loaded: - assert (gdx.File(rawgdx).info('p1') == 'unknown parameter p1(s) — 1 ' + assert (gdx.File(rawgdx).info('p1') == 'unknown parameter p1(s), 1 ' 'records: Example parameter with animal data') def test_dealias(self, gdxfile):