From 33dffc97c8c6e8411fd108a4e2a53ecd97adcfba Mon Sep 17 00:00:00 2001 From: jboone100 Date: Thu, 24 Mar 2016 10:06:30 -0700 Subject: [PATCH] Don't raise RecordNotFound exception for exists() on nonexistent record --- src/main/client/exists.c | 13 +++++++++++++ test/new_tests/test_exists.py | 8 +++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/client/exists.c b/src/main/client/exists.c index 848923902..17a76903d 100644 --- a/src/main/client/exists.c +++ b/src/main/client/exists.c @@ -99,6 +99,19 @@ extern PyObject * AerospikeClient_Exists_Invoke( py_result = PyTuple_New(2); PyTuple_SetItem(py_result, 0, py_result_key); PyTuple_SetItem(py_result, 1, py_result_meta); + } else if( err.code == AEROSPIKE_ERR_RECORD_NOT_FOUND ) { + as_error_reset(&err); + + PyObject * py_result_key = NULL; + PyObject * py_result_meta = Py_None; + + key_to_pyobject(&err, &key, &py_result_key); + + py_result = PyTuple_New(2); + PyTuple_SetItem(py_result, 0, py_result_key); + PyTuple_SetItem(py_result, 1, py_result_meta); + + Py_INCREF(py_result_meta); } else { as_error_update(&err, err.code, NULL); diff --git a/test/new_tests/test_exists.py b/test/new_tests/test_exists.py index 6b3a45e39..f6983aca2 100644 --- a/test/new_tests/test_exists.py +++ b/test/new_tests/test_exists.py @@ -81,11 +81,9 @@ def test_neg_exists_with_record_expiry(self, put_data): policy = {'timeout': 1000} put_data(self.as_connection, key, rec, meta, policy) time.sleep(2) - try: - key, meta = self.as_connection.exists(key) - assert meta is None - except e.RecordNotFound as exception: - assert exception.code == 2 + + key, meta = self.as_connection.exists(key) + assert meta is None @pytest.mark.parametrize("key, ex, ex_code", [ # reason for xfail CLIENT-533