Commit 75f1beb7 authored by Marius Wachtler's avatar Marius Wachtler

Add support for METH_OLDARGS and list.pop(long)

parent 6290c7cd
...@@ -80,6 +80,19 @@ public: ...@@ -80,6 +80,19 @@ public:
raiseExcHelper(TypeError, "%s() takes exactly one argument (%d given)", self->name, varargs->size()); raiseExcHelper(TypeError, "%s() takes exactly one argument (%d given)", self->name, varargs->size());
} }
rtn = (Box*)self->func(self->passthrough, varargs->elts[0]); rtn = (Box*)self->func(self->passthrough, varargs->elts[0]);
} else if (self->ml_flags == METH_OLDARGS) {
/* the really old style */
if (kwargs == NULL || PyDict_Size(kwargs) == 0) {
int size = PyTuple_GET_SIZE(varargs);
Box* arg = varargs;
if (size == 1)
arg = PyTuple_GET_ITEM(varargs, 0);
else if (size == 0)
arg = NULL;
rtn = self->func(self->passthrough, arg);
} else {
raiseExcHelper(TypeError, "%.200s() takes no keyword arguments", self->name);
}
} else { } else {
RELEASE_ASSERT(0, "0x%x", self->ml_flags); RELEASE_ASSERT(0, "0x%x", self->ml_flags);
} }
......
...@@ -99,11 +99,10 @@ extern "C" Box* listPop(BoxedList* self, Box* idx) { ...@@ -99,11 +99,10 @@ extern "C" Box* listPop(BoxedList* self, Box* idx) {
return rtn; return rtn;
} }
if (idx->cls != int_cls) { int64_t n = PyInt_AsSsize_t(idx);
if (n == -1 && PyErr_Occurred())
raiseExcHelper(TypeError, "an integer is required"); raiseExcHelper(TypeError, "an integer is required");
}
int64_t n = static_cast<BoxedInt*>(idx)->n;
if (n < 0) if (n < 0)
n = self->size + n; n = self->size + n;
......
...@@ -2584,7 +2584,7 @@ void setupRuntime() { ...@@ -2584,7 +2584,7 @@ void setupRuntime() {
} }
BoxedModule* createModule(const std::string& name, const char* fn, const char* doc) { BoxedModule* createModule(const std::string& name, const char* fn, const char* doc) {
assert(!fn || strlen(fn) && "probably wanted to set the fn to <stdin>?"); assert((!fn || strlen(fn)) && "probably wanted to set the fn to <stdin>?");
BoxedDict* d = getSysModulesDict(); BoxedDict* d = getSysModulesDict();
Box* b_name = boxStringPtr(&name); Box* b_name = boxStringPtr(&name);
......
...@@ -22,6 +22,7 @@ for i in xrange(-10, 10): ...@@ -22,6 +22,7 @@ for i in xrange(-10, 10):
for i in xrange(-5, 4): for i in xrange(-5, 4):
l3 = range(5) l3 = range(5)
print i, l3.pop(i), l3 print i, l3.pop(i), l3
print range(5).pop(2L)
for i in xrange(-5, 4): for i in xrange(-5, 4):
l3 = range(5) l3 = range(5)
......
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