text
stringlengths
79
3.72M
<vulnerable_code> """ pass def parse_arg(self, argname: str, displayname: str): if self.format_unit == 'O&': return """ if (!{converter}({argname}, &{paramname})) {{{{ self.default = bool(self.default) self.c_default = str(int(self.default)...
<vulnerable_code> cpp_endif = "#endif /* " + conditional + " */" assert clinic is not None assert f.full_name is not None if methoddef_define and f.full_name not in clinic.ifndef_symbols: clinic.ifndef_symbols.add(f.full_name) methoddef_ifn...
<vulnerable_code> ('LOAD_NAME', 1, 11), ('POP_JUMP_IF_TRUE', lbl := self.Label(), 12), ('LOAD_CONST', 2, 13), lbl, ('LOAD_CONST', 3, 14), ('RETURN_VALUE', 14), expected_insts = [ ('LOAD_NAME', 1, 11), ('POP_JUMP_IF_TR...
<vulnerable_code> return fixed; } static int insert_prefix_instructions(_PyCompile_CodeUnitMetadata *umd, basicblock *entryblock, int *fixed, int nfreevars, int code_flags) assert(umd->u_firstlineno > 0); /* Add the generator prefix instructions. */ if (code_flags & (CO_GENER...
<vulnerable_code> return stack; } Py_LOCAL_INLINE(void) stackdepth_push(basicblock ***sp, basicblock *b, int depth) { assert(b->b_startdepth < 0 || b->b_startdepth == depth); if (b->b_startdepth < depth && b->b_startdepth < 100) { assert(b->b_startdepth < 0); b->b_startdepth = depth; ...
<vulnerable_code> a='[' b=NAME c=for_if_clauses d=']' { _PyAST_ListComp(b, c, EXTRA) } ) for_if_clauses[asdl_comprehension_seq*]: ( a[asdl_comprehension_seq*]=(y=[ASYNC] 'for' a=NAME 'in' b=NAME c[asdl_expr_seq*]=('if' z=NAME { z })* { _PyAST_comprehension(_PyAST_N...
<vulnerable_code> def test_async(self): self.check_tokenize('async = 1', """\ ASYNC 'async' (1, 0) (1, 5) EQUAL '=' (1, 6) (1, 7) NUMBER '1' (1, 8) (1, 9) """) NAME 'a' (1, 0) (1, 1) EQUAL '=' (1, 2) (1, 3) LP...
<vulnerable_code> self.assertEqual(tree.body[1].type_comment, None) def test_asyncvar(self): for tree in self.parse_all(asyncvar, maxver=6): pass def test_asynccomp(self): for tree in self.parse_all(asynccomp, minver=6):<commit_title>[PATCH 016/395] Small fixes to code gener...
<vulnerable_code>COLONEQUAL = 53 EXCLAMATION = 54 OP = 55 AWAIT = 56 ASYNC = 57 TYPE_IGNORE = 58 TYPE_COMMENT = 59 SOFT_KEYWORD = 60 FSTRING_START = 61 FSTRING_MIDDLE = 62 FSTRING_END = 63 COMMENT = 64 NL = 65 # These aren't used by the C tokenizer but are needed for tokenize.py ERRORTOKEN = 66 ENCODING = 67 N_TOKENS =...
<vulnerable_code> (KeywordToken[]) {{NULL, -1}}, (KeywordToken[]) {{NULL, -1}}, (KeywordToken[]) { {"if", 642}, {"as", 640}, {"in", 651}, {"or", 574}, {"is", 582}, {NULL, -1}, }, (KeywordToken[]) { {"del", 604}, {"def", 652}, {"f...
<vulnerable_code> if (flags->cf_flags & PyCF_TYPE_COMMENTS) { parser_flags |= PyPARSE_TYPE_COMMENTS; } if ((flags->cf_flags & PyCF_ONLY_AST) && flags->cf_feature_version < 7) { parser_flags |= PyPARSE_ASYNC_HACKS; } if (flags->cf_flags & PyCF_ALLOW_INCOMPLETE_INPUT) { parser_f...
<vulnerable_code> "COLONEQUAL", "EXCLAMATION", "OP", "AWAIT", "ASYNC", "TYPE_IGNORE", "TYPE_COMMENT", "SOFT_KEYWORD",<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I found in PR gh-106798 (issue gh-106797) and in PR gh-106716 (is...
<vulnerable_code> tok->decoding_buffer = NULL; tok->readline = NULL; tok->type_comments = 0; tok->async_hacks = 0; tok->async_def = 0; tok->async_def_indent = 0; tok->async_def_nl = 0; tok->interactive_underflow = IUNDERFLOW_NORMAL; tok->str = NULL; tok->report_warnings = 1; /...
<vulnerable_code> if (type > DEDENT && type < OP) { type = OP; } else if (type == ASYNC || type == AWAIT) { type = NAME; } else if (type == NEWLINE) { Py_DECREF(str); if (!it->tok->implicit_newline) {<commit_title>[PATCH 016/395] Sma...
<vulnerable_code>issoftkeyword = frozenset(softkwlist).__contains__ '''.lstrip() EXTRA_KEYWORDS = ["async", "await"] def main() -> None: parser = argparse.ArgumentParser( description="Generate the Lib/keywords.py file from the grammar." gen.collect_rules() with args.keyword_file as thefile: ...
<vulnerable_code> if name in ("NAME", "NUMBER", "STRING", "OP", "TYPE_COMMENT"): name = name.lower() return name, f"self.{name}()" if name in ("NEWLINE", "DEDENT", "INDENT", "ENDMARKER", "ASYNC", "AWAIT"): # Avoid using names that can be Python keywords ret...
<vulnerable_code> ('py:meth', '_SubParsersAction.add_parser'), ] # Disable Docutils smartquotes for several translations smartquotes_excludes = { 'languages': ['ja', 'fr', 'zh_TW', 'zh_CN'], 'builders': ['man', 'text'],<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>Thes...
<vulnerable_code> ('c:type', 'uintmax_t'), ('c:type', 'va_list'), ('c:type', 'wchar_t'), # Standard C macros ('c:macro', 'LLONG_MAX'), ('c:macro', 'LLONG_MIN'),<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I found in PR gh-106798 (issue...
<vulnerable_code> for step, path in enumerate([other] + list(other.parents)): if self.is_relative_to(path): break else: raise ValueError(f"{str(self)!r} and {str(other)!r} have different anchors") if step and not walk_up: raise ValueError(f"{str...
<vulnerable_code> self.assertRaises(ValueError, p.relative_to, P('a/b/c')) self.assertRaises(ValueError, p.relative_to, P('a/c')) self.assertRaises(ValueError, p.relative_to, P('/a')) self.assertRaises(ValueError, p.relative_to, P('/'), walk_up=True) self.assertRaises(ValueError, ...
<vulnerable_code> 'impl_definition': d('block'), } DestBufferType = dict[str, Callable[..., Any]] DestBufferList = list[DestBufferType] self.destination_buffers_stack: DestBufferList = [] self, name: str, item: int = 0 ): d = s...
<vulnerable_code>class rwbuffer: pass class robuffer: pass def str_converter_key(types, encoding, zeroes): return (frozenset(types), bool(encoding), bool(zeroes)) str_converter_argument_map: dict[str, str] = {} class str_converter(CConverter): type = 'const char *'<commit_title>[PATCH 016/395] Small fixes to...
<vulnerable_code>signatures ("docstrings") for CPython builtins. For more information see https://docs.python.org/3/howto/clinic.html""") cmdline.add_argument("-f", "--force", action='store_true') cmdline.add_argument("-o", "--output", type=str) cmdline.add_argument("-v", "--verbose", action='store_true') ...
<vulnerable_code> /* prepare_localsplus adds instructions for generators that push * and pop an item on the stack. This assertion makes sure there * is space on the stack for that. * It should always be true, because at least one expression is * required to turn a function into a generator. ...
<vulnerable_code> ('c:func', 'vsnprintf'), # Standard C types ('c:type', 'FILE'), ('c:type', '__int'), ('c:type', 'intmax_t'), ('c:type', 'off_t'), ('c:type', 'ptrdiff_t'), ('c:type', 'size_t'), ('c:type', 'ssize_t'), ('c:type', 'time_t'), ('c:type', 'uintmax_t'), ('c:type...
<vulnerable_code> #include "zlib.h" #include "stdbool.h" #if defined(ZLIB_VERNUM) && ZLIB_VERNUM < 0x1221 #error "At least zlib version 1.2.2.1 is required"<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I found in PR gh-106798 (issue gh-106797) and in PR gh-1...
<vulnerable_code> if (PyLong_CheckExact(value)) { int overflow; long longValue; #ifdef TCL_WIDE_INT_TYPE Tcl_WideInt wideValue; #endif longValue = PyLong_AsLongAndOverflow(value, &overflow); if (!overflow) { return Tcl_NewLongObj(longValue); } /* If...
<vulnerable_code>import textwrap import types import unittest PAIR = (0,1) expected = func.events self.assertEqual(events, expected) class MonitoringEventsTest(MonitoringEventsBase, unittest.TestCase): def test_just_pass(self): class CheckEvents(MonitoringTestBase, unittest.TestCase): ...
<vulnerable_code> exc = args[0]; /* fall through */ case 0: ERROR_IF(do_raise(tstate, exc, cause), exception_unwind); break; default: _PyErr_SetString(tstate, PyExc_SystemError, assert(exc && PyExceptionIn...
<vulnerable_code>static void monitor_raise(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *instr); static int monitor_stop_iteration(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *instr); } } ...
<vulnerable_code> [PY_MONITORING_EVENT_C_RETURN] = "C_RETURN", [PY_MONITORING_EVENT_PY_THROW] = "PY_THROW", [PY_MONITORING_EVENT_RAISE] = "RAISE", [PY_MONITORING_EVENT_EXCEPTION_HANDLED] = "EXCEPTION_HANDLED", [PY_MONITORING_EVENT_C_RAISE] = "C_RAISE", [PY_MONITORING_EVENT_PY_UNWIND] = "PY_UNWIND...
<vulnerable_code>_OPNAME_WIDTH = 20 _OPARG_WIDTH = 5 def _get_jump_target(op, arg, offset): """Gets the bytecode offset of the jump target if this is a jump instruction. Otherwise return None. """ deop = _deoptop(op) caches = _inline_cache_entries[deop] if deop in hasjrel: if _is_backw...
<vulnerable_code> }, } _inline_cache_entries = [ sum(_cache_format.get(opname[opcode], {}).values()) for opcode in range(256) ]<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I found in PR gh-106798 (issue gh-106797) and in PR gh-106716 (issue gh-106706...
<vulnerable_code> specialized_opcodes = [ op.lower() for op in opcode._specializations if opcode._inline_cache_entries[opcode.opmap[op]] ] self.assertIn('load_attr', specialized_opcodes) self.assertIn('binary_subscr', specialized_opcodes)<commit_title>[...
<vulnerable_code> iobj.write("\n#ifdef NEED_OPCODE_TABLES\n") iobj.write("\nconst uint8_t _PyOpcode_Caches[256] = {\n") for i, entries in enumerate(opcode["_inline_cache_entries"]): if entries: iobj.write(f" [{opname[i]}] = {entries},\n") iobj.write("};\n")...
<vulnerable_code> E = sys.monitoring.events SIMPLE_EVENTS = [ (E.PY_START, "start"), (E.PY_RESUME, "resume"), (E.PY_RETURN, "return"), (E.PY_YIELD, "yield"), (E.JUMP, "jump"), (E.BRANCH, "branch"), (E.RAISE, "raise"), (E.PY_UNWIND, "unwind"), (E.EXCEPTION_HANDLED, "exception_handled...
<vulnerable_code> PyObject *self = PyMethod_GET_SELF(method); PyObject *func = PyMethod_GET_FUNCTION(method); Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); PyObject *result; if (nargsf & PY_VECTORCALL_ARGUMENTS_OFFSET) { nargs += 1; PyObject *tmp = newargs[0]; newargs[0] = s...
<vulnerable_code> assert(val && PyExceptionInstance_Check(val)); exc = PyExceptionInstance_Class(val); tb = PyException_GetTraceback(val); Py_XDECREF(tb); assert(PyLong_Check(lasti)); (void)lasti; // Shut up compiler warning if asserts are off ...
<vulnerable_code>static void monitor_unwind(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *instr); static void monitor_handled(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *exc); static void monitor...
<vulnerable_code> *opcode_ptr = INSTRUMENTED_INSTRUCTION; } #ifndef NDEBUG static bool instruction_has_event(PyCodeObject *code, int offset) { _Py_CODEUNIT instr = _PyCode_CODE(code)[offset]; int opcode = instr.op.code; if (opcode == INSTRUMENTED_LINE) { opcode = code->_co_monitoring->lines[offs...
<vulnerable_code>} PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywordsFast(PyObject *args, PyObject *keywords, struct _PyArg_Parser *parser, va_list va) { int retval; va_list lva; va_copy(lva, va); retval = vgetargskeywordsfast(args, keywords, parser, &lva, 0); va_end(lva)...
<vulnerable_code> self.assertIn(r0, ("raise", "reraise")) h0 = h[0] self.assertIn(h0, ("handled", "unwind")) class StopiterationRecorder(ExceptionRecorder): event_type = E.PY_UNWIND def __call__(self, *args): self.events.append(("unwind", None)) class ExceptionHa...
<vulnerable_code> if (no_tools_for_event(tstate, frame, PY_MONITORING_EVENT_PY_UNWIND)) { return; } _Py_call_instrumentation_exc0(tstate, PY_MONITORING_EVENT_PY_UNWIND, frame, instr); } <commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I found...
<vulnerable_code> return call_profile_func(self, args[2]); } static PyObject * sys_profile_call_or_return( _PyLegacyEventHandler *self, PyObject *const *args, return call_trace_func(self, Py_None); } static PyObject * sys_trace_return( _PyLegacyEventHandler *self, PyObject *const *args, ret...
<vulnerable_code> Py_DECREF(v); return NULL; } for (member = p->gr_mem; *member != NULL; member++) { PyObject *x = PyUnicode_DecodeFSDefault(*member); if (x == NULL || PyList_Append(w, x) != 0) { Py_XDECREF(x); Py_DECREF(w);<commit_title>[PATCH 016/395] Sma...
<vulnerable_code> /* SF #1511317: h_aliases can be NULL */ if (h->h_aliases) { for (pch = h->h_aliases; *pch != NULL; pch++) { int status; tmp = PyUnicode_FromString(*pch); if (tmp == NULL) goto err; } } for (pch = h->h_addr_list; *pc...
<vulnerable_code> # test_xxsubinterpreters covers the remaining Interpreter.run() behavior. class StressTests(TestBase): # In these tests we generally want a lot of interpreters,<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I found in PR gh-106798 (...
<vulnerable_code>from test.support.script_helper import assert_python_ok, assert_python_failure from test.support import threading_helper from test.support import import_helper import textwrap import unittest import warnings self.assertRaises(TypeError, sys.intern, S("abc")) def test_sys_flags(self): ...
<vulnerable_code> return _Py_INTERP_CACHED_OBJECT(interp, interned_strings); } Py_ssize_t _PyUnicode_InternedSize(void) { return PyObject_Length(get_interned_dict(_PyInterpreterState_GET())); } static int init_interned_dict(PyInterpreterState *interp) { assert(get_interned_dict(interp) == NULL); PyObje...
<vulnerable_code>} _Py_hashtable_entry_t * _Py_hashtable_get_entry_generic(_Py_hashtable_t *ht, const void *key) {<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I found in PR gh-106798 (issue gh-106797) and in PR gh-106716 (issue gh-106706).<fixed_code> } ...
<vulnerable_code> self.write(".kind = 1,") self.write(".compact = 1,") self.write(".ascii = 1,") self.write(f"._data = {make_string_literal(s.encode('ascii'))},") return f"& {name}._ascii.ob_base" else: ...
<vulnerable_code> try: import _testsinglephase except ImportError: sys.modules.pop('_testsinglephase') return False else: del sys.modules['_testsinglephase']<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I found in PR...
<vulnerable_code>def require_pure_python(module, *, skip=False): _require_loader(module, SourceFileLoader, skip) def remove_files(name): for f in (name + ".py", name + ".pyc", del sys.modules[name] def requires_subinterpreters(meth): """Decorator to skip a test if subinterp...
<vulnerable_code> return NULL; } PyObject *mod, *mdict; PyObject *modules = MODULES(tstate->interp); PyThreadState *tstate = _PyThreadState_GET(); mod = import_find_extension(tstate, name, path); if (mod != NULL) { const char *name_buf = PyUnicode_AsUTF8(name); assert(n...
<vulnerable_code>#include "pycore_atomic_funcs.h" // _Py_atomic_int_get() #include "pycore_bitutils.h" // _Py_bswap32() #include "pycore_bytesobject.h" // _PyBytes_Find() #include "pycore_ceval.h" // _PyEval_AddPendingCall #include "pycore_compile.h" // _PyCompile_CodeGen, _PyCompile_OptimizeCfg, _PyCo...
<vulnerable_code>/* interpreters module */ /* low-level access to interpreter primitives */ #ifndef Py_BUILD_CORE_BUILTIN # define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" #include "pycore_atexit.h" // _Py_AtExit() #include "pycore_interp_id.h" // _PyInterpreterState_GetIDObject() /* ...
<vulnerable_code>/* interpreters module */ /* low-level access to interpreter primitives */ #ifndef Py_BUILD_CORE_BUILTIN # define Py_BUILD_CORE_MODULE 1 #endif #include "Python.h" #include "pycore_interp.h" // _PyInterpreterState_GetMainModule() #include "pycore_interp_id.h" // _PyInterpreterState_GetIDO...
<vulnerable_code> int _Py_AtExit(PyInterpreterState *interp, atexit_datacallbackfunc func, void *data) { assert(interp == _PyInterpreterState_GET()); atexit_callback *callback = PyMem_Malloc(sizeof(atexit_callback));<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_descrip...
<vulnerable_code>#include "Python.h" #include "pycore_abstract.h" // _PyIndex_Check() #include "pycore_interp.h" // _PyInterpreterState_LookUpID() #include "pycore_interp_id.h" // _PyInterpreterID_Type typedef struct interpid { interp_id_converter(PyObject *arg, void *ptr) { int64_t id; if (PyObject_Ty...
<vulnerable_code>} PyObject * _PyInterpreterState_GetMainModule(PyInterpreterState *interp) { PyObject *modules = _PyImport_GetModules(interp); if (modules == NULL) {<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I found in PR gh-106798 (issue gh-1067...
<vulnerable_code>from test.support.script_helper import assert_python_ok, assert_python_failure from test.support import threading_helper from test.support import import_helper from test.support import interpreters import textwrap import unittest import warnings # count the number of test runs, used to create unique ...
<vulnerable_code> """) self.assertIsInstance(function.return_converter, clinic.int_return_converter) def test_star(self): function = self.parse_function(""" module os<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I found...
<vulnerable_code> return line, _, returns = line.partition('->') full_name, _, c_basename = line.partition(' as ') full_name = full_name.strip() return_converter = None if returns: ast_input = f"def x() -> {returns}: pass" module = None ...
<vulnerable_code> ) as proc: proc.wait() if expect_success and proc.returncode: self.fail("".join(proc.stderr)) stdout = proc.stdout.read() stderr = proc.stderr.read() # Clinic never writes to stderr.<commit_title>[PATCH 016/395] Small f...
<vulnerable_code> if dev_mode: args.extend(('-X', 'dev')) for opt in ('faulthandler', 'tracemalloc', 'importtime', 'showrefcount', 'utf8'): if opt in xoptions: value = xoptions[opt] if value is True:<commit_title>[PATCH 016/395] Small fixes to code generato...
<vulnerable_code> PyCFunction _py_float_as_integer_ratio; } decimal_state; static decimal_state global_state; #define GLOBAL_STATE() (&global_state) #if !defined(MPD_VERSION_HEX) || MPD_VERSION_HEX < 0x02050000 #error "libmpdec version >= 2.5.0 required" } static PyObject * flags_as_exception(uint32_t flags) {...
<vulnerable_code> } _PyLong_SetSignAndDigitCount(result, size != 0, size); _PyObject_Init((PyObject*)result, &PyLong_Type); return result; } <commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I found in PR gh-106798 (issue gh-106797) and in PR gh-10...
<vulnerable_code> # Was this class defined with an explicit __hash__? Note that if # __eq__ is defined in this class, then python will automatically # set __hash__ to None. This is a heuristic, as it's possible # that such a __hash__ == None was not auto-generated, but it # close enough. class_...
<vulnerable_code> ('parser_definition', d('block')), ('impl_definition', d('block')), )) def get_destination(self, name): d = self.destinations.get(name) _module_and_class = clinic.Clinic._module_and_class class ClinicWholeFileTest(_ParserBase): def setUp(self): ...
<vulnerable_code> if existing_function.name == function_name: break else: existing_function = None if not existing_function: print("class", cls, "module", module, "existing", existing) ...
<vulnerable_code> return printer.f.getvalue() def _module_and_class(self, fields): """ fields should be an iterable of field names. returns a tuple of (module, class). this function is only ever used to find the parent of where a new class/module should go. ...
<vulnerable_code> #include "Python.h" #include "pycore_import.h" // _PyImport_BootstrapImp() #include "pycore_initconfig.h" // _PyStatus_OK() #include "pycore_interp.h" // struct _import_runtime_state #include "pycore_namespace.h" // _PyNamespace_Type #include "pycore_pyerrors.h" // _PyErr_Se...
<vulnerable_code>} //------------------------- // "detached" thread states //------------------------- void _PyThreadState_InitDetached(PyThreadState *tstate, PyInterpreterState *interp) { _PyRuntimeState *runtime = interp->runtime; HEAD_LOCK(runtime); interp->threads.next_unique_id += 1; uint64_t i...
<vulnerable_code># undef HAVE_SCHED_SETAFFINITY #endif #if defined(HAVE_SYS_XATTR_H) && defined(__linux__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__) # define USE_XATTRS # include <linux/limits.h> // Needed for XATTR_SIZE_MAX on musl libc. #endif<commit_title>[PATCH 016/395] Small fixes to code generator...
<vulnerable_code> import dbm Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback) def open(filename, flag='c', protocol=None, writeback=False): """Open a persistent dictionary for reading and writing.<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_descrip...
<vulnerable_code> consist solely of whitespace characters. """ if predicate is None: def predicate(line): return line.strip() def prefixed_lines(): for line in text.splitlines(True): yield (prefix + line if predicate(line) else line) return ''.join(prefixed_li...
<vulnerable_code> globals: dict[str, Any], *, filename: str = '-' ) -> FunctionType: """ Takes an ast.Expr node. Compiles and evaluates it. Returns the result of the expression. globals represents the globals dict the expression should see. (There's no equivalent for "local...
<vulnerable_code> if self.type =='file': d = {} filename = self.clinic.filename assert filename is not None d['path'] = filename dirname, basename = os.path.split(filename) if not dirname: language: CLanguage, printer...
<vulnerable_code> def output_templates( self, f: Function ) -> dict[str, str]: parameters = list(f.parameters.values()) assert parameters cpp_if = "#if " + conditional cpp_endif = "#endif /* " + conditional + " */" assert clinic is not...
<vulnerable_code> ContextManager = type(C.localcontext()) check_disallow_instantiation(self, ContextManager) @requires_docstrings @requires_cdecimal class SignatureTest(unittest.TestCase):<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I found i...
<vulnerable_code> return -1; } #ifdef CONFIG_32 static PyObject * value_error_ptr(const char *mesg) { PyErr_SetString(PyExc_ValueError, mesg); return NULL; } #endif static int type_error_int(const char *mesg) initialized to new SignalDicts. Once a SignalDict is tied to a context, it cannot be deleted...
<vulnerable_code> result.extend([ dict( name="OpenSSL 1.1.1u", url="https://www.openssl.org/source/openssl-1.1.1u.tar.gz", checksum='e2f8d84b523eecd06c7be7626830370300fbcc15386bf5142d72758f6963ebc6', buildrecipe=build_universal_openssl, ...
<vulnerable_code> x = pointer(i) self.assertEqual(x._objects, {'1': i}) class PointerToStructure(unittest.TestCase): def test(self):<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I found in PR gh-106798 (issue gh-106797) and in PR gh-10671...
<vulnerable_code>Pointer_get_contents(CDataObject *self, void *closure) { StgDictObject *stgdict; if (*(void **)self->b_ptr == NULL) { PyErr_SetString(PyExc_ValueError, stgdict = PyObject_stgdict((PyObject *)self); assert(stgdict); /* Cannot be NULL for pointer instances */ return PyCData_...
<vulnerable_code>import re import subprocess import sys import types import unittest backend = SystemTapBackend() optimize_python = 2 if __name__ == '__main__': unittest.main()<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I found in PR gh-10679...
<vulnerable_code> msg = "unknown destination command 'nosuchcommand'" self.assertIn(msg, out) class ClinicGroupPermuterTest(TestCase): def _test(self, l, m, r, output):<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I found in PR gh-106798 ...
<vulnerable_code> when an extension is loaded. This includes when it is imported for the first time. Here's a summary, using importlib._boostrap._load() as a starting point. 1. importlib._bootstrap._load() 2. _load(): acquire import lock<commit_title>[PATCH 016/395] Small fixes to code genera...
<vulnerable_code> (9*2, 8*3, 7*4, 6*5, 5*6, 4*7, 3*8, 2*9)) def test_recursive_as_param(self): class A(object): pass a = A() c_int.from_param(a) class AsParamWrapper(object): def __init__(self, param): self._as_parameter_ = param ...
<vulnerable_code> def test_issue_7959(self): proto = self.functype.__func__(None) class X(object): def func(self): pass def __init__(self): self.v = proto(self.func)<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These ...
<vulnerable_code> def test_floats(self): # c_float and c_double can be created from # Python int and float class FloatLike(object): def __float__(self): return 2.0 f = FloatLike() self.assertEqual(t(f).value, 2.0) def test_integers(self): ...
<vulnerable_code> # TypeError: has no from_param method self.assertRaises(TypeError, setattr, func, "argtypes", (object,)) class Adapter(object): def from_param(cls, obj): return None self.assertEqual(func(None), None) self.assertEqual(func(object()),...
<vulnerable_code> self._ip = self._ip_int_from_string(addr_str) def __str__(self): ip_str = super().__str__() return ip_str + '%' + self._scope_id if self._scope_id else ip_str def __hash__(self):<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>T...
<vulnerable_code> self.assertEqual(str(self.ipv6_scoped_interface.ip), '2001:658:22a:cafe:200::1') def testGetScopeId(self): self.assertEqual(self.ipv6_address.scope_id, None)<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commi...
<vulnerable_code> null = NULL; } op(_SKIP_CACHE, (unused/1 -- )) { } op(_GUARD_GLOBALS_VERSION, (version/1 --)) { PyDictObject *dict = (PyDictObject *)GLOBALS(); DEOPT_IF(!PyDict_CheckExact(dict), LOAD_GLOBAL); } macro(LOAD_GLOBAL_MOD...
<vulnerable_code> for (int i = 0; i < nuops; i++) { oparg = orig_oparg; uint64_t operand = 0; int offset = expansion->uops[i].offset; switch (expansion->uops[i].size) { case OPA...
<vulnerable_code> total_args++; } DEOPT_IF(total_args != 1, CALL); PyInterpreterState *interp = _PyInterpreterState_GET(); DEOPT_IF(callable != interp->callable_cache.len, CALL); STAT_INC(CALL, hit); PyObject *arg = args[0]; ...
<vulnerable_code>typedef struct { PyObject_HEAD PyObject *name; PyObject *args; PyObject *kwds; } methodcallerobject; /* AC 3.5: variable number of arguments, not currently support by AC */ static PyObject * methodcaller_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return NULL; }...
<vulnerable_code> /* It is the responsibility of the owning generator/coroutine * to have cleared the generator pointer */ assert(f->f_frame->owner != FRAME_OWNED_BY_GENERATOR || _PyFrame_GetGenerator(f->f_frame)->gi_frame_state == FRAME_CLEARED); if (_PyObject_GC_IS_TRACKED(f)) { _PyO...
<vulnerable_code> from test import support, test_tools from test.support import os_helper from test.support import SHORT_TIMEOUT, requires_subprocess from test.support.os_helper import TESTFN, unlink from textwrap import dedent from unittest import TestCase import collections import inspect import os.path import subpro...
<vulnerable_code>from __future__ import annotations import abc import ast import builtins as bltns import collections clinic = None def main(argv: list[str]) -> None: import sys import argparse cmdline = argparse.ArgumentParser( description="""Preprocessor for CPython C files. The purpose of the...