File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change 27
27
28
28
#include "dpctl_capi.h"
29
29
#include <complex>
30
+ #include <exception>
30
31
#include <memory>
31
32
#include <pybind11/pybind11.h>
32
33
#include <sycl/sycl.hpp>
@@ -759,9 +760,6 @@ class usm_memory : public py::object
759
760
auto const & api = ::dpctl ::detail ::dpctl_capi ::get ();
760
761
DPCTLSyclUSMRef usm_ref = reinterpret_cast < DPCTLSyclUSMRef > (usm_ptr );
761
762
sycl ::queue * q_ptr = new sycl ::queue (q );
762
- if (!q_ptr ) {
763
- throw std ::bad_alloc ();
764
- }
765
763
DPCTLSyclQueueRef QRef = reinterpret_cast < DPCTLSyclQueueRef > (q_ptr );
766
764
767
765
auto vacuous_destructor = []() {};
@@ -777,12 +775,17 @@ class usm_memory : public py::object
777
775
0 );
778
776
779
777
if (is_ok ) {
780
- std ::shared_ptr < void > * opaque_ptr =
781
- new std ::shared_ptr < void > (shptr );
782
- if (!opaque_ptr ) {
778
+ std ::shared_ptr < void > * opaque_ptr = nullptr ;
779
+ std ::exception_ptr eptr ;
780
+ try {
781
+ opaque_ptr = new std ::shared_ptr < void > (shptr );
782
+ } catch (const std ::exception & e ) {
783
+ eptr = std ::make_exception_ptr (e );
784
+ }
785
+ if (eptr ) {
783
786
Py_DECREF (_memory );
784
787
delete q_ptr ;
785
- throw std ::bad_alloc ( );
788
+ std ::rethrow_exception ( eptr );
786
789
}
787
790
Py_MemoryObject * memobj =
788
791
reinterpret_cast < Py_MemoryObject * > (_memory );
You can’t perform that action at this time.
0 commit comments