Download tasks/codeql_python_benchmark51_v2/pyvul-3819b1a7530257524a75/patch.diff from Benchanything/checkerbench: direct link, hf CLI and curl.
- Browser
- Download file 1.29 kB
-
https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_python_benchmark51_v2/pyvul-3819b1a7530257524a75/patch.diff
- Command line
-
hf download hf://datasets/Benchanything/checkerbench/tasks/codeql_python_benchmark51_v2/pyvul-3819b1a7530257524a75/patch.diff
-
curl -L -o patch.diff https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_python_benchmark51_v2/pyvul-3819b1a7530257524a75/patch.diff
1.29 kB
| diff --git a/templated_dictionary/__init__.py b/templated_dictionary/__init__.py | |
| index 994166a..ec004c0 100644 | |
| --- a/templated_dictionary/__init__.py | |
| +++ b/templated_dictionary/__init__.py | |
| # vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=python:textwidth=0: | |
| from collections.abc import MutableMapping | |
| -import jinja2 | |
| +from jinja2 import sandbox | |
| # pylint: disable=no-member,unsupported-assignment-operation | |
| class TemplatedDictionary(MutableMapping): | |
| ''' | |
| self.__dict__.update(*args, **kwargs) | |
| + self.sandbox = sandbox.SandboxedEnvironment(keep_trailing_newline=True) | |
| + | |
| self._aliases = {} | |
| if alias_spec: | |
| for aliased_to, aliases in alias_spec.items(): | |
| class TemplatedDictionary(MutableMapping): | |
| orig = last = value | |
| max_recursion = self.__dict__.get('jinja_max_recursion', 5) | |
| for _ in range(max_recursion): | |
| - template = jinja2.Template(value, keep_trailing_newline=True) | |
| - value = _to_native(template.render(self.__dict__)) | |
| + value = _to_native(self.sandbox.from_string(value).render(self.__dict__, func=lambda:None)) | |
| if value == last: | |
| return value | |
| last = value | |