Skip to content

[CLIENT-3188] Fix unraisable exception warnings in Python 3.13 reported by tests by chaining hidden exceptions with the ones returned to user #751

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 116 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
4fd892b
try this without changing macro.
juliannguyen4 Apr 9, 2025
38636f3
revert
juliannguyen4 Apr 9, 2025
4106758
exc can be anything
juliannguyen4 Apr 9, 2025
a3df92c
fix
juliannguyen4 Apr 9, 2025
7706e52
fix
juliannguyen4 Apr 9, 2025
be2adf4
fix one of the warnings
juliannguyen4 Apr 9, 2025
69ba181
fix for append
juliannguyen4 Apr 9, 2025
8ea25bd
fix batch write warning
juliannguyen4 Apr 9, 2025
d59f54e
helper shouldnt raise an exception, only api calls?
juliannguyen4 Apr 9, 2025
73e26ea
comment
juliannguyen4 Apr 9, 2025
89edad8
cherry pick changes from 31add987..CLIENT-2159-mem-leak-fixes
juliannguyen4 Apr 10, 2025
ff75f63
Merge remote-tracking branch 'origin/dev' into CLIENT-3188-fix-pytest…
juliannguyen4 Apr 10, 2025
b03a53c
fix
juliannguyen4 Apr 10, 2025
1896dd6
add back for now until we rm batch get ops
juliannguyen4 Apr 10, 2025
a63db19
alr a pointer
juliannguyen4 Apr 11, 2025
eec50cb
alr a pointer
juliannguyen4 Apr 11, 2025
3377954
wrong type
juliannguyen4 Apr 11, 2025
f9342f8
fix
juliannguyen4 Apr 11, 2025
8006efe
fix
juliannguyen4 Apr 11, 2025
a70933e
forward result from helper
juliannguyen4 Apr 11, 2025
e9657d3
support nested submodules
juliannguyen4 Apr 11, 2025
71532fb
fix
juliannguyen4 Apr 11, 2025
2393252
decref error
juliannguyen4 Apr 11, 2025
188379d
cleaner
juliannguyen4 Apr 11, 2025
593964d
check in one place
juliannguyen4 Apr 11, 2025
6e7e0d3
fix bad err msg
juliannguyen4 Apr 14, 2025
9c93cd4
dont delete exc attrs
juliannguyen4 Apr 14, 2025
a1ed358
fix
juliannguyen4 Apr 16, 2025
35259ce
fix
juliannguyen4 Apr 16, 2025
836c82b
Merge remote-tracking branch 'origin/dev' into CLIENT-3188-fix-pytest…
juliannguyen4 Apr 16, 2025
77380fc
fix
juliannguyen4 Apr 16, 2025
65d1836
fix all operate api
juliannguyen4 Apr 16, 2025
77b2fb3
unused
juliannguyen4 Apr 16, 2025
ffefbf5
fix
juliannguyen4 Apr 17, 2025
2894954
rm dup
juliannguyen4 Apr 17, 2025
5ecdc46
add check
juliannguyen4 Apr 17, 2025
8d670d3
check if an object's type is a subclass
juliannguyen4 Apr 17, 2025
dad0a57
fix
juliannguyen4 Apr 17, 2025
a75f61d
scan is overriding exception
juliannguyen4 Apr 17, 2025
cf0e041
unused
juliannguyen4 Apr 17, 2025
c833ec1
fix
juliannguyen4 Apr 17, 2025
f3bb3de
helper shouldnt raise exc
juliannguyen4 Apr 17, 2025
f45d32e
fix
juliannguyen4 Apr 17, 2025
be2dc53
wrong function in error msg
juliannguyen4 Apr 17, 2025
dd71768
raise native exception instead of throwing our own
juliannguyen4 Apr 17, 2025
b3f2b8d
use native exception
juliannguyen4 Apr 17, 2025
ab1641a
set can be None
juliannguyen4 Apr 17, 2025
2ac035b
fix
juliannguyen4 Apr 17, 2025
f4f5fce
propagate exception up instead of ignoring it
juliannguyen4 Apr 17, 2025
4aee2b9
fix
juliannguyen4 Apr 17, 2025
4e5c507
api now returns native exception from callbacks
juliannguyen4 Apr 17, 2025
98b0610
also fix for query.foreach()
juliannguyen4 Apr 17, 2025
806f110
fix remaining tests
juliannguyen4 Apr 17, 2025
d162fc4
fix all query tests
juliannguyen4 Apr 17, 2025
728302d
fix
juliannguyen4 Apr 18, 2025
6a17ecb
fix some
juliannguyen4 Apr 18, 2025
c5ceed0
just hide orig error to preserve backwards compat
juliannguyen4 Apr 18, 2025
1ad2403
Treat pytest.PytestUnraisableExceptionWarning as an error
juliannguyen4 Apr 18, 2025
21f5f58
fix one
juliannguyen4 Apr 18, 2025
c518a89
plug
juliannguyen4 Apr 18, 2025
cb5da8b
return native
juliannguyen4 Apr 18, 2025
4ecc305
fix
juliannguyen4 Apr 18, 2025
128c34a
Merge remote-tracking branch 'origin/dev' into CLIENT-3188-fix-pytest…
juliannguyen4 Apr 18, 2025
f78285e
fix
juliannguyen4 Apr 18, 2025
b824343
TypeError now
juliannguyen4 Apr 18, 2025
e4f8fcc
fix
juliannguyen4 Apr 18, 2025
d45c026
fix
juliannguyen4 Apr 18, 2025
7465538
fail with the same error as before but handle the native exc properly
juliannguyen4 Apr 18, 2025
0abbfcd
just typecast
juliannguyen4 Apr 18, 2025
9b2d826
run for both CE + EE
juliannguyen4 Apr 18, 2025
75c7e4b
upgrade ancient version
juliannguyen4 Apr 18, 2025
08bfd9c
Revert "upgrade ancient version"
juliannguyen4 Apr 18, 2025
2dfae4e
Revert "run for both CE + EE"
juliannguyen4 Apr 18, 2025
952e550
also test ee with warning set to err
juliannguyen4 Apr 18, 2025
72e1b4e
fix the last one
juliannguyen4 Apr 18, 2025
374c8e7
improve comment
juliannguyen4 Apr 18, 2025
934ce4a
move explanation to header file
juliannguyen4 Apr 18, 2025
93c90d3
fix
juliannguyen4 Apr 18, 2025
ef00df5
Merge remote-tracking branch 'origin/dev' into CLIENT-3188-fix-pytest…
juliannguyen4 Apr 18, 2025
ec16347
rm outdated comment, fix mem leaks
juliannguyen4 Apr 18, 2025
c312089
these shouldve been rm'd
juliannguyen4 Apr 18, 2025
83c4e44
cleanup a bit
juliannguyen4 Apr 18, 2025
48b3305
rm
juliannguyen4 Apr 21, 2025
565ebfd
revert
juliannguyen4 Apr 21, 2025
1843d82
improve commenting
juliannguyen4 Apr 21, 2025
a89fdbe
switch
juliannguyen4 Apr 21, 2025
e704e27
move to end. explain how tp_name works differently with python native…
juliannguyen4 Apr 21, 2025
e8bbd4c
bad comment
juliannguyen4 Apr 21, 2025
1fab144
mark as unused to make easier to read
juliannguyen4 Apr 21, 2025
4b00435
explain better
juliannguyen4 Apr 21, 2025
be3d7be
remove the last of raise_exception_old
juliannguyen4 Apr 21, 2025
ccc5a95
just put back for now. plug wherever an error happens later on
juliannguyen4 Apr 21, 2025
ff371c3
Revert tests.
juliannguyen4 Apr 21, 2025
2eab491
unneeded return since if stmt below will catch
juliannguyen4 Apr 21, 2025
7bfb384
make code simpler for now
juliannguyen4 Apr 21, 2025
dffa422
F
juliannguyen4 Apr 21, 2025
7624653
better
juliannguyen4 Apr 21, 2025
1aae8e2
instead of clearing, chain exceptions
juliannguyen4 Apr 21, 2025
2a50725
use newer helper for later vers
juliannguyen4 Apr 21, 2025
4f7db8a
Revert "use newer helper for later vers"
juliannguyen4 Apr 21, 2025
66999f7
split into 2 paths
juliannguyen4 Apr 21, 2025
4121353
not the same
juliannguyen4 Apr 21, 2025
89f80bf
fix here, too
juliannguyen4 Apr 21, 2025
1a53409
revert
juliannguyen4 Apr 22, 2025
073c2a2
revert breaking changes
juliannguyen4 Apr 22, 2025
5c3868b
forgot
juliannguyen4 Apr 22, 2025
8436b27
outdated comment
juliannguyen4 Apr 22, 2025
2daff02
undo
juliannguyen4 Apr 22, 2025
f35e95e
undo
juliannguyen4 Apr 22, 2025
f5f7a84
unneeded
juliannguyen4 Apr 22, 2025
7d39167
prevent undefined behavior
juliannguyen4 Apr 22, 2025
0b7b310
add coverage testing for new code
juliannguyen4 Apr 22, 2025
da15204
consolidate into one place
juliannguyen4 Apr 22, 2025
8e025e1
dont change meaning of code
juliannguyen4 Apr 22, 2025
a298dbe
Add simple test for exc chaining
juliannguyen4 Apr 22, 2025
f8482b7
Merge remote-tracking branch 'origin/dev' into CLIENT-3188-fix-pytest…
juliannguyen4 Apr 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ jobs:
container-name: aerospike

- name: Run tests
run: python -m pytest ./new_tests -vv
run: python -m pytest ./new_tests -vv -W error::pytest.PytestUnraisableExceptionWarning
working-directory: test

test-lowest-supported-server:
Expand Down Expand Up @@ -413,12 +413,12 @@ jobs:

- uses: actions/setup-python@v2
with:
python-version: ${{ env.LOWEST_SUPPORTED_PY_VERSION }}
python-version: "3.13"
architecture: 'x64'

- uses: actions/download-artifact@v4
with:
name: wheel-${{ env.LOWEST_SUPPORTED_PY_VERSION }}
name: wheel-3.13

- name: Install client
run: pip install *.whl
Expand All @@ -433,7 +433,7 @@ jobs:
docker-hub-password: ${{ secrets.DOCKER_HUB_BOT_PW }}

- name: Run tests
run: python -m pytest ./new_tests/test_{mrt_functionality,admin_*}.py
run: python -m pytest ./new_tests/test_{mrt_functionality,admin_*,compress}.py -W error::pytest.PytestUnraisableExceptionWarning
working-directory: test

- name: Show logs if failed
Expand Down
8 changes: 7 additions & 1 deletion src/include/conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,15 @@ PyObject *create_py_cluster_from_as_cluster(as_error *error_p,
PyObject *create_py_node_from_as_node(as_error *error_p,
struct as_node_s *node);

// Checks if pyobject is an instance of a class type defined in aerospike_helpers or one of its submodules
// If expected_submodule_name is NULL, the type is expected to be defined directly in the aerospike_helpers package
// If is_subclass_instance is true, we expect the instance's type to directly inherit from aerospike_helpers.<expected_submodule_name>.<expected_type_name>
// We need this method because classes defined natively in Python are heap-allocated types:
// https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_name
bool is_pyobj_correct_as_helpers_type(PyObject *obj,
const char *expected_submodule_name,
const char *expected_type_name);
const char *expected_type_name,
bool is_subclass_instance);
PyObject *create_class_instance_from_module(as_error *error_p,
const char *module_name,
const char *class_name,
Expand Down
3 changes: 3 additions & 0 deletions src/include/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

PyObject *AerospikeException_New(void);
void raise_exception(as_error *err);
void raise_exception_base(as_error *err, PyObject *py_key, PyObject *py_bin,
PyObject *py_module, PyObject *py_func,
PyObject *py_name);
PyObject *raise_exception_old(as_error *err);
void remove_exception(as_error *err);
void set_aerospike_exc_attrs_using_tuple_of_attrs(PyObject *py_exc,
Expand Down
20 changes: 2 additions & 18 deletions src/main/client/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,24 +168,8 @@ PyObject *AerospikeClient_Apply_Invoke(AerospikeClient *self, PyObject *py_key,
as_val_destroy(result);

if (err.code != AEROSPIKE_OK) {
PyObject *py_err = NULL;
error_to_pyobject(&err, &py_err);
PyObject *exception_type = raise_exception_old(&err);
set_aerospike_exc_attrs_using_tuple_of_attrs(exception_type, py_err);
if (PyObject_HasAttrString(exception_type, "key")) {
PyObject_SetAttrString(exception_type, "key", py_key);
}
if (PyObject_HasAttrString(exception_type, "bin")) {
PyObject_SetAttrString(exception_type, "bin", Py_None);
}
if (PyObject_HasAttrString(exception_type, "module")) {
PyObject_SetAttrString(exception_type, "module", py_module);
}
if (PyObject_HasAttrString(exception_type, "func")) {
PyObject_SetAttrString(exception_type, "func", py_function);
}
PyErr_SetObject(exception_type, py_err);
Py_DECREF(py_err);
raise_exception_base(&err, py_key, Py_None, py_module, py_function,
Py_None);
return NULL;
}

Expand Down
25 changes: 18 additions & 7 deletions src/main/client/batch_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,21 @@ static PyObject *AerospikeClient_BatchWriteInvoke(AerospikeClient *self,
}
}

// TODO check that py_object is an instance of class
if (!is_pyobj_correct_as_helpers_type(py_obj, "batch.records",
"BatchRecords", false)) {
as_error_update(err, AEROSPIKE_ERR_PARAM,
"batch_records must be an "
"aerospike_helpers.batch.records.BatchRecords "
"instance");
goto CLEANUP4;
}

py_batch_records = PyObject_GetAttrString(py_obj, FIELD_NAME_BATCH_RECORDS);
if (py_batch_records == NULL || !PyList_Check(py_batch_records)) {
as_error_update(err, AEROSPIKE_ERR_PARAM,
"%s must be a list of BatchRecord",
FIELD_NAME_BATCH_RECORDS);
if (py_batch_records) {
Py_DECREF(py_batch_records);
}
goto CLEANUP4;
goto CLEANUP3;
}

py_batch_records_size = PyList_Size(py_batch_records);
Expand All @@ -193,13 +197,20 @@ static PyObject *AerospikeClient_BatchWriteInvoke(AerospikeClient *self,
for (Py_ssize_t i = 0; i < py_batch_records_size; i++) {
garbage *garb = as_vector_get(&garbage_list, i);
PyObject *py_batch_record = PyList_GetItem(py_batch_records, i);
// TODO check that this is an instance/subclass on BatchRecord
if (py_batch_record == NULL) {
as_error_update(
err, AEROSPIKE_ERR_PARAM,
"py_batch_record is NULL, %s must be a list of BatchRecord",
FIELD_NAME_BATCH_RECORDS);
goto CLEANUP4;
goto CLEANUP3;
}

if (is_pyobj_correct_as_helpers_type(py_batch_record, "batch.records",
"BatchRecord", true) == false) {
as_error_update(
err, AEROSPIKE_ERR_PARAM,
"batch_record must be a BatchRecord class instance");
goto CLEANUP3;
}

// extract as_batch_base_record fields
Expand Down
13 changes: 1 addition & 12 deletions src/main/client/exists.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,7 @@ extern PyObject *AerospikeClient_Exists_Invoke(AerospikeClient *self,
}

if (err.code != AEROSPIKE_OK) {
PyObject *py_err = NULL;
error_to_pyobject(&err, &py_err);
PyObject *exception_type = raise_exception_old(&err);
set_aerospike_exc_attrs_using_tuple_of_attrs(exception_type, py_err);
if (PyObject_HasAttrString(exception_type, "key")) {
PyObject_SetAttrString(exception_type, "key", py_key);
}
if (PyObject_HasAttrString(exception_type, "bin")) {
PyObject_SetAttrString(exception_type, "bin", Py_None);
}
PyErr_SetObject(exception_type, py_err);
Py_DECREF(py_err);
raise_exception_base(&err, py_key, Py_None, Py_None, Py_None, Py_None);
}

return py_result;
Expand Down
13 changes: 1 addition & 12 deletions src/main/client/get.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,7 @@ PyObject *AerospikeClient_Get_Invoke(AerospikeClient *self, PyObject *py_key,
}

if (err.code != AEROSPIKE_OK) {
PyObject *py_err = NULL;
error_to_pyobject(&err, &py_err);
PyObject *exception_type = raise_exception_old(&err);
set_aerospike_exc_attrs_using_tuple_of_attrs(exception_type, py_err);
if (PyObject_HasAttrString(exception_type, "key")) {
PyObject_SetAttrString(exception_type, "key", py_key);
}
if (PyObject_HasAttrString(exception_type, "bin")) {
PyObject_SetAttrString(exception_type, "bin", Py_None);
}
PyErr_SetObject(exception_type, py_err);
Py_DECREF(py_err);
raise_exception_base(&err, py_key, Py_None, Py_None, Py_None, Py_None);
return NULL;
}

Expand Down
22 changes: 3 additions & 19 deletions src/main/client/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,12 @@ static bool AerospikeClient_InfoAll_each(as_error *err, const as_node *node,

CLEANUP:
if (udata_ptr->error.code != AEROSPIKE_OK) {
PyObject *py_err = NULL;
error_to_pyobject(&udata_ptr->error, &py_err);
PyObject *exception_type = raise_exception_old(&udata_ptr->error);
set_aerospike_exc_attrs_using_tuple_of_attrs(exception_type, py_err);
PyErr_SetObject(exception_type, py_err);
Py_DECREF(py_err);
raise_exception(&udata_ptr->error);
PyGILState_Release(gil_state);
return false;
}
if (err->code != AEROSPIKE_OK) {
PyObject *py_err = NULL;
error_to_pyobject(err, &py_err);
PyObject *exception_type = raise_exception_old(err);
set_aerospike_exc_attrs_using_tuple_of_attrs(exception_type, py_err);
PyErr_SetObject(exception_type, py_err);
Py_DECREF(py_err);
raise_exception(err);
PyGILState_Release(gil_state);
return false;
}
Expand Down Expand Up @@ -211,13 +201,7 @@ static PyObject *AerospikeClient_InfoAll_Invoke(AerospikeClient *self,
Py_DECREF(py_ustr);
}
if (info_callback_udata.error.code != AEROSPIKE_OK) {
PyObject *py_err = NULL;
error_to_pyobject(&info_callback_udata.error, &py_err);
PyObject *exception_type =
raise_exception_old(&info_callback_udata.error);
set_aerospike_exc_attrs_using_tuple_of_attrs(exception_type, py_err);
PyErr_SetObject(exception_type, py_err);
Py_DECREF(py_err);
raise_exception(&info_callback_udata.error);
if (py_nodes) {
Py_DECREF(py_nodes);
}
Expand Down
23 changes: 2 additions & 21 deletions src/main/client/operate.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,7 @@ static inline bool isExprOp(int op);

#define EXCEPTION_ON_ERROR() \
if (err.code != AEROSPIKE_OK) { \
PyObject *py_err = NULL; \
error_to_pyobject(&err, &py_err); \
PyObject *exception_type = raise_exception_old(&err); \
set_aerospike_exc_attrs_using_tuple_of_attrs(exception_type, py_err); \
if (PyObject_HasAttrString(exception_type, "key")) { \
PyObject_SetAttrString(exception_type, "key", py_key); \
} \
if (PyObject_HasAttrString(exception_type, "bin")) { \
PyObject_SetAttrString(exception_type, "bin", py_bin); \
} \
PyErr_SetObject(exception_type, py_err); \
Py_DECREF(py_err); \
raise_exception_base(&err, py_key, py_bin, Py_None, Py_None, Py_None); \
return NULL; \
}

Expand Down Expand Up @@ -1211,15 +1200,7 @@ PyObject *AerospikeClient_OperateOrdered(AerospikeClient *self, PyObject *args,

CLEANUP:
if (err.code != AEROSPIKE_OK) {
PyObject *py_err = NULL;
error_to_pyobject(&err, &py_err);
PyObject *exception_type = raise_exception_old(&err);
set_aerospike_exc_attrs_using_tuple_of_attrs(exception_type, py_err);
if (PyObject_HasAttrString(exception_type, "key")) {
PyObject_SetAttrString(exception_type, "key", py_key);
}
PyErr_SetObject(exception_type, py_err);
Py_DECREF(py_err);
raise_exception_base(&err, py_key, Py_None, Py_None, Py_None, Py_None);
return NULL;
}
return py_result;
Expand Down
13 changes: 1 addition & 12 deletions src/main/client/put.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,7 @@ PyObject *AerospikeClient_Put_Invoke(AerospikeClient *self, PyObject *py_key,

// If an error occurred, tell Python.
if (err.code != AEROSPIKE_OK) {
PyObject *py_err = NULL;
error_to_pyobject(&err, &py_err);
PyObject *exception_type = raise_exception_old(&err);
set_aerospike_exc_attrs_using_tuple_of_attrs(exception_type, py_err);
if (PyObject_HasAttrString(exception_type, "key")) {
PyObject_SetAttrString(exception_type, "key", py_key);
}
if (PyObject_HasAttrString(exception_type, "bin")) {
PyObject_SetAttrString(exception_type, "bin", py_bins);
}
PyErr_SetObject(exception_type, py_err);
Py_DECREF(py_err);
raise_exception_base(&err, py_key, py_bins, Py_None, Py_None, Py_None);
return NULL;
}

Expand Down
27 changes: 22 additions & 5 deletions src/main/client/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,23 +376,40 @@ static PyObject *AerospikeClient_QueryApply_Invoke(
}

PyObject *py_op = PyTuple_GetItem(py_predicate, 0);
PyObject *py_op_data = PyTuple_GetItem(py_predicate, 1);
if (!py_op) {
as_error_update(&err, AEROSPIKE_ERR_CLIENT,
"Failed to get predicate elements");
goto CLEANUP;
}

if (!py_op || !py_op_data) {
PyObject *py_op_data = PyTuple_GetItem(py_predicate, 1);
if (!py_op_data) {
as_error_update(&err, AEROSPIKE_ERR_CLIENT,
"Failed to get predicate elements");
goto CLEANUP;
}
if (!PyLong_Check(py_op_data)) {
else if (!PyLong_Check(py_op_data)) {
as_error_update(&err, AEROSPIKE_ERR_PARAM, "Invalid Predicate");
goto CLEANUP;
}

as_predicate_type op = (as_predicate_type)PyLong_AsLong(py_op);
long op = PyLong_AsLong(py_op);
if (op == -1 && PyErr_Occurred()) {
as_error_update(&err, AEROSPIKE_ERR_PARAM,
"unknown predicate type");
goto CLEANUP;
}

as_index_datatype op_data =
(as_index_datatype)PyLong_AsLong(py_op_data);
if (op == -1 && PyErr_Occurred()) {
as_error_update(&err, AEROSPIKE_ERR_PARAM,
"unknown index data type");
goto CLEANUP;
}

rc = query_where_add(
&query_ptr, op, op_data,
&query_ptr, (as_predicate_type)op, op_data,
size > 2 ? PyTuple_GetItem(py_predicate, 2) : Py_None,
size > 3 ? PyTuple_GetItem(py_predicate, 3) : Py_None,
size > 4 ? PyTuple_GetItem(py_predicate, 4) : Py_None,
Expand Down
13 changes: 1 addition & 12 deletions src/main/client/remove.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,7 @@ PyObject *AerospikeClient_Remove_Invoke(AerospikeClient *self, PyObject *py_key,
}

if (err.code != AEROSPIKE_OK) {
PyObject *py_err = NULL;
error_to_pyobject(&err, &py_err);
PyObject *exception_type = raise_exception_old(&err);
set_aerospike_exc_attrs_using_tuple_of_attrs(exception_type, py_err);
if (PyObject_HasAttrString(exception_type, "key")) {
PyObject_SetAttrString(exception_type, "key", py_key);
}
if (PyObject_HasAttrString(exception_type, "bin")) {
PyObject_SetAttrString(exception_type, "bin", Py_None);
}
PyErr_SetObject(exception_type, py_err);
Py_DECREF(py_err);
raise_exception_base(&err, py_key, Py_None, Py_None, Py_None, Py_None);
return NULL;
}

Expand Down
30 changes: 2 additions & 28 deletions src/main/client/remove_bin.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,7 @@ AerospikeClient_RemoveBin_Invoke(AerospikeClient *self, PyObject *py_key,
}

if (err->code != AEROSPIKE_OK) {
PyObject *py_err = NULL;
error_to_pyobject(err, &py_err);
PyObject *exception_type = raise_exception_old(err);
set_aerospike_exc_attrs_using_tuple_of_attrs(exception_type, py_err);
if (PyObject_HasAttrString(exception_type, "key")) {
PyObject_SetAttrString(exception_type, "key", py_key);
}
if (PyObject_HasAttrString(exception_type, "bin")) {
PyObject_SetAttrString(exception_type, "bin", Py_None);
}
PyErr_SetObject(exception_type, py_err);
Py_DECREF(py_err);
raise_exception_base(err, py_key, Py_None, Py_None, Py_None, Py_None);
return NULL;
}
return PyLong_FromLong(0);
Expand All @@ -197,7 +186,6 @@ PyObject *AerospikeClient_RemoveBin(AerospikeClient *self, PyObject *args,
PyObject *py_key = NULL;
PyObject *py_policy = NULL;
PyObject *py_binList = NULL;
PyObject *py_result = NULL;
PyObject *py_meta = NULL;

as_error err;
Expand Down Expand Up @@ -236,20 +224,6 @@ PyObject *AerospikeClient_RemoveBin(AerospikeClient *self, PyObject *args,

CLEANUP:

if (err.code != AEROSPIKE_OK || !py_result) {
PyObject *py_err = NULL;
error_to_pyobject(&err, &py_err);
PyObject *exception_type = raise_exception_old(&err);
set_aerospike_exc_attrs_using_tuple_of_attrs(exception_type, py_err);
if (PyObject_HasAttrString(exception_type, "key")) {
PyObject_SetAttrString(exception_type, "key", py_key);
}
if (PyObject_HasAttrString(exception_type, "bin")) {
PyObject_SetAttrString(exception_type, "bin", Py_None);
}
PyErr_SetObject(exception_type, py_err);
Py_DECREF(py_err);
return NULL;
}
raise_exception_base(&err, py_key, Py_None, Py_None, Py_None, Py_None);
return NULL;
}
Loading
Loading