Skip to content

Commit

Permalink
Python bindings: gdal.Translate()/gdal.Warp()/etc.: make sure not to …
Browse files Browse the repository at this point in the history
…modify provided options[] array (fixes #9259)
  • Loading branch information
rouault committed Feb 20, 2024
1 parent e7f14b7 commit 2d1c988
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions swig/include/python/gdal_python.i
Original file line number Diff line number Diff line change
Expand Up @@ -2011,7 +2011,8 @@ def InfoOptions(options=None, format='text', deserialize=True,
if '-json' in new_options:
format = 'json'
else:
new_options = options
import copy
new_options = copy.copy(options)
if format == 'json':
new_options += ['-json']
elif format != "text":
Expand Down Expand Up @@ -2130,7 +2131,8 @@ def VectorInfoOptions(options=None,
if '-json' in new_options:
format = 'json'
else:
new_options = options
import copy
new_options = copy.copy(options)
if format == 'json':
new_options += ['-json']
elif format != "text":
Expand Down Expand Up @@ -2207,7 +2209,8 @@ def MultiDimInfoOptions(options=None, detailed=False, array=None, arrayoptions=N
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
import copy
new_options = copy.copy(options)
if detailed:
new_options += ['-detailed']
if array:
Expand Down Expand Up @@ -2367,7 +2370,8 @@ def TranslateOptions(options=None, format=None,
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
import copy
new_options = copy.copy(options)
if format is not None:
new_options += ['-of', format]
if outputType != gdalconst.GDT_Unknown:
Expand Down Expand Up @@ -2633,7 +2637,8 @@ def WarpOptions(options=None, format=None,
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
import copy
new_options = copy.copy(options)
if srcBands:
for b in srcBands:
new_options += ['-srcband', str(b)]
Expand Down Expand Up @@ -2979,7 +2984,8 @@ def VectorTranslateOptions(options=None, format=None,
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
import copy
new_options = copy.copy(options)
if format is not None:
new_options += ['-f', format]
if srcSRS is not None:
Expand Down Expand Up @@ -3248,7 +3254,8 @@ def DEMProcessingOptions(options=None, colorFilename=None, format=None,
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
import copy
new_options = copy.copy(options)
if format is not None:
new_options += ['-of', format]
if creationOptions is not None:
Expand Down Expand Up @@ -3380,7 +3387,8 @@ def NearblackOptions(options=None, format=None,
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
import copy
new_options = copy.copy(options)
if format is not None:
new_options += ['-of', format]
if creationOptions is not None:
Expand Down Expand Up @@ -3525,7 +3533,8 @@ def GridOptions(options=None, format=None,
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
import copy
new_options = copy.copy(options)
if format is not None:
new_options += ['-of', format]
if outputType != gdalconst.GDT_Unknown:
Expand Down Expand Up @@ -3692,7 +3701,8 @@ def RasterizeOptions(options=None, format=None,
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
import copy
new_options = copy.copy(options)
if format is not None:
new_options += ['-of', format]
if outputType != gdalconst.GDT_Unknown:
Expand Down Expand Up @@ -3881,7 +3891,8 @@ def FootprintOptions(options=None,
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
import copy
new_options = copy.copy(options)
if format is not None:
new_options += ['-of', format]
if bands is not None:
Expand Down Expand Up @@ -4106,7 +4117,8 @@ def BuildVRTOptions(options=None,
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
import copy
new_options = copy.copy(options)
if resolution is not None:
new_options += ['-resolution', str(resolution)]
if outputBounds is not None:
Expand Down Expand Up @@ -4278,7 +4290,8 @@ def TileIndexOptions(options=None,
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
import copy
new_options = copy.copy(options)
if overwrite:
new_options += ['-overwrite']
if recursive:
Expand Down Expand Up @@ -4434,7 +4447,8 @@ def MultiDimTranslateOptions(options=None, format=None, creationOptions=None,
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
import copy
new_options = copy.copy(options)
if format is not None:
new_options += ['-of', format]
if creationOptions is not None:
Expand Down

0 comments on commit 2d1c988

Please sign in to comment.