text stringlengths 79 3.72M |
|---|
<vulnerable_code>};
static PyMemberDef gen_memberlist[] = {
{"gi_frame", T_OBJECT, offsetof(PyGenObject, gi_frame), READONLY},
{"gi_code", T_OBJECT, offsetof(PyGenObject, gi_code), READONLY},
{NULL} /* Sentinel */
};
};
static PyMemberDef coro_memberlist[] = {
{"cr_frame", T_... |
<vulnerable_code>};
static PyMemberDef tb_memberlist[] = {
{"tb_frame", T_OBJECT, OFF(tb_frame), READONLY},
{"tb_lasti", T_INT, OFF(tb_lasti), READONLY},
{"tb_lineno", T_INT, OFF(tb_lineno), READONLY},
{NULL} /* Sentinel */<commit_title>[PATCH 003/413]... |
<vulnerable_code>};
static PyMemberDef gen_memberlist[] = {
{"gi_frame", T_OBJECT, offsetof(PyGenObject, gi_frame), READONLY|AUDIT_READ},
{"gi_code", T_OBJECT, offsetof(PyGenObject, gi_code), READONLY|AUDIT_READ},
{NULL} /* Sentinel */
};
};
static PyMemberDef coro_memberlist[] = {
... |
<vulnerable_code>};
static PyMemberDef tb_memberlist[] = {
{"tb_frame", T_OBJECT, OFF(tb_frame), READONLY|AUDIT_READ},
{"tb_lasti", T_INT, OFF(tb_lasti), READONLY},
{"tb_lineno", T_INT, OFF(tb_lineno), READONLY},
{NULL} /* Sentinel */<commit_title>[PAT... |
<vulnerable_code> pass
""")
class PerfPatma(TestPatma):
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
pass
""")
@no_perf
def test_patma_285(self):
self.assert_syntax_error("""
m... |
<vulnerable_code>#define literal_expr_type 1048
#define complex_number_type 1049
#define signed_number_type 1050
#define imaginary_number_type 1051
#define capture_pattern_type 1052
#define pattern_capture_target_type 1053
#define wildcard_pattern_type 1054
#define value_pattern_type 1055
#define attr_type 1056 // Lef... |
<vulnerable_code>_PyPegen_ensure_imaginary(Parser *p, expr_ty exp)
{
if (exp->kind != Constant_kind || !PyComplex_CheckExact(exp->v.Constant.value)) {
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(exp, "Imaginary number required in complex literal");
return NULL;
}
return exp;<commit_title>[PATCH 003/41... |
<vulnerable_code> break;
case MatchAs_kind:
if (node_->v.MatchAs.pattern) {
CALL(astfold_pattern, expr_ty, node_->v.MatchAs.pattern);
}
break;
case MatchOr_kind:<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-2509... |
<vulnerable_code>static int
pattern_helper_store_name(struct compiler *c, identifier n, pattern_context *pc)
{
if (forbidden_name(c, n, Store)) {
return 0;
}
return 1;
}
static int
compiler_pattern_capture(struct compiler *c, identifier n, pattern_context *pc)
{
RETURN_IF_FALSE(pattern_helper_s... |
<vulnerable_code><commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
# This ann_module isn't for test_typing,
# it's for test_module
a:int=3
b:str=4 |
<vulnerable_code> self.assertEqual(CC.__annotations__['xx'], 'ANNOT')
def test_var_annot_module_semantics(self):
with self.assertRaises(AttributeError):
print(test.__annotations__)
self.assertEqual(ann_module.__annotations__,
{1: 2, 'x': int, 'y': str, 'f': t... |
<vulnerable_code> melon = Descr()
self.assertRaises(RuntimeError, getattr, M("mymod"), "melon")
# frozen and namespace module reprs are tested in importlib.
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
melon = Des... |
<vulnerable_code> except OSError:
pass
def test_no_annotations_if_not_needed(self):
class C: pass
with self.assertRaises(AttributeError):
C.__annotations__
def test_use_existing_annotations(self):
ns = {'__annotations__': {1: 2}}<commit_title>[PATCH 003/4... |
<vulnerable_code><commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
import unittest
class TypeAnnotationTests(unittest.TestCase):
def test_lazy_create_annotations(self):
# type objects lazy create their __annotations__ dict on demand.
... |
<vulnerable_code> else:
base_globals = globalns
ann = base.__dict__.get('__annotations__', {})
base_locals = dict(vars(base)) if localns is None else localns
if localns is None and globalns is None:
# This is surprising, but required. Befor... |
<vulnerable_code>_Py_IDENTIFIER(__doc__);
_Py_IDENTIFIER(__name__);
_Py_IDENTIFIER(__spec__);
static PyMemberDef module_members[] = {
{"__dict__", T_OBJECT, offsetof(PyModuleObject, md_dict), READONLY},
static PyObject *
module_dir(PyObject *self, PyObject *args)
{
_Py_IDENTIFIER(__dict__);
_Py_IDENTIFIER(... |
<vulnerable_code>
/* alphabetical order */
_Py_IDENTIFIER(__abstractmethods__);
_Py_IDENTIFIER(__class__);
_Py_IDENTIFIER(__class_getitem__);
_Py_IDENTIFIER(__classcell__);
return _PyDict_SetItemId(type->tp_dict, &PyId___doc__, value);
}
/*[clinic input]
type.__instancecheck__ -> bool
{"__dict__", (getter)ty... |
<vulnerable_code> # and __doc__ is None
foo = ModuleType.__new__(ModuleType)
self.assertTrue(foo.__dict__ is None)
self.assertRaises(SystemError, dir, foo)
try:
s = foo.__name__
self.fail("__name__ = %s" % repr(s))<commit_title>[PATCH 003/413] bpo-43651: Fi... |
<vulnerable_code> return NULL;
}
d = ((PyModuleObject *)m)->md_dict;
if (d == NULL ||
(name = _PyDict_GetItemIdWithError(d, &PyId___name__)) == NULL ||
!PyUnicode_Check(name))
{
}
}
else {
const char *name = PyModule_GetName(self);
... |
<vulnerable_code>import unittest.mock
from test.support import requires, swap_attr
import tkinter as tk
from .tkinter_testing_utils import run_in_tk_mainloop
from idlelib.delegator import Delegator
from idlelib.editor import fixwordbreaks
from idlelib import macosx
from idlelib.percolator import Percolator
import idle... |
<vulnerable_code> stack(), trace() - get info about frames on the stack or in a traceback
signature() - get a Signature object for the callable
"""
# This module is in the public domain. No warranties.
# See Include/object.h
TPFLAGS_IS_ABSTRACT = 1 << 20
# ----------------------------------------------------... |
<vulnerable_code><commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
a:int=3
b:str="foo"
class MyClass:
a:int=4
b:str="bar"
def __init__(self, a, b):
self.a = a
self.b = b
def __eq__(self, other):
return isinstance(o... |
<vulnerable_code><commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
from __future__ import annotations
def foo(a, b, c): pass |
<vulnerable_code>from test import inspect_fodder as mod
from test import inspect_fodder2 as mod2
from test import support
from test.test_import import _ready_to_import
attrs = [a[0] for a in inspect.getmembers(C)]
self.assertNotIn('missing', attrs)
class TestIsDataDescriptor(unittest.TestCase):
... |
<vulnerable_code>
### MAPPINGS ###
class Mapping(Collection):
"""A Mapping is a generic container for associating key/value
pairs.
__slots__ = ()
@abstractmethod
def __getitem__(self, key):
raise KeyError
__reversed__ = None
Mapping.register(mappingproxy)
### SEQUENCES ###
cl... |
<vulnerable_code>_Py_IDENTIFIER(__abstractmethods__);
_Py_IDENTIFIER(__class__);
_Py_IDENTIFIER(__dict__);
_Py_IDENTIFIER(__bases__);
_Py_IDENTIFIER(_abc_impl);
_Py_IDENTIFIER(__subclasscheck__);
return ret;
}
/*[clinic input]
_abc._abc_init
return NULL;
}
Py_DECREF(data);
Py_RETURN_NONE;
}
... |
<vulnerable_code> PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
/* tp_flags */
de... |
<vulnerable_code> .name = "array.array",
.basicsize = sizeof(arrayobject),
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
Py_TPFLAGS_IMMUTABLETYPE),
.slots = array_slots,
};
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_co... |
<vulnerable_code> PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
0, ... |
<vulnerable_code> 0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_BASETYPE | Py_TPFLAGS_DICT_SUBCLASS |
_Py_TPFLAGS_MATCH_SELF, /* tp_flags */
dictionary_doc, /* tp_doc */
dict_tr... |
<vulnerable_code> 0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_BASETYPE | Py_TPFLAGS_LIST_SUBCLASS |
_Py_TPFLAGS_MATCH_SELF, /* tp_flags */
list___init____doc__, /* tp_doc */
(traver... |
<vulnerable_code> PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
&memory_as_buffer, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
memoryview__doc__, /* ... |
<vulnerable_code> PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
range_doc, /* tp_doc */
0, /* tp_traverse */
... |
<vulnerable_code> 0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_BASETYPE | Py_TPFLAGS_TUPLE_SUBCLASS |
_Py_TPFLAGS_MATCH_SELF, /* tp_flags */
tuple_new__doc__, /* tp_doc */
(trave... |
<vulnerable_code> else if (PyType_IsSubtype(base, &PyDict_Type)) {
type->tp_flags |= Py_TPFLAGS_DICT_SUBCLASS;
}
if (PyType_HasFeature(base, _Py_TPFLAGS_MATCH_SELF)) {
type->tp_flags |= _Py_TPFLAGS_MATCH_SELF;
}
}
static int<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in... |
<vulnerable_code> }
case TARGET(MATCH_MAPPING): {
// PUSH(isinstance(TOS, _collections_abc.Mapping))
PyObject *subject = TOP();
// Fast path for dicts:
if (PyDict_Check(subject)) {
Py_INCREF(Py_True);
PUSH(Py_True);
... |
<vulnerable_code> Py_CLEAR(interp->importlib);
Py_CLEAR(interp->import_func);
Py_CLEAR(interp->dict);
Py_CLEAR(interp->map_abc);
Py_CLEAR(interp->seq_abc);
#ifdef HAVE_FORK
Py_CLEAR(interp->before_forkers);
Py_CLEAR(interp->after_forkers_parent);<commit_title>[PATCH 003/413] bpo-43651: Fix En... |
<vulnerable_code> */
if (!(PyType_IsSubtype(newto, &PyModule_Type) &&
PyType_IsSubtype(oldto, &PyModule_Type)) &&
(!(newto->tp_flags & Py_TPFLAGS_HEAPTYPE) ||
!(oldto->tp_flags & Py_TPFLAGS_HEAPTYPE))) {
PyErr_Format(PyExc_TypeError,
"__class__ assignment o... |
<vulnerable_code> def assert_raise_on_new_sys_type(self, sys_attr):
# Users are intentionally prevented from creating new instances of
# sys.flags, sys.version_info, and sys.getwindowsversion.
attr_type = type(sys_attr)
with self.assertRaises(TypeError):
attr_type()
... |
<vulnerable_code>static PyType_Spec PyCursesPanel_Type_spec = {
.name = "_curses_panel.panel",
.basicsize = sizeof(PyCursesPanelObject),
.flags = Py_TPFLAGS_DEFAULT,
.slots = PyCursesPanel_Type_slots
};
if (state->PyCursesPanel_Type == NULL) {
return -1;
}
((PyTypeObject *)state->Py... |
<vulnerable_code>#ifdef NCURSES_VERSION
/* ncurses_version */
if (NcursesVersionType.tp_name == NULL) {
if (PyStructSequence_InitType2(&NcursesVersionType,
&ncurses_version_desc) < 0)
return NULL;
}
v = make_ncurses_version();
if (v == NULL)... |
<vulnerable_code> "_tkinter.Tcl_Obj",
sizeof(PyTclObject),
0,
Py_TPFLAGS_DEFAULT,
PyTclObject_Type_slots,
};
"_tkinter.tktimertoken",
sizeof(TkttObject),
0,
Py_TPFLAGS_DEFAULT,
Tktt_Type_slots,
};
"_tkinter.tkapp",
sizeof(TkappObject),
0,
Py_TPFLAGS_DEFAULT,
... |
<vulnerable_code> 0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
channelid_doc, /* tp_doc */
0, ... |
<vulnerable_code> members[k].name = NULL;
}
int
PyStructSequence_InitType2(PyTypeObject *type, PyStructSequence_Desc *desc)
{
PyMemberDef *members;
Py_ssize_t n_members, n_unnamed_members;
type->tp_base = &PyTuple_Type;
type->tp_methods = structseq_methods;
type->tp_new = structseq_new;
type... |
<vulnerable_code> CHECK(!(type->tp_flags & Py_TPFLAGS_READYING));
CHECK(type->tp_dict != NULL);
return 1;
#undef CHECK
}
if (type->tp_new == NULL) {
_PyErr_Format(tstate, PyExc_TypeError,
"cannot create '%.100s' instances",
type->tp_name);
ret... |
<vulnerable_code>
/* version_info */
if (VersionInfoType.tp_name == NULL) {
if (PyStructSequence_InitType2(&VersionInfoType,
&version_info_desc) < 0) {
goto type_init_failed;
}
}
version_info = make_version_info(tstate);
SET_SYS("ver... |
<vulnerable_code> def test_internal_types(self):
# internal types like _hashlib.HASH are not constructable
with self.assertRaisesRegex(
TypeError, "cannot create 'HASH' instance"
):
HASH()
with self.assertRaisesRegex(
TypeError, "cannot create 'HASH... |
<vulnerable_code> def test_internal_types(self):
# internal types like _hashlib.C_HMAC are not constructable
with self.assertRaisesRegex(
TypeError, "cannot create 'HMAC' instance"
):
C_HMAC()
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-... |
<vulnerable_code>}
/* LCOV_EXCL_STOP */
/* {Py_tp_new, NULL} doesn't block __new__ */
static PyObject *
_disabled_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
PyErr_Format(PyExc_TypeError,
"cannot create '%.100s' instances", _PyType_Name(type));
return NULL;
}
static PyObject*
py_digest... |
<vulnerable_code>#endif
} DirEntry;
static PyObject *
_disabled_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
PyErr_Format(PyExc_TypeError,
"cannot create '%.100s' instances", _PyType_Name(type));
return NULL;
}
static void
DirEntry_dealloc(DirEntry *entry)
{
};
static PyType_Slot DirEn... |
<vulnerable_code> timeout=support.SHORT_TIMEOUT,
returncode=1)
class MiscTests(EmbeddingTestsMixin, unittest.TestCase):
def test_unicode_id_init(self):
# bpo-42882: Test that _PyUnicode_FromId() works
# when Python is initia... |
<vulnerable_code> int fd;
} PyStdPrinter_Object;
static PyObject *
stdprinter_new(PyTypeObject *type, PyObject *args, PyObject *kews)
{
PyStdPrinter_Object *self;
assert(type != NULL && type->tp_alloc != NULL);
self = (PyStdPrinter_Object *) type->tp_alloc(type, 0);
if (self != NULL) {
sel... |
<vulnerable_code>/* Set up a preliminary stderr printer until we have enough
infrastructure for the io module in place.
Use UTF-8/surrogateescape and ignore EAGAIN errors. */
static PyStatus
_PySys_SetPreliminaryStderr(PyObject *sysdict)
{<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (G... |
<vulnerable_code>#include <windows.h>
#endif
/* Uncomment to display statistics on interned strings at exit
in _PyUnicode_ClearInterned(). */
/* #define INTERNED_STATS 1 */
if (size == 0)
_Py_RETURN_UNICODE_EMPTY();
/* Single character Unicode objects in the Latin-1 range are
shared when usi... |
<vulnerable_code>#include <sys/ioctl.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif /* HAVE_FCNTL_H */
static size_t
is_valid_wide_char(wchar_t ch)
{
if (Py_UNICODE_IS_SURROGATE(ch)) {
// Reject lone surrogate characters
return 0;
return str;
}
#ifdef MS_WINDOWS
static __int64 secs_b... |
<vulnerable_code> "elephant"
X.__doc__ = "banana"
self.assertEqual(X.__doc__, "banana")
with self.assertRaises(TypeError) as cm:
type(list).__dict__["__doc__"].__set__(list, "blah")
self.assertIn("can't set list.__doc__", str(cm.exception))
with self.assert... |
<vulnerable_code>static int
check_set_special_type_attr(PyTypeObject *type, PyObject *value, const char *name)
{
if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) {
PyErr_Format(PyExc_TypeError,
"can't set %s.%s", type->tp_name, name);
return 0;
}
if (!value) {
PyErr_... |
<vulnerable_code> Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='', offset=154, starts_line=None, is_jump_target=False),
Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=156, starts_line=None, is_jump_target=False),
Instruction(opname='POP_BLOCK', opcode=... |
<vulnerable_code> (-4, 'line'),
(-4, 'return'),
(2, 'line'),
(-3, 'call'),
(-2, 'line'),
(-2, 'return'),
(2, 'return')])
def test_if_false_in_try_except(self):
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in t... |
<vulnerable_code>compiler_unwind_fblock(struct compiler *c, struct fblockinfo *info,
int preserve_tos)
{
switch (info->fb_type) {
case WHILE_LOOP:
case EXCEPTION_HANDLER:
case WITH:
case ASYNC_WITH:
ADDOP(c, POP_BLOCK);
if (preserve_tos... |
<vulnerable_code> a[:] = [F()] * 10
self.assertEqual(select.select([], a, []), ([], a[:5], []))
def tearDownModule():
support.reap_children()
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
a[:] = [F()] * 10
self.asse... |
<vulnerable_code> return self;
}
static PyObject *
poll_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
PyErr_Format(PyExc_TypeError, "Cannot create '%.200s' instances", _PyType_Name(type));
return NULL;
}
static void
poll_dealloc(pollObject *self)
{
static PyType_Slot poll_Type_slots[] = {
... |
<vulnerable_code> self.assertRaises(TypeError, array.array, 'xx')
self.assertRaises(ValueError, array.array, 'x')
@support.cpython_only
def test_immutable(self):
# bpo-43908: check that array.array is immutable<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25... |
<vulnerable_code>import tempfile
import unittest
from test.support import requires, verbose, SaveSignals
from test.support.import_helper import import_module
# Optionally test curses module. This currently requires that the
panel.set_userptr(A())
panel.set_userptr(None)
@requires_curses_func('pa... |
<vulnerable_code>from test import support
from test.support import import_helper
gdbm = import_helper.import_module("dbm.gnu") #skip if not supported
import unittest
import os
self.g.close()
unlink(filename)
def test_key_methods(self):
self.g = gdbm.open(filename, 'c')
self.asse... |
<vulnerable_code> if c_functools:
cmp_to_key = c_functools.cmp_to_key
class TestCmpToKeyPy(TestCmpToKey, unittest.TestCase):
cmp_to_key = staticmethod(py_functools.cmp_to_key)<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
if c_func... |
<vulnerable_code> self.assertGreaterEqual(sre_compile.MAXREPEAT, 0)
self.assertGreaterEqual(sre_compile.MAXGROUPS, 0)
class ExternalTests(unittest.TestCase):
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
self.assertGreaterEqua... |
<vulnerable_code> check('{\n')
check('}\n')
def test_new_tcl_obj(self):
self.assertRaises(TypeError, _tkinter.Tcl_Obj)
class BigmemTclTest(unittest.TestCase):
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
check('{\... |
<vulnerable_code> thread = threading.Thread(target=func)
self.assertEqual(thread.name, "Thread-5 (func)")
# Create a bunch of threads, let each do some work, wait until all are
# done.
def test_various_ops(self):<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io ... |
<vulnerable_code>import sys
import unicodedata
import unittest
from test.support import open_urlresource, requires_resource, script_helper
class UnicodeMethodsTest(unittest.TestCase):
class UnicodeMiscTest(UnicodeDatabaseTest):
def test_failed_import_during_compiling(self):
# Issue 4367
# Decodi... |
<vulnerable_code> with self.assertRaisesRegex(OverflowError, 'int too large'):
zlib.decompressobj().flush(sys.maxsize + 1)
class BaseCompressTestCase(object):
def check_big_compress_buffer(self, size, compress_func):<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-250... |
<vulnerable_code> // dbmtype_spec does not have Py_TPFLAGS_BASETYPE flag
// which prevents to create a subclass.
// So calling PyType_GetModuleState() in this file is always safe.
.flags = Py_TPFLAGS_DEFAULT,
.slots = dbmtype_spec_slots,
};
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning... |
<vulnerable_code>static PyType_Spec keyobject_type_spec = {
.name = "functools.KeyWrapper",
.basicsize = sizeof(keyobject),
.flags = Py_TPFLAGS_DEFAULT,
.slots = keyobject_type_slots
};
static PyType_Spec lru_list_elem_type_spec = {
.name = "functools._lru_list_elem",
.basicsize = sizeof(lru_li... |
<vulnerable_code> // dbmtype_spec does not have Py_TPFLAGS_BASETYPE flag
// which prevents to create a subclass.
// So calling PyType_GetModuleState() in this file is always safe.
.flags = Py_TPFLAGS_DEFAULT,
.slots = gdbmtype_spec_slots,
};
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarnin... |
<vulnerable_code> .name = "re.Pattern",
.basicsize = sizeof(PatternObject),
.itemsize = sizeof(SRE_CODE),
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE,
.slots = pattern_slots,
};
.name = "re.Match",
.basicsize = sizeof(MatchObject),
.itemsize = sizeof(Py_ssize_t),
.flags = ... |
<vulnerable_code>static PyType_Spec lock_type_spec = {
.name = "_thread.lock",
.basicsize = sizeof(lockobject),
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
.slots = lock_type_slots,
};
static PyType_Spec local_dummy_type_spec = {
.name = "_thread._localdummy",
.basicsize = sizeof(localdum... |
<vulnerable_code>static PyType_Spec winapi_overlapped_type_spec = {
.name = "_winapi.Overlapped",
.basicsize = sizeof(OverlappedObject),
.flags = Py_TPFLAGS_DEFAULT,
.slots = winapi_overlapped_type_slots,
};
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_descri... |
<vulnerable_code>static PyType_Spec arrayiter_spec = {
.name = "array.arrayiterator",
.basicsize = sizeof(arrayiterobject),
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
.slots = arrayiter_slots,
};
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description... |
<vulnerable_code>static PyType_Spec multibytecodec_spec = {
.name = MODULE_NAME ".MultibyteCodec",
.basicsize = sizeof(MultibyteCodecObject),
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
.slots = multibytecodec_slots,
};
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25... |
<vulnerable_code>static PyType_Spec _xml_parse_type_spec = {
.name = "pyexpat.xmlparser",
.basicsize = sizeof(xmlparseobject),
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
.slots = _xml_parse_type_spec_slots,
};
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<comm... |
<vulnerable_code>static PyType_Spec ucd_type_spec = {
.name = "unicodedata.UCD",
.basicsize = sizeof(PreviousDBVersion),
.flags = Py_TPFLAGS_DEFAULT,
.slots = ucd_type_slots
};
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
static PyTyp... |
<vulnerable_code>};
static PyType_Spec Comptype_spec = {
"zlib.Compress",
sizeof(compobject),
0,
Py_TPFLAGS_DEFAULT,
Comptype_slots
};
static PyType_Slot Decomptype_slots[] = {
};
static PyType_Spec Decomptype_spec = {
"zlib.Decompress",
sizeof(compobject),
0,
Py_TPFLAGS_DEFAULT,
... |
<vulnerable_code> tp = type(select.poll())
self.assertRaises(TypeError, tp)
def tearDownModule():
support.reap_children()
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
tp = type(select.poll())
self.assertRaises(Type... |
<vulnerable_code> return self;
}
static PyObject *
devpoll_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
PyErr_Format(PyExc_TypeError, "Cannot create '%.200s' instances", _PyType_Name(type));
return NULL;
}
static void
devpoll_dealloc(devpollObject *self)
{
{Py_tp_dealloc, devpoll_dealloc... |
<vulnerable_code>import unittest
import weakref
from test.support import gc_collect
from test.support.script_helper import assert_python_ok
import sys
del foo.__annotations__
def test_annotations_are_created_correctly(self):
from test import ann_module4
self.assertTrue("__annotations__... |
<vulnerable_code>
if ((dict == NULL) || !PyDict_Check(dict)) {
PyErr_Format(PyExc_TypeError, "<module>.__dict__ is not a dictionary");
return NULL;
}
static int
module_set_annotations(PyModuleObject *m, PyObject *value, void *Py_UNUSED(ignored))
{
PyObject *dict = _PyObject_GetAttrId((PyObj... |
<vulnerable_code> if fips_mode is not None:
self.assertIsInstance(fips_mode, int)
@unittest.skipUnless(HASH is not None, 'need _hashlib')
def test_internal_types(self):
# internal types like _hashlib.HASH are not constructable
with self.assertRaisesRegex(
TypeErro... |
<vulnerable_code>static PyType_Spec md5_type_spec = {
.name = "_md5.md5",
.basicsize = sizeof(MD5object),
.flags = Py_TPFLAGS_DEFAULT,
.slots = md5_type_slots
};
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
static PyType_Spec md5_typ... |
<vulnerable_code>static PyType_Spec sha1_type_spec = {
.name = "_sha1.sha1",
.basicsize = sizeof(SHA1object),
.flags = Py_TPFLAGS_DEFAULT,
.slots = sha1_type_slots
};
}
Py_INCREF(st->sha1_type);
if (PyModule_AddObject(module,
"SHA1Type",
... |
<vulnerable_code>static PyType_Spec sha224_type_spec = {
.name = "_sha256.sha224",
.basicsize = sizeof(SHAobject),
.flags = Py_TPFLAGS_DEFAULT,
.slots = sha256_types_slots
};
static PyType_Spec sha256_type_spec = {
.name = "_sha256.sha256",
.basicsize = sizeof(SHAobject),
.flags = Py_TPFLAG... |
<vulnerable_code>static PyType_Spec sha512_sha384_type_spec = {
.name = "_sha512.sha384",
.basicsize = sizeof(SHAobject),
.flags = Py_TPFLAGS_DEFAULT,
.slots = sha512_sha384_type_slots
};
static PyType_Spec sha512_sha512_type_spec = {
.name = "_sha512.sha512",
.basicsize = sizeof(SHAobject),
... |
<vulnerable_code> squeezer = Mock()
squeezer.editwin.text = Text(root)
squeezer.editwin.per = Percolator(squeezer.editwin.text)
# Set default values for the configuration settings.
squeezer.auto_squeeze_min_lines = 50<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in... |
<vulnerable_code> if max_num_fields < num_fields:
raise ValueError('Max number of fields exceeded')
pairs = [s1 for s1 in qs.split(separator)]
r = []
for name_value in pairs:
if not name_value and not strict_parsing:
continue
nv = name_value.split('=', 1)<comm... |
<vulnerable_code> Argument:
distance -- a number
Move the turtle backward by distance ,opposite to the direction the
turtle is headed. Do not change the turtle's heading.
Example (for a Turtle instance named turtle):<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in... |
<vulnerable_code># This just tests whether the parser accepts them all.
from test.support import check_syntax_error
from test.support.warnings_helper import check_syntax_warning
import inspect
import unittest
def test_var_annot_in_module(self):
# check that functions fail the same way when executed
... |
<vulnerable_code>/* On success, return value >= 0
On failure, return -1 */
static inline Py_ssize_t
Buffer_InitAndGrow(_BlocksOutputBuffer *buffer, Py_ssize_t max_length,
char **next_out, uint32_t *avail_out)
{
Py_ssize_t allocated;
/* On success, return value >= 0
On failure, return -1 */... |
<vulnerable_code>/* On success, return value >= 0
On failure, return -1 */
static inline Py_ssize_t
Buffer_InitAndGrow(_BlocksOutputBuffer *buffer, Py_ssize_t max_length,
uint8_t **next_out, size_t *avail_out)
{
Py_ssize_t allocated;
/* On success, return value >= 0
On failure, return -1 *... |
<vulnerable_code>/* On success, return value >= 0
On failure, return -1 */
static inline Py_ssize_t
Buffer_InitAndGrow(_BlocksOutputBuffer *buffer, Py_ssize_t max_length,
Bytef **next_out, uint32_t *avail_out)
{
Py_ssize_t allocated;
/* On success, return value >= 0
On failure, return -1 *... |
<vulnerable_code>EXPORT_FUNC(_PyObject_New)
EXPORT_FUNC(_PyObject_NewVar)
EXPORT_FUNC(_PyState_AddModule)
EXPORT_FUNC(_PyThreadState_Init)
EXPORT_FUNC(_PyThreadState_Prealloc)
EXPORT_FUNC(_PyTrash_deposit_object)<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed... |
<vulnerable_code>
def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen,
match_args, kw_only):
# Now that dicts retain insertion order, there's no reason to use
# an ordered dict. I am leveraging that ordering here, because
# derived class fields overwrite base class fields... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.