File tree 2 files changed +22
-2
lines changed
2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -231,14 +231,16 @@ def _save(
231
231
if self ._fallback (cloudpickle_fallback ):
232
232
attacks += [(self ._CLOUDPICKLE , cloudpickle .dump )]
233
233
234
- e = None
234
+ e : Exception | None = None
235
235
for suffix , save_method in attacks :
236
+ e = None
236
237
p = filename .with_suffix (suffix )
237
238
try :
238
239
with open (p , "wb" ) as filehandle :
239
240
save_method (node , filehandle )
240
241
return
241
- except Exception :
242
+ except Exception as ee :
243
+ e = ee
242
244
p .unlink (missing_ok = True )
243
245
if e is not None :
244
246
raise e
Original file line number Diff line number Diff line change 2
2
from pathlib import Path
3
3
from tempfile import TemporaryDirectory
4
4
5
+ import cloudpickle
6
+ from pint import UnitRegistry
7
+
5
8
from pyiron_workflow .nodes .function import as_function_node
6
9
from pyiron_workflow .nodes .standard import UserInput
7
10
from pyiron_workflow .storage import PickleStorage , TypeNotFoundError , available_backends
@@ -134,6 +137,21 @@ def Unimportable(x):
134
137
finally :
135
138
interface .delete (node = u , cloudpickle_fallback = True )
136
139
140
+ def test_uncloudpickleable (self ):
141
+ ureg = UnitRegistry ()
142
+ with self .assertRaises (
143
+ TypeError ,
144
+ msg = "Sanity check that this can't even be cloudpickled"
145
+ ):
146
+ cloudpickle .dumps (ureg )
147
+
148
+ interface = PickleStorage (cloudpickle_fallback = True )
149
+ n = UserInput (ureg , label = "uncloudpicklable_node" )
150
+ with self .assertRaises (
151
+ TypeError ,
152
+ msg = "Exception should be caught and saving should fail"
153
+ ):
154
+ interface .save (n )
137
155
138
156
if __name__ == "__main__" :
139
157
unittest .main ()
You can’t perform that action at this time.
0 commit comments