[Python-checkins] cpython (2.7): don't let a tuple msg be interpreted as arguments to AssertionError (closes

benjamin.peterson python-checkins at python.org
Thu Oct 27 14:24:54 CEST 2011


http://hg.python.org/cpython/rev/7bef55ae5753
changeset:   73143:7bef55ae5753
branch:      2.7
user:        Benjamin Peterson <benjamin at python.org>
date:        Thu Oct 27 08:21:59 2011 -0400
summary:
  don't let a tuple msg be interpreted as arguments to AssertionError (closes #13268)

files:
  Misc/NEWS        |  2 ++
  Python/compile.c |  6 ++----
  2 files changed, 4 insertions(+), 4 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -9,6 +9,8 @@
 Core and Builtins
 -----------------
 
+- Issue #13268: Fix the assert statement when a tuple is passed as the message.
+
 - Issue #13018: Fix reference leaks in error paths in dictobject.c.
   Patch by Suman Saha.
 
diff --git a/Python/compile.c b/Python/compile.c
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -2079,11 +2079,9 @@
     ADDOP_O(c, LOAD_GLOBAL, assertion_error, names);
     if (s->v.Assert.msg) {
         VISIT(c, expr, s->v.Assert.msg);
-        ADDOP_I(c, RAISE_VARARGS, 2);
+        ADDOP_I(c, CALL_FUNCTION, 1);
     }
-    else {
-        ADDOP_I(c, RAISE_VARARGS, 1);
-    }
+    ADDOP_I(c, RAISE_VARARGS, 1);
     compiler_use_next_block(c, end);
     return 1;
 }

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list