Commit bbb19558 authored by Marius Wachtler's avatar Marius Wachtler

Add round(int), property.__doc__, code.co_firstlineno return -1 if not set

parent 43c13953
...@@ -129,6 +129,7 @@ ...@@ -129,6 +129,7 @@
#define HAVE_UNISTD_H 1 #define HAVE_UNISTD_H 1
#define HAVE_UTIME_H 1 #define HAVE_UTIME_H 1
#define HAVE_WCHAR_H 1 #define HAVE_WCHAR_H 1
#define HAVE_WORKING_TZSET 1
#define HAVE_PUTENV 1 #define HAVE_PUTENV 1
// Added this for some Pyston modifications: // Added this for some Pyston modifications:
......
...@@ -1017,12 +1017,10 @@ Box* input(Box* prompt) { ...@@ -1017,12 +1017,10 @@ Box* input(Box* prompt) {
} }
Box* builtinRound(Box* _number, Box* _ndigits) { Box* builtinRound(Box* _number, Box* _ndigits) {
if (!isSubclass(_number->cls, float_cls)) double x = PyFloat_AsDouble(_number);
if (PyErr_Occurred())
raiseExcHelper(TypeError, "a float is required"); raiseExcHelper(TypeError, "a float is required");
BoxedFloat* number = (BoxedFloat*)_number;
double x = number->d;
/* interpret 2nd argument as a Py_ssize_t; clip on overflow */ /* interpret 2nd argument as a Py_ssize_t; clip on overflow */
Py_ssize_t ndigits = PyNumber_AsSsize_t(_ndigits, NULL); Py_ssize_t ndigits = PyNumber_AsSsize_t(_ndigits, NULL);
if (ndigits == -1 && PyErr_Occurred()) if (ndigits == -1 && PyErr_Occurred())
......
...@@ -62,6 +62,9 @@ public: ...@@ -62,6 +62,9 @@ public:
return boxInt(-1); return boxInt(-1);
} }
if (cl->source->ast->lineno == (uint32_t)-1)
return boxInt(-1);
return boxInt(cl->source->ast->lineno); return boxInt(cl->source->ast->lineno);
} }
......
...@@ -188,7 +188,7 @@ void setupDescr() { ...@@ -188,7 +188,7 @@ void setupDescr() {
new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedProperty, prop_set))); new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedProperty, prop_set)));
property_cls->giveAttr("fdel", property_cls->giveAttr("fdel",
new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedProperty, prop_del))); new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedProperty, prop_del)));
property_cls->giveAttr("fdoc", property_cls->giveAttr("__doc__",
new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedProperty, prop_doc))); new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedProperty, prop_doc)));
property_cls->freeze(); property_cls->freeze();
......
...@@ -2111,7 +2111,8 @@ extern "C" bool nonzero(Box* obj) { ...@@ -2111,7 +2111,8 @@ extern "C" bool nonzero(Box* obj) {
ASSERT(isUserDefined(obj->cls) || obj->cls == classobj_cls || obj->cls == type_cls ASSERT(isUserDefined(obj->cls) || obj->cls == classobj_cls || obj->cls == type_cls
|| isSubclass(obj->cls, Exception) || obj->cls == file_cls || obj->cls == traceback_cls || isSubclass(obj->cls, Exception) || obj->cls == file_cls || obj->cls == traceback_cls
|| obj->cls == instancemethod_cls || obj->cls == module_cls || obj->cls == capifunc_cls || obj->cls == instancemethod_cls || obj->cls == module_cls || obj->cls == capifunc_cls
|| obj->cls == builtin_function_or_method_cls || obj->cls == method_cls, || obj->cls == builtin_function_or_method_cls || obj->cls == method_cls || obj->cls == frame_cls
|| obj->cls == capi_getset_cls || obj->cls == pyston_getset_cls,
"%s.__nonzero__", getTypeName(obj)); // TODO "%s.__nonzero__", getTypeName(obj)); // TODO
// TODO should rewrite these? // TODO should rewrite these?
......
...@@ -108,7 +108,7 @@ print callable(lambda: 1) ...@@ -108,7 +108,7 @@ print callable(lambda: 1)
print range(5L, 7L) print range(5L, 7L)
for n in [0, 1, 2, 3, 4, 5]: for n in [0, 1, 2, 3, 4, 5]:
print round(-1.1, n), round(-1.9, n), round(0.5, n), round(-0.5, n), round(-0.123456789, n) print round(-1.1, n), round(-1.9, n), round(0.5, n), round(-0.5, n), round(-0.123456789, n), round(1, n)
print list(iter(xrange(100).__iter__().next, 20)) print list(iter(xrange(100).__iter__().next, 20))
......
...@@ -8,7 +8,7 @@ class C(object): ...@@ -8,7 +8,7 @@ class C(object):
def fset(self, val): def fset(self, val):
print 'in fset, val =', val print 'in fset, val =', val
x = property(fget, fset) x = property(fget, fset, None, "Doc String")
c = C() c = C()
print c.x print c.x
...@@ -16,6 +16,7 @@ print C.x.__get__(c, C) ...@@ -16,6 +16,7 @@ print C.x.__get__(c, C)
print type(C.x.__get__(None, C)) print type(C.x.__get__(None, C))
c.x = 7 c.x = 7
print c.x print c.x
print C.x.__doc__
class C2(object): class C2(object):
@property @property
......
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