]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-105751: test_ctypes avoids "from ctypes import *" (#105768)
authorVictor Stinner <vstinner@python.org>
Wed, 14 Jun 2023 03:34:11 +0000 (05:34 +0200)
committerGitHub <noreply@github.com>
Wed, 14 Jun 2023 03:34:11 +0000 (03:34 +0000)
Using "import *" prevents linters like pyflakes to detect undefined names
(usually missing imports).

Replace c_voidp with c_void_p.

48 files changed:
Lib/ctypes/_endian.py
Lib/test/test_ctypes/test_anon.py
Lib/test/test_ctypes/test_array_in_pointer.py
Lib/test/test_ctypes/test_arrays.py
Lib/test/test_ctypes/test_as_parameter.py
Lib/test/test_ctypes/test_bitfields.py
Lib/test/test_ctypes/test_buffers.py
Lib/test/test_ctypes/test_bytes.py
Lib/test/test_ctypes/test_byteswap.py
Lib/test/test_ctypes/test_callbacks.py
Lib/test/test_ctypes/test_cast.py
Lib/test/test_ctypes/test_cfuncs.py
Lib/test/test_ctypes/test_checkretval.py
Lib/test/test_ctypes/test_delattr.py
Lib/test/test_ctypes/test_errno.py
Lib/test/test_ctypes/test_find.py
Lib/test/test_ctypes/test_frombuffer.py
Lib/test/test_ctypes/test_funcptr.py
Lib/test/test_ctypes/test_functions.py
Lib/test/test_ctypes/test_incomplete.py
Lib/test/test_ctypes/test_init.py
Lib/test/test_ctypes/test_internals.py
Lib/test/test_ctypes/test_keeprefs.py
Lib/test/test_ctypes/test_libc.py
Lib/test/test_ctypes/test_loading.py
Lib/test/test_ctypes/test_memfunctions.py
Lib/test/test_ctypes/test_numbers.py
Lib/test/test_ctypes/test_objects.py
Lib/test/test_ctypes/test_pep3118.py
Lib/test/test_ctypes/test_pickling.py
Lib/test/test_ctypes/test_pointers.py
Lib/test/test_ctypes/test_prototypes.py
Lib/test/test_ctypes/test_python_api.py
Lib/test/test_ctypes/test_random_things.py
Lib/test/test_ctypes/test_repr.py
Lib/test/test_ctypes/test_returnfuncptrs.py
Lib/test/test_ctypes/test_simplesubclasses.py
Lib/test/test_ctypes/test_sizes.py
Lib/test/test_ctypes/test_slicing.py
Lib/test/test_ctypes/test_stringptr.py
Lib/test/test_ctypes/test_strings.py
Lib/test/test_ctypes/test_struct_fields.py
Lib/test/test_ctypes/test_structures.py
Lib/test/test_ctypes/test_unaligned_structures.py
Lib/test/test_ctypes/test_values.py
Lib/test/test_ctypes/test_varsize_struct.py
Lib/test/test_ctypes/test_win32.py
Lib/test/test_ctypes/test_wintypes.py

index b5446c049bc9dcb007cd05cc9df8bb94fc3de730..3febb3118b8230762f605d4d4a725954fbc3ca27 100644 (file)
@@ -1,5 +1,5 @@
 import sys
-from ctypes import *
+from ctypes import Array, Structure, Union
 
 _array_type = type(Array)
 
index d378392ebe28443d36fe6eae9aafad7927b8cc46..704f7a3d38a5acf4e1e99ec7e3800a43e0e7b365 100644 (file)
@@ -1,6 +1,6 @@
 import unittest
 import test.support
-from ctypes import *
+from ctypes import c_int, Union, Structure, sizeof
 
 class AnonTest(unittest.TestCase):
 
index ca1edcf6210176ca0f1d1a951527569af209ee1f..a149aa9463f30c34faca1c0b7d9c70a48ed25bdc 100644 (file)
@@ -1,5 +1,5 @@
 import unittest
-from ctypes import *
+from ctypes import c_byte, Structure, POINTER, cast
 from binascii import hexlify
 import re
 
index 473083870ca6e5944ee45527692ba3510b4b2bc5..4f8747d46ae366ef84f67aa5ad9b1a5754658abe 100644 (file)
@@ -2,7 +2,10 @@ import ctypes
 import sys
 import unittest
 import warnings
-from ctypes import *
+from ctypes import (Structure, Array, sizeof, addressof,
+                    create_string_buffer, create_unicode_buffer,
+                    c_char, c_wchar, c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint,
+                    c_long, c_ulonglong, c_float, c_double, c_longdouble)
 from test.support import bigmemtest, _2G
 
 from test.test_ctypes import need_symbol
index fcf99ff057920be55f77ca10c49ea53956011e74..1048c5064c3c1742017f18d7547f136443a1750d 100644 (file)
@@ -1,8 +1,12 @@
-import unittest
+import _ctypes_test
 import ctypes
-from ctypes import *
+import unittest
+from ctypes import (Structure, CDLL, CFUNCTYPE,
+                    POINTER, pointer, byref,
+                    c_short, c_int, c_long, c_longlong,
+                    c_byte, c_wchar, c_float, c_double,
+                    ArgumentError)
 from test.test_ctypes import need_symbol
-import _ctypes_test
 
 dll = CDLL(_ctypes_test.__file__)
 
index dad71a0ba7ee4aa343e1a48f9091b070635eb299..e7b06dd767f9ea78257a7eb8f5a2d0f0cc14ed18 100644 (file)
@@ -1,4 +1,8 @@
-from ctypes import *
+from ctypes import (CDLL, Structure, sizeof, POINTER, byref, alignment,
+                    LittleEndianStructure, BigEndianStructure,
+                    c_byte, c_ubyte, c_char, c_char_p, c_void_p, c_wchar,
+                    c_uint32, c_uint64,
+                    c_short, c_ushort, c_int, c_uint, c_long, c_ulong, c_longlong, c_ulonglong)
 from test.test_ctypes import need_symbol
 from test import support
 import unittest
index a9be2023aa0fa08fbbaaa2a6c11e1fcbecd738db..c6c59b926798e05a817de13013edac948a3fe6f3 100644 (file)
@@ -1,4 +1,5 @@
-from ctypes import *
+from ctypes import (create_string_buffer, create_unicode_buffer, sizeof,
+                    c_char, c_wchar)
 from test.test_ctypes import need_symbol
 import unittest
 
index 092ec5af0524c408a2e78dbf8fa568db5233bce6..3538ed7d7197ccc0c380b8158385e969042b20f2 100644 (file)
@@ -1,7 +1,7 @@
 """Test where byte objects are accepted"""
-import unittest
 import sys
-from ctypes import *
+import unittest
+from ctypes import Structure, c_char, c_char_p, c_wchar, c_wchar_p
 
 class BytesTest(unittest.TestCase):
     def test_c_char(self):
index 7e98559dfbccb64add67837e3972b84ac7302bc9..7507c07d8a8a95740323232658f366d4780f9e93 100644 (file)
@@ -1,7 +1,13 @@
 import sys, unittest, struct, math, ctypes
 from binascii import hexlify
 
-from ctypes import *
+from ctypes import (Structure, Union, LittleEndianUnion, BigEndianUnion,
+                    BigEndianStructure, LittleEndianStructure,
+                    POINTER, sizeof, cast,
+                    c_byte, c_ubyte, c_char, c_wchar, c_void_p,
+                    c_short, c_ushort, c_int, c_uint,
+                    c_long, c_ulong, c_longlong, c_ulonglong,
+                    c_uint32, c_float, c_double)
 
 def bin(s):
     return hexlify(memoryview(s)).decode().upper()
index a5c2e430d85ad05c8dbdecb701fd8753687ee054..7ce9775978fa4b4bd91c7c43855119e630410937 100644 (file)
@@ -3,7 +3,12 @@ import unittest
 from test import support
 
 import ctypes
-from ctypes import *
+from ctypes import (CDLL, cdll, Structure, CFUNCTYPE,
+                    ArgumentError, POINTER, sizeof,
+                    c_byte, c_ubyte, c_char, c_char_p,
+                    c_short, c_ushort, c_int, c_uint,
+                    c_long, c_longlong, c_ulonglong, c_ulong,
+                    c_float, c_double, c_longdouble, py_object)
 from test.test_ctypes import need_symbol
 from _ctypes import CTYPES_MAX_ARGCOUNT
 import _ctypes_test
index 7ee23b16f1b00bdb1dbdd81feccc6f7ae46edef3..641b0783515c658a55b6d63df8a68b2eb10beedc 100644 (file)
@@ -1,7 +1,9 @@
-from ctypes import *
-from test.test_ctypes import need_symbol
-import unittest
 import sys
+import unittest
+from ctypes import (Structure, Union, POINTER, cast, sizeof, addressof,
+                    c_void_p, c_char_p, c_wchar_p,
+                    c_byte, c_short, c_int)
+from test.test_ctypes import need_symbol
 
 class Test(unittest.TestCase):
 
@@ -12,7 +14,7 @@ class Test(unittest.TestCase):
         ptr = cast(array, POINTER(c_int))
         self.assertEqual([ptr[i] for i in range(3)], [42, 17, 2])
 
-        if 2*sizeof(c_short) == sizeof(c_int):
+        if 2 * sizeof(c_short) == sizeof(c_int):
             ptr = cast(array, POINTER(c_short))
             if sys.byteorder == "little":
                 self.assertEqual([ptr[i] for i in range(6)],
index d66e679799c54378973af3cf8a7bf0b10b54245e..9cbde8a13091f295484c7742693bb8d10fd877c9 100644 (file)
@@ -1,13 +1,14 @@
-# A lot of failures in these tests on Mac OS X.
-# Byte order related?
-
 import unittest
 import ctypes
-from ctypes import *
+from ctypes import (CDLL,
+                    c_byte, c_ubyte, c_char,
+                    c_short, c_ushort, c_int, c_uint,
+                    c_long, c_ulong, c_longlong, c_ulonglong,
+                    c_float, c_double, c_longdouble)
 from test.test_ctypes import need_symbol
-
 import _ctypes_test
 
+
 class CFunctions(unittest.TestCase):
     _dll = CDLL(_ctypes_test.__file__)
 
@@ -210,5 +211,6 @@ if hasattr(ctypes, 'WinDLL'):
     class stdcallCFunctions(CFunctions):
         _dll = stdcall_dll(_ctypes_test.__file__)
 
+
 if __name__ == '__main__':
     unittest.main()
index b4834322ea7f8a57770dad468aa96824552ef8b8..fe5f2442cd7b4ed8535af52de76ed2682abb3b5d 100644 (file)
@@ -1,15 +1,16 @@
-import unittest
-
 import ctypes
-from ctypes import *
+import unittest
+from ctypes import CDLL, c_int
 from test.test_ctypes import need_symbol
 
+
 class CHECKED(c_int):
     def _check_retval_(value):
         # Receives a CHECKED instance.
         return str(value.value)
     _check_retval_ = staticmethod(_check_retval_)
 
+
 class Test(unittest.TestCase):
 
     def test_checkretval(self):
@@ -32,5 +33,7 @@ class Test(unittest.TestCase):
         oleaut32 = ctypes.oledll.oleaut32
         self.assertRaises(OSError, oleaut32.CreateTypeLib2, 0, None, None)
 
+
+
 if __name__ == "__main__":
     unittest.main()
index 0f4d58691b55e7dfef3303e2bf15b782363f5ff1..10d2fe066fc068557ef5d71d4c84a40420e72166 100644 (file)
@@ -1,9 +1,11 @@
 import unittest
-from ctypes import *
+from ctypes import Structure, c_char, c_int
+
 
 class X(Structure):
     _fields_ = [("foo", c_int)]
 
+
 class TestCase(unittest.TestCase):
     def test_simple(self):
         self.assertRaises(TypeError,
@@ -17,5 +19,6 @@ class TestCase(unittest.TestCase):
         self.assertRaises(TypeError,
                           delattr, X(), "foo")
 
+
 if __name__ == "__main__":
     unittest.main()
index bfc20bd68fc7f0575f1a8ee19fd14847859e0fa5..3376322299d29ecd6ee324c9383d88b5fb0882c7 100644 (file)
@@ -2,14 +2,15 @@ import unittest, os, errno
 import threading
 
 import ctypes
-from ctypes import *
+from ctypes import CDLL, c_int, c_char_p, c_wchar_p, get_errno, set_errno
 from ctypes.util import find_library
 
 class Test(unittest.TestCase):
     def test_open(self):
         libc_name = find_library("c")
         if libc_name is None:
-            raise unittest.SkipTest("Unable to find C library")
+            self.skipTest("Unable to find C library")
+
         libc = CDLL(libc_name, use_errno=True)
         if os.name == "nt":
             libc_open = libc._open
@@ -73,5 +74,6 @@ class Test(unittest.TestCase):
 
         ctypes.set_last_error(0)
 
+
 if __name__ == "__main__":
     unittest.main()
index 1ff9d019b138a4f1b723bb0946bba655333a5ac1..7a1658b63cbac772c2a016b64e852fd6a81f1a20 100644 (file)
@@ -1,11 +1,12 @@
-import unittest
-import unittest.mock
 import os.path
 import sys
 import test.support
-from test.support import os_helper
-from ctypes import *
+import unittest
+import unittest.mock
+from ctypes import CDLL, RTLD_GLOBAL
 from ctypes.util import find_library
+from test.support import os_helper
+
 
 # On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.
 class Test_OpenGL_libs(unittest.TestCase):
@@ -36,11 +37,13 @@ class Test_OpenGL_libs(unittest.TestCase):
                 cls.gl = CDLL(lib_gl, mode=RTLD_GLOBAL)
             except OSError:
                 pass
+
         if lib_glu:
             try:
                 cls.glu = CDLL(lib_glu, RTLD_GLOBAL)
             except OSError:
                 pass
+
         if lib_gle:
             try:
                 cls.gle = CDLL(lib_gle)
index 55c244356b30d0e2913c31e8f0159ab810a32191..e3e1267387848e95d7781ad6ab7417233c2d78ea 100644 (file)
@@ -1,7 +1,7 @@
-from ctypes import *
 import array
 import gc
 import unittest
+from ctypes import Structure, Union, Array, sizeof, c_char, c_int
 
 class X(Structure):
     _fields_ = [("c_int", c_int)]
index ef6772c6e88b654a350440b19fe2827c37c919c0..72684d6d1cd19b81d464242ae11b0b6085d1a325 100644 (file)
@@ -1,6 +1,8 @@
-import unittest
+import _ctypes_test
 import ctypes
-from ctypes import *
+import unittest
+from ctypes import (CDLL, Structure, CFUNCTYPE, sizeof,
+                    c_void_p, c_char_p, c_char, c_int, c_uint, c_long)
 
 try:
     WINFUNCTYPE = ctypes.WINFUNCTYPE
@@ -8,9 +10,9 @@ except AttributeError:
     # fake to enable this test on Linux
     WINFUNCTYPE = CFUNCTYPE
 
-import _ctypes_test
 lib = CDLL(_ctypes_test.__file__)
 
+
 class CFuncPtrTestCase(unittest.TestCase):
     def test_basic(self):
         X = WINFUNCTYPE(c_int, c_int, c_int)
@@ -21,8 +23,8 @@ class CFuncPtrTestCase(unittest.TestCase):
         x = X(func)
         self.assertEqual(x.restype, c_int)
         self.assertEqual(x.argtypes, (c_int, c_int))
-        self.assertEqual(sizeof(x), sizeof(c_voidp))
-        self.assertEqual(sizeof(X), sizeof(c_voidp))
+        self.assertEqual(sizeof(x), sizeof(c_void_p))
+        self.assertEqual(sizeof(X), sizeof(c_void_p))
 
     def test_first(self):
         StdCallback = WINFUNCTYPE(c_int, c_int, c_int)
@@ -129,5 +131,6 @@ class CFuncPtrTestCase(unittest.TestCase):
 
         self.assertRaises(TypeError, _CFuncPtr, 13, "name", 42, "iid")
 
+
 if __name__ == '__main__':
     unittest.main()
index 3f331703a0db220255e14dd2c063bf6e4bdd2f2d..a14924a9413cec5fd83568163196225fe2128876 100644 (file)
@@ -6,7 +6,11 @@ Later...
 """
 
 import ctypes
-from ctypes import *
+from ctypes import (CDLL, Structure, Array, CFUNCTYPE,
+                    byref, POINTER, pointer, ArgumentError,
+                    c_char, c_wchar, c_byte, c_char_p,
+                    c_short, c_int, c_long, c_longlong,
+                    c_float, c_double, c_longdouble)
 from test.test_ctypes import need_symbol
 import sys, unittest
 
index 0b53c15f1f99863bdd79f7922e782aff51b7b767..552effaa3db973c03f353b64fd51055f567b6cbf 100644 (file)
@@ -1,7 +1,7 @@
 import ctypes
 import unittest
 import warnings
-from ctypes import *
+from ctypes import Structure, POINTER, pointer, c_char_p
 
 ################################################################
 #
index 75fad112a01ffbbe4f069fe872176ba66d2db455..113425e5823edc35ba20d71bd46d75a478a6d97d 100644 (file)
@@ -1,5 +1,6 @@
-from ctypes import *
 import unittest
+from ctypes import Structure, c_int
+
 
 class X(Structure):
     _fields_ = [("a", c_int),
@@ -15,6 +16,7 @@ class X(Structure):
         self.a = 9
         self.b = 12
 
+
 class Y(Structure):
     _fields_ = [("x", X)]
 
@@ -36,5 +38,6 @@ class InitTest(unittest.TestCase):
         self.assertEqual((y.x.a, y.x.b), (9, 12))
         self.assertEqual(y.x.new_was_called, False)
 
+
 if __name__ == "__main__":
     unittest.main()
index 271e3f57f817430dcd94726051a6a945a119c4de..1290f80111d28392033ff909ca9785f743e72d50 100644 (file)
@@ -1,6 +1,6 @@
 # This tests the internal _objects attribute
 import unittest
-from ctypes import *
+from ctypes import Structure, POINTER, c_char_p, c_int
 from sys import getrefcount as grc
 
 # XXX This test must be reviewed for correctness!!!
index 94c02573fa19d88c9ac59ae98f0d8d13fd072d3c..ecfcda13945dc67b35a2cf9fd2f0d0962697e263 100644 (file)
@@ -1,4 +1,4 @@
-from ctypes import *
+from ctypes import Structure, POINTER, pointer, c_char_p, c_int
 import unittest
 
 class SimpleTestCase(unittest.TestCase):
index 56285b5ff8151275aba9de5f197d2c385822e849..8664529f0944763db78dbbf533b822770865c671 100644 (file)
@@ -1,10 +1,13 @@
 import unittest
 
-from ctypes import *
-import _ctypes_test
+from ctypes import (CDLL, CFUNCTYPE, POINTER, create_string_buffer, sizeof,
+                    c_void_p, c_char, c_int, c_double, c_size_t)
+
 
+import _ctypes_test
 lib = CDLL(_ctypes_test.__file__)
 
+
 def three_way_cmp(x, y):
     """Return -1 if x < y, 0 if x == y and 1 if x > y"""
     return (x > y) - (x < y)
index fec26aab1d8031cbc023690e202163c4e3a6c3eb..0cbfcf01c0cf2b824ae642586e9d3bac81ab3582 100644 (file)
@@ -1,15 +1,15 @@
-from ctypes import *
 import ctypes
 import os
 import shutil
 import subprocess
 import sys
-import unittest
 import test.support
-from test.support import import_helper
-from test.support import os_helper
+import unittest
+from test.support import import_helper, os_helper
+from ctypes import CDLL, cdll, addressof, c_void_p, c_char_p
 from ctypes.util import find_library
 
+
 libc_name = None
 
 def setUpModule():
@@ -126,6 +126,7 @@ class LoaderTest(unittest.TestCase):
         kernel32.GetProcAddress.restype = c_void_p
         proc = kernel32.GetProcAddress(advapi32._handle, b"CloseEventLog")
         self.assertTrue(proc)
+
         # This is the real test: call the function via 'call_function'
         self.assertEqual(0, call_function(proc, (None,)))
 
@@ -196,6 +197,5 @@ class LoaderTest(unittest.TestCase):
                         "WinDLL('_sqlite3.dll'); p.close()")
 
 
-
 if __name__ == "__main__":
     unittest.main()
index d5c973521177c8f9429a75cc649e90b47f56fcf3..3f3b6319edb13a3858da497c1da0c0b3c9d31110 100644 (file)
@@ -1,7 +1,11 @@
 import sys
 from test import support
 import unittest
-from ctypes import *
+from ctypes import (POINTER, sizeof, cast,
+                    create_string_buffer, string_at,
+                    create_unicode_buffer, wstring_at,
+                    memmove, memset,
+                    c_char_p, c_byte, c_ubyte, c_wchar)
 from test.test_ctypes import need_symbol
 
 class MemFunctionsTest(unittest.TestCase):
index aad6af4b8671ce1e4bae96273d240132b42384d8..061876f9f776d67c412c3de8c4ba4f253c796872 100644 (file)
@@ -3,8 +3,10 @@ import sys
 import unittest
 from array import array
 from operator import truth
-from ctypes import *
-from ctypes import _SimpleCData
+from ctypes import (byref, sizeof, alignment, _SimpleCData,
+                    c_char, c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint,
+                    c_long, c_ulong, c_longlong, c_ulonglong,
+                    c_float, c_double, c_longdouble, c_bool)
 
 def valid_ranges(*types):
     # given a sequence of numeric types, collect their _type_
index 44a3c61ad792678dc40b1b9adf93b2cc3939068d..78b1634115bdb4a31ebeb60df38e5324e6d25f3a 100644 (file)
@@ -11,7 +11,7 @@ is None.
 
 Here is an array of string pointers:
 
->>> from ctypes import *
+>>> from ctypes import Structure, c_int, c_char_p
 >>> array = (c_char_p * 5)()
 >>> print(array._objects)
 None
index 038161745df90531ba393b47b0d25a3bd57ef01c..c8eb584858ca9d176a913cd9d2cea7a95b9e92ac 100644 (file)
@@ -1,5 +1,10 @@
 import unittest
-from ctypes import *
+from ctypes import (CFUNCTYPE, POINTER, sizeof, Union,
+                    Structure, LittleEndianStructure, BigEndianStructure,
+                    c_char, c_byte, c_ubyte,
+                    c_short, c_ushort, c_int, c_uint,
+                    c_long, c_ulong, c_longlong, c_ulonglong, c_uint64,
+                    c_bool, c_float, c_double, c_longdouble, py_object)
 import re, sys
 
 if sys.byteorder == "little":
index c4a79b977931c8a9f57a7ea1f70b54316eedfa88..1df79be9fbac1dc1a5c566e9378c1780006787bf 100644 (file)
@@ -1,9 +1,13 @@
 import unittest
 import pickle
-from ctypes import *
+from ctypes import (CDLL, Structure, CFUNCTYPE, pointer,
+                    c_void_p, c_char_p, c_wchar_p, c_char, c_wchar, c_int, c_double)
+
+
 import _ctypes_test
 dll = CDLL(_ctypes_test.__file__)
 
+
 class X(Structure):
     _fields_ = [("a", c_int), ("b", c_double)]
     init_called = 0
index 7b6c3f5babe481861b055b680ee81a6db1257186..7d13aebdbbeafe61d8bc39fe82b016fa6ec82051 100644 (file)
@@ -1,8 +1,11 @@
-import unittest, sys
-
-import ctypes
-from ctypes import *
 import _ctypes_test
+import ctypes
+import sys
+import unittest
+from ctypes import (CDLL, CFUNCTYPE, Structure, POINTER, pointer, byref, sizeof,
+                    c_void_p, c_char_p,
+                    c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint,
+                    c_long, c_ulong, c_longlong, c_ulonglong, c_float, c_double)
 
 ctype_types = [c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint,
                  c_long, c_ulong, c_longlong, c_ulonglong, c_double, c_float]
index bf27561487ac816abd75084b955b1f9490b65f96..fe620439a25b29d279dbec8855b57aaecff5159d 100644 (file)
@@ -1,4 +1,7 @@
-from ctypes import *
+from ctypes import (CDLL, CFUNCTYPE, POINTER, ArgumentError,
+                    pointer, byref, sizeof, addressof,
+                    c_void_p, c_char_p, c_wchar_p, c_char, c_wchar, c_buffer,
+                    c_short, c_int, c_long, c_longlong, c_double)
 from test.test_ctypes import need_symbol
 import unittest
 
index de8989e2c3300f738adf8734fbe606d98655d594..3799311751a055abd697a2ffbe892c9cb0139b8b 100644 (file)
@@ -1,6 +1,8 @@
-from ctypes import *
 import unittest
 from test import support
+from ctypes import (pythonapi, POINTER, c_buffer, sizeof,
+                    py_object, c_char_p, c_char, c_long, c_size_t)
+
 
 ################################################################
 # This section should be moved into ctypes\__init__.py, when it's ready.
@@ -82,5 +84,6 @@ class PythonAPITestCase(unittest.TestCase):
         self.assertEqual(repr(py_object(42)), "py_object(42)")
         self.assertEqual(repr(py_object(object)), "py_object(%r)" % object)
 
+
 if __name__ == "__main__":
     unittest.main()
index cfd355a7f0835f4389237454a186a768cf67318d..fcea8e847eb6069f2ba5942fb34a32c2715806b1 100644 (file)
@@ -1,9 +1,9 @@
-from ctypes import *
-import ctypes
 import contextlib
-from test import support
-import unittest
+import ctypes
 import sys
+import unittest
+from test import support
+from ctypes import CFUNCTYPE, c_void_p, c_char_p, c_int, c_double
 
 
 def callback_func(arg):
index 60a2c803453d5330a0d4d5833770f383c61df466..bb6b5ae5e799fd299e305c2a79d07d9ea6c0cb55 100644 (file)
@@ -1,4 +1,6 @@
-from ctypes import *
+from ctypes import (c_byte, c_short, c_int, c_long, c_longlong,
+                    c_ubyte, c_ushort, c_uint, c_ulong, c_ulonglong,
+                    c_float, c_double, c_longdouble, c_bool, c_char)
 import unittest
 
 subclasses = []
@@ -25,5 +27,6 @@ class ReprTest(unittest.TestCase):
         self.assertEqual("c_char(b'x')", repr(c_char(b'x')))
         self.assertEqual("<X object at", repr(X(b'x'))[:12])
 
+
 if __name__ == "__main__":
     unittest.main()
index 1974f40df643b2d969c7068dd9d0fdb2c2fcf5d0..6a624133554ef88daeb72fd7986612c861628d8f 100644 (file)
@@ -1,5 +1,5 @@
 import unittest
-from ctypes import *
+from ctypes import CDLL, CFUNCTYPE, ArgumentError, c_char_p, c_void_p, c_char
 
 import _ctypes_test
 
@@ -62,5 +62,6 @@ class ReturnFuncPtrTestCase(unittest.TestCase):
         self.assertRaises(ArgumentError, strchr, b"abcdef", 3.0)
         self.assertRaises(TypeError, strchr, b"abcdef")
 
+
 if __name__ == "__main__":
     unittest.main()
index 3da2794a7942eddf2a12e2160726feded1ec7740..6072b62de5d53a5b84947df202f64180c41d6a9c 100644 (file)
@@ -1,5 +1,6 @@
 import unittest
-from ctypes import *
+from ctypes import Structure, CFUNCTYPE, c_int
+
 
 class MyInt(c_int):
     def __eq__(self, other):
@@ -7,6 +8,7 @@ class MyInt(c_int):
             return NotImplementedError
         return self.value == other.value
 
+
 class Test(unittest.TestCase):
 
     def test_compare(self):
@@ -51,5 +53,6 @@ class Test(unittest.TestCase):
 
         self.assertEqual(s.x, MyInt(42))
 
+
 if __name__ == "__main__":
     unittest.main()
index bf8d6ea35aa39946b6985cb16f22c8d66ef4aa20..e981ccfad5ec9576a3af54eecf0a61aae2628ddc 100644 (file)
@@ -1,7 +1,9 @@
 # Test specifically-sized containers.
 
-from ctypes import *
-
+from ctypes import (sizeof,
+                    c_int8, c_uint8, c_int16, c_uint16,
+                    c_int32, c_uint32, c_int64, c_uint64,
+                    c_void_p, c_size_t, c_ssize_t, c_time_t, SIZEOF_TIME_T)
 import unittest
 
 
index b3e68f9a822d94cfad16fefc7feea5d1f051c095..8979b27fda2141df87b8383c5a0f76c0c8d4b394 100644 (file)
@@ -1,5 +1,6 @@
 import unittest
-from ctypes import *
+from ctypes import (CDLL, POINTER, sizeof,
+                    c_byte, c_short, c_int, c_long, c_char, c_wchar, c_char_p)
 from test.test_ctypes import need_symbol
 
 import _ctypes_test
index c20951f4ce0016930de71c56b71b5621e4d1d227..1eae154a907b5ed6ee19b108447ba5af80d3dfe5 100644 (file)
@@ -1,6 +1,6 @@
 import unittest
 from test import support
-from ctypes import *
+from ctypes import CDLL, Structure, POINTER, c_buffer, c_char, c_char_p
 
 import _ctypes_test
 
index a9003be3f506e2725dc92b347535042a902a23a7..62d84cc43aa9b2f5ca26aaf3153c048d0e81e873 100644 (file)
@@ -1,5 +1,5 @@
 import unittest
-from ctypes import *
+from ctypes import c_buffer, sizeof, byref, c_char, c_wchar
 from test.test_ctypes import need_symbol
 
 class StringArrayTestCase(unittest.TestCase):
index e444f5e1f77919b1a0a714f4d9517d364fe66645..17a2e69f76d94d82fa725e1fa6bdd967aab4c740 100644 (file)
@@ -1,5 +1,5 @@
 import unittest
-from ctypes import *
+from ctypes import Structure, Union, sizeof, c_char, c_int
 
 class StructFieldsTestCase(unittest.TestCase):
     # Structure/Union classes must get 'finalized' sooner or
index df39dc7f50d3f7becd28920eee7562518c4bb89d..04ed73a49c76fdfb7bbe8090a86f6251127e8220 100644 (file)
@@ -1,7 +1,11 @@
 import platform
 import sys
 import unittest
-from ctypes import *
+from ctypes import (CDLL, Structure, Union, POINTER, sizeof, byref, alignment,
+                    c_void_p, c_char, c_wchar, c_byte, c_ubyte,
+                    c_uint8, c_uint16, c_uint32,
+                    c_short, c_ushort, c_int, c_uint,
+                    c_long, c_ulong, c_longlong, c_ulonglong, c_float, c_double)
 from test.test_ctypes import need_symbol
 from struct import calcsize
 import _ctypes_test
index ee7fb45809bf7b68424367b09909bf7ca04c9127..a7e1796d4d63f9b0cd4d1ca84629dccfd3e2ae7e 100644 (file)
@@ -1,5 +1,8 @@
 import sys, unittest
-from ctypes import *
+from ctypes import (Structure, BigEndianStructure, LittleEndianStructure,
+                    c_byte, c_short, c_int, c_long, c_longlong,
+                    c_float, c_double,
+                    c_ushort, c_uint, c_ulong, c_ulonglong)
 
 structures = []
 byteswapped_structures = []
index 435fdd22ea2be1c6dc8b9c4e8301ce3d4fabaf9e..9707e032dc37cc5542ba77a5e3973bfe8eb062c7 100644 (file)
@@ -6,7 +6,7 @@ import _imp
 import importlib.util
 import unittest
 import sys
-from ctypes import *
+from ctypes import Structure, CDLL, POINTER, pythonapi, c_ubyte, c_char_p, c_int
 from test.support import import_helper
 
 import _ctypes_test
index f409500f013c42487b9983311e8e9f840d9c5553..d2fa0b36c785e6c5a6ec2458e8089007c2bb106e 100644 (file)
@@ -1,4 +1,4 @@
-from ctypes import *
+from ctypes import Structure, sizeof, resize, c_int
 import unittest
 
 class VarSizeTest(unittest.TestCase):
index 43ed9dbe10c28e592fa02c2cc24c4a2f6970bc29..a8987dd1da6896cebbab900a020a8fdc61302f8c 100644 (file)
@@ -1,11 +1,13 @@
 # Windows specific tests
 
+import _ctypes_test
 import ctypes
-from ctypes import *
-import unittest, sys
+import sys
+import unittest
+from ctypes import (CDLL, Structure, POINTER, pointer, sizeof, byref,
+                    c_void_p, c_char, c_int, c_long)
 from test import support
 
-import _ctypes_test
 
 @unittest.skipUnless(sys.platform == "win32", 'Windows-specific test')
 class FunctionCallTestCase(unittest.TestCase):
@@ -94,6 +96,7 @@ class TestWinError(unittest.TestCase):
         self.assertEqual(e.errno, errno.EINVAL)
         self.assertEqual(e.winerror, ERROR_INVALID_PARAMETER)
 
+
 class Structures(unittest.TestCase):
     def test_struct_by_value(self):
         class POINT(Structure):
@@ -136,5 +139,6 @@ class Structures(unittest.TestCase):
         from ctypes import _pointer_type_cache
         del _pointer_type_cache[RECT]
 
+
 if __name__ == '__main__':
     unittest.main()
index a01b9b1d0f3109b641de36bb9b3d140f63818668..66fb8b78545a60eb45bbc12c89894c68c0351e12 100644 (file)
@@ -5,7 +5,7 @@ import unittest
 
 # also work on POSIX
 
-from ctypes import *
+from ctypes import POINTER, cast, c_int16
 from ctypes import wintypes