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

Skip to content

Commit 6cd2a20

Browse files
committed
Kill more lingering string exceptions in Lib/plat-mac/.
1 parent b9678e7 commit 6cd2a20

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

Lib/plat-mac/FrameWork.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def dispatch(self, event):
229229
def asyncevents(self, onoff):
230230
"""asyncevents - Set asynchronous event handling on or off"""
231231
if MacOS.runtimemodel == 'macho':
232-
raise 'Unsupported in MachoPython'
232+
raise NotImplementedError('Unsupported in MachoPython')
233233
old = self._doing_asyncevents
234234
if old:
235235
MacOS.SetEventHandler()
@@ -577,7 +577,7 @@ def additem(self, label, shortcut=None, callback=None, kind=None):
577577

578578
def delitem(self, item):
579579
if item != len(self.items):
580-
raise 'Can only delete last item of a menu'
580+
raise ValueError('Can only delete last item of a menu')
581581
self.menu.DeleteMenuItem(item)
582582
del self.items[item-1]
583583

Lib/plat-mac/MiniAEFrame.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ def callback_wrapper(self, _request, _reply):
141141
elif ('****', '****') in self.ae_handlers:
142142
_function = self.ae_handlers[('****', '****')]
143143
else:
144-
raise 'Cannot happen: AE callback without handler', (_class, _type)
144+
raise RuntimeError('AE callback without handler: '
145+
+ str((_class, _type)))
145146

146147
# XXXX Do key-to-name mapping here
147148

Lib/plat-mac/PixMapWrapper.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ def _unstuff(self, element):
9393

9494
def __setattr__(self, attr, val):
9595
if attr == 'baseAddr':
96-
raise 'UseErr', "don't assign to .baseAddr -- assign to .data instead"
96+
raise RuntimeError("don't assign to .baseAddr "
97+
"-- assign to .data instead")
9798
elif attr == 'data':
9899
self.__dict__['data'] = val
99100
self._stuff('baseAddr', id(self.data) + MacOS.string_id_to_buffer)
@@ -121,7 +122,7 @@ def __getattr__(self, attr):
121122
return self._unstuff('rowBytes') & 0x7FFF
122123
elif attr == 'bounds':
123124
# return bounds in official Left, Top, Right, Bottom order!
124-
return ( \
125+
return (
125126
self._unstuff('left'),
126127
self._unstuff('top'),
127128
self._unstuff('right'),
@@ -161,7 +162,7 @@ def fromstring(self,s,width,height,format=imgformat.macrgb):
161162
# so convert if necessary
162163
if format != imgformat.macrgb and format != imgformat.macrgb16:
163164
# (LATER!)
164-
raise "NotImplementedError", "conversion to macrgb or macrgb16"
165+
raise NotImplementedError("conversion to macrgb or macrgb16")
165166
self.data = s
166167
self.bounds = (0,0,width,height)
167168
self.cmpCount = 3
@@ -182,7 +183,7 @@ def tostring(self, format=imgformat.macrgb):
182183
return self.data
183184
# otherwise, convert to the requested format
184185
# (LATER!)
185-
raise "NotImplementedError", "data format conversion"
186+
raise NotImplementedError("data format conversion")
186187

187188
def fromImage(self,im):
188189
"""Initialize this PixMap from a PIL Image object."""

0 commit comments

Comments
 (0)