diff options
author | Christian Heimes <christian@cheimes.de> | 2008-03-16 00:32:36 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2008-03-16 00:32:36 (GMT) |
commit | 08976cb6967a071682612211579385e35fd68eda (patch) | |
tree | e74e9a0b0366f53e3deaddfe397a41f7cce88d65 /Python | |
parent | dd15f6c315f20c1a9a540dd757cd63e27dbe9f3c (diff) | |
download | cpython-08976cb6967a071682612211579385e35fd68eda.zip cpython-08976cb6967a071682612211579385e35fd68eda.tar.gz cpython-08976cb6967a071682612211579385e35fd68eda.tar.bz2 |
Merged revisions 61404-61407 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61404 | raymond.hettinger | 2008-03-15 21:02:04 +0100 (Sat, 15 Mar 2008) | 17 lines
Removed Exact/Inexact after discussion with Yasskin.
Unlike Scheme where exactness is implemented as taints, the Python
implementation associated exactness with data types. This created
inheritance issues (making an exact subclass of floats would result
in the subclass having both an explicit Exact registration and an
inherited Inexact registration). This was a problem for the
decimal module which was designed to span both exact and inexact
arithmetic. There was also a question of use cases and no examples
were found where ABCs for exactness could be used to improve code.
One other issue was having separate tags for both the affirmative
and negative cases. This is at odds with the approach taken
elsewhere in the Python (i.e. we don't have an ABC both Hashable
and Unhashable).
........
r61405 | raymond.hettinger | 2008-03-15 21:37:50 +0100 (Sat, 15 Mar 2008) | 1 line
Zap one more use of Exact/Inexact.
........
r61406 | neal.norwitz | 2008-03-15 23:03:18 +0100 (Sat, 15 Mar 2008) | 9 lines
Add a warning for code like:
assert (0, 'message')
An empty tuple does not create a warning. While questionable usage:
assert (), 'message'
should not display a warning. Tested manually.
The warning message could be improved. Feel free to update it.
........
r61407 | neal.norwitz | 2008-03-15 23:36:01 +0100 (Sat, 15 Mar 2008) | 1 line
Handle memory allocation failure. Found by Adam Olsen
........
Diffstat (limited to 'Python')
-rw-r--r-- | Python/compile.c | 8 | ||||
-rw-r--r-- | Python/symtable.c | 5 |
2 files changed, 11 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c index 6ad3822..7d5ada6 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2223,6 +2223,14 @@ compiler_assert(struct compiler *c, stmt_ty s) if (assertion_error == NULL) return 0; } + if (s->v.Assert.test->kind == Tuple_kind && + asdl_seq_LEN(s->v.Assert.test->v.Tuple.elts) > 0) { + const char* msg = + "assertion is always true, perhaps remove parentheses?"; + if (PyErr_WarnExplicit(PyExc_SyntaxWarning, msg, c->c_filename, + c->u->u_lineno, NULL, NULL) == -1) + return 0; + } VISIT(c, expr, s->v.Assert.test); end = compiler_new_block(c); if (end == NULL) diff --git a/Python/symtable.c b/Python/symtable.c index 84d0067..b896c52 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -33,8 +33,9 @@ PySTEntry_New(struct symtable *st, identifier name, _Py_block_ty block, k = PyLong_FromVoidPtr(key); if (k == NULL) goto fail; - ste = (PySTEntryObject *)PyObject_New(PySTEntryObject, - &PySTEntry_Type); + ste = PyObject_New(PySTEntryObject, &PySTEntry_Type); + if (ste == NULL) + goto fail; ste->ste_table = st; ste->ste_id = k; ste->ste_tmpname = 0; |