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

Skip to content

Commit ad66742

Browse files
committed
Fix raise with 2to3
M idlelib/configHandler.py M idlelib/tabpage.py M idlelib/EditorWindow.py M idlelib/rpc.py M idlelib/IOBinding.py M idlelib/RemoteDebugger.py M idlelib/TreeWidget.py
1 parent e45be28 commit ad66742

7 files changed

Lines changed: 19 additions & 19 deletions

File tree

Lib/idlelib/EditorWindow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _find_module(fullname, path=None):
3838
try:
3939
path = module.__path__
4040
except AttributeError:
41-
raise ImportError, 'No source for module ' + module.__name__
41+
raise ImportError('No source for module ' + module.__name__)
4242
return file, filename, descr
4343

4444
class EditorWindow(object):
@@ -955,14 +955,14 @@ def getvar(self, name):
955955
value = var.get()
956956
return value
957957
else:
958-
raise NameError, name
958+
raise NameError(name)
959959

960960
def setvar(self, name, value, vartype=None):
961961
var = self.get_var_obj(name, vartype)
962962
if var:
963963
var.set(value)
964964
else:
965-
raise NameError, name
965+
raise NameError(name)
966966

967967
def get_var_obj(self, name, vartype=None):
968968
var = self.tkinter_vars.get(name)

Lib/idlelib/IOBinding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def coding_spec(str):
132132
codecs.lookup(name)
133133
except LookupError:
134134
# The standard encoding error does not indicate the encoding
135-
raise LookupError, "Unknown encoding "+name
135+
raise LookupError("Unknown encoding "+name)
136136
return name
137137

138138

Lib/idlelib/RemoteDebugger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def __init__(self, conn, fid):
206206

207207
def __getattr__(self, name):
208208
if name[:1] == "_":
209-
raise AttributeError, name
209+
raise AttributeError(name)
210210
if name == "f_code":
211211
return self._get_f_code()
212212
if name == "f_globals":
@@ -270,7 +270,7 @@ def __getitem__(self, key):
270270

271271
def __getattr__(self, name):
272272
##print >>sys.__stderr__, "failed DictProxy.__getattr__:", name
273-
raise AttributeError, name
273+
raise AttributeError(name)
274274

275275

276276
class GUIAdapter:

Lib/idlelib/TreeWidget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
if os.path.isdir(_icondir):
3333
ICONDIR = _icondir
3434
elif not os.path.isdir(ICONDIR):
35-
raise RuntimeError, "can't find icon directory (%r)" % (ICONDIR,)
35+
raise RuntimeError("can't find icon directory (%r)" % (ICONDIR,))
3636

3737
def listicons(icondir=ICONDIR):
3838
"""Utility to display the available icons."""

Lib/idlelib/configHandler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,13 @@ def GetSectionList(self, configSet, configType):
259259
configType must be one of ('main','extensions','highlight','keys')
260260
"""
261261
if not (configType in ('main','extensions','highlight','keys')):
262-
raise InvalidConfigType, 'Invalid configType specified'
262+
raise InvalidConfigType('Invalid configType specified')
263263
if configSet == 'user':
264264
cfgParser=self.userCfg[configType]
265265
elif configSet == 'default':
266266
cfgParser=self.defaultCfg[configType]
267267
else:
268-
raise InvalidConfigSet, 'Invalid configSet specified'
268+
raise InvalidConfigSet('Invalid configSet specified')
269269
return cfgParser.sections()
270270

271271
def GetHighlight(self, theme, element, fgBg=None):
@@ -293,7 +293,7 @@ def GetHighlight(self, theme, element, fgBg=None):
293293
if fgBg == 'bg':
294294
return highlight["background"]
295295
else:
296-
raise InvalidFgBg, 'Invalid fgBg specified'
296+
raise InvalidFgBg('Invalid fgBg specified')
297297

298298
def GetThemeDict(self,type,themeName):
299299
"""
@@ -309,7 +309,7 @@ def GetThemeDict(self,type,themeName):
309309
elif type == 'default':
310310
cfgParser=self.defaultCfg['highlight']
311311
else:
312-
raise InvalidTheme, 'Invalid theme type specified'
312+
raise InvalidTheme('Invalid theme type specified')
313313
#foreground and background values are provded for each theme element
314314
#(apart from cursor) even though all these values are not yet used
315315
#by idle, to allow for their use in the future. Default values are
@@ -624,7 +624,7 @@ def GetExtraHelpSourceList(self,configSet):
624624
elif configSet=='default':
625625
cfgParser=self.defaultCfg['main']
626626
else:
627-
raise InvalidConfigSet, 'Invalid configSet specified'
627+
raise InvalidConfigSet('Invalid configSet specified')
628628
options=cfgParser.GetOptionList('HelpFiles')
629629
for option in options:
630630
value=cfgParser.Get('HelpFiles',option,default=';')

Lib/idlelib/rpc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ def decoderesponse(self, response):
256256
return None
257257
if how == "ERROR":
258258
self.debug("decoderesponse: Internal ERROR:", what)
259-
raise RuntimeError, what
260-
raise SystemError, (how, what)
259+
raise RuntimeError(what)
260+
raise SystemError(how, what)
261261

262262
def decode_interrupthook(self):
263263
""
@@ -331,7 +331,7 @@ def putmessage(self, message):
331331
r, w, x = select.select([], [self.sock], [])
332332
n = self.sock.send(s[:BUFSIZE])
333333
except (AttributeError, TypeError):
334-
raise IOError, "socket no longer exists"
334+
raise IOError("socket no longer exists")
335335
except socket.error:
336336
raise
337337
else:
@@ -557,7 +557,7 @@ def __getattr__(self, name):
557557
(name,), {})
558558
return value
559559
else:
560-
raise AttributeError, name
560+
raise AttributeError(name)
561561

562562
def __getattributes(self):
563563
self.__attributes = self.sockio.remotecall(self.oid,

Lib/idlelib/tabpage.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def ChangePage(self,pageName=None):
4646
if pageName in self.pages.keys():
4747
self.activePage.set(pageName)
4848
else:
49-
raise InvalidTabPage, 'Invalid TabPage Name'
49+
raise InvalidTabPage('Invalid TabPage Name')
5050
## pop up the active 'tab' only
5151
for page in self.pages.keys():
5252
self.pages[page]['tab'].config(relief=RIDGE)
@@ -59,7 +59,7 @@ def GetActivePage(self):
5959

6060
def AddPage(self,pageName):
6161
if pageName in self.pages.keys():
62-
raise AlreadyExists, 'TabPage Name Already Exists'
62+
raise AlreadyExists('TabPage Name Already Exists')
6363
self.pages[pageName]={'tab':PageTab(self.tabBar),
6464
'page':Frame(self,borderwidth=2,relief=RAISED)}
6565
self.pages[pageName]['tab'].button.config(text=pageName,
@@ -74,7 +74,7 @@ def AddPage(self,pageName):
7474

7575
def RemovePage(self,pageName):
7676
if not pageName in self.pages.keys():
77-
raise InvalidTabPage, 'Invalid TabPage Name'
77+
raise InvalidTabPage('Invalid TabPage Name')
7878
self.pages[pageName]['tab'].pack_forget()
7979
self.pages[pageName]['page'].grid_forget()
8080
self.pages[pageName]['tab'].destroy()

0 commit comments

Comments
 (0)