Skip to content

Commit

Permalink
Refactor the incomplete stream logic
Browse files Browse the repository at this point in the history
  • Loading branch information
LinZhihao-723 committed Dec 6, 2023
1 parent 9dfd5dd commit 2ca1109
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/clp_ffi_py/ir/native/decoding_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,15 @@ auto generic_decode_log_events(
if (decoder_buffer->try_read()) {
continue;
}
if (false == allow_incomplete_stream) {
return nullptr;
if (allow_incomplete_stream
&& static_cast<bool>(
PyErr_ExceptionMatches(PyDecoderBuffer::get_py_incomplete_stream_error())
))
{
PyErr_Clear();
Py_RETURN_NONE;
}
auto const is_incomplete_stream_error{static_cast<bool>(
PyErr_ExceptionMatches(PyDecoderBuffer::get_py_incomplete_stream_error())
)};
if (false == is_incomplete_stream_error) {
return nullptr;
}
PyErr_Clear();
Py_RETURN_NONE;
return nullptr;
}
if (ffi::ir_stream::IRErrorCode_Eof == err) {
Py_RETURN_NONE;
Expand Down

0 comments on commit 2ca1109

Please sign in to comment.