Skip to content

Commit 4a53999

Browse files
Jiri Bajertcalmant
authored andcommitted
Made ignoring of import errors compatible with Python 2.x
1 parent 1eeb2ba commit 4a53999

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

javaobj/v1/unmarshaller.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838
# Standard library
3939
from typing import Any, Union
40-
import contextlib
4140
import os
4241
import struct
4342

@@ -112,10 +111,12 @@ def __init__(self, stream, use_numpy_arrays=False):
112111

113112
# Numpy array support
114113
if self.use_numpy_arrays:
115-
with contextlib.suppress(ImportError):
114+
try:
116115
global numpy
117116
import numpy as np
118117
numpy = np
118+
except ImportError:
119+
pass
119120

120121
# Check stream
121122
if stream is None:

0 commit comments

Comments
 (0)