Download tasks/codeql_python_benchmark51_v2/pyvul-4954e5890cce23c8b03d/patch.diff from Benchanything/checkerbench: direct link, hf CLI and curl.
- Browser
- Download file 2.6 kB
-
https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_python_benchmark51_v2/pyvul-4954e5890cce23c8b03d/patch.diff
- Command line
-
hf download hf://datasets/Benchanything/checkerbench/tasks/codeql_python_benchmark51_v2/pyvul-4954e5890cce23c8b03d/patch.diff
-
curl -L -o patch.diff https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_python_benchmark51_v2/pyvul-4954e5890cce23c8b03d/patch.diff
2.6 kB
| diff --git a/PIL/EpsImagePlugin.py b/PIL/EpsImagePlugin.py | |
| index a8706b05f..fcfae8a81 100644 | |
| --- a/PIL/EpsImagePlugin.py | |
| +++ b/PIL/EpsImagePlugin.py | |
| def Ghostscript(tile, size, fp, scale=1): | |
| import tempfile, os, subprocess | |
| - file = tempfile.mktemp() | |
| + out_fd, file = tempfile.mkstemp() | |
| + os.close(out_fd) | |
| # Build ghostscript command | |
| command = ["gs", | |
| diff --git a/PIL/Image.py b/PIL/Image.py | |
| index 87631d6f7..915f5b1df 100644 | |
| --- a/PIL/Image.py | |
| +++ b/PIL/Image.py | |
| class Image: | |
| self.readonly = 0 | |
| def _dump(self, file=None, format=None): | |
| - import tempfile | |
| + import tempfile, os | |
| if not file: | |
| - file = tempfile.mktemp() | |
| + f, file = tempfile.mkstemp(format or '') | |
| + os.close(f) | |
| + | |
| self.load() | |
| if not format or format == "PPM": | |
| self.im.save_ppm(file) | |
| else: | |
| - file = file + "." + format | |
| + if file.endswith(format): | |
| + file = file + "." + format | |
| self.save(file, format) | |
| return file | |
| diff --git a/PIL/IptcImagePlugin.py b/PIL/IptcImagePlugin.py | |
| index 157b73509..104153002 100644 | |
| --- a/PIL/IptcImagePlugin.py | |
| +++ b/PIL/IptcImagePlugin.py | |
| class IptcImageFile(ImageFile.ImageFile): | |
| self.fp.seek(offset) | |
| # Copy image data to temporary file | |
| - outfile = tempfile.mktemp() | |
| - o = open(outfile, "wb") | |
| + o_fd, outfile = tempfile.mkstemp(text=False) | |
| + o = os.fdopen(o_fd) | |
| if encoding == "raw": | |
| # To simplify access to the extracted file, | |
| # prepend a PPM header | |
| diff --git a/PIL/JpegImagePlugin.py b/PIL/JpegImagePlugin.py | |
| index 90d3b5194..67dc5ba7d 100644 | |
| --- a/PIL/JpegImagePlugin.py | |
| +++ b/PIL/JpegImagePlugin.py | |
| class JpegImageFile(ImageFile.ImageFile): | |
| # ALTERNATIVE: handle JPEGs via the IJG command line utilities | |
| import tempfile, os | |
| - file = tempfile.mktemp() | |
| - os.system("djpeg %s >%s" % (self.filename, file)) | |
| + f, path = tempfile.mkstemp() | |
| + os.close(f) | |
| + if os.path.exists(self.filename): | |
| + os.system("djpeg '%s' >'%s'" % (self.filename, path)) | |
| + else: | |
| + raise ValueError("Invalid Filename") | |
| try: | |
| - self.im = Image.core.open_ppm(file) | |
| + self.im = Image.core.open_ppm(path) | |
| finally: | |
| - try: os.unlink(file) | |
| + try: os.unlink(path) | |
| except: pass | |
| self.mode = self.im.mode | |