Commit 643a89bc authored by Kevin Modzelewski's avatar Kevin Modzelewski

Misc fixes/improvements

parent 7ea987f7
......@@ -2578,7 +2578,8 @@ template <ExceptionStyle S> BoxedInt* lenInternal(Box* obj, LenRewriteArgs* rewr
if (rtn == NULL) {
if (S == CAPI) {
PyErr_Format(TypeError, "object of type '%s' has no len()", getTypeName(obj));
if (!PyErr_Occurred())
PyErr_Format(TypeError, "object of type '%s' has no len()", getTypeName(obj));
return NULL;
} else
raiseExcHelper(TypeError, "object of type '%s' has no len()", getTypeName(obj));
......@@ -3694,7 +3695,8 @@ Box* runtimeCallInternal(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec ar
if (!rtn) {
if (S == CAPI) {
PyErr_Format(TypeError, "'%s' object is not callable", getTypeName(obj));
if (!PyErr_Occurred())
PyErr_Format(TypeError, "'%s' object is not callable", getTypeName(obj));
return NULL;
} else
raiseExcHelper(TypeError, "'%s' object is not callable", getTypeName(obj));
......@@ -4689,7 +4691,7 @@ extern "C" Box* getitem_capi(Box* target, Box* slice) noexcept {
if (!rewrite_args.out_success) {
rewriter.reset(NULL);
} else {
} else if (rtn) {
rewriter->commitReturning(rewrite_args.out_rtn);
}
} else {
......
......@@ -143,7 +143,7 @@ template <ExceptionStyle S> Box* tupleGetitem(BoxedTuple* self, Box* slice) {
}
}
assert(self->cls == tuple_cls);
assert(isSubclass(self->cls, tuple_cls));
if (PyIndex_Check(slice)) {
Py_ssize_t i = PyNumber_AsSsize_t(slice, PyExc_IndexError);
......
......@@ -41,11 +41,11 @@ void parseSlice(BoxedSlice* slice, int size, i64* out_start, i64* out_stop, i64*
throwCAPIException();
}
bool isSliceIndex(Box* b) {
bool isSliceIndex(Box* b) noexcept {
return b->cls == none_cls || b->cls == int_cls || PyIndex_Check(b);
}
void adjustNegativeIndicesOnObject(Box* obj, i64* start_out, i64* stop_out) {
void adjustNegativeIndicesOnObject(Box* obj, i64* start_out, i64* stop_out) noexcept {
i64 start = *start_out;
i64 stop = *stop_out;
PySequenceMethods* m;
......
......@@ -36,9 +36,9 @@ inline void sliceIndex(Box* b, int64_t* out) {
throwCAPIException();
}
bool isSliceIndex(Box* b);
bool isSliceIndex(Box* b) noexcept;
void adjustNegativeIndicesOnObject(Box* obj, i64* start, i64* stop);
void adjustNegativeIndicesOnObject(Box* obj, i64* start, i64* stop) noexcept;
// Adjust the start and stop bounds of the sequence we are slicing to its size.
// Ensure stop >= start and remain within bounds.
......
# run_args: -n
# statcheck: 1 <= noninit_count("slowpath_runtimecall") < 20
# statcheck: 1 <= noninit_count("slowpath_runtimecall") + noninit_count("slowpath_runtimecall_capi") < 20
# Make sure we can patch some basic varargs cases
......
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