text stringlengths 79 3.72M |
|---|
<vulnerable_code> bluc = None
print(bluch)
for func, suggestion in [(Substitution, "blech?"),
(Elimination, "blch?"),
(Addition, "bluchin?"),
(EliminationOverAddition, "blucha?"),
... |
<vulnerable_code> PyObject* suggestions = _Py_Offer_Suggestions(value);
if (suggestions) {
// Add a trailer ". Did you mean: (...)?"
err = PyFile_WriteString(". Did you mean: ", f);
if (err == 0) {
err = PyFile_WriteObject(suggestions, f, Py_PRINT_RAW);
err += PyFi... |
<vulnerable_code>import sys
from _ast import *
from contextlib import contextmanager, nullcontext
from enum import IntEnum, auto
def parse(source, filename='<unknown>', mode='exec', *,
# We unparse those infinities to INFSTR.
_INFSTR = "1e" + repr(sys.float_info.max_10_exp + 1)
class _Precedence(IntEnum):
"""Pre... |
<vulnerable_code> )
return enum_dict
def __new__(metacls, cls, bases, classdict, boundary=None, **kwds):
# an Enum class is final once enumeration items have been defined; it
# cannot be mixed with other types (int, float, etc.) if it has an
# inherited __new__ un... |
<vulnerable_code>from enum import IntEnum
__all__ = ['HTTPStatus']
class HTTPStatus(IntEnum):
"""HTTP status codes and reason phrases
Status codes from the following RFCs are all observed:<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
from e... |
<vulnerable_code>import marshal
import re
from enum import Enum
from functools import cmp_to_key
from dataclasses import dataclass
from typing import Dict
__all__ = ["Stats", "SortKey", "FunctionProfile", "StatsProfile"]
class SortKey(str, Enum):
CALLS = 'calls', 'ncalls'
CUMULATIVE = 'cumulative', 'cumtime'... |
<vulnerable_code>__version__ = "2.2.1"
@enum.global_enum
class RegexFlag(enum.IntFlag, boundary=enum.KEEP):
ASCII = A = sre_compile.SRE_FLAG_ASCII # assume ascii "locale"
IGNORECASE = I = sre_compile.SRE_FLAG_IGNORECASE # ignore case
LOCALE = L = sre_compile.SRE_FLAG_LOCALE # assume current 8-bit locale<co... |
<vulnerable_code>import os
from collections import namedtuple
from enum import Enum as _Enum, IntEnum as _IntEnum, IntFlag as _IntFlag
import _ssl # if we can't import it, let the error propagate
_SSLv2_IF_EXISTS = getattr(_SSLMethod, 'PROTOCOL_SSLv2', None)
class TLSVersion(_IntEnum):
MINIMUM_SUPPO... |
<vulnerable_code>import ast
import builtins
import dis
import os
import sys
import types
with self.assertRaisesRegex(ValueError, f"Name node can't be used with '{constant}' constant"):
compile(expr, "<test>", "eval")
class ASTHelpers_Test(unittest.TestCase):
maxDiff = None<commit_title... |
<vulnerable_code>import threading
from collections import OrderedDict
from enum import Enum, IntEnum, StrEnum, EnumType, Flag, IntFlag, unique, auto
from enum import STRICT, CONFORM, EJECT, KEEP
from io import StringIO
from pickle import dumps, loads, PicklingError, HIGHEST_PROTOCOL
from test import support
... |
<vulnerable_code>import errno
from http import client, HTTPStatus
import io
# see issue40084
self.assertTrue({'description', 'name', 'phrase', 'value'} <= set(dir(HTTPStatus(404))))
def test_status_lines(self):
# Test HTTP status lines
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWa... |
<vulnerable_code>from test import support
from io import StringIO
from pstats import SortKey
import pstats
import cProfile
self.assertEqual(
self.stats.sort_type,
self.stats.sort_arg_dict_default[member.value][-1])
def test_sort_starts_mix(self):
self.as... |
<vulnerable_code>import errno
import os
import random
self.assertIsInstance(sig, signal.Signals)
self.assertEqual(sys.platform, "win32")
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
class PosixTests(unittest.TestCase):<commit_title>[PATCH 003/413] bpo-43651: Fix En... |
<vulnerable_code> fileno=afile.fileno())
self.assertEqual(cm.exception.errno, errno.ENOTSOCK)
@unittest.skipUnless(HAVE_SOCKET_CAN, 'SocketCan required for this test.')
class BasicCANTest(unittest.TestCase):<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-2509... |
<vulnerable_code>import socket
import select
import time
import gc
import os
import errno
ssl = import_helper.import_module("ssl")
from ssl import TLSVersion, _TLSContentType, _TLSMessageType
Py_DEBUG = hasattr(sys, 'gettotalrefcount')
Py_DEBUG_WIN32 = Py_DEBUG and sys.platform == 'win32'
s.connect((... |
<vulnerable_code> PI = 3.1415926
class Int(enum.IntEnum):
IDES = 15
class Str(str, enum.Enum):
ABC = 'abc'
# Testing Unicode formatting strings...
self.assertEqual("%s, %s" % (Str.ABC, Str.ABC),
'ABC, ABC')
self.assertEq... |
<vulnerable_code>import builtins
import contextlib
import copy
import io
import os
import pickle
class BaseTestUUID:
uuid = None
def test_UUID(self):
equal = self.assertEqual
ascending = []<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fix... |
<vulnerable_code> return dict
class EventType(enum.StrEnum):
KeyPress = '2'
Key = KeyPress
KeyRelease = '3'
Deactivate = '37'
MouseWheel = '38'
__str__ = str.__str__
class Event:
"""Container for the properties of an event.<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning ... |
<vulnerable_code>import unittest
import tkinter
from test import support
from tkinter.test.support import AbstractTkTest, AbstractDefaultRootTest
" num=3 delta=-1 focus=True"
" x=10 y=20 width=300 height=200>")
def test_getboolean(self):
for v in 'true', '... |
<vulnerable_code>import os
import sys
from enum import Enum
__author__ = 'Ka-Ping Yee <ping@zesty.ca>'
bytes_ = bytes # The built-in bytes type
class SafeUUID(Enum):
safe = 0
unsafe = -1
unknown = None<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description... |
<vulnerable_code> floor = _floor
n += 0.0 # convert to float for a small speed improvement
return [population[floor(random() * n)] for i in _repeat(None, k)]
cum_weights = list(_accumulate(weights))
elif weights is not None:
raise TypeErr... |
<vulnerable_code> try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3, False)
try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_TLSv1, False)
# SSLv23 client with specific SSL options
if no_sslv2_implies_sslv3_hello():
# No SSLv2 => client will use an SSLv3 hello o... |
<vulnerable_code>#endif
/* OpenSSL API 1.1.0+ does not include version methods */
#ifndef OPENSSL_NO_TLS1_METHOD
extern const SSL_METHOD *TLSv1_method(void);
#endif<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
#endif
/* OpenSSL API 1.1.0+ does not i... |
<vulnerable_code>
ns = {}
exec(txt, globals, ns)
func = ns['__create_fn__'](**locals)
for arg, annotation in func.__annotations__.copy().items():
func.__annotations__[arg] = locals[annotation]
return func
def _field_assign(frozen, name, value, self_name):
# If we're a frozen class, then... |
<vulnerable_code># Python 3.10a6 3434 (PEP 634: Structural Pattern Matching)
# Python 3.10a7 3435 Use instruction offsets (as opposed to byte offsets).
# Python 3.10b1 3436 (Add GEN_START bytecode #43683)
#
# MAGIC must change whenever the bytecode emitted by the compiler may no
# Whenever MAGIC_NUMBER is ... |
<vulnerable_code>import tokenize
import token
import types
import typing
import warnings
import functools
import builtins
code = getattr(obj, '__code__', None)
defaults = getattr(obj, '__defaults__', _void) # Important to use _void ...
kwdefaults = getattr(obj, '__kwdefaults__', _void) # ... and not None he... |
<vulnerable_code>import dataclasses
import typing
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
#from __future__ import annotations
USING_STRINGS = False
# dataclass_module_1.py and dataclass_module_1_str.py are identical
# except only the latter use... |
<vulnerable_code><commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
from __future__ import annotations
USING_STRINGS = True
# dataclass_module_1.py and dataclass_module_1_str.py are identical
# except only the latter uses string annotations.
import datac... |
<vulnerable_code>from dataclasses import dataclass, InitVar
from typing import ClassVar
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
#from __future__ import annotations
USING_STRINGS = False
# dataclass_module_2.py and dataclass_module_2_str.py are ... |
<vulnerable_code><commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
from __future__ import annotations
USING_STRINGS = True
# dataclass_module_2.py and dataclass_module_2_str.py are identical
# except only the latter uses string annotations.
from datacla... |
<vulnerable_code>import dataclasses
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
from __future__ import annotations
import dataclasses
|
<vulnerable_code>import unittest
import sys
from textwrap import dedent
class PostponedAnnotationsTestCase(unittest.TestCase):
template = dedent(
"""
def f() -> {ann}:
...
def g(arg: {ann}) -> None:
...
async def f2() -> {ann}:
...
async d... |
<vulnerable_code> pass
""",
"""async def foo():
def bar():
[i async for i in els]
pass
""",
"""def baz():
async def foo(a=await b):
pass<commit_title>[PATCH 003/... |
<vulnerable_code>import inspect
import builtins
import unittest
from textwrap import dedent
from unittest.mock import Mock
from typing import ClassVar, Any, List, Union, Tuple, Dict, Generic, TypeVar, Optional
from typing import get_type_hints
self.assertEqual(len(the_fields), 3)
self.assertEqual(the_f... |
<vulnerable_code> 2 0 SETUP_ANNOTATIONS
2 LOAD_CONST 0 (1)
4 STORE_NAME 0 (x)
6 LOAD_CONST 1 ('int')
8 LOAD_NAME 1 (__annotations__)
10 LOAD_CONST 2 ('x')
1... |
<vulnerable_code>
def _default_update(self):
def f(a: int):
"""This is a test"""
pass
f.attr = 'This is also a test'
self.assertEqual(wrapper.__name__, 'f')
self.assertEqual(wrapper.__qualname__, f.__qualname__)
self.assertEqual(wrapper.attr, 'This is... |
<vulnerable_code> z = 2
def __init__(self, x):
self.x: int = x
self.assertEqual(C.__annotations__, {'_C__foo': 'int', 's': 'str'})
with self.assertRaises(NameError):
class CBad:
no_such_name_defined.attr: int = 0
return {... |
<vulnerable_code>
self.assertFullArgSpecEquals(mod2.annotated, ['arg1'],
ann_e={'arg1' : list},
formatted="(arg1: list)")
self.assertFullArgSpecEquals(mod2.keyword_only_arg, [],
kwonlyargs_e=['... |
<vulnerable_code> def test_use_existing_annotations(self):
ns = {'__annotations__': {1: 2}}
exec('x: int', ns)
self.assertEqual(ns['__annotations__'], {'x': 'int', 1: 2})
def test_do_not_recreate_annotations(self):
# Don't rely on the existence of the '__annotations__' global.<co... |
<vulnerable_code> def f(x: int, /): ...
return f
assert inner_has_pos_only().__annotations__ == {'x': 'int'}
class Something:
def method(self):
def f(x: int, /): ...
return f
assert Something().method().__annotations__ == {'x'... |
<vulnerable_code> |\x20\x20
| NO_MEANING = 'eggs'
|\x20\x20
| __annotations__ = {'NO_MEANING': 'str'}
\x20\x20\x20\x20
class C(builtins.object)
| Methods defined here:
Data and other attributes defined here:<br>
<dl><dt><strong>NO_MEANING</strong> = 'eggs'</dl>
<dl><dt><strong>__annotati... |
<vulnerable_code> Traceback (most recent call last):
SyntaxError: cannot assign to __debug__
>>> with (lambda *:0): pass
Traceback (most recent call last):
SyntaxError: named arguments must follow bare *<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_descrip... |
<vulnerable_code> ForwardBefore = 'Forward' | T
def forward_after(x: ForwardAfter[int]) -> None: ...
def forward_before(x: ForwardBefore[int]) -> None: ...
assert typing.get_args(typing.get_type_hints(forward_after, localns=locals())['x']) == (int, Forward)
assert typing.get_args(... |
<vulnerable_code> def test_no_eval_union(self):
u = Union[int, str]
def f(x: u): ...
self.assertIs(get_type_hints(f, globals(), locals())['x'], u)
def test_function_repr_union(self):
def fun() -> int: ...
self.assertEqual(gth(HasForeignBaseClass),
... |
<vulnerable_code> def __init__(self, arg, is_argument=True):
if not isinstance(arg, str):
raise TypeError(f"Forward reference must be a string -- got {arg!r}")
# Double-stringified forward references is a result of activating
# the 'annotations' future by default. This way, we el... |
<vulnerable_code>static int astfold_arguments(arguments_ty node_, PyArena *ctx_, _PyASTOptimizeState *state);
static int astfold_comprehension(comprehension_ty node_, PyArena *ctx_, _PyASTOptimizeState *state);
static int astfold_keyword(keyword_ty node_, PyArena *ctx_, _PyASTOptimizeState *state);
static int astfold_w... |
<vulnerable_code>compiler_visit_argannotation(struct compiler *c, identifier id,
expr_ty annotation, Py_ssize_t *annotations_len)
{
if (annotation) {
PyObject *mangled = _Py_Mangle(c->u->u_private, id);
if (!mangled)
return 0;
ADDOP_LOAD_CONST(c, mangled);
Py_DECREF(... |
<vulnerable_code> } else if (strcmp(feature, FUTURE_GENERATOR_STOP) == 0) {
continue;
} else if (strcmp(feature, FUTURE_ANNOTATIONS) == 0) {
continue;
} else if (strcmp(feature, "braces") == 0) {
PyErr_SetString(PyExc_SyntaxError,
"n... |
<vulnerable_code># @generated by pegen from ./Tools/peg_generator/pegen/metagrammar.gram
import ast
from typing import Optional
from pegen.parser import memoize, memoize_left_rec, logger, Parser
from ast import literal_eval<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_descr... |
<vulnerable_code># @generated by pegen from {filename}
import ast
from typing import Optional
from pegen.parser import memoize, memoize_left_rec, logger, Parser
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
# @generated by pegen from {filename}
imp... |
<vulnerable_code>
# should not apply to subclasses, see issue #31161
s = '''if True:\nprint "No indent"'''
ckmsg(s, "expected an indented block", IndentationError)
s = '''if True:\n print()\n\texec "mixed tabs and spaces"'''
ckmsg(s, "inconsistent use of tabs and spaces i... |
<vulnerable_code> Traceback (most recent call last):
SyntaxError: invalid syntax
Make sure that the old "raise X, Y[, Z]" form is gone:
>>> raise X, Y
Traceback (most recent call last):<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
Trace... |
<vulnerable_code>#define invalid_group_type 1195
#define invalid_import_from_targets_type 1196
#define invalid_with_stmt_type 1197
#define invalid_except_block_type 1198
#define invalid_match_stmt_type 1199
#define invalid_case_block_type 1200
#define invalid_if_stmt_type 1201
#define invalid_elif_stmt_type 1202
#defin... |
<vulnerable_code>_PyType_GetModuleByDef(PyTypeObject *type, struct PyModuleDef *def)
{
assert(PyType_Check(type));
assert(type->tp_mro);
int i;
for (i = 0; i < PyTuple_GET_SIZE(type->tp_mro); i++) {
PyObject *super = PyTuple_GET_ITEM(type->tp_mro, i);
if (!PyType_HasFeature((PyTypeObject... |
<vulnerable_code>
new_mro = PySequence_Tuple(mro_result);
Py_DECREF(mro_result);
if (new_mro == NULL)
return NULL;
if (custom && mro_check(type, new_mro) < 0) {
Py_DECREF(new_mro);
return NULL;
}
return new_mro;
}
new_mro = mro_invoke(type); /* might cause reentra... |
<vulnerable_code> All rights reserved.
*/
/* partial object **********************************************************/
typedef struct {
PyObject_HEAD
PyObject *fn;
PyObject *args;
PyObject *kw;
PyObject *dict; /* __dict__ */
PyObject *weakreflist; /* List of weak references */
ve... |
<vulnerable_code> }
// Create and initialize the new interpreter.
PyThreadState *save_tstate = PyThreadState_Swap(NULL);
// XXX Possible GILState issues?
PyThreadState *tstate = _Py_NewInterpreter(isolated);
PyThreadState_Swap(save_tstate);<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWar... |
<vulnerable_code> zero or more directories and subdirectories.
"""
sys.audit("glob.glob", pathname, recursive)
if root_dir is not None:
root_dir = os.fspath(root_dir)
else:<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
ze... |
<vulnerable_code>/* ABCMeta implementation */
#include "Python.h"
#include "clinic/_abc.c.h"
/*[clinic input]
static inline _abcmodule_state*
get_abc_state(PyObject *module)
{
void *state = PyModule_GetState(module);
assert(state != NULL);
return (_abcmodule_state *)state;
}<commit_title>[PATCH 003/413] b... |
<vulnerable_code>#include "Python.h"
#include "pycore_long.h" // _PyLong_GetZero()
#include "pycore_object.h" // _PyObject_GC_TRACK
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_tuple.h" // _PyTuple_ITEMS()
static inline _functools_state *
get_functools_state(PyObjec... |
<vulnerable_code>
#include "Python.h"
#include "clinic/_operator.c.h"
typedef struct {
static inline _operator_state*
get_operator_state(PyObject *module)
{
void *state = PyModule_GetState(module);
assert(state != NULL);
return (_operator_state *)state;
}<commit_title>[PATCH 003/413] bpo-43651: Fix Encodi... |
<vulnerable_code>#endif
#include "Python.h"
#include "structmember.h" // PyMemberDef
PyDoc_STRVAR(pickle_module_doc,
static PickleState *
_Pickle_GetState(PyObject *module)
{
return (PickleState *)PyModule_GetState(module);
}
/* Find the module instance imported in the currently running sub-interpreter<c... |
<vulnerable_code>#include "Python.h"
#include "structmember.h" // PyMemberDef
#include <stddef.h> // offsetof()
static simplequeue_state *
simplequeue_get_state(PyObject *module)
{
simplequeue_state *state = PyModule_GetState(module);
assert(state);
return state;
}<commit_title>[PATCH... |
<vulnerable_code>/* ---------------------------------------------------------------*/
#include "Python.h"
#ifdef HAVE_PROCESS_H
# include <process.h> // getpid()
#endif
static inline _randomstate*
get_random_state(PyObject *module)
{
void *state = PyModule_GetState(module);
assert(state != NULL);
... |
<vulnerable_code>
#include "Python.h"
#include "pycore_long.h" // _PyLong_GetZero()
#include "structmember.h" // PyMemberDef
#include "sre.h"
static _sremodulestate *
get_sre_module_state(PyObject *m)
{
_sremodulestate *state = (_sremodulestate *)PyModule_GetState(m);
assert(state);
return... |
<vulnerable_code>#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h" // PyMemberDef
#include <ctype.h>
static inline _structmodulestate*
get_struct_state(PyObject *module)
{
void *state = PyModule_GetState(module);
assert(state != NULL);
return (_structmodulestate *)state;
}<com... |
<vulnerable_code>/* Interface to Sjoerd's portable C thread library */
#include "Python.h"
#include "pycore_pylifecycle.h"
#include "pycore_interp.h" // _PyInterpreterState.num_threads
#include "pycore_pystate.h" // _PyThreadState_Init()
#include <stddef.h> // offsetof()
#include "structmemb... |
<vulnerable_code>/* See http://www.python.org/2.4/license for licensing details. */
#include "Python.h"
#include "moduleobject.h" // PyModuleDef_Slot
#include "structmember.h" // PyMemberDef
static inline WinApiState*
winapi_get_state(PyObject *module)
{
void *state = PyModule_GetState(module);
... |
<vulnerable_code>
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h" // PyMemberDef
#include <stddef.h> // offsetof()
static array_state *
get_array_state(PyObject *module)
{
return (array_state *)PyModule_GetState(module);
}
#define find_array_state_by_type(tp) \<commit_... |
<vulnerable_code>
#include "Python.h"
#include "pycore_fileutils.h"
#ifdef MS_WINDOWS
/* include <windows.h> early to avoid conflict with pycore_condvar.h:
static inline _posixstate*
get_posix_state(PyObject *module)
{
void *state = PyModule_GetState(module);
assert(state != NULL);
return (_posixstate *... |
<vulnerable_code>
#include "Python.h"
#include "pycore_ceval.h" // _PyEval_BuiltinsFromGlobals()
#include "pycore_object.h" // _PyObject_GC_UNTRACK()
#include "frameobject.h" // PyFrameObject
PyObject *builtins = _PyDict_GetItemIdWithError(globals, &PyId___builtins__);
if (builtins) {
... |
<vulnerable_code>#include "Python.h"
#include "pycore_interp.h" // PyInterpreterState.importlib
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "structmember.h" // PyMemberDef
static Py_ssize_t max_module_number;
_Py_IDENTIFIER(__name__);
_Py_IDENTIFIER(__spec__);
typedef struct... |
<vulnerable_code>#include "pycore_call.h"
#include "pycore_compile.h" // _Py_Mangle()
#include "pycore_initconfig.h"
#include "pycore_object.h"
#include "pycore_pyerrors.h"
#include "pycore_pystate.h" // _PyThreadState_GET()
if (m == NULL) {
return NULL;
}
return PyModule_GetState(m);
}
... |
<vulnerable_code> #
# array objects
self.add(Extension('array', ['arraymodule.c']))
# Context Variables
self.add(Extension('_contextvars', ['_contextvarsmodule.c']))
self.add(Extension("_asyncio", ["_asynciomodule.c"],
extra_compile_args=['-DPy... |
<vulnerable_code>#ifdef MS_WINDOWS
/* Issue #26227: gethostbyaddr() returns a string encoded
* to the ANSI code page */
return PyUnicode_DecodeFSDefault(name);
#else
/* Decode from UTF-8 */
return PyUnicode_FromString(name);<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH... |
<vulnerable_code>CONVERT_STRING_TEST_NAME_F = 5
class TestIntEnumConvert(unittest.TestCase):
def test_convert_value_lookup_priority(self):
test_type = enum.IntEnum._convert_(
'UnittestConvert',
filter=lambda x: x.startswith('CONVERT_TEST_'))
def test_convert_repr_and_st... |
<vulnerable_code> if self.is_snan():
raise TypeError('Cannot hash a signaling NaN value.')
elif self.is_nan():
return _PyHASH_NAN
else:
if self._sign:
return -_PyHASH_INF<commit_title>[PATCH 003/413] bpo-43651: Fix En... |
<vulnerable_code> #error "No valid combination of CONFIG_64, CONFIG_32 and _PyHASH_BITS"
#endif
const Py_hash_t py_hash_inf = 314159;
const Py_hash_t py_hash_nan = 0;
mpd_uint_t ten_data[1] = {10};
mpd_t ten = {MPD_POS|MPD_STATIC|MPD_CONST_DATA,
0, 2, 1, 1, ten_data};
ret... |
<vulnerable_code>complex_hash(PyComplexObject *v)
{
Py_uhash_t hashreal, hashimag, combined;
hashreal = (Py_uhash_t)_Py_HashDouble(v->cval.real);
if (hashreal == (Py_uhash_t)-1)
return -1;
hashimag = (Py_uhash_t)_Py_HashDouble(v->cval.imag);
if (hashimag == (Py_uhash_t)-1)
return -1;... |
<vulnerable_code>static Py_hash_t
float_hash(PyFloatObject *v)
{
return _Py_HashDouble(v->ob_fval);
}
static PyObject *<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
static Py_hash_t
float_hash(PyFloatObject *v)
{
return _Py_HashDouble((PyObje... |
<vulnerable_code> If the result of the reduction is infinity (this is impossible for
integers, floats and Decimals) then use the predefined hash value
_PyHASH_INF for x >= 0, or -_PyHASH_INF for x < 0, instead.
_PyHASH_INF, -_PyHASH_INF and _PyHASH_NAN are also used for the
hashes of float and Decimal inf... |
<vulnerable_code> PyStructSequence_SET_ITEM(hash_info, field++,
PyLong_FromLong(_PyHASH_INF));
PyStructSequence_SET_ITEM(hash_info, field++,
PyLong_FromLong(_PyHASH_NAN));
PyStructSequence_SET_ITEM(hash_info, field++,
P... |
<vulnerable_code> if build:
l.append(build)
try:
ints = map(int, l)
except ValueError:
strings = l
else:
strings = list(map(str, ints))
version = '.'.join(strings[:3])
return version
return release, version, csd, ptype
winver = getwindowsversion()
... |
<vulnerable_code>{
HANDLE hFindFile;
WIN32_FIND_DATAW FileData;
hFindFile = FindFirstFileW(pszFile, &FileData);
if (hFindFile == INVALID_HANDLE_VALUE)
return FALSE;
FindClose(hFindFile);
find_data_to_file_info(&FileData, info, reparse_tag);
return TRUE;<commit_title>[PATCH 003/413] b... |
<vulnerable_code>
_IGNORED_WINERRORS = (
21, # ERROR_NOT_READY - drive exists but is not accessible
1921, # ERROR_CANT_RESOLVE_FILENAME - fix for broken symlink pointing to itself
)
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
_IGNORED_WIN... |
<vulnerable_code> while (--n > 0 && (filename[n] == L'\\' || filename[n] == L'/')) {
((LPWSTR)filename)[n] = L'\0';
}
if (!n || filename[n] == L':') {
// Nothing left te query
free((void *)filename);
return FALSE;
}<commit_title>[PATCH 003/4... |
<vulnerable_code>
DEBUG = False
def any(name, alternates):
"Return a named group pattern matching list of alternates."
return "(?P<%s>" % name + "|".join(alternates) + ")"
def make_pat():
kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b"
builtinlist = [str(name) for name in dir(builtins)
... |
<vulnerable_code>import io
import re
import socket
import collections.abc
from urllib.parse import urlsplit
def connect(self):
"""Connect to the host and port specified in __init__."""
self.sock = self._create_connection(
(self.host,self.port), self.timeout, self.source_address)
... |
<vulnerable_code> gc.get_referents(y)
if __name__ == "__main__":
from test.support import suppress_msvcrt_asserts
<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
gc.get_referents(y)
def test_http_client():
import http.client
def ... |
<vulnerable_code> ["gc.get_objects", "gc.get_referrers", "gc.get_referents"]
)
if __name__ == "__main__":
unittest.main()<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
["gc.get_objects", "gc.get_referrers", "gc.get_... |
<vulnerable_code> goto error;
}
PyTuple_SetItem(args, i, cur_py_value);
}
return args;<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>
goto error;
}
PyTuple_SET_ITEM(args, i, cur_py_value... |
<vulnerable_code> if (!converted) {
goto error;
}
PyTuple_SetItem(row, i, converted);
}
if (PyErr_Occurred())
PyObject* func_args;
PyObject* result;
int numcols;
PyObject* descriptor;
PyObject* column_name;
sqlite_int64 lastrowid;
goto... |
<vulnerable_code> ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
self.assertRaises(TypeError, ctx.load_verify_locations, cadata=object)
with self.assertRaisesRegex(ssl.SSLError, "no start line"):
ctx.load_verify_locations(cadata="broken")
with self.assertRaisesRegex(ssl.SSLErr... |
<vulnerable_code>{
BIO *biobuf = NULL;
X509_STORE *store;
int retval = 0, err, loaded = 0;
assert(filetype == SSL_FILETYPE_ASN1 || filetype == SSL_FILETYPE_PEM);
}
err = ERR_peek_last_error();
if ((filetype == SSL_FILETYPE_ASN1) &&
(loaded > 0) &&
(ERR_GET_LIB(err)... |
<vulnerable_code>modules in setup scripts."""
import os
import warnings
# This class is really only used by the "build_ext" command, so it might
line = file.readline()
if line is None: # eof
break
if _variable_rx.match(line): # VAR=VALUE, handled i... |
<vulnerable_code>import os
import re
import sys
from .errors import DistutilsPlatformError
# These are needed in a couple of spots, so just compute them once.
PREFIX = os.path.normpath(sys.prefix)
EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
BASE_PREFIX = os.path.normpath(sys.base_prefix)
BASE_EXEC_PREFIX = os.pat... |
<vulnerable_code>import unittest
import os
import sys
from test.support import run_unittest, missing_compiler_executable
support.LoggingSilencer,
unittest.TestCase):
def test_check_library_dist(self):
pkg_dir, dist = self.create_dist()
cmd = build_c... |
<vulnerable_code> site.USER_BASE = self.mkdtemp()
from distutils.command import build_ext
build_ext.USER_BASE = site.USER_BASE
# bpo-30132: On Windows, a .pdb file may be created in the current
# working directory. Create a temporary working directory to cleanup
site.USER... |
<vulnerable_code>import unittest
import os
import sys
from test.support import run_unittest, missing_compiler_executable
from distutils.command.config import dump_file, config
self._logs = []
self.old_log = log.info
log.info = self._info
def tearDown(self):
log.info = self.old_log
... |
<vulnerable_code> support.LoggingSilencer,
unittest.TestCase):
def test_home_installation_scheme(self):
# This ensure two things:
# - that --home generates the desired set of directory names<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in te... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.