[pypy-commit] pypy py3.6: fix error message of barry_as_FLUFL, important work!

cfbolz pypy.commits at gmail.com
Mon Sep 16 07:38:07 EDT 2019


Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch: py3.6
Changeset: r97489:03c11d539a67
Date: 2019-09-16 13:37 +0200
http://bitbucket.org/pypy/pypy/changeset/03c11d539a67/

Log:	fix error message of barry_as_FLUFL, important work!

diff --git a/pypy/interpreter/astcompiler/astbuilder.py b/pypy/interpreter/astcompiler/astbuilder.py
--- a/pypy/interpreter/astcompiler/astbuilder.py
+++ b/pypy/interpreter/astcompiler/astbuilder.py
@@ -939,7 +939,7 @@
             elif comp_type == tokens.NOTEQUAL:
                 flufl = self.compile_info.flags & consts.CO_FUTURE_BARRY_AS_BDFL
                 if flufl and comp_node.get_value() == '!=':
-                    self.error('invalid comparison', comp_node)
+                    self.error("with Barry as BDFL, use '<>' instead of '!='", comp_node)
                 elif not flufl and comp_node.get_value() == '<>':
                     self.error('invalid comparison', comp_node)
                 return ast.NotEq
diff --git a/pypy/interpreter/test/test_compiler.py b/pypy/interpreter/test/test_compiler.py
--- a/pypy/interpreter/test/test_compiler.py
+++ b/pypy/interpreter/test/test_compiler.py
@@ -744,7 +744,7 @@
                 sys.path[:] = copy
             return x
         """)
-        assert space.float_w(w_result) == 0
+        assert space.is_true(w_result)
 
     def test_filename_in_syntaxerror(self):
         e = py.test.raises(OperationError, self.compiler.compile, """if 1:
@@ -917,9 +917,11 @@
         code = "from __future__ import barry_as_FLUFL; 2 {0} 3"
         compile(code.format('<>'), '<BDFL test>', 'exec',
                 __future__.CO_FUTURE_BARRY_AS_BDFL)
-        raises(SyntaxError, compile, code.format('!='),
+        with raises(SyntaxError) as excinfo:
+            compile(code.format('!='),
                '<FLUFL test>', 'exec',
                __future__.CO_FUTURE_BARRY_AS_BDFL)
+        assert excinfo.value.msg == "with Barry as BDFL, use '<>' instead of '!='"
 
     def test_guido_as_bdfl(self):
         # from test_flufl.py :-)


More information about the pypy-commit mailing list