mirror of
https://github.com/python/cpython.git
synced 2025-10-18 20:58:48 +00:00
Raise statement normalization in Lib/ctypes/.
This commit is contained in:
parent
9604e66660
commit
a73bfee73d
5 changed files with 10 additions and 12 deletions
|
@ -14,7 +14,7 @@ from _ctypes import ArgumentError
|
||||||
from struct import calcsize as _calcsize
|
from struct import calcsize as _calcsize
|
||||||
|
|
||||||
if __version__ != _ctypes_version:
|
if __version__ != _ctypes_version:
|
||||||
raise Exception, ("Version number mismatch", __version__, _ctypes_version)
|
raise Exception("Version number mismatch", __version__, _ctypes_version)
|
||||||
|
|
||||||
if _os.name in ("nt", "ce"):
|
if _os.name in ("nt", "ce"):
|
||||||
from _ctypes import FormatError
|
from _ctypes import FormatError
|
||||||
|
@ -67,7 +67,7 @@ def create_string_buffer(init, size=None):
|
||||||
buftype = c_char * init
|
buftype = c_char * init
|
||||||
buf = buftype()
|
buf = buftype()
|
||||||
return buf
|
return buf
|
||||||
raise TypeError, init
|
raise TypeError(init)
|
||||||
|
|
||||||
def c_buffer(init, size=None):
|
def c_buffer(init, size=None):
|
||||||
## "deprecated, use create_string_buffer instead"
|
## "deprecated, use create_string_buffer instead"
|
||||||
|
@ -297,18 +297,16 @@ else:
|
||||||
buftype = c_wchar * init
|
buftype = c_wchar * init
|
||||||
buf = buftype()
|
buf = buftype()
|
||||||
return buf
|
return buf
|
||||||
raise TypeError, init
|
raise TypeError(init)
|
||||||
|
|
||||||
POINTER(c_char).from_param = c_char_p.from_param #_SimpleCData.c_char_p_from_param
|
POINTER(c_char).from_param = c_char_p.from_param #_SimpleCData.c_char_p_from_param
|
||||||
|
|
||||||
# XXX Deprecated
|
# XXX Deprecated
|
||||||
def SetPointerType(pointer, cls):
|
def SetPointerType(pointer, cls):
|
||||||
if _pointer_type_cache.get(cls, None) is not None:
|
if _pointer_type_cache.get(cls, None) is not None:
|
||||||
raise RuntimeError, \
|
raise RuntimeError("This type already exists in the cache")
|
||||||
"This type already exists in the cache"
|
|
||||||
if id(pointer) not in _pointer_type_cache:
|
if id(pointer) not in _pointer_type_cache:
|
||||||
raise RuntimeError, \
|
raise RuntimeError("What's this???")
|
||||||
"What's this???"
|
|
||||||
pointer.set_type(cls)
|
pointer.set_type(cls)
|
||||||
_pointer_type_cache[cls] = pointer
|
_pointer_type_cache[cls] = pointer
|
||||||
del _pointer_type_cache[id(pointer)]
|
del _pointer_type_cache[id(pointer)]
|
||||||
|
@ -357,7 +355,7 @@ class CDLL(object):
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
if name.startswith('__') and name.endswith('__'):
|
if name.startswith('__') and name.endswith('__'):
|
||||||
raise AttributeError, name
|
raise AttributeError(name)
|
||||||
func = self.__getitem__(name)
|
func = self.__getitem__(name)
|
||||||
setattr(self, name, func)
|
setattr(self, name, func)
|
||||||
return func
|
return func
|
||||||
|
|
|
@ -124,7 +124,7 @@ def dyld_find(name, executable_path=None, env=None):
|
||||||
), env):
|
), env):
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
return path
|
return path
|
||||||
raise ValueError, "dylib %s could not be found" % (name,)
|
raise ValueError("dylib %s could not be found" % (name,))
|
||||||
|
|
||||||
def framework_find(fn, executable_path=None, env=None):
|
def framework_find(fn, executable_path=None, env=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -186,7 +186,7 @@ else:
|
||||||
class stdcall_dll(WinDLL):
|
class stdcall_dll(WinDLL):
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
if name[:2] == '__' and name[-2:] == '__':
|
if name[:2] == '__' and name[-2:] == '__':
|
||||||
raise AttributeError, name
|
raise AttributeError(name)
|
||||||
func = self._FuncPtr(("s_" + name, self))
|
func = self._FuncPtr(("s_" + name, self))
|
||||||
setattr(self, name, func)
|
setattr(self, name, func)
|
||||||
return func
|
return func
|
||||||
|
|
|
@ -42,7 +42,7 @@ def find_lib(name):
|
||||||
return os.path.realpath(dyld_find(dylib))
|
return os.path.realpath(dyld_find(dylib))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
raise ValueError, "%s not found" % (name,)
|
raise ValueError("%s not found" % (name,))
|
||||||
|
|
||||||
class MachOTest(unittest.TestCase):
|
class MachOTest(unittest.TestCase):
|
||||||
if sys.platform == "darwin":
|
if sys.platform == "darwin":
|
||||||
|
|
|
@ -3,7 +3,7 @@ import unittest, sys
|
||||||
|
|
||||||
def callback_func(arg):
|
def callback_func(arg):
|
||||||
42 / arg
|
42 / arg
|
||||||
raise ValueError, arg
|
raise ValueError(arg)
|
||||||
|
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue