Commit 586ceed6 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge commit '9216f615' into refcounting

parents bb191d97 9216f615
......@@ -747,7 +747,8 @@ float_rem(PyObject *v, PyObject *w)
return PyFloat_FromDouble(mod);
}
static PyObject *
// pyston change: make this not static
PyObject *
float_divmod(PyObject *v, PyObject *w)
{
double vx, wx;
......@@ -987,7 +988,8 @@ float_nonzero(PyFloatObject *v)
return v->ob_fval != 0.0;
}
static int
// pyston change: make not static
int
float_coerce(PyObject **pv, PyObject **pw)
{
if (PyInt_Check(*pw)) {
......@@ -1949,7 +1951,8 @@ PyDoc_STRVAR(float_getformat_doc,
"'unknown', 'IEEE, big-endian' or 'IEEE, little-endian' best describes the\n"
"format of floating point numbers used by the C type named by typestr.");
static PyObject *
// pyston change: make not static
PyObject *
float_setformat(PyTypeObject *v, PyObject* args)
{
char* typestr;
......
This diff is collapsed.
......@@ -154,9 +154,17 @@ Box* getFrame(int depth) {
return BoxedFrame::boxFrame(std::move(it));
}
extern "C" int PyFrame_GetLineNumber(PyFrameObject* f) noexcept {
BoxedInt* lineno = (BoxedInt*)BoxedFrame::lineno((Box*)f, NULL);
return lineno->n;
extern "C" int PyFrame_GetLineNumber(PyFrameObject* _f) noexcept {
// TODO remove this when we are able to introspect exited frames:
// We check if the frame exited and only return the correct line number when it is still available.
// Because of a limitation in out current frame introspection we can also not inspect OSRed frames.
BoxedFrame* f = (BoxedFrame*)_f;
PythonFrameIterator new_it = f->it.getCurrentVersion();
if (new_it.exists() && new_it.getFrameInfo()->frame_obj == f) {
BoxedInt* lineno = (BoxedInt*)BoxedFrame::lineno((Box*)f, NULL);
return lineno->n;
}
return -1;
}
extern "C" PyObject* PyFrame_GetGlobals(PyFrameObject* f) noexcept {
......
This diff is collapsed.
This diff is collapsed.
......@@ -49,8 +49,8 @@ Box* longSub(BoxedLong* lhs, Box* rhs);
Box* longMul(BoxedLong* lhs, Box* rhs);
Box* longDiv(BoxedLong* lhs, Box* rhs);
Box* longPow(BoxedLong* lhs, Box* rhs, Box* mod = None);
Box* longLshift(BoxedLong* lhs, Box* rhs);
Box* longRshift(BoxedLong* lhs, Box* rhs);
Box* longLShiftLong(BoxedLong* lhs, Box* _rhs);
Box* longRShiftLong(BoxedLong* lhs, Box* _rhs);
Box* longHex(BoxedLong* v);
Box* longOct(BoxedLong* v);
......
......@@ -111,3 +111,29 @@ print sys.float_info
if 1:
x = -2.0
print(float.__long__(sys.float_info.max))
print(float.__int__(sys.float_info.max))
data = ["-1.0", "0.0", "1.0",
"5.0", "-5.0",
"5", "5L", "0L", "5+5j",
"\"5\"", "None",
]
operations = ["__rpow__",
"__ridv__",
"__divmod__", "__rdivmod__",
"__rtruediv__",
"__coerce__"
]
for x in data:
for y in data:
for operation in operations:
try:
print(eval("float.{op}({arg1}, {arg2})".format(op=operation,
arg1=x,
arg2=y)))
except Exception as e:
print(e.message)
......@@ -178,3 +178,53 @@ if sys.version_info >= (2, 7, 6):
print(e.message)
else:
print("int() missing string argument")
pow_test_data = [42, 3, 3L, 4.5, "x", 0, -42, None]
for rhs in pow_test_data:
for lhs in pow_test_data:
for mod in pow_test_data:
try:
print(int.__rpow__(rhs, lhs, mod))
except Exception as e:
print(e.message)
unary_test_data = [-42, -0, 0, 42, max_int, min_int]
for i in unary_test_data:
print(int.__abs__(i))
print(int.__long__(i))
print(int.__float__(i))
data = ["-1", "0", "1",
"5", "-5",
"5.0", "5L", "0L", "5+5j", "0.0",
"\"5\"", "None",
]
operations = ["__radd__",
"__rand__",
"__ror__",
"__rxor__",
"__rsub__",
"__rmul__",
"__rdiv__",
"__rfloordiv__",
"__rpow__",
"__rmod__",
"__rdivmod__",
"__rtruediv__",
"__rrshift__",
"__rlshift__",
"__coerce__",
]
for x in data:
for y in data:
for operation in operations:
try:
print(eval("int.{op}({arg1}, {arg2})".format(op=operation,
arg1=x,
arg2=y)))
except Exception as e:
print(e.message)
......@@ -162,3 +162,43 @@ for i in range(-10, 10):
for i in xrange(100):
for j in xrange(100):
print i, j, hash((1 << i) - (1 << j))
pow_test_data = [42L, 3, 4.5, "x", 0, -42, None]
for rhs in pow_test_data:
for lhs in pow_test_data:
for mod in pow_test_data:
try:
print(long.__rpow__(rhs, lhs, mod))
except Exception as e:
print(e.message)
unary_test_data = [-42, -0, 0, 42]
for i in unary_test_data:
print(int.__abs__(i))
print(int.__long__(i))
data = ["-1L", "0L", "1L",
"42L", "-42L",
"42.0", "5", "0", "5+5j", "0.0",
"\"42\"", "None",
]
operations = ["__rpow__",
"__rshift__",
"__lshift__",
"__rrshift__",
"__rlshift__",
"__coerce__",
]
for x in data:
for y in data:
for operation in operations:
try:
print(eval("long.{op}({arg1}, {arg2})".format(op=operation,
arg1=x,
arg2=y)))
except Exception as e:
print(e.message)
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