Skip to content

Commit d11b68a

Browse files
committed
Fix more exception slicing.
1 parent 7357c23 commit d11b68a

File tree

9 files changed

+15
-15
lines changed

9 files changed

+15
-15
lines changed

Demo/pdist/cvslock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def setlockdir(self):
131131
return
132132
except os.error as msg:
133133
self.lockdir = None
134-
if msg[0] == EEXIST:
134+
if msg.args[0] == EEXIST:
135135
try:
136136
st = os.stat(self.cvslck)
137137
except os.error:

Demo/scripts/toaiff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ def _toaiff(filename, temps):
8989
ftype = ftype[0] # All we're interested in
9090
except IOError as msg:
9191
if type(msg) == type(()) and len(msg) == 2 and \
92-
type(msg[0]) == type(0) and type(msg[1]) == type(''):
93-
msg = msg[1]
92+
type(msg.args[0]) == type(0) and type(msg.args[1]) == type(''):
93+
msg = msg.args[1]
9494
if type(msg) != type(''):
9595
msg = repr(msg)
9696
raise error(filename + ': ' + msg)

Lib/distutils/file_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0,
139139
macostools.copy(src, dst, 0, preserve_times)
140140
except os.error as exc:
141141
raise DistutilsFileError(
142-
"could not copy '%s' to '%s': %s" % (src, dst, exc[-1]))
142+
"could not copy '%s' to '%s': %s" % (src, dst, exc.args[-1]))
143143

144144
# If linking (hard or symbolic), use the appropriate system call
145145
# (Unix only, of course, but that's the caller's responsibility)

Lib/distutils/spawn.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def _spawn_nt(cmd, search_path=1, verbose=0, dry_run=0):
6767
except OSError as exc:
6868
# this seems to happen when the command isn't found
6969
raise DistutilsExecError(
70-
"command '%s' failed: %s" % (cmd[0], exc[-1]))
70+
"command '%s' failed: %s" % (cmd[0], exc.args[-1]))
7171
if rc != 0:
7272
# and this reflects the command running but failing
7373
raise DistutilsExecError(
@@ -88,7 +88,7 @@ def _spawn_os2(cmd, search_path=1, verbose=0, dry_run=0):
8888
except OSError as exc:
8989
# this seems to happen when the command isn't found
9090
raise DistutilsExecError(
91-
"command '%s' failed: %s" % (cmd[0], exc[-1]))
91+
"command '%s' failed: %s" % (cmd[0], exc.args[-1]))
9292
if rc != 0:
9393
# and this reflects the command running but failing
9494
print("command '%s' failed with exit status %d" % (cmd[0], rc))
@@ -124,7 +124,7 @@ def _spawn_posix(cmd, search_path=1, verbose=0, dry_run=0):
124124
if exc.errno == errno.EINTR:
125125
continue
126126
raise DistutilsExecError(
127-
"command '%s' failed: %s" % (cmd[0], exc[-1]))
127+
"command '%s' failed: %s" % (cmd[0], exc.args[-1]))
128128
if os.WIFSIGNALED(status):
129129
raise DistutilsExecError(
130130
"command '%s' terminated by signal %d"

Lib/filecmp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ def phase2(self): # Distinguish files, directories, funnies
149149
try:
150150
a_stat = os.stat(a_path)
151151
except os.error as why:
152-
# print 'Can\'t stat', a_path, ':', why[1]
152+
# print('Can\'t stat', a_path, ':', why.args[1])
153153
ok = 0
154154
try:
155155
b_stat = os.stat(b_path)
156156
except os.error as why:
157-
# print 'Can\'t stat', b_path, ':', why[1]
157+
# print('Can\'t stat', b_path, ':', why.args[1])
158158
ok = 0
159159

160160
if ok:

Lib/plat-mac/EasyDialogs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ def AskFileForOpen(
651651
rr = Nav.NavChooseFile(args)
652652
good = 1
653653
except Nav.error as arg:
654-
if arg[0] != -128: # userCancelledErr
654+
if arg.args[0] != -128: # userCancelledErr
655655
raise Nav.error(arg)
656656
return None
657657
if not rr.validRecord or not rr.selection:
@@ -704,7 +704,7 @@ def AskFileForSave(
704704
rr = Nav.NavPutFile(args)
705705
good = 1
706706
except Nav.error as arg:
707-
if arg[0] != -128: # userCancelledErr
707+
if arg.args[0] != -128: # userCancelledErr
708708
raise Nav.error(arg)
709709
return None
710710
if not rr.validRecord or not rr.selection:
@@ -764,7 +764,7 @@ def AskFolder(
764764
rr = Nav.NavChooseFolder(args)
765765
good = 1
766766
except Nav.error as arg:
767-
if arg[0] != -128: # userCancelledErr
767+
if arg.args[0] != -128: # userCancelledErr
768768
raise Nav.error(arg)
769769
return None
770770
if not rr.validRecord or not rr.selection:

Lib/plat-mac/aetools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def unpackevent(ae, formodulename=""):
8686
try:
8787
desc = ae.AEGetAttributeDesc(key, '****')
8888
except (AE.Error, MacOS.Error) as msg:
89-
if msg[0] != -1701 and msg[0] != -1704:
89+
if msg.args[0] not in (-1701, -1704):
9090
raise
9191
continue
9292
attributes[key] = unpack(desc, formodulename)

Lib/plat-mac/gensuitemodule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def processfile(fullname, output=None, basepkgname=None,
191191
try:
192192
aedescobj, launched = OSATerminology.GetAppTerminology(fullname)
193193
except MacOS.Error as arg:
194-
if arg[0] in (-1701, -192): # errAEDescNotFound, resNotFound
194+
if arg.args[0] in (-1701, -192): # errAEDescNotFound, resNotFound
195195
if verbose:
196196
print("GetAppTerminology failed with errAEDescNotFound/resNotFound, trying manually", file=verbose)
197197
aedata, sig = getappterminology(fullname, verbose=verbose)

Lib/plat-mac/terminalcommand.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def run(command):
3636
try:
3737
theEvent.AESend(SEND_MODE, kAENormalPriority, kAEDefaultTimeout)
3838
except AE.Error as why:
39-
if why[0] != -600: # Terminal.app not yet running
39+
if why.args[0] != -600: # Terminal.app not yet running
4040
raise
4141
os.system(START_TERMINAL)
4242
time.sleep(1)

0 commit comments

Comments
 (0)