Skip to content

Commit 3ff0e69

Browse files
LeonardoEmiliLeonardo Emili
andauthored
Avoid mutating user-provided arguments in preprocessing utils (#42126)
* fix: deepcopy kwargs to avoid mutating user-provided arguments * mod: shallow copy instead of deepcopy --------- Co-authored-by: Leonardo Emili <lemili@apple.com>
1 parent 31839d7 commit 3ff0e69

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/transformers/processing_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,9 @@ class MyProcessingKwargs(ProcessingKwargs, CommonKwargs, TextKwargs, ImagesKwarg
12261226
Dictionary of per-modality kwargs to be passed to each modality-specific processor.
12271227
12281228
"""
1229+
# holding a copy to avoid mutating user-provided arguments
1230+
kwargs = kwargs.copy()
1231+
12291232
# Initialize dictionaries
12301233
output_kwargs = {
12311234
"text_kwargs": {},

0 commit comments

Comments
 (0)