Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e45be28

Browse files
committed
Convert raise statements in Lib/plat-{mac,os2emx}.
1 parent cfe02a4 commit e45be28

51 files changed

Lines changed: 506 additions & 506 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Lib/plat-mac/Audio_mac.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def writeframes(self, data):
4848
self._chan = Snd.SndNewChannel(5, 0, self._callback)
4949
nframes = len(data) / self._nchannels / self._sampwidth
5050
if len(data) != nframes * self._nchannels * self._sampwidth:
51-
raise error, 'data is not a whole number of frames'
51+
raise error('data is not a whole number of frames')
5252
while self._gc and \
5353
self.getfilled() + nframes > \
5454
self._qsize / self._nchannels / self._sampwidth:

Lib/plat-mac/Carbon/ControlAccessor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def SetControlData(control, part, selector, data):
3131
setfunc(control, part, selector, data)
3232
return
3333
if not _codingdict.has_key(selector):
34-
raise KeyError, ('Unknown control selector', selector)
34+
raise KeyError('Unknown control selector', selector)
3535
structfmt, coder, decoder = _codingdict[selector]
3636
if coder:
3737
data = coder(data)
@@ -44,7 +44,7 @@ def GetControlData(control, part, selector):
4444
setfunc, getfunc = _accessdict[selector]
4545
return getfunc(control, part, selector, data)
4646
if not _codingdict.has_key(selector):
47-
raise KeyError, ('Unknown control selector', selector)
47+
raise KeyError('Unknown control selector', selector)
4848
structfmt, coder, decoder = _codingdict[selector]
4949
data = control.GetControlData(part, selector)
5050
if structfmt:

Lib/plat-mac/Carbon/MediaDescr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def decode(self, data):
1515
data = data[:self.size]
1616
values = struct.unpack(self.fmt, data)
1717
if len(values) != len(self.names):
18-
raise Error, ('Format length does not match number of names', descr)
18+
raise Error('Format length does not match number of names', descr)
1919
rv = {}
2020
for i in range(len(values)):
2121
name = self.names[i]

Lib/plat-mac/Carbon/Qt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
try:
33
_ = AddFilePreview
44
except:
5-
raise ImportError, "Old (2.3) _Qt.so module loaded in stead of new (2.4) _Qt.so"
5+
raise ImportError("Old (2.3) _Qt.so module loaded in stead of new (2.4) _Qt.so")

Lib/plat-mac/EasyDialogs.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def _update(self, value):
306306
self.w.HideWindow()
307307
self.w = None
308308
self.d = None
309-
raise KeyboardInterrupt, ev
309+
raise KeyboardInterrupt(ev)
310310
else:
311311
if part == 4: # inDrag
312312
self.w.DragWindow(where, screenbounds)
@@ -526,7 +526,7 @@ def GetArgv(optionlist=None, commandlist=None, addoldfile=1, addnewfile=1, addfo
526526
elif n == ARGV_CMDLINE_DATA:
527527
pass # Nothing to do
528528
else:
529-
raise RuntimeError, "Unknown dialog item %d"%n
529+
raise RuntimeError("Unknown dialog item %d"%n)
530530

531531
for stringtoadd in stringstoadd:
532532
if '"' in stringtoadd or "'" in stringtoadd or " " in stringtoadd:
@@ -550,14 +550,14 @@ def GetArgv(optionlist=None, commandlist=None, addoldfile=1, addnewfile=1, addfo
550550
if item[0] == '"':
551551
while item[-1] != '"':
552552
if not tmplist:
553-
raise RuntimeError, "Unterminated quoted argument"
553+
raise RuntimeError("Unterminated quoted argument")
554554
item = item + ' ' + tmplist[0]
555555
del tmplist[0]
556556
item = item[1:-1]
557557
if item[0] == "'":
558558
while item[-1] != "'":
559559
if not tmplist:
560-
raise RuntimeError, "Unterminated quoted argument"
560+
raise RuntimeError("Unterminated quoted argument")
561561
item = item + ' ' + tmplist[0]
562562
del tmplist[0]
563563
item = item[1:-1]
@@ -652,7 +652,7 @@ def AskFileForOpen(
652652
good = 1
653653
except Nav.error as arg:
654654
if arg[0] != -128: # userCancelledErr
655-
raise Nav.error, arg
655+
raise Nav.error(arg)
656656
return None
657657
if not rr.validRecord or not rr.selection:
658658
return None
@@ -664,7 +664,7 @@ def AskFileForOpen(
664664
return tpwanted(rr.selection_fsr[0].as_pathname())
665665
if issubclass(tpwanted, str):
666666
return tpwanted(rr.selection_fsr[0].as_pathname(), 'utf8')
667-
raise TypeError, "Unknown value for argument 'wanted': %s" % repr(tpwanted)
667+
raise TypeError("Unknown value for argument 'wanted': %s" % repr(tpwanted))
668668

669669
def AskFileForSave(
670670
message=None,
@@ -705,12 +705,12 @@ def AskFileForSave(
705705
good = 1
706706
except Nav.error as arg:
707707
if arg[0] != -128: # userCancelledErr
708-
raise Nav.error, arg
708+
raise Nav.error(arg)
709709
return None
710710
if not rr.validRecord or not rr.selection:
711711
return None
712712
if issubclass(tpwanted, Carbon.File.FSRef):
713-
raise TypeError, "Cannot pass wanted=FSRef to AskFileForSave"
713+
raise TypeError("Cannot pass wanted=FSRef to AskFileForSave")
714714
if issubclass(tpwanted, Carbon.File.FSSpec):
715715
return tpwanted(rr.selection[0])
716716
if issubclass(tpwanted, str):
@@ -727,7 +727,7 @@ def AskFileForSave(
727727
if issubclass(tpwanted, str):
728728
return str(fullpath, 'utf8')
729729
return tpwanted(fullpath)
730-
raise TypeError, "Unknown value for argument 'wanted': %s" % repr(tpwanted)
730+
raise TypeError("Unknown value for argument 'wanted': %s" % repr(tpwanted))
731731

732732
def AskFolder(
733733
message=None,
@@ -765,7 +765,7 @@ def AskFolder(
765765
good = 1
766766
except Nav.error as arg:
767767
if arg[0] != -128: # userCancelledErr
768-
raise Nav.error, arg
768+
raise Nav.error(arg)
769769
return None
770770
if not rr.validRecord or not rr.selection:
771771
return None
@@ -777,7 +777,7 @@ def AskFolder(
777777
return tpwanted(rr.selection_fsr[0].as_pathname())
778778
if issubclass(tpwanted, str):
779779
return tpwanted(rr.selection_fsr[0].as_pathname(), 'utf8')
780-
raise TypeError, "Unknown value for argument 'wanted': %s" % repr(tpwanted)
780+
raise TypeError("Unknown value for argument 'wanted': %s" % repr(tpwanted))
781781

782782

783783
def test():

Lib/plat-mac/MiniAEFrame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def lowlevelhandler(self, event):
7979
c = chr(message & charCodeMask)
8080
if modifiers & cmdKey:
8181
if c == '.':
82-
raise KeyboardInterrupt, "Command-period"
82+
raise KeyboardInterrupt("Command-period")
8383
if c == 'q':
8484
if hasattr(MacOS, 'OutputSeen'):
8585
MacOS.OutputSeen()

Lib/plat-mac/aetools.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def keysubst(arguments, keydict):
111111
del arguments[k]
112112
arguments[keydict[k]] = v
113113
elif k != '----' and k not in ok:
114-
raise TypeError, 'Unknown keyword argument: %s'%k
114+
raise TypeError('Unknown keyword argument: %s'%k)
115115

116116
def enumsubst(arguments, key, edict):
117117
"""Substitute a single enum keyword argument, if it occurs"""
@@ -122,7 +122,7 @@ def enumsubst(arguments, key, edict):
122122
if v in edict:
123123
arguments[key] = Enum(edict[v])
124124
elif not v in ok:
125-
raise TypeError, 'Unknown enumerator: %s'%v
125+
raise TypeError('Unknown enumerator: %s'%v)
126126

127127
def decodeerror(arguments):
128128
"""Create the 'best' argument for a raise MacOS.Error"""
@@ -174,7 +174,7 @@ def __init__(self, signature=None, start=0, timeout=0):
174174
self.target = AE.AECreateDesc(AppleEvents.typeApplSignature, signature)
175175
self.target_signature = signature
176176
else:
177-
raise TypeError, "signature should be 4-char string or AEDesc"
177+
raise TypeError("signature should be 4-char string or AEDesc")
178178
self.send_flags = AppleEvents.kAEWaitReply
179179
self.send_priority = AppleEvents.kAENormalPriority
180180
if timeout:
@@ -214,7 +214,7 @@ def newevent(self, code, subcode, parameters = {}, attributes = {}):
214214
def sendevent(self, event):
215215
"""Send a pre-created appleevent, await the reply and unpack it"""
216216
if not self.__ensure_WMAvailable():
217-
raise RuntimeError, "No window manager access, cannot send AppleEvent"
217+
raise RuntimeError("No window manager access, cannot send AppleEvent")
218218
reply = event.AESend(self.send_flags, self.send_priority,
219219
self.send_timeout)
220220
parameters, attributes = unpackevent(reply, self._moduleName)
@@ -248,7 +248,7 @@ def _get(self, _object, asfile=None, _attributes={}):
248248
_reply, _arguments, _attributes = self.send(_code, _subcode,
249249
_arguments, _attributes)
250250
if 'errn' in _arguments:
251-
raise Error, decodeerror(_arguments)
251+
raise Error(decodeerror(_arguments))
252252

253253
if '----' in _arguments:
254254
return _arguments['----']
@@ -278,7 +278,7 @@ def _set(self, _object, _attributes={}, **_arguments):
278278
_reply, _arguments, _attributes = self.send(_code, _subcode,
279279
_arguments, _attributes)
280280
if _arguments.get('errn', 0):
281-
raise Error, decodeerror(_arguments)
281+
raise Error(decodeerror(_arguments))
282282
# XXXX Optionally decode result
283283
if '----' in _arguments:
284284
return _arguments['----']
@@ -295,7 +295,7 @@ def __getattr__(self, name):
295295
if name in self._propdict:
296296
cls = self._propdict[name]
297297
return cls()
298-
raise AttributeError, name
298+
raise AttributeError(name)
299299

300300
# Tiny Finder class, for local use only
301301

@@ -308,14 +308,14 @@ def open(self, _object, _attributes={}, **_arguments):
308308
_code = 'aevt'
309309
_subcode = 'odoc'
310310

311-
if _arguments: raise TypeError, 'No optional args expected'
311+
if _arguments: raise TypeError('No optional args expected')
312312
_arguments['----'] = _object
313313

314314

315315
_reply, _arguments, _attributes = self.send(_code, _subcode,
316316
_arguments, _attributes)
317317
if 'errn' in _arguments:
318-
raise Error, decodeerror(_arguments)
318+
raise Error(decodeerror(_arguments))
319319
# XXXX Optionally decode result
320320
if '----' in _arguments:
321321
return _arguments['----']

Lib/plat-mac/aetypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ def __getattr__(self, name):
541541
if name in self._propdict:
542542
cls = self._propdict[name]
543543
return cls(self)
544-
raise AttributeError, name
544+
raise AttributeError(name)
545545

546546

547547
class DelayedComponentItem:

Lib/plat-mac/applesingle.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,30 @@ def __init__(self, fileobj, verbose=False):
4949
try:
5050
magic, version, ig, nentry = struct.unpack(AS_HEADER_FORMAT, header)
5151
except ValueError as arg:
52-
raise Error, "Unpack header error: %s" % (arg,)
52+
raise Error("Unpack header error: %s" % (arg,))
5353
if verbose:
5454
print('Magic: 0x%8.8x' % (magic,))
5555
print('Version: 0x%8.8x' % (version,))
5656
print('Entries: %d' % (nentry,))
5757
if magic != AS_MAGIC:
58-
raise Error, "Unknown AppleSingle magic number 0x%8.8x" % (magic,)
58+
raise Error("Unknown AppleSingle magic number 0x%8.8x" % (magic,))
5959
if version != AS_VERSION:
60-
raise Error, "Unknown AppleSingle version number 0x%8.8x" % (version,)
60+
raise Error("Unknown AppleSingle version number 0x%8.8x" % (version,))
6161
if nentry <= 0:
62-
raise Error, "AppleSingle file contains no forks"
62+
raise Error("AppleSingle file contains no forks")
6363
headers = [fileobj.read(AS_ENTRY_LENGTH) for i in range(nentry)]
6464
self.forks = []
6565
for hdr in headers:
6666
try:
6767
restype, offset, length = struct.unpack(AS_ENTRY_FORMAT, hdr)
6868
except ValueError as arg:
69-
raise Error, "Unpack entry error: %s" % (arg,)
69+
raise Error("Unpack entry error: %s" % (arg,))
7070
if verbose:
7171
print("Fork %d, offset %d, length %d" % (restype, offset, length))
7272
fileobj.seek(offset)
7373
data = fileobj.read(length)
7474
if len(data) != length:
75-
raise Error, "Short read: expected %d bytes got %d" % (length, len(data))
75+
raise Error("Short read: expected %d bytes got %d" % (length, len(data)))
7676
self.forks.append((restype, data))
7777
if restype == AS_DATAFORK:
7878
self.datafork = data
@@ -84,12 +84,12 @@ def tofile(self, path, resonly=False):
8484
data = False
8585
if resonly:
8686
if self.resourcefork is None:
87-
raise Error, "No resource fork found"
87+
raise Error("No resource fork found")
8888
fp = open(path, 'wb')
8989
fp.write(self.resourcefork)
9090
fp.close()
9191
elif (self.resourcefork is None and self.datafork is None):
92-
raise Error, "No useful forks found"
92+
raise Error("No useful forks found")
9393
else:
9494
if self.datafork is not None:
9595
fp = open(path, 'wb')

Lib/plat-mac/bgenlocations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
pass
4141

4242
if not os.path.exists(BGENDIR):
43-
raise Error, "Please fix bgenlocations.py, BGENDIR does not exist: %s" % BGENDIR
43+
raise Error("Please fix bgenlocations.py, BGENDIR does not exist: %s" % BGENDIR)
4444
if not os.path.exists(INCLUDEDIR):
45-
raise Error, "Please fix bgenlocations.py, INCLUDEDIR does not exist: %s" % INCLUDEDIR
45+
raise Error("Please fix bgenlocations.py, INCLUDEDIR does not exist: %s" % INCLUDEDIR)
4646
if not os.path.exists(TOOLBOXDIR):
47-
raise Error, "Please fix bgenlocations.py, TOOLBOXDIR does not exist: %s" % TOOLBOXDIR
47+
raise Error("Please fix bgenlocations.py, TOOLBOXDIR does not exist: %s" % TOOLBOXDIR)
4848

4949
# Sigh, due to the way these are used make sure they end with : or /.
5050
if BGENDIR[-1] != os.sep:

0 commit comments

Comments
 (0)