package bubbros tags 585187 + upstream patch thanks On 09-Jun-2010, mo...@debian.org wrote: > One of the changes brought by Python 2.6 is the removal of string > exceptions, so they won't work in Python 2.6 (just a side note: they > were also buggy before, since they were not guaranteed to work > reliable even in <2.6)
The attached patch addresses this bug, by converting each non-standard ‘raise’ statement to use an exception instance correctly. -- \ “Some people, when confronted with a problem, think ‘I know, | `\ I'll use regular expressions’. Now they have two problems.” | _o__) —Jamie Zawinski, in alt.religion.emacs | Ben Finney <b...@benfinney.id.au>
# 01-standard-raise-statements.patch # # Description: Use standard syntax for ‘raise’ with exception instances. # Author: Ben Finney <ben+deb...@benfinney.id.au> # Bug-Debian: http://bugs.debian.org/585187 # Last-Update: 2010-06-15 === modified file 'bubbob/boards.py' --- old/bubbob/boards.py 2010-06-15 07:19:05 +0000 +++ new/bubbob/boards.py 2010-06-15 07:39:50 +0000 @@ -1432,7 +1432,7 @@ assert test.height == height, "some boards have a different height" except Exception, e: print 'Caught "%s" in level "%s":' % (e, B.__name__) - raise e + raise bwidth = width*CELL bheight = height*CELL bheightmod = (height+2)*CELL === modified file 'bubbob/images/buildcolors.py' --- old/bubbob/images/buildcolors.py 2010-06-15 07:19:05 +0000 +++ new/bubbob/images/buildcolors.py 2010-06-15 07:39:50 +0000 @@ -280,7 +280,7 @@ else: # from now on we should always use the palette approach; # comment out the following line to restore the old color-rotation code. - raise IOError("cannot find the palette file %r" % (tmp,)) + raise IOError("cannot find the palette file %(tmp)r" % vars()) if __name__ == '__auto__': # when execfile'd from images.py === modified file 'bubbob/macbinary.py' --- old/bubbob/macbinary.py 2010-06-15 07:19:05 +0000 +++ new/bubbob/macbinary.py 2010-06-15 07:39:50 +0000 @@ -105,10 +105,10 @@ class Subfile: def __init__(self, f, start, length): if start < 0: - raise ValueError, 'negative position' + raise ValueError("negative position") if isinstance(f, Subfile): if start + length > f.length: - raise ValueError, 'subfile out of bounds' + raise ValueError("subfile out of bounds") f, start = f.f, f.start+start self.f = f self.start = start @@ -124,7 +124,7 @@ return self.f.read(size) def seek(self, npos): if npos < 0: - raise ValueError, 'negative position' + raise ValueError("negative position") self.position = npos @@ -186,7 +186,7 @@ f = self.subfile() pattype, patmap, patdata = struct.unpack(">Hll", f.read(10)) if pattype != 1: - raise ValueError, 'Pattern type not supported' + raise ValueError("Pattern type not supported") f.seek(patmap) (rowBytes, h, w, packType, packSize, pixelType, pixelSize, cmpCount, cmpSize, pmTable) = ( @@ -194,9 +194,9 @@ isBitmap = (rowBytes & 0x8000) != 0 rowBytes &= 0x3FFF if packType != 0: - raise ValueError, 'packed image not supported' + raise ValueError("packed image not supported") if pixelType != 0 or cmpCount != 1: - raise ValueError, 'direct RGB image not supported' + raise ValueError("direct RGB image not supported") assert cmpSize == pixelSize and pixelSize in [1,2,4,8] f.seek(pmTable) colormap = loadcolormap(f) === modified file 'bubbob/test_rnglevel.py' --- old/bubbob/test_rnglevel.py 2010-06-15 07:19:05 +0000 +++ new/bubbob/test_rnglevel.py 2010-06-15 07:39:50 +0000 @@ -61,4 +61,4 @@ else: for line in level.walls: print line - raise AssertionError("full height wall in column %d" % x) + raise AssertionError("full height wall in column %(x)d" % vars()) === modified file 'common/gamesrv.py' --- old/common/gamesrv.py 2010-06-15 07:19:05 +0000 +++ new/common/gamesrv.py 2010-06-15 07:39:50 +0000 @@ -986,7 +986,7 @@ else: break else: - raise error, "server cannot find a free TCP socket port" + raise error("server cannot find a free TCP socket port") else: raise @@ -1288,13 +1288,13 @@ elif SERVER_SHUTDOWN and not ewtd and not owtd: SERVER_SHUTDOWN -= delay if SERVER_SHUTDOWN <= 0.001: - raise SystemExit, "Server shutdown requested." + raise SystemExit("Server shutdown requested.") elif clients or getattr(game, 'autoreset', 0): servertimeout = None elif servertimeout is None: servertimeout = time() + SERVER_TIMEOUT elif time() > servertimeout: - raise SystemExit, "No more server activity, timing out." + raise SystemExit("No more server activity, timing out.") except KeyboardInterrupt: if game is None or not game.FnExcHandler(1): raise === modified file 'common/javaserver.py' --- old/common/javaserver.py 2010-06-15 07:19:05 +0000 +++ new/common/javaserver.py 2010-06-15 07:39:50 +0000 @@ -123,7 +123,7 @@ data = wave_cache[code[0]] = wav2au(snd.read()) break else: - raise KeyError, code[0] + raise KeyError(code[0]) return StringIO(data), 'audio/wav' === modified file 'display/modes.py' --- old/display/modes.py 2010-06-15 07:19:05 +0000 +++ new/display/modes.py 2010-06-15 07:39:50 +0000 @@ -142,16 +142,17 @@ return info if last_chance is not None: return last_chance - raise KeyError, 'no driver available!' + raise KeyError("no driver available!") else: # find mode by name for info in lst: if info.name.upper() == name.upper(): err = info.imperror() + info_name = info.name if err: - raise KeyError, '%s: %s' % (info.name, err) + raise KeyError("%(info_name)s: %(err)s" % vars()) return info - raise KeyError, '%s: no such driver' % name + raise KeyError("%(name)s: no such driver" % vars()) def findmode_err(*args): try: === modified file 'display/pclient.py' --- old/display/pclient.py 2010-06-15 07:19:05 +0000 +++ new/display/pclient.py 2010-06-15 07:39:50 +0000 @@ -44,11 +44,11 @@ self.rect = None return self.pixmap elif attr in ('bmpcode', 'rect'): - raise KeyError, attr + raise KeyError(attr) elif attr == 'originalrect': self.originalrect = self.rect return self.originalrect - raise AttributeError, attr + raise AttributeError(attr) def clear(self): if self.__dict__.has_key('pixmap'): del self.pixmap @@ -115,13 +115,13 @@ while 1: t = self.s.recv(200) if not t and not hasattr(self.s, 'RECV_CAN_RETURN_EMPTY'): - raise error, "connexion closed" + raise error("connection closed") initialbuf += t if len(initialbuf) >= len(MSG_WELCOME): head = initialbuf[:len(MSG_WELCOME)] tail = initialbuf[len(MSG_WELCOME):] if head != MSG_WELCOME: - raise error, "connected to something not a game server" + raise error("connected to something not a game server") if '\n' in tail: break n = tail.index('\n') === modified file 'display/puremixer.py' --- old/display/puremixer.py 2010-06-15 07:19:05 +0000 +++ new/display/puremixer.py 2010-06-15 07:39:50 +0000 @@ -64,7 +64,7 @@ byteorder = self.byteorder # done if (freq, bytes, signed, channels, byteorder) != self.parameters: - raise ValueError, 'sound sample conversion failed' + raise ValueError("sound sample conversion failed") return data def wavesample(self, file): @@ -114,10 +114,12 @@ elif byte == 4: typecode = 'i' else: - raise ValueError, 'cannot convert endianness for samples of %d bytes' % byte + raise ValueError( + "cannot convert endianness for samples of %(byte)d bytes" + % vars()) import array a = array.array(typecode, data) if a.itemsize != byte: - raise ValueError, 'endianness convertion failed' + raise ValueError("endianness conversion failed") a.byteswap() return a.tostring() === modified file 'display/pythonxlibintf.py' --- old/display/pythonxlibintf.py 2010-06-15 07:19:05 +0000 +++ new/display/pythonxlibintf.py 2010-06-15 07:39:50 +0000 @@ -72,7 +72,7 @@ elif depth == 24 or depth == 32: p_size = 8, 8, 8 else: - raise ValueError, 'unsupported screen depth %d' % depth + raise ValueError("unsupported screen depth %(depth)d" % vars()) imgdata = [] maskdata = [] === modified file 'http2/httppages.py' --- old/http2/httppages.py 2010-06-15 07:19:05 +0000 +++ new/http2/httppages.py 2010-06-15 07:39:50 +0000 @@ -34,7 +34,7 @@ if not attr.startswith('_'): return None else: - raise AttributeError, attr + raise AttributeError(attr) class PageServer: @@ -237,7 +237,7 @@ host = headers['remote host'] host = socket.gethostbyname(host) if host != '127.0.0.1': - raise HTTPRequestError, "Access denied" + raise HTTPRequestError("Access denied") return None, self.indexurl ## def listloader(self, headers, s=[], **options): @@ -253,7 +253,7 @@ def newloader(self, headers, **options): if not self.Game: - raise HTTPRequestError, "Complete bub-n-bros installation needed" + raise HTTPRequestError("Complete bub-n-bros installation needed") locals = { 'Game': self.Game, 'options': self.globaloptions, @@ -323,9 +323,10 @@ httpport = int(httpport[0]) except (ValueError, IndexError): if port: - raise HTTPRequestError, "This server is not running HTTP." + raise HTTPRequestError("This server is not running HTTP.") else: - raise HTTPRequestError, "Sorry, I cannot connect the Java applet to a server using this field." + raise HTTPRequestError( + "Sorry, I cannot connect the Java applet to a server using this field.") return None, 'http://%s:%s/' % (host, httpport) # now is a good time to generate the color files if we can @@ -458,7 +459,8 @@ if dpy.getmodule() is None: return None # redirect to the Java applet if dpy is None or snd is None: - raise HTTPRequestError, "No installed graphics or sounds drivers. See the settings page." + raise HTTPRequestError( + "No installed graphics or sounds drivers. See the settings page.") options = self.localoptions result = ['--cfg='+no_quote_worries(self.filename)] for key, value in options.dict().items(): === modified file 'http2/sf/bb12.py' --- old/http2/sf/bb12.py 2010-06-15 07:19:05 +0000 +++ new/http2/sf/bb12.py 2010-06-15 07:39:50 +0000 @@ -123,7 +123,7 @@ f.seek(0, 2) e = Entry(f) if e.pos >= SIZEMAX: - raise "Sorry, server database too big" + raise RuntimeError("Sorry, server database too big") hostname = string.split(srv, ':')[0] if '.' not in hostname: Entry.Notice = 'Server hostname "%s" incomplete.' % hostname
signature.asc
Description: Digital signature