Stopped modules from importing themselves

This commit is contained in:
Andrew Murray 2015-12-02 16:37:50 +11:00
parent 82c7ea8489
commit a9efd7ad98
2 changed files with 3 additions and 6 deletions

View File

@ -16,6 +16,7 @@
# below for the original description. # below for the original description.
from __future__ import print_function from __future__ import print_function
import sys
DESCRIPTION = """ DESCRIPTION = """
pyCMS pyCMS
@ -240,7 +241,6 @@ def get_display_profile(handle=None):
:returns: None if the profile is not known. :returns: None if the profile is not known.
""" """
import sys
if sys.platform == "win32": if sys.platform == "win32":
from PIL import ImageWin from PIL import ImageWin
if isinstance(handle, ImageWin.HDC): if isinstance(handle, ImageWin.HDC):
@ -943,7 +943,6 @@ def versions():
(pyCMS) Fetches versions. (pyCMS) Fetches versions.
""" """
import sys
return ( return (
VERSION, core.littlecms_version, VERSION, core.littlecms_version,
sys.version.split()[0], Image.VERSION sys.version.split()[0], Image.VERSION
@ -954,10 +953,9 @@ def versions():
if __name__ == "__main__": if __name__ == "__main__":
# create a cheap manual from the __doc__ strings for the functions above # create a cheap manual from the __doc__ strings for the functions above
from PIL import ImageCms
print(__doc__) print(__doc__)
for f in dir(ImageCms): for f in dir(sys.modules[__name__]):
doc = None doc = None
try: try:
exec("doc = %s.__doc__" % (f)) exec("doc = %s.__doc__" % (f))

View File

@ -206,9 +206,8 @@ if __name__ == "__main__":
# use doctest to make sure the test program behaves as documented! # use doctest to make sure the test program behaves as documented!
import doctest import doctest
import selftest
print("Running selftest:") print("Running selftest:")
status = doctest.testmod(selftest) status = doctest.testmod(sys.modules[__name__])
if status[0]: if status[0]:
print("*** %s tests of %d failed." % status) print("*** %s tests of %d failed." % status)
exit_status = 1 exit_status = 1