From 9ce4b58df41c061d62a3b35a4c57cc33c954ee6d Mon Sep 17 00:00:00 2001 From: Mike Romberg Date: Mon, 6 Jun 2016 01:28:40 -0600 Subject: [PATCH] Make the check for python3 -relative does python runtime check. --- Source/Modules/python.cxx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 22703bb72..92dd35c5f 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1251,13 +1251,14 @@ public: Printf(out, "import %s%s%s%s\n", apkg, *Char(apkg) ? "." : "", pfx, mod); Delete(apkg); } else { - if (py3) { - if (py3_rlen1) - Printf(out, "from . import %.*s\n", py3_rlen1, rpkg); - Printf(out, "from .%s import %s%s\n", rpkg, pfx, mod); - } else { - Printf(out, "import %s%s%s%s\n", rpkg, *Char(rpkg) ? "." : "", pfx, mod); - } + Printf(out, "import sys\n"); + Printf(out, "if sys.version_info > (2, 7, 0):\n"); + if (py3_rlen1) + Printf(out, tab4 "from . import %.*s\n", py3_rlen1, rpkg); + Printf(out, tab4 "from .%s import %s%s\n", rpkg, pfx, mod); + Printf(out, "else:\n"); + Printf(out, tab4 "import %s%s%s%s\n", rpkg, *Char(rpkg) ? "." : "", + pfx, mod); Delete(rpkg); } return out;