text stringlengths 79 3.72M |
|---|
<vulnerable_code>#define NEED_OPCODE_TABLES
#include "pycore_opcode_utils.h"
#undef NEED_OPCODE_TABLES
#include "pycore_flowgraph.h"
#include "pycore_code.h" // _PyCode_New()
#include "pycore_compile.h"
#include "pycore_intrinsics.h"
#include "pycore_long.h" // _PyLong_GetZero()
#include "pycore_pysta... |
<vulnerable_code>#include "pycore_opcode_utils.h"
#include "pycore_pyerrors.h"
#include "pycore_range.h"
#include "pycore_sliceobject.h"
#include "pycore_uops.h"
<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... |
<vulnerable_code>#include "Python.h"
#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_code.h" // _PyCode_New()
#include "pycore_long.h" // _PyLong_DigitCount
#include "pycore_hashtable.h" // _Py_hashtable_t
#include "marshal.h" // Py_MARSHAL_VERSION
/*[cli... |
<vulnerable_code>#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_runtime.h" // _Py_ID()
#include "pycore_runtime_init.h" // _PyRuntimeState_INIT
#include "pycore_sliceobject.h" // _PySlice_Fini()
#include "pycore_sysmodule.h" // _PySys_ClearAuditHooks()
#include "pycore_traceback... |
<vulnerable_code>#include "pycore_floatobject.h" // _PyFloat_DebugMallocStats()
#include "pycore_initconfig.h" // _PyStatus_EXCEPTION()
#include "pycore_namespace.h" // _PyNamespace_Type
#include "pycore_object.h" // _PyType_CheckConsistency(), _Py_FatalRefcountError()
#include "pycore_pyerrors.h" ... |
<vulnerable_code> exclude_patterns.append(venvdir + '/*')
nitpick_ignore = [
# Do not error nit-picky mode builds when _SubParsersAction.add_parser cannot
# be resolved, as the method is currently undocumented. For context, see
# https://github.com/python/cpython/pull/103289.<commit_title>[PATCH 016/395... |
<vulnerable_code>
#include "Python.h"
#include "frameobject.h"
#include "interpreteridobject.h" // _PyInterpreterID_LookUp()
#include "pycore_atomic_funcs.h" // _Py_atomic_int_get()
#include "pycore_bitutils.h" // _Py_bswap32()
#include "pycore_bytesobject.h" // _PyBytes_Find()
#include "pycore_compile.h" //... |
<vulnerable_code>#endif
#include "Python.h"
#include "interpreteridobject.h"
#include "pycore_atexit.h" // _Py_AtExit()
/*<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>
#include "Python.h"
#include "pycore_interp.h" // _PyInterpreterState_GetMainModule()
#include "interpreteridobject.h"
#define MODULE_NAME "_xxsubinterpreters"<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I found in PR gh-106798 (is... |
<vulnerable_code>#include "Python.h"
#include "pycore_abstract.h" // _PyIndex_Check()
#include "pycore_interp.h" // _PyInterpreterState_LookUpID()
#include "interpreteridobject.h"
typedef struct interpid {<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits ... |
<vulnerable_code>#include "pycore_dict.h" // _PyObject_MakeDictFromInstanceAttributes()
#include "pycore_floatobject.h" // _PyFloat_DebugMallocStats()
#include "pycore_initconfig.h" // _PyStatus_EXCEPTION()
#include "pycore_namespace.h" // _PyNamespace_Type
#include "pycore_object.h" // PyAPI_D... |
<vulnerable_code>Include/cpython/fileutils.h Py_CPYTHON_FILEUTILS_H 1
Include/cpython/frameobject.h Py_CPYTHON_FRAMEOBJECT_H 1
Include/cpython/import.h Py_CPYTHON_IMPORT_H 1
Include/cpython/interpreteridobject.h Py_CPYTHON_INTERPRETERIDOBJECT_H 1
Include/cpython/listobject.h Py_CPYTHON_LISTOBJECT_H 1
Include/cpython/me... |
<vulnerable_code> records to the target, if there is one. Override if you want
different behaviour.
The record buffer is also cleared by this operation.
"""
self.acquire()
try:<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These r... |
<vulnerable_code>#include "pycore_abstract.h" // _PyObject_RealIsSubclass()
#include "pycore_call.h" // _PyStack_AsDict()
#include "pycore_ceval.h" // _Py_EnterRecursiveCallTstate()
#include "pycore_object.h" // _PyObject_GC_UNTRACK()
#include "pycore_pystate.h" // _PyThreadState_GET(... |
<vulnerable_code>#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_ceval.h" // _Py_EnterRecursiveCallTstate()
#include "pycore_context.h" // _PyContextTokenMissing_Type
#include "pycore_dict.h" // _PyObject_MakeDictFromInstanceAttributes()
#include "pycore_floatobject.h... |
<vulnerable_code>#include "Python.h"
#include "pycore_code.h"
#include "pycore_dict.h"
#include "pycore_function.h" // _PyFunction_GetVersionForCurrentState()
#include "pycore_global_strings.h" // _Py_ID()
#include "pycore_moduleobject.h"
#include "pycore_object.h"
#include "pycore_opcode.h" // _PyOpcode_C... |
<vulnerable_code> def _add_reader(self, fd, callback, *args):
self._check_closed()
handle = events.Handle(callback, args, self, None)
try:
key = self._selector.get_key(fd)
except KeyError:
self._selector.register(fd, selectors.EVENT_READ,
... |
<vulnerable_code> sock.connect.assert_called_with(('127.0.0.1', 0))
def test_add_reader(self):
self.loop._selector.get_key.side_effect = KeyError
cb = lambda: True
self.loop.add_reader(1, cb)
def test_add_reader_existing(self):
reader = mock.Mock()
writer... |
<vulnerable_code>do_monitor_exc(PyThreadState *tstate, _PyInterpreterFrame *frame,
_Py_CODEUNIT *instr, int event)
{
assert(event < PY_MONITORING_UNGROUPED_EVENTS);
PyObject *exc = PyErr_GetRaisedException();
assert(exc != NULL);
int err = _Py_call_instrumentation_arg(tstate, event, frame... |
<vulnerable_code>static inline bool
monitors_equals(_Py_Monitors a, _Py_Monitors b)
{
for (int i = 0; i < PY_MONITORING_UNGROUPED_EVENTS; i++) {
if (a.tools[i] != b.tools[i]) {
return false;
}
monitors_sub(_Py_Monitors a, _Py_Monitors b)
{
_Py_Monitors res;
for (int i = 0; i < PY... |
<vulnerable_code> _PyGC_InitState(&interp->gc);
PyConfig_InitPythonConfig(&interp->config);
_PyType_InitCache(interp);
for (int i = 0; i < PY_MONITORING_UNGROUPED_EVENTS; i++) {
interp->monitors.tools[i] = 0;
}
for (int t = 0; t < PY_MONITORING_TOOL_IDS; t++) {
for (int e = 0; e <... |
<vulnerable_code>#include "pycore_call.h" // _PyObject_CallNoArgsTstate()
#include "pycore_ceval.h" // _Py_EnterRecursiveCallTstate()
#include "pycore_dict.h" // _PyDict_FromItems()
#include "pycore_modsupport.h" // _Py_VaBuildStack()
#include "pycore_object.h" // _PyCFunctionWithKey... |
<vulnerable_code> # All the functions after here are intended as extension points.
#
def simple_declaration(self, by_reference=False, *, in_parser=False):
"""
Computes the basic declaration of the variable.
Used in computing the prototype declaration and the
variable declarat... |
<vulnerable_code> co_code = code.co_code
JUMP_BACKWARD = opcode.opmap["JUMP_BACKWARD"]
for i in range(0, len(co_code), 2):
if co_code[i] == JUMP_BACKWARD or 1:
try:
return _testinternalcapi.get_executor(code, i)
except ValueError:<commit_title>[PATCH 016/395] S... |
<vulnerable_code> fut.set_result(total_sent)
return
try:
sent = os.sendfile(fd, fileno, offset, blocksize)
except (BlockingIOError, InterruptedError):<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I f... |
<vulnerable_code>from turtle import *
color('red', 'yellow')
begin_fill()
while True:
forward(200)
left(170)
if abs(pos()) < 1:
break
end_fill()
done()<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) ... |
<vulnerable_code> missing = object()
tmsg = self._catalog.get(message, missing)
if tmsg is missing:
if self._fallback:
return self._fallback.gettext(message)
return message
return tmsg
def ngettext(self, msgid1, msgid2, n):
try:<commit_... |
<vulnerable_code> eq(x, 'Hay %s fichero')
x = gettext.ngettext('There is %s file', 'There are %s files', 2)
eq(x, 'Hay %s ficheros')
def test_plural_context_forms1(self):
eq = self.assertEqual
eq(x, 'Hay %s fichero')
x = t.ngettext('There is %s file', 'There are %s fi... |
<vulnerable_code> assert not self._msgstack
# Look for final set of defects
if root.get_content_maintype() == 'multipart' \
and not root.is_multipart():
defect = errors.MultipartInvariantViolationDefect()
self.policy.handle_defect(root, defect)
retur... |
<vulnerable_code> self.assertIsInstance(msg.get_payload(), str)
self.assertIsInstance(msg.get_payload(decode=True), bytes)
def test_bytes_parser_does_not_close_file(self):
with openfile('msg_02.txt', 'rb') as fp:
email.parser.BytesParser().parse(fp)<commit_title>[PATCH 016/395] S... |
<vulnerable_code> def test_open_with_pathlib_bytes_path(self):
gdbm.open(FakePath(os.fsencode(filename)), "c").close()
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-106798 (issue gh-1... |
<vulnerable_code> Py_RETURN_NONE;
}
static PyObject *
gdbm__enter__(PyObject *self, PyObject *args)
{
_GDBM_GDBM_SYNC_METHODDEF
_GDBM_GDBM_GET_METHODDEF
_GDBM_GDBM_SETDEFAULT_METHODDEF
{"__enter__", gdbm__enter__, METH_NOARGS, NULL},
{"__exit__", gdbm__exit__, METH_VARARGS, NULL},
{NULL, ... |
<vulnerable_code> missing = object()
tmsg = self._catalog.get(ctxt_msg_id, missing)
if tmsg is missing:
if self._fallback:
return self._fallback.pgettext(context, message)
return message
return tmsg
def npgettext(self, context, msgid1, msgid2, ... |
<vulnerable_code> x = gettext.npgettext('With context',
'There is %s file', 'There are %s files', 2)
eq(x, 'Hay %s ficheros (context)')
def test_plural_forms2(self):
eq = self.assertEqual
x = t.npgettext('With context',
'There is ... |
<vulnerable_code> self.assertNotIn(b'xxx', d)
self.assertRaises(KeyError, lambda: d[b'xxx'])
def setUp(self):
self.addCleanup(setattr, dbm, '_defaultmod', dbm._defaultmod)
dbm._defaultmod = self.module<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commi... |
<vulnerable_code> db['a'] = 'b'
self.assertRaises(dbm.ndbm.error, bool, db)
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-106798 (issue gh-106797) and in PR gh-106716 (issue g... |
<vulnerable_code> return default_value;
}
static PyObject *
dbm__enter__(PyObject *self, PyObject *args)
{
_DBM_DBM_KEYS_METHODDEF
_DBM_DBM_GET_METHODDEF
_DBM_DBM_SETDEFAULT_METHODDEF
{"__enter__", dbm__enter__, METH_NOARGS, NULL},
{"__exit__", dbm__exit__, METH_VARARGS, NULL},
{NULL, NULL... |
<vulnerable_code>#define OPENSSL_NO_DEPRECATED 1
#include "Python.h"
#include "pycore_weakref.h" // _PyWeakref_GET_REF()
/* Include symbols from _socket module */<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) a... |
<vulnerable_code>from test.support.script_helper import assert_python_failure, assert_python_ok
# Skip this test if the _testcapi module isn't available.
_testcapi = import_helper.import_module('_testcapi')
@requires_subprocess()
class PyMemDebugTests(unittest.TestCase):
def check_pyobject_is_freed(self, func_n... |
<vulnerable_code> Py_RETURN_NONE;
}
static PyObject *
test_pyobject_is_freed(const char *test_name, PyObject *op)
{
if (!_PyObject_IsFreed(op)) {
PyErr_SetString(PyExc_AssertionError,
"object is not seen as freed");
return NULL;
}
Py_RETURN_NONE;
}
static PyObjec... |
<vulnerable_code>#undef NDEBUG
#include "Python.h"
// Used for clone_with_conv_f1 and clone_with_conv_v2<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>
#undef NDEBUG... |
<vulnerable_code>#undef NDEBUG
#include "Python.h"
#include "frameobject.h"
#include "pycore_atomic_funcs.h" // _Py_atomic_int_get()
#include "pycore_bitutils.h" // _Py_bswap32()
#include "pycore_bytesobject.h" // _PyBytes_Find()
#include "pycore_initconfig.h" // _Py_GetConfigsAsDict()
#include "pycore_interp.h... |
<vulnerable_code>#include "pycore_code.h" // stats
#include "pycore_dict.h" // PyDictKeysObject
#include "pycore_gc.h" // _PyObject_GC_IS_TRACKED()
#include "pycore_object.h" // _PyObject_GC_TRACK()
#include "pycore_pyerrors.h" // _PyErr_GetRaisedException()
#include "pycore_pys... |
<vulnerable_code>#include "pycore_interp.h" // _PyInterpreterState.float_state
#include "pycore_long.h" // _PyLong_GetOne()
#include "pycore_modsupport.h" // _PyArg_NoKwnames()
#include "pycore_object.h" // _PyObject_Init()
#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR
#include "py... |
<vulnerable_code>#include "pycore_list.h" // struct _Py_list_state, _PyListIterObject
#include "pycore_long.h" // _PyLong_DigitCount
#include "pycore_modsupport.h" // _PyArg_NoKwnames()
#include "pycore_object.h" // _PyObject_GC_TRACK()
#include "pycore_tuple.h" // _PyTuple_FromArray... |
<vulnerable_code>
#include "Python.h"
#include "pycore_code.h" // stats
#include "pycore_obmalloc.h"
#include "pycore_pyerrors.h" // _Py_FatalErrorFormat()
#include "pycore_pymem.h"<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I found in PR gh-1... |
<vulnerable_code>#include "pycore_gc.h" // _PyObject_GC_IS_TRACKED()
#include "pycore_initconfig.h" // _PyStatus_OK()
#include "pycore_modsupport.h" // _PyArg_NoKwnames()
#include "pycore_object.h" // _PyObject_GC_TRACK(), _Py_FatalRefcountError()
/*[clinic input]
class tuple "PyTupleObject *" ... |
<vulnerable_code>#include "pycore_long.h" // _PY_LONG_MAX_STR_DIGITS_THRESHOLD
#include "pycore_modsupport.h" // _PyModule_CreateInitialized()
#include "pycore_namespace.h" // _PyNamespace_New()
#include "pycore_object.h" // _PyObject_IS_GC()
#include "pycore_pathconfig.h" // _PyPathConfig_Com... |
<vulnerable_code>*/
#include "Python.h"
#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_object.h"
#include "pycore_pyerrors.h" // _Py_FatalErrorFormat()
#include "pycore_pylifecycle.h" // _Py_IsInterpreterFinalizing()
#include "structmember.h" // PyMemberDef<commit_title>[PA... |
<vulnerable_code>#include <stdbool.h>
#include <Python.h>
#include "pycore_unicodeobject.h" // _PyUnicode_DecodeUnicodeEscapeInternal()
#include "tokenizer.h"<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 g... |
<vulnerable_code> exclude_patterns.append(venvdir + '/*')
nitpick_ignore = [
# Standard C types
('c:type', 'FILE'),
('c:type', '__int'),<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... |
<vulnerable_code>Write bytes to a file descriptor starting at a particular offset.
Write buffer to fd, starting at offset bytes from the beginning of
the file. Returns the number of bytes writte. Does not change the
current file offset.
[clinic start generated code]*/
static Py_ssize_t
os_pwrite_impl(PyObject *modu... |
<vulnerable_code>#include "Python.h"
#include "pycore_object.h" // _PyObject_GET_WEAKREFS_LISTPTR
#include "pycore_weakref.h" // _PyWeakref_IS_DEAD()
<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 P... |
<vulnerable_code>
#include "Python.h"
#include "pycore_context.h"
#include "pycore_initconfig.h"
#include "pycore_interp.h" // PyInterpreterState.gc
#include "pycore_object.h"
#include "pycore_pyerrors.h"
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_weakref.h" // _PyWeakref_ClearRef... |
<vulnerable_code>*/
#include "Python.h"
#include "pycore_modsupport.h" // _PyArg_NoKwnames()
#include "pycore_object.h" // _PyObject_GC_UNTRACK()
#include "pycore_setobject.h" // _PySet_NextEntry() definition<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These re... |
<vulnerable_code>#include "Python.h"
#include "pycore_frame.h"
#include "pycore_initconfig.h"
#include "pycore_interp.h" // PyInterpreterState.warnings<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-... |
<vulnerable_code>#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_ceval.h" // _PyEval_Vector()
#include "pycore_compile.h" // _PyAST_Compile()
#include "pycore_long.h" // _PyLong_CompactValue
#include "pycore_modsupport.h" // _PyArg_NoKwnames()
#include "pycore_obje... |
<vulnerable_code>/* New getargs implementation */
#include "Python.h"
#include "pycore_tuple.h" // _PyTuple_ITEMS()
#include "pycore_pylifecycle.h" // _PyArg_Fini
#include <ctype.h>
#include <float.h><commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I... |
<vulnerable_code>#include "Python.h"
#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_ceval.h" // _PyEval_SetAsyncGenFinalizer()
#include "pycore_frame.h" // _PyInterpreterFrame
#include "pycore_initconfig.h" // _PyStatus_EXCEPTION()
#include "pycore_long.h" // _P... |
<vulnerable_code>
test_tools.skip_if_missing('cases_generator')
with test_tools.imports_under_tool('cases_generator'):
import generate_cases
from parser import StackEffect
class TestEffects(unittest.TestCase):
StackEffect("q", "", "", ""),
StackEffect("r", "", "", ""),
]
... |
<vulnerable_code><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>
import re
import sys
import typing
from flags import InstructionFlags, variable_used
from formatting i... |
<vulnerable_code><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>
import dataclasses
from formatting import Formatter
import lexer as lx
import parsing
@dataclasses.d... |
<vulnerable_code><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>
import contextlib
import re
import typing
from parsing import StackEffect
UNUSED = "unused"
class F... |
<vulnerable_code>"""Generate the main interpreter switch.
Reads the instruction definitions from bytecodes.c.
Writes the cases to generated_cases.c.h, which is #included in ceval.c.
"""
import argparse
import contextlib
import dataclasses
import os
import posixpath
import re
import sys
import typing
import lexer as ... |
<vulnerable_code><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>
import dataclasses
import re
import typing
from flags import InstructionFlags, variable_used_unspecial... |
<vulnerable_code>"""Parser for bytecodes.inst."""
from dataclasses import dataclass, field
from typing import NamedTuple, Callable, TypeVar, Literal
import lexer as lx
from plexer import PLexer
res = func(self)
if res is None:
self.setpos(begin)
return
end = self.getpos... |
<vulnerable_code>
def collect_testcapi(info_add):
try:
import _testcapi
except ImportError:
return
call_func(info_add, 'pymem.allocator', _testcapi, 'pymem_getallocatorsname')
def collect_resource(info_add):<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_descr... |
<vulnerable_code>
# Memory allocator debug hooks
try:
import _testcapi
except ImportError:
pass
else:
code = "import _testcapi; print(_testcapi.pymem_getallocatorsname())"
with support.SuppressCrashReport():
out = self.run_x... |
<vulnerable_code> "sys.getallocatedblocks unavailable on this build")
def test_getallocatedblocks(self):
try:
import _testcapi
except ImportError:
with_pymalloc = support.with_pymalloc()
else:
try:
alloc_name = _test... |
<vulnerable_code> Py_RETURN_NONE;
}
static PyObject *
test_pymem_getallocatorsname(PyObject *self, PyObject *args)
{
const char *name = _PyMem_GetCurrentAllocatorName();
if (name == NULL) {
PyErr_SetString(PyExc_RuntimeError, "cannot get allocators name");
return NULL;
}
return PyUni... |
<vulnerable_code>}
static PyMethodDef module_functions[] = {
{"get_configs", get_configs, METH_NOARGS},
{"get_recursion_depth", get_recursion_depth, METH_NOARGS},
{"check_pyobject_null_is_freed", check_pyobject_null_is_freed, METH_NOARGS},
{"check_pyobject_uninitialized_is_freed",
... |
<vulnerable_code>/* Return the initial module search path. */
#include "Python.h"
#include "marshal.h" // PyMarshal_ReadObjectFromString
#include "osdefs.h" // DELIM
#include "pycore_initconfig.h"
#include "pycore_fileutils.h"
#include "pycore_pathconfig.h"
#include <wchar.h>
#ifdef MS_WIND... |
<vulnerable_code>
from test import support, test_tools
from test.support import os_helper
from textwrap import dedent
from unittest import TestCase
import collections
import inspect
import os.path
import sys
import unittest
class ClinicExternalTest(TestCase):
maxDiff = None
def test_external(self):
CL... |
<vulnerable_code>clinic = None
def main(argv):
import sys
import argparse
cmdline = argparse.ArgumentParser(
print()
cmdline.print_usage()
sys.exit(-1)
converters = []
return_converters = []
ignored = set("""
add_c_converter
... |
<vulnerable_code>
/* This is used strictly by Py_INCREF(). */
void
_Py_IncRefTotal_DO_NOT_USE_THIS(void)
{
reftotal_increment(_PyInterpreterState_GET());
}
/* This is used strictly by Py_DECREF(). */
void
_Py_DecRefTotal_DO_NOT_USE_THIS(void)
{
reftotal_decrement(_PyInterpreterState_GET());
}<commit_title>[PAT... |
<vulnerable_code>
# First, let's see if there are any method definitions
for member in self.cls.__dict__.values():
if isinstance(member, types.FunctionType):
for lineno, end_lineno in self.lineno_found:
if lineno <= member.__code__.co_f... |
<vulnerable_code>import shutil
import sys
import types
import textwrap
import unicodedata
import unittest
self.assertSourceEqual(mod2.cls213, 218, 222)
self.assertSourceEqual(mod2.cls213().func219(), 220, 221)
@unittest.skipIf(
support.is_emscripten or support.is_wasi,
"socket.accep... |
<vulnerable_code>from test import shadowed_super
class A:
def f(self):
return 'A'
super(MyType, type(mytype)).__setattr__(mytype, "bar", 1)
self.assertEqual(mytype.bar, 1)
test("foo1")
test("foo2")
if __name__ == "__main__":<commit_title>[PATCH 016/395] Small fix... |
<vulnerable_code> PyTypeObject *cls = (PyTypeObject *)class;
int method_found = 0;
res2 = _PySuper_Lookup(cls, self, name,
cls->tp_getattro == PyObject_GenericGetAttr ? &method_found : NULL);
Py_DECREF(global_super);
Py_DECREF... |
<vulnerable_code> new_docstring += line
self.function.docstring = new_docstring
def format_docstring(self):
f = self.function
new_or_init = f.kind.new_or_init
if new_or_init and not f.docstring:
right_bracket_count = 0
def fix_right_bracket_count(desired):
... |
<vulnerable_code> return SUCCESS;
}
static basicblock *
copy_basicblock(cfg_builder *g, basicblock *block)
{
static inline int
basicblock_returns(const basicblock *b) {
cfg_instr *last = _PyCfg_BasicblockLastInstr(b);
return last && (last->i_opcode == RETURN_VALUE || last->i_opcode == RETURN_CONST);
}
... |
<vulnerable_code> # try to access any
__message__: str
def __getattribute__(self, name: str):
if name in ('__repr__', '__message__'):
return super().__getattribute__(name)
# raise RuntimeError(repr(name))
self.format_unit = format_unit
def cleanup(self):
nam... |
<vulnerable_code>
class CRenderData:
def __init__(self):
# The C statements to declare variables.
# Should be full lines with \n eol characters.
self.declarations = []
# The C statements required to initialize the variables before the parse call.
# Should be full lines wit... |
<vulnerable_code> u->u_metadata.u_argcount = 0;
u->u_metadata.u_posonlyargcount = 0;
u->u_metadata.u_kwonlyargcount = 0;
u->u_ste = PySymtable_Lookup(c->c_st, key);
if (!u->u_ste) {
compiler_unit_free(u);
return ERROR;
comprehension_ty outermost;
int scope_type = c->u->u_scope... |
<vulnerable_code>}
PySTEntryObject *
PySymtable_Lookup(struct symtable *st, void *key)
{
PyObject *k, *v;
<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>
}
PySTEn... |
<vulnerable_code> NoReturn,
Protocol,
TypeGuard,
overload,
)
fail("Stepped on a land mine, trying to access attribute " + repr(name) + ":\n" + self.__message__)
def add_c_converter(
f: type[CConverter],
name: str | None = None
) -> type[CConverter]:
if not name:
nam... |
<vulnerable_code> def __init__(self) -> None:
self.counts = collections.Counter[str]()
def get_value(self, key: str, args, kwargs) -> str: # type: ignore[override]
self.counts[key] += 1
return ''
# This lets the self_converter overrule the user-settable
# name, *just* for the t... |
<vulnerable_code>
__all__ = ["version", "bootstrap"]
_PACKAGE_NAMES = ('pip',)
_PIP_VERSION = "23.1.2"
_PROJECTS = [
("pip", _PIP_VERSION, "py3"),
]<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... |
<vulnerable_code> if (m == NULL)
return NULL;
Py_INCREF(&CustomType);
if (PyModule_AddObject(m, "Custom", (PyObject *) &CustomType) < 0) {
Py_DECREF(&CustomType);
Py_DECREF(m);
return NULL;
}<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_desc... |
<vulnerable_code> if (m == NULL)
return NULL;
Py_INCREF(&SubListType);
if (PyModule_AddObject(m, "SubList", (PyObject *) &SubListType) < 0) {
Py_DECREF(&SubListType);
Py_DECREF(m);
return NULL;
}<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_... |
<vulnerable_code> return -1;
}
if (PyModule_AddObject(module, "datetime_CAPI", x) < 0) {
Py_DECREF(x);
return -1;
}
<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... |
<vulnerable_code>
/* Init mpd_ssize_t constants */
for (ssize_cm = ssize_constants; ssize_cm->name != NULL; ssize_cm++) {
ASSIGN_PTR(obj, PyLong_FromSsize_t(ssize_cm->val));
CHECK_INT(PyModule_AddObject(m, ssize_cm->name, obj));
obj = NULL;
}
/* Init int constants */<commit_titl... |
<vulnerable_code> defined(GDBM_VERSION_PATCH)
PyObject *obj = Py_BuildValue("iii", GDBM_VERSION_MAJOR,
GDBM_VERSION_MINOR, GDBM_VERSION_PATCH);
if (obj == NULL) {
return -1;
}
if (PyModule_AddObject(module, "_GDBM_VERSION", obj) < 0) {
Py_DECREF(obj);... |
<vulnerable_code> return -1;
}
if (PyModule_AddObject(module, "openssl_md_meth_names", state.set) < 0) {
Py_DECREF(state.set);
return -1;
}
return 0;
}
/*[clinic input]<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>These repair nits I f... |
<vulnerable_code>static int
heapq_exec(PyObject *m)
{
PyObject *about = PyUnicode_FromString(__about__);
if (PyModule_AddObject(m, "__about__", about) < 0) {
Py_DECREF(about);
return -1;
}
return 0;<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>T... |
<vulnerable_code>
_locale_state *state = get_locale_state(module);
state->Error = PyErr_NewException("locale.Error", NULL, NULL);
if (state->Error == NULL) {
return -1;
}
Py_INCREF(get_locale_state(module)->Error);
if (PyModule_AddObject(module, "Error", get_locale_state(module)->Error) ... |
<vulnerable_code>static int
module_add_int_constant(PyObject *m, const char *name, long long value)
{
PyObject *o = PyLong_FromLongLong(value);
if (o == NULL) {
return -1;
}
if (PyModule_AddObject(m, name, o) == 0) {
return 0;
}
Py_DECREF(o);
return -1;
}
static int<commit_t... |
<vulnerable_code> ADD_FLAG(HAVE_BROKEN_SEM_UNLINK);
#endif
if (PyModule_AddObject(module, "flags", flags) < 0) {
Py_DECREF(flags);
return -1;
}
<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)... |
<vulnerable_code>#define addbool(m, key, value) \
do { \
PyObject *bool_obj = (value) ? Py_True : Py_False; \
PyModule_AddObject((m), (key), Py_NewRef(bool_obj)); \
} while (0)
addbool(m, "HAS_SNI", 1);<commit_title>[PATCH 016/395] Small fixes to code generator (#106845)<commit_description>... |
<vulnerable_code> return -1;
}
PyObject *HeapDocCType = PyType_FromSpec(&HeapDocCType_spec);
if (HeapDocCType == NULL) {
return -1;
}
PyModule_AddObject(m, "HeapDocCType", HeapDocCType);
/* bpo-41832: Add a new type to test PyType_FromSpec()
now can accept a NULL tp_doc s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.