Commit e4e23719 authored by Marius Wachtler's avatar Marius Wachtler

fix a bug where compare could ignore CAPI exceptions and add _heapq

parent dc8e8251
...@@ -39,6 +39,7 @@ file(GLOB_RECURSE STDMODULE_SRCS Modules ...@@ -39,6 +39,7 @@ file(GLOB_RECURSE STDMODULE_SRCS Modules
_collectionsmodule.c _collectionsmodule.c
_csv.c _csv.c
_functoolsmodule.c _functoolsmodule.c
_heapqmodule.c
_iomodule.c _iomodule.c
_math.c _math.c
_randommodule.c _randommodule.c
......
# expected: fail
"""Unittests for heapq.""" """Unittests for heapq."""
import sys import sys
......
...@@ -23,6 +23,8 @@ cmp_lt(PyObject *x, PyObject *y) ...@@ -23,6 +23,8 @@ cmp_lt(PyObject *x, PyObject *y)
lt = PyString_FromString("__lt__"); lt = PyString_FromString("__lt__");
if (lt == NULL) if (lt == NULL)
return -1; return -1;
// Pyston change:
PyGC_RegisterStaticConstant(lt);
} }
if (PyObject_HasAttr(x, lt)) if (PyObject_HasAttr(x, lt))
return PyObject_RichCompareBool(x, y, Py_LT); return PyObject_RichCompareBool(x, y, Py_LT);
...@@ -621,7 +623,7 @@ maintains the heap invariant!\n"); ...@@ -621,7 +623,7 @@ maintains the heap invariant!\n");
PyDoc_STRVAR(__about__, PyDoc_STRVAR(__about__,
"Heap queues\n\ "Heap queues\n\
\n\ \n\
[explanation by Franois Pinard]\n\ [explanation by François Pinard]\n\
\n\ \n\
Heaps are arrays for which a[k] <= a[2*k+1] and a[k] <= a[2*k+2] for\n\ Heaps are arrays for which a[k] <= a[2*k+1] and a[k] <= a[2*k+2] for\n\
all k, counting elements from 0. For the sake of comparison,\n\ all k, counting elements from 0. For the sake of comparison,\n\
......
...@@ -5913,12 +5913,15 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit ...@@ -5913,12 +5913,15 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit
assert(!lhs->cls->is_user_defined); assert(!lhs->cls->is_user_defined);
Box* r = lhs->cls->tp_richcompare(lhs, rhs, cpython_op_type); Box* r = lhs->cls->tp_richcompare(lhs, rhs, cpython_op_type);
if (!r)
throwCAPIException();
RELEASE_ASSERT(r != NotImplemented, "%s returned notimplemented?", lhs->cls->tp_name); RELEASE_ASSERT(r != NotImplemented, "%s returned notimplemented?", lhs->cls->tp_name);
if (rewrite_args) { if (rewrite_args) {
rewrite_args->out_rtn rewrite_args->out_rtn
= rewrite_args->rewriter->call(true, (void*)lhs->cls->tp_richcompare, rewrite_args->lhs, = rewrite_args->rewriter->call(true, (void*)lhs->cls->tp_richcompare, rewrite_args->lhs,
rewrite_args->rhs, rewrite_args->rewriter->loadConst(cpython_op_type)) rewrite_args->rhs, rewrite_args->rewriter->loadConst(cpython_op_type))
->setType(RefType::OWNED); ->setType(RefType::OWNED);
rewrite_args->rewriter->checkAndThrowCAPIException(rewrite_args->out_rtn);
rewrite_args->out_success = true; rewrite_args->out_success = true;
} }
return r; return r;
......
...@@ -51,49 +51,50 @@ ...@@ -51,49 +51,50 @@
#include "runtime/super.h" #include "runtime/super.h"
#include "runtime/util.h" #include "runtime/util.h"
extern "C" void initarray();
extern "C" void init_ast();
extern "C" void initbinascii();
extern "C" void init_bisect(); extern "C" void init_bisect();
extern "C" void init_codecs();
extern "C" void init_collections();
extern "C" void initcStringIO();
extern "C" void init_csv();
extern "C" void initdatetime();
extern "C" void initerrno(); extern "C" void initerrno();
extern "C" void init_sha(); extern "C" void initfcntl();
extern "C" void init_sha256(); extern "C" void init_functools();
extern "C" void init_sha512(); extern "C" void initgc();
extern "C" void init_md5(); extern "C" void init_heapq();
extern "C" void init_random(); extern "C" void initimp();
extern "C" void init_sre(); extern "C" void init_io();
extern "C" void inititertools();
extern "C" void initmath(); extern "C" void initmath();
extern "C" void init_md5();
extern "C" void initoperator(); extern "C" void initoperator();
extern "C" void initbinascii();
extern "C" void initpwd();
extern "C" void initposix(); extern "C" void initposix();
extern "C" void init_struct(); extern "C" void initpwd();
extern "C" void initdatetime(); extern "C" void init_random();
extern "C" void init_functools();
extern "C" void init_collections();
extern "C" void inititertools();
extern "C" void initresource(); extern "C" void initresource();
extern "C" void initsignal();
extern "C" void initselect(); extern "C" void initselect();
extern "C" void initfcntl(); extern "C" void init_sha();
extern "C" void inittime(); extern "C" void init_sha256();
extern "C" void initarray(); extern "C" void init_sha512();
extern "C" void initzlib(); extern "C" void initsignal();
extern "C" void init_codecs();
extern "C" void init_socket(); extern "C" void init_socket();
extern "C" void _PyUnicode_Init(); extern "C" void init_sqlite3();
extern "C" void _PyWarnings_Init() noexcept; extern "C" void init_sre();
extern "C" void _string_init(); extern "C" void init_ssl();
extern "C" void initstrop();
extern "C" void init_struct();
extern "C" void inittime();
extern "C" void initunicodedata(); extern "C" void initunicodedata();
extern "C" void init_weakref(); extern "C" void init_weakref();
extern "C" void initcStringIO();
extern "C" void init_io();
extern "C" void initzipimport(); extern "C" void initzipimport();
extern "C" void init_csv(); extern "C" void initzlib();
extern "C" void init_ssl();
extern "C" void init_sqlite3();
extern "C" void PyMarshal_Init(); extern "C" void PyMarshal_Init();
extern "C" void initstrop(); extern "C" void _PyUnicode_Init();
extern "C" void initgc(); extern "C" void _PyWarnings_Init() noexcept;
extern "C" void init_ast(); extern "C" void _string_init();
extern "C" void initimp();
namespace pyston { namespace pyston {
...@@ -4101,6 +4102,7 @@ struct _inittab _PyImport_Inittab[] = { { "array", initarray }, ...@@ -4101,6 +4102,7 @@ struct _inittab _PyImport_Inittab[] = { { "array", initarray },
{ "errno", initerrno }, { "errno", initerrno },
{ "fcntl", initfcntl }, { "fcntl", initfcntl },
{ "_functools", init_functools }, { "_functools", init_functools },
{ "_heapq", init_heapq },
{ "imp", initimp }, { "imp", initimp },
{ "_io", init_io }, { "_io", init_io },
{ "itertools", inititertools }, { "itertools", inititertools },
......
...@@ -92,7 +92,6 @@ test_getargs2 [unknown] ...@@ -92,7 +92,6 @@ test_getargs2 [unknown]
test_global SyntaxWarnings for global statements after uses test_global SyntaxWarnings for global statements after uses
test_gl [unknown] test_gl [unknown]
test_grammar bug in our tokenizer test_grammar bug in our tokenizer
test_heapq [unknown]
test_hotshot [unknown] test_hotshot [unknown]
test_idle [unknown] test_idle [unknown]
test_imageop [unknown] test_imageop [unknown]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment