Skip to content

Commit 10ef3ba

Browse files
committed
Catch Python >= 3.5.4 error for relative imports in non-packages.
- Error is now an ImportError rather than SystemError.
1 parent e2c06d2 commit 10ef3ba

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

stone/backends/python_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def generate_imports_for_referenced_namespaces(
103103
for ns in imported_namespaces:
104104
backend.emit(ns.name + ',')
105105
backend.emit(')')
106-
backend.emit('except (SystemError, ValueError):')
106+
backend.emit('except (ImportError, SystemError, ValueError):')
107107
# Fallback if imported from outside a package.
108108
with backend.indent():
109109
for ns in imported_namespaces:
@@ -119,7 +119,7 @@ def generate_imports_for_referenced_namespaces(
119119
try:
120120
from . import stone_validators as bv
121121
from . import stone_base as bb
122-
except (SystemError, ValueError):
122+
except (ImportError, SystemError, ValueError):
123123
# Catch errors raised when importing a relative module when not in a package.
124124
# This makes testing this file directly (outside of a package) easier.
125125
import stone_validators as bv{type_ignore_comment}

stone/backends/python_rsrc/stone_base.py

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

1111
try:
1212
from . import stone_validators as bv
13-
except (SystemError, ValueError):
13+
except (ImportError, SystemError, ValueError):
1414
# Catch errors raised when importing a relative module when not in a package.
1515
# This makes testing this file directly (outside of a package) easier.
1616
import stone_validators as bv # type: ignore

stone/backends/python_rsrc/stone_serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
try:
2525
from . import stone_base as bb # noqa: F401 # pylint: disable=unused-import
2626
from . import stone_validators as bv
27-
except (SystemError, ValueError):
27+
except (ImportError, SystemError, ValueError):
2828
# Catch errors raised when importing a relative module when not in a package.
2929
# This makes testing this file directly (outside of a package) easier.
3030
import stone_validators as bb # type: ignore # noqa: F401 # pylint: disable=unused-import

test/test_python_type_stubs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def _api():
180180
try:
181181
from . import stone_validators as bv
182182
from . import stone_base as bb
183-
except (SystemError, ValueError):
183+
except (ImportError, SystemError, ValueError):
184184
# Catch errors raised when importing a relative module when not in a package.
185185
# This makes testing this file directly (outside of a package) easier.
186186
import stone_validators as bv # type: ignore

0 commit comments

Comments
 (0)