Skip to content

Commit 32a3aa8

Browse files
author
Troy Melhase
committed
Special case for "x != None" replaced with "x is not None".
1 parent ddf6711 commit 32a3aa8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

java2python/lib/walker.g

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,12 @@ returns [exp = block.unknownExpression]
580580
{exp = ("%s & %s", (left, right))}
581581

582582
| #(NOT_EQUAL left=expr[block] right=expr[block])
583-
{exp = ("%s != %s", (left, right))}
583+
{
584+
if right in ("None", (("%s", "None"))):
585+
exp = ("%s is not %s", (left, right))
586+
else:
587+
exp = ("(%s != %s)", (left, right))
588+
}
584589

585590
| #(EQUAL left=expr[block] right=expr[block])
586591
{

0 commit comments

Comments
 (0)