Skip to content

Commit 181d94c

Browse files
author
4b796c65
committed
Python 2 fixes
1 parent ff4b47e commit 181d94c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tdl/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _formatChar(char):
3333
"""
3434
if char is None:
3535
return None
36-
if isinstance(char, int):
36+
if isinstance(char, int) or not _IS_PYTHON3 and isinstance(char, long):
3737
return char
3838
if isinstance(char, (str, bytes)) and len(char) == 1:
3939
return ord(char)
@@ -68,7 +68,7 @@ def _iscolor(color):
6868
return True
6969
if isinstance(color, (tuple, list, _Color)):
7070
return len(color) == 3
71-
if color.__class__ is int:
71+
if color.__class__ is int or not _IS_PYTHON3 and color.__class__ is long:
7272
return True
7373
return False
7474

@@ -80,7 +80,7 @@ def _formatColor(color):
8080
# avoid isinstance, checking __class__ gives a small speed increase
8181
if color.__class__ is _Color:
8282
return color
83-
if color.__class__ is int:
83+
if color.__class__ is int or not _IS_PYTHON3 and color.__class__ is long:
8484
# format a web style color with the format 0xRRGGBB
8585
return _Color(color >> 16 & 0xff, color >> 8 & 0xff, color & 0xff)
8686
return _Color(*color)
@@ -157,7 +157,8 @@ def _normalizeRect(self, x, y, width, height):
157157
raise AssertionError's for any problems
158158
"""
159159
old = x, y, width, height
160-
assert self._drawable(x, y)
160+
assert isinstance(x, int), 'x must be an integer, got %s' % repr(x)
161+
assert isinstance(y, int), 'y must be an integer, got %s' % repr(y)
161162
if width == None: # if width or height are None then extend them to the edge
162163
width = self.width - x
163164
if height == None:
@@ -236,7 +237,7 @@ def blit(self, source, x=0, y=0, width=None, height=None, srcx=0, srcy=0):
236237

237238
# _normalizeRect will break negative values in this case, so enforce
238239
# an assert on positive numbers in this one case
239-
assert width >= 0 and height >= 0, 'width and height cannot be negaitve'
240+
assert width >= 0 and height >= 0, 'width and height cannot be negative'
240241
x, y, width, height = self._normalizeRect(x, y, width, height)
241242
srcx, srcy, width, height = source._normalizeRect(srcx, srcy, width, height)
242243

0 commit comments

Comments
 (0)