@@ -252,9 +252,9 @@ def _save_code(pickler, obj):
252252 else os .path .basename (obj .co_filename )
253253 )
254254 co_firstlineno = 1
255- # The rest is the same as in the original dill implementation
255+ # The rest is the same as in the original dill implementation (with also a version check for 3.10)
256256 if dill ._dill .PY3 :
257- if hasattr (obj , "co_posonlyargcount" ):
257+ if hasattr (obj , "co_posonlyargcount" ): # python 3.8 (16 args)
258258 args = (
259259 obj .co_argcount ,
260260 obj .co_posonlyargcount ,
@@ -269,11 +269,11 @@ def _save_code(pickler, obj):
269269 co_filename ,
270270 obj .co_name ,
271271 co_firstlineno ,
272- obj .co_lnotab ,
272+ obj .co_linetable if sys . version_info >= ( 3 , 10 ) else obj . co_lnotab ,
273273 obj .co_freevars ,
274274 obj .co_cellvars ,
275275 )
276- else :
276+ else : # python 3.7 (15 args)
277277 args = (
278278 obj .co_argcount ,
279279 obj .co_kwonlyargcount ,
@@ -354,11 +354,12 @@ def save_code(pickler, obj):
354354 # The rest is the same as in the original dill implementation, except for the replacements:
355355 # - obj.co_filename => co_filename
356356 # - obj.co_firstlineno => co_firstlineno
357+ # - obj.co_lnotab => obj.co_linetable for >= 3.10 since co_lnotab was deprecated
357358 ############################################################################################################
358359
359360 if hasattr (obj , "co_endlinetable" ): # python 3.11a (20 args)
360361 args = (
361- obj .co_lnotab , # for < python 3.10 [not counted in args]
362+ obj .co_linetable , # Modification for huggingface/datasets ############################################
362363 obj .co_argcount ,
363364 obj .co_posonlyargcount ,
364365 obj .co_kwonlyargcount ,
@@ -382,7 +383,7 @@ def save_code(pickler, obj):
382383 )
383384 elif hasattr (obj , "co_exceptiontable" ): # python 3.11 (18 args)
384385 args = (
385- obj .co_lnotab , # for < python 3.10 [not counted in args]
386+ obj .co_linetable , # Modification for huggingface/datasets #######################################
386387 obj .co_argcount ,
387388 obj .co_posonlyargcount ,
388389 obj .co_kwonlyargcount ,
@@ -404,7 +405,7 @@ def save_code(pickler, obj):
404405 )
405406 elif hasattr (obj , "co_linetable" ): # python 3.10 (16 args)
406407 args = (
407- obj .co_lnotab , # for < python 3.10 [not counted in args]
408+ obj .co_linetable , # Modification for huggingface/datasets #######################################
408409 obj .co_argcount ,
409410 obj .co_posonlyargcount ,
410411 obj .co_kwonlyargcount ,
0 commit comments