Skip to content

Commit 21c7e8a

Browse files
committed
Fix ModuleNotFoundError naming error with Python 3.6
1 parent bcb80c9 commit 21c7e8a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/mysqlx/protobuf/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
"""This module contains the implementation of a helper class for MySQL X
3030
Protobuf messages."""
3131

32+
try:
33+
ModuleNotFoundError
34+
except NameError:
35+
ModuleNotFoundError = ImportError
36+
3237
_SERVER_MESSAGES_TUPLES = (
3338
("Mysqlx.ServerMessages.Type.OK",
3439
"Mysqlx.Ok"),
@@ -241,10 +246,10 @@ def parse_server_message(msg_type, payload):
241246
msg = _mysqlxpb_pure.new_message(msg_type_name)
242247
msg.ParseFromString(payload)
243248
return msg
244-
except (ImportError, SyntaxError, TypeError) as err:
249+
except (ImportError, ModuleNotFoundError, SyntaxError, TypeError) as err:
245250
HAVE_PROTOBUF = False
246251
HAVE_PROTOBUF_ERROR = err if PROTOBUF_VERSION is not None \
247-
else "Protobuf >=3.0.0 is required"
252+
else "Protobuf >=3.0.0 is required"
248253
if not HAVE_MYSQLXPB_CEXT:
249254
raise ImportError("Protobuf is not available: {}"
250255
"".format(HAVE_PROTOBUF_ERROR))

0 commit comments

Comments
 (0)