You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/pythonx.ex
+53-20Lines changed: 53 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -606,33 +606,51 @@ defmodule Pythonx do
606
606
{:ok,binary}->
607
607
Pythonx.NIF.load_object(binary)
608
608
609
-
{:error,"pickle",%Pythonx.Error{}=error}->
610
-
raiseArgumentError,"""
611
-
failed to serialize the given object using the built-in pickle module. The pickle module does not support all object types, for extended pickling support add the following package:
612
-
613
-
cloudpickle==3.1.2
614
-
615
-
Original error: #{Exception.message(error)}
616
-
"""
617
-
618
-
{:error,module,%Pythonx.Error{}=error}->
619
-
raiseRuntimeError,"""
620
-
failed to serialize the given object using the #{module} module.
621
-
622
-
Original error: #{Exception.message(error)}
623
-
"""
624
-
625
-
{:exception,exception}->
609
+
{:error,exception}->
626
610
raiseexception
627
611
end
628
612
end
629
613
630
614
@docfalse
631
615
def__dump__(object)do
632
616
trydo
633
-
Pythonx.NIF.dump_object(object)
617
+
casePythonx.NIF.dump_object(object)do
618
+
{:ok,binary}->
619
+
{:ok,binary}
620
+
621
+
{:error,"pickle",%Pythonx.Error{}=error}->
622
+
{:error,
623
+
ArgumentError.exception("""
624
+
failed to serialize the given object using the built-in pickle module. The pickle module does not support all object types, for extended pickling support add the following package:
625
+
626
+
cloudpickle==3.1.2
627
+
628
+
Original error: #{Exception.message(error)}
629
+
""")}
630
+
631
+
{:error,module,%Pythonx.Error{}=error}->
632
+
{:error,
633
+
RuntimeError.exception("""
634
+
failed to serialize the given object using the #{module} module.
635
+
636
+
Original error: #{Exception.message(error)}
637
+
""")}
638
+
end
634
639
rescue
635
-
error->{:exception,error}
640
+
errorinPythonx.Error->
641
+
# We don't want to return Pythonx.Error as is, because we
642
+
# would need more elaborate logic to track it, like we do in
643
+
# remote_eval/4, so we convert it into a RuntimeError instead.
644
+
# This should only really happen if there is an implementation
645
+
# error in Pythonx itself, since pickling errors are handled
646
+
# explicitly above.
647
+
{:error,
648
+
RuntimeError.exception("""
649
+
failed to serialize the given object, got Python exception: #{Exception.message(error)}
0 commit comments