From e8b3c90e14f6791451ea3768975ba5eac0107785 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Sat, 6 Mar 2021 10:44:07 -0800 Subject: [PATCH] Fix unintentional re-import of package z3 in z3printer, in python3. (#5082) --- src/api/python/z3/z3printer.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/api/python/z3/z3printer.py b/src/api/python/z3/z3printer.py index 6bc247b58..34e4bd69e 100644 --- a/src/api/python/z3/z3printer.py +++ b/src/api/python/z3/z3printer.py @@ -5,7 +5,19 @@ # # Author: Leonardo de Moura (leonardo) ############################################ -import sys, io, z3 +import sys, io + +# We want to import submodule z3 here, but there's no way +# to do that that works correctly on both Python 2 and 3. +if sys.version < '3': + # In Python 2: an implicit-relative import of submodule z3. + # In Python 3: an undesirable import of global package z3. + import z3 +else: + # In Python 2: an illegal circular import. + # In Python 3: an explicit-relative import of submodule z3. + from . import z3 + from .z3consts import * from .z3core import * from ctypes import *