Skip to content

Commit a73bfee

Browse files
committed
Raise statement normalization in Lib/ctypes/.
1 parent 9604e66 commit a73bfee

5 files changed

Lines changed: 10 additions & 12 deletions

File tree

Lib/ctypes/__init__.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from struct import calcsize as _calcsize
1515

1616
if __version__ != _ctypes_version:
17-
raise Exception, ("Version number mismatch", __version__, _ctypes_version)
17+
raise Exception("Version number mismatch", __version__, _ctypes_version)
1818

1919
if _os.name in ("nt", "ce"):
2020
from _ctypes import FormatError
@@ -67,7 +67,7 @@ def create_string_buffer(init, size=None):
6767
buftype = c_char * init
6868
buf = buftype()
6969
return buf
70-
raise TypeError, init
70+
raise TypeError(init)
7171

7272
def c_buffer(init, size=None):
7373
## "deprecated, use create_string_buffer instead"
@@ -297,18 +297,16 @@ def create_unicode_buffer(init, size=None):
297297
buftype = c_wchar * init
298298
buf = buftype()
299299
return buf
300-
raise TypeError, init
300+
raise TypeError(init)
301301

302302
POINTER(c_char).from_param = c_char_p.from_param #_SimpleCData.c_char_p_from_param
303303

304304
# XXX Deprecated
305305
def SetPointerType(pointer, cls):
306306
if _pointer_type_cache.get(cls, None) is not None:
307-
raise RuntimeError, \
308-
"This type already exists in the cache"
307+
raise RuntimeError("This type already exists in the cache")
309308
if id(pointer) not in _pointer_type_cache:
310-
raise RuntimeError, \
311-
"What's this???"
309+
raise RuntimeError("What's this???")
312310
pointer.set_type(cls)
313311
_pointer_type_cache[cls] = pointer
314312
del _pointer_type_cache[id(pointer)]
@@ -357,7 +355,7 @@ def __repr__(self):
357355

358356
def __getattr__(self, name):
359357
if name.startswith('__') and name.endswith('__'):
360-
raise AttributeError, name
358+
raise AttributeError(name)
361359
func = self.__getitem__(name)
362360
setattr(self, name, func)
363361
return func

Lib/ctypes/macholib/dyld.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def dyld_find(name, executable_path=None, env=None):
124124
), env):
125125
if os.path.isfile(path):
126126
return path
127-
raise ValueError, "dylib %s could not be found" % (name,)
127+
raise ValueError("dylib %s could not be found" % (name,))
128128

129129
def framework_find(fn, executable_path=None, env=None):
130130
"""

Lib/ctypes/test/test_cfuncs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def test_void(self):
186186
class stdcall_dll(WinDLL):
187187
def __getattr__(self, name):
188188
if name[:2] == '__' and name[-2:] == '__':
189-
raise AttributeError, name
189+
raise AttributeError(name)
190190
func = self._FuncPtr(("s_" + name, self))
191191
setattr(self, name, func)
192192
return func

Lib/ctypes/test/test_macholib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def find_lib(name):
4242
return os.path.realpath(dyld_find(dylib))
4343
except ValueError:
4444
pass
45-
raise ValueError, "%s not found" % (name,)
45+
raise ValueError("%s not found" % (name,))
4646

4747
class MachOTest(unittest.TestCase):
4848
if sys.platform == "darwin":

Lib/ctypes/test/test_random_things.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
def callback_func(arg):
55
42 / arg
6-
raise ValueError, arg
6+
raise ValueError(arg)
77

88
if sys.platform == "win32":
99

0 commit comments

Comments
 (0)