Use // where Python 2 int division was assumed
Several spots ported from Python 2 use / on ints and feed the result somewhere that requires an int. In Python 3 / is true division and yields a float, so these raise TypeError when the line runs. - fishing/NormalBingo, DiagonalBingo, ThreewayBingo: id = self.cardSize / 2 produces 12.5; in NormalBingo that float flows through checkForWin into colCheck's 1 << ... + colId and crashes when the BINGO button is pressed. Also fixed the center-row skip NormalBingo CARD_ROWS / 2. - safezone/Train: random.randrange(4, (self.MarkDelta - waitTime) / 2) passes a float bound to randrange (Cashbot HQ exterior train), raising TypeError. - shtiker/EventsPage: range(len(urls) / 2) passes a float to range() on the blocking news-download path. All changed to //.
This commit is contained in:
parent
a5ecbb8b1e
commit
8642e4d0af
|
|
@ -24,7 +24,7 @@ class DiagonalBingo(BingoCardBase.BingoCardBase):
|
|||
return self.onFDiag(id) | self.onBDiag(id)
|
||||
|
||||
def checkForBingo(self):
|
||||
id = self.cardSize / 2
|
||||
id = self.cardSize // 2
|
||||
if self.checkForWin(id):
|
||||
return BingoGlobals.WIN
|
||||
return BingoGlobals.NO_UPDATE
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@ class NormalBingo(BingoCardBase.BingoCardBase):
|
|||
return 1
|
||||
|
||||
def checkForBingo(self):
|
||||
id = self.cardSize / 2
|
||||
id = self.cardSize // 2
|
||||
if self.checkForWin(id):
|
||||
return BingoGlobals.WIN
|
||||
for i in range(BingoGlobals.CARD_ROWS):
|
||||
if i != BingoGlobals.CARD_ROWS / 2:
|
||||
if i != BingoGlobals.CARD_ROWS // 2:
|
||||
rowResult = self.rowCheck(i)
|
||||
colResult = self.colCheck(i)
|
||||
if rowResult | colResult:
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class ThreewayBingo(BingoCardBase.BingoCardBase):
|
|||
return self.onRow(2, id) | self.onFDiag(id) | self.onBDiag(id)
|
||||
|
||||
def checkForBingo(self):
|
||||
id = self.cardSize / 2
|
||||
id = self.cardSize // 2
|
||||
if self.checkForWin(id):
|
||||
return BingoGlobals.WIN
|
||||
return BingoGlobals.NO_UPDATE
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ class Train(DirectObject):
|
|||
nextRun = Sequence(Func(self.__showStart))
|
||||
if trainShouldStop == 0:
|
||||
waitTime = 3
|
||||
totalTime = random.randrange(4, (self.MarkDelta - waitTime) / 2)
|
||||
totalTime = random.randrange(4, (self.MarkDelta - waitTime) // 2)
|
||||
sfxStopTime = 4.3
|
||||
halfway = (self.trackStartPos + self.trackEndPos) / 2
|
||||
halfway.setX(150)
|
||||
|
|
|
|||
|
|
@ -779,7 +779,7 @@ class EventsPage(ShtikerPage.ShtikerPage):
|
|||
urlStrings = urlfile.read()
|
||||
urlfile.close()
|
||||
urls = urlStrings.split('\r\n')
|
||||
for index in range(len(urls) / 2):
|
||||
for index in range(len(urls) // 2):
|
||||
imageUrl = urls[index * 2]
|
||||
textUrl = urls[index * 2 + 1]
|
||||
img = PNMImage()
|
||||
|
|
|
|||
Loading…
Reference in New Issue