From a9efd7ad98aa1ae0a511b2fb098f2f277745246b Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 2 Dec 2015 16:37:50 +1100 Subject: [PATCH] Stopped modules from importing themselves --- PIL/ImageCms.py | 6 ++---- selftest.py | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/PIL/ImageCms.py b/PIL/ImageCms.py index ebf127df3..ba5504acb 100644 --- a/PIL/ImageCms.py +++ b/PIL/ImageCms.py @@ -16,6 +16,7 @@ # below for the original description. from __future__ import print_function +import sys DESCRIPTION = """ pyCMS @@ -240,7 +241,6 @@ def get_display_profile(handle=None): :returns: None if the profile is not known. """ - import sys if sys.platform == "win32": from PIL import ImageWin if isinstance(handle, ImageWin.HDC): @@ -943,7 +943,6 @@ def versions(): (pyCMS) Fetches versions. """ - import sys return ( VERSION, core.littlecms_version, sys.version.split()[0], Image.VERSION @@ -954,10 +953,9 @@ def versions(): if __name__ == "__main__": # create a cheap manual from the __doc__ strings for the functions above - from PIL import ImageCms print(__doc__) - for f in dir(ImageCms): + for f in dir(sys.modules[__name__]): doc = None try: exec("doc = %s.__doc__" % (f)) diff --git a/selftest.py b/selftest.py index 4ffae3a16..71f2354f8 100644 --- a/selftest.py +++ b/selftest.py @@ -206,9 +206,8 @@ if __name__ == "__main__": # use doctest to make sure the test program behaves as documented! import doctest - import selftest print("Running selftest:") - status = doctest.testmod(selftest) + status = doctest.testmod(sys.modules[__name__]) if status[0]: print("*** %s tests of %d failed." % status) exit_status = 1