@@ -252,9 +252,9 @@ def _save_code(pickler, obj):
252
252
else os .path .basename (obj .co_filename )
253
253
)
254
254
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)
256
256
if dill ._dill .PY3 :
257
- if hasattr (obj , "co_posonlyargcount" ):
257
+ if hasattr (obj , "co_posonlyargcount" ): # python 3.8 (16 args)
258
258
args = (
259
259
obj .co_argcount ,
260
260
obj .co_posonlyargcount ,
@@ -269,11 +269,11 @@ def _save_code(pickler, obj):
269
269
co_filename ,
270
270
obj .co_name ,
271
271
co_firstlineno ,
272
- obj .co_lnotab ,
272
+ obj .co_linetable if sys . version_info >= ( 3 , 10 ) else obj . co_lnotab ,
273
273
obj .co_freevars ,
274
274
obj .co_cellvars ,
275
275
)
276
- else :
276
+ else : # python 3.7 (15 args)
277
277
args = (
278
278
obj .co_argcount ,
279
279
obj .co_kwonlyargcount ,
@@ -354,11 +354,12 @@ def save_code(pickler, obj):
354
354
# The rest is the same as in the original dill implementation, except for the replacements:
355
355
# - obj.co_filename => co_filename
356
356
# - obj.co_firstlineno => co_firstlineno
357
+ # - obj.co_lnotab => obj.co_linetable for >= 3.10 since co_lnotab was deprecated
357
358
############################################################################################################
358
359
359
360
if hasattr (obj , "co_endlinetable" ): # python 3.11a (20 args)
360
361
args = (
361
- obj .co_lnotab , # for < python 3.10 [not counted in args]
362
+ obj .co_linetable , # Modification for huggingface/datasets ############################################
362
363
obj .co_argcount ,
363
364
obj .co_posonlyargcount ,
364
365
obj .co_kwonlyargcount ,
@@ -382,7 +383,7 @@ def save_code(pickler, obj):
382
383
)
383
384
elif hasattr (obj , "co_exceptiontable" ): # python 3.11 (18 args)
384
385
args = (
385
- obj .co_lnotab , # for < python 3.10 [not counted in args]
386
+ obj .co_linetable , # Modification for huggingface/datasets #######################################
386
387
obj .co_argcount ,
387
388
obj .co_posonlyargcount ,
388
389
obj .co_kwonlyargcount ,
@@ -404,7 +405,7 @@ def save_code(pickler, obj):
404
405
)
405
406
elif hasattr (obj , "co_linetable" ): # python 3.10 (16 args)
406
407
args = (
407
- obj .co_lnotab , # for < python 3.10 [not counted in args]
408
+ obj .co_linetable , # Modification for huggingface/datasets #######################################
408
409
obj .co_argcount ,
409
410
obj .co_posonlyargcount ,
410
411
obj .co_kwonlyargcount ,
0 commit comments