Python: Do not import all of sys when using -relativeimport
This commit is contained in:
parent
dd40a25349
commit
81adedd7dd
2 changed files with 8 additions and 7 deletions
|
|
@ -1251,14 +1251,14 @@ public:
|
|||
Printf(out, "import %s%s%s%s\n", apkg, *Char(apkg) ? "." : "", pfx, mod);
|
||||
Delete(apkg);
|
||||
} else {
|
||||
Printf(out, "import sys\n");
|
||||
Printf(out, "if sys.version_info >= (2, 7, 0):\n");
|
||||
Printf(out, "from sys import version_info\n");
|
||||
Printf(out, "if version_info >= (2, 7, 0):\n");
|
||||
if (py3_rlen1)
|
||||
Printf(out, tab4 "from . import %.*s\n", py3_rlen1, rpkg);
|
||||
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);
|
||||
Printf(out, tab4 "import %s%s%s%s\n", rpkg, *Char(rpkg) ? "." : "", pfx, mod);
|
||||
Printf(out, "del version_info\n");
|
||||
Delete(rpkg);
|
||||
}
|
||||
return out;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue