Bug#958463: pathological: Syntax Warning about "is with a literal" (python3 compatibility?)

Ionen Wolkens ionen at gentoo.org
Sun Jun 6 03:54:53 BST 2021


On Wed, Apr 22, 2020 at 02:26:40PM +0200, Alex wrote:
> /usr/share/games/pathological/pathological.py:137: SyntaxWarning: "is" with a literal. Did you mean "=="?
>   if colorkey is -1:
> 
> This looks like it may be incompatible or incompatible in the future. It
> is probably easy to fix with a patch or in the upstream.

Liberal use of "is" actually is what prevents >=pygame-2 from being
usable with this game, e.g. 'event.type is KEYDOWN' never matches.
See: pygame-2.0.1/buildconfig/pygame-stubs/constants.pyi

Given it fixes colorkey as well, may want this patch from Gentoo.
https://bugs.gentoo.org/794211

--- a/pathological.py
+++ b/pathological.py
@@ -133,3 +133,3 @@
 	if colorkey is not None:
-		if colorkey is -1:
+		if colorkey == -1:
 			colorkey = image.get_at((0,0))
@@ -1395,6 +1395,6 @@
 			for event in pygame.event.get():
-				if event.type is QUIT:
+				if event.type == QUIT:
 					return -4
-				elif event.type is KEYDOWN:
-					if event.key is K_ESCAPE: return -3
+				elif event.type == KEYDOWN:
+					if event.key == K_ESCAPE: return -3
 					elif event.key == ord('n'): return 2
@@ -1419,3 +1419,3 @@
 
-				elif event.type is MOUSEBUTTONDOWN:
+				elif event.type == MOUSEBUTTONDOWN:
 					if self.paused:
@@ -1713,5 +1713,5 @@
 			for event in pygame.event.get():
-				if event.type is QUIT:
+				if event.type == QUIT:
 					return -2
-				elif event.type is KEYDOWN:
+				elif event.type == KEYDOWN:
 					if event.key == K_ESCAPE: return -1
@@ -1744,3 +1744,3 @@
 					return 1
-				elif event.type is MOUSEBUTTONDOWN:
+				elif event.type == MOUSEBUTTONDOWN:
 					return 1
@@ -1799,5 +1799,5 @@
 		for event in pygame.event.get():
-			if event.type is QUIT:
+			if event.type == QUIT:
 				return None
-			elif event.type is KEYUP:
+			elif event.type == KEYUP:
 				if event.key == K_LSHIFT:
@@ -1806,3 +1806,3 @@
 					shift_state &= ~KMOD_RSHIFT
-			elif event.type is KEYDOWN:
+			elif event.type == KEYDOWN:
 				if event.key == K_LSHIFT:
@@ -1994,3 +1994,3 @@
 			for event in pygame.event.get():
-				if event.type is QUIT:
+				if event.type == QUIT:
 					if self.curpage == 1:
@@ -1999,3 +1999,3 @@
 					return -2
-				elif event.type is KEYDOWN:
+				elif event.type == KEYDOWN:
 					if event.key == K_F2:
@@ -2032,3 +2032,3 @@
 					continue
-				elif event.type is MOUSEBUTTONDOWN:
+				elif event.type == MOUSEBUTTONDOWN:
 					if self.curpage == 1:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-games-devel/attachments/20210605/f572eb8f/attachment-0001.sig>


More information about the Pkg-games-devel mailing list