text
stringlengths
79
3.72M
<vulnerable_code> __match_args__ = ma self.assertIs(C(42).__match_args__, ma) if __name__ == '__main__': unittest.main()<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code> __match_args__ = ma self.assertIs(C(42)....
<vulnerable_code> :license: Python license. """ from os import path from sphinx.addnodes import glossary from sphinx.util import logging from docutils.nodes import definition_list_item import json logger = logging.getLogger(__name__) def process_glossary_nodes(app, doctree, fromdocname): if not app.env.glos...
<vulnerable_code> if (t->bytes == NULL) { return -1; } _PyArena_AddPyObject(p->arena, t->bytes); int lineno = type == STRING ? p->tok->first_lineno : p->tok->lineno; const char *line_start = type == STRING ? p->tok->multi_line_start : p->tok->line_start;<commit_title>[PATCH 003/413] bpo-4365...
<vulnerable_code> return seq; } /* Constructs an arguments_ty object out of all the parsed constructs in the parameters rule */ arguments_ty _PyPegen_make_arguments(Parser *p, asdl_arg_seq *slash_without_default, SlashWithDefault *slash_with_default, asdl_arg_seq *plain_names, ...
<vulnerable_code> return 0; } // Instrumentation to count the effectiveness of memoization. // The array counts the number of tokens skipped by memoization, // indexed by type. } return ret; } int // bool _PyPegen_is_memoized(Parser *p, int type, void *pres) for (Memo *m = t->memo; m != NULL; m = m->...
<vulnerable_code>static PyObject * clear_memo_stats(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(ignored)) { _PyPegen_clear_memo_statistics(); Py_RETURN_NONE; } static PyObject * get_memo_stats(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(ignored)) { return _PyPegen_get_memo_statistics(); } // TODO: W...
<vulnerable_code> PyMem_Free(arr->items); } int _PyPegen_fill_token(Parser *p) { type = PyTokenizer_Get(p->tok, &start, &end); } if (type == ENDMARKER && p->start_rule == Py_single_input && p->parsing_started) { type = NEWLINE; /* Add an extra newline */ p->parsing_started = 0; ...
<vulnerable_code> PySSL_END_ALLOW_THREADS_S(pw_info->thread_state); if (pw_info->callable) { fn_ret = _PyObject_CallNoArg(pw_info->callable); if (!fn_ret) {<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code> PySSL_END_ALLOW_THR...
<vulnerable_code>IS_LIBRESSL = ssl.OPENSSL_VERSION.startswith('LibreSSL') IS_OPENSSL_1_1_0 = not IS_LIBRESSL and ssl.OPENSSL_VERSION_INFO >= (1, 1, 0) IS_OPENSSL_1_1_1 = not IS_LIBRESSL and ssl.OPENSSL_VERSION_INFO >= (1, 1, 1) PY_SSL_DEFAULT_CIPHERS = sysconfig.get_config_var('PY_SSL_DEFAULT_CIPHERS') PROTOCOL_TO_TLS...
<vulnerable_code>#endif /* Include generated data (error codes) */ #include "_ssl_data.h" #if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER) # define OPENSSL_VERSION_1_1 1<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code> #...
<vulnerable_code> It takes two arguments: - the path to the OpenSSL source tree (e.g. git checkout) - the path to the C file to be generated (probably Modules/_ssl_data.h) """ import datetime import glob import os import re import sys import _ssl def parse_error_codes(h_file, prefix, libcode): pat = re.compile...
<vulnerable_code> OPENSSL_RECENT_VERSIONS = [ "1.1.1k", # "3.0.0-alpha12" ] LIBRESSL_OLD_VERSIONS = [<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code> OPENSSL_RECENT_VERSIONS = [ "1.1.1k", # "3.0.0-alpha14" ] LIBRESSL_OLD_VERSIONS = [
<vulnerable_code> Extension( '_ssl', ['_ssl.c'], depends=['socketmodule.h', '_ssl/debughelpers.c'], **openssl_extension_kwargs ) )<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in tes...
<vulnerable_code>import unittest def funcattrs(**kwds): self.assertEqual(C.foo(), 42) self.assertEqual(C().foo(), 42) def test_staticmethod_function(self): @staticmethod def notamethod(x): return x self.assertRaises(TypeError, notamethod, 1) def test_dotted...
<vulnerable_code> self.assertEqual(d.foo(1), (d, 1)) self.assertEqual(D.foo(d, 1), (d, 1)) # Test for a specific crash (SF bug 528132) def f(cls, arg): return (cls, arg) ff = classmethod(f) self.assertEqual(ff.__get__(0, int)(42), (int, 42)) self.assertEqual(ff.__g...
<vulnerable_code> '''A static method''' ... self.assertEqual(self._get_summary_lines(X.__dict__['sm']), "<staticmethod object>") self.assertEqual(self._get_summary_lines(X.sm), """\ sm(x, y) A static method '''A class method''' ...
<vulnerable_code> class C: def foo(cls): pass x = staticmethod(C.foo) self.assertTrue(repr(x).startswith('<staticmethod object at 0x')) x = classmethod(C.foo) self.assertTrue(repr(x).startswith('<classmethod object at 0x')) def test_unsortable(self): # Rep...
<vulnerable_code>func_repr(PyFunctionObject *op) { return PyUnicode_FromFormat("<function %U at %p>", op->func_qualname, op); } static int }; /* Class method object */ /* A class method receives the class as implicit first argument, return -1; Py_INCREF(callable); ...
<vulnerable_code>OP_SINGLE_ECDH_USE = getattr(ssl, "OP_SINGLE_ECDH_USE", 0) OP_CIPHER_SERVER_PREFERENCE = getattr(ssl, "OP_CIPHER_SERVER_PREFERENCE", 0) OP_ENABLE_MIDDLEBOX_COMPAT = getattr(ssl, "OP_ENABLE_MIDDLEBOX_COMPAT", 0) # Ubuntu has patched OpenSSL and changed behavior of security level 2 # see https://bugs.py...
<vulnerable_code>#endif #ifdef SSL_OP_SINGLE_ECDH_USE options |= SSL_OP_SINGLE_ECDH_USE; #endif SSL_CTX_set_options(self->ctx, options); PyModule_AddIntConstant(m, "OP_NO_RENEGOTIATION", SSL_OP_NO_RENEGOTIATION); #endif #ifdef X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT PyModule_A...
<vulnerable_code> stat = os.stat open = os.open listdir = os.listdir # removed in the future. pass def _opener(self, name, flags, mode=0o666): # A stub for the opener argument to built-in open() return self._accessor.open(self, flags, mode) # Public API @cla...
<vulnerable_code> userhome = join(drive, os.environ['HOMEPATH']) if i != 1: #~user # Try to guess user home directory. By default all users directories # are located in the same place and are named by corresponding # usernames. If current user home directory points to nonstandard ...
<vulnerable_code>from functools import wraps, partial _builtins = {name for name in dir(builtins) if not name.startswith('_')} FILTER_DIR = True self._mock_children[name] = result elif isinstance(result, _SpecState): result = create_autospec( result.spec, result.spec...
<vulnerable_code> with self.assertRaises(RuntimeError): create_autospec(async_func, instance=True) def test_create_autospec_awaitable_class(self): awaitable_mock = create_autospec(spec=AwaitableClass()) self.assertIsInstance(create_autospec(awaitable_mock), AsyncMock) def te...
<vulnerable_code> call, DEFAULT, patch, sentinel, MagicMock, Mock, NonCallableMock, NonCallableMagicMock, AsyncMock, _Call, _CallList, create_autospec ) self.assertRaisesRegex(ValueError, 'Bazinga!', mock) def test_reset_mock(self): parent = Mock() spec = ["something"] ...
<vulnerable_code> alias = self.types['alias'] self.assertEqual( str(alias), 'Product([Field(identifier, name), Field(identifier, asname, opt=True)])') def test_attributes(self): stmt = self.types['stmt']<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in t...
<vulnerable_code> mod.body[0].module = " __future__ ".strip() compile(mod, "<test>", "exec") def test_base_classes(self): self.assertTrue(issubclass(ast.For, ast.stmt)) self.assertTrue(issubclass(ast.Name, ast.expr)) def test_level_as_none(self): body = [ast.ImportFrom(m...
<vulnerable_code> ) simple_name[expr_ty]: NAME import_as_names_from[asdl_alias_seq*]: a[asdl_alias_seq*]=','.import_as_name_from+ { a } import_as_name_from[alias_ty]: a=NAME 'as' b=NAME { _PyAST_alias(((expr_ty) a)->v.Name.id, ((expr_ty) b)->v.Name.id, p->arena) } ...
<vulnerable_code> } asdl_alias_seq* _res = NULL; int _mark = p->mark; { // '(' import_from_as_names ','? ')' if (p->error_indicator) { D(p->level--); ) { D(fprintf(stderr, "%*c+ import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...
<vulnerable_code> /* Creates an alias with '*' as the identifier name */ alias_ty _PyPegen_alias_for_star(Parser *p) { PyObject *str = PyUnicode_InternFromString("*"); if (!str) { return NULL; Py_DECREF(str); return NULL; } return _PyAST_alias(str, NULL, p->arena); } /* Creates ...
<vulnerable_code> "value", }; static PyObject* ast2obj_alias(struct ast_state *state, void*); static const char * const alias_fields[]={ "name", "asname", alias_fields, 2, "alias(identifier name, identifier? asname)"); if (!state->alias_type) return 0; if (!a...
<vulnerable_code>_PyDict_NewKeysForClass(void) { PyDictKeysObject *keys = new_keys_object(PyDict_MINSIZE); if (keys == NULL) PyErr_Clear(); else keys->dk_lookup = lookdict_split; return keys; } <commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_desc...
<vulnerable_code>_Py_IDENTIFIER(__abstractmethods__); _Py_IDENTIFIER(__class__); _Py_IDENTIFIER(__class_getitem__); _Py_IDENTIFIER(__delitem__); _Py_IDENTIFIER(__dict__); _Py_IDENTIFIER(__doc__); _Py_IDENTIFIER(__module__); _Py_IDENTIFIER(__name__); _Py_IDENTIFIER(__new__); _Py_IDENTIFIER(__set_name__); _Py_IDENTIFIER(...
<vulnerable_code>} // Test Py_NewRef() and Py_XNewRef() functions static PyObject* test_refcount(PyObject *self, PyObject *Py_UNUSED(ignored)) { PyObject *obj = PyList_New(0); if (obj == NULL) { return NULL; } assert(Py_REFCNT(obj) == 1); // Test Py_NewRef() PyObject *ref = Py_NewRef(...
<vulnerable_code> return _Py_XNewRef(obj); } #ifdef __cplusplus } #endif<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code> return _Py_XNewRef(obj); } #undef Py_Is #undef Py_IsNone #undef Py_IsTrue #undef Py_IsFalse // Export Py_Is(), Py_IsNone(),...
<vulnerable_code> /* Execute compiled code */ /* XXX TO DO: gen_status = PyIter_Send(receiver, v, &retval); } else { _Py_IDENTIFIER(send); if (v == Py_None && PyIter_Check(receiver)) { retval = Py_TYPE(receiver)->tp_iternext(receiver); ...
<vulnerable_code> # __match_args__ # # | no | yes | <--- class has __match_args__ in __dict__? # +=======+=======+ # | add | | <- the default # +=======+=======+ # __match_args__ is always added unless the class already defines it. It is a # tuple of __init__ parameter names; non-init fields must be matc...
<vulnerable_code> c: int self.assertEqual(X.__match_args__, ("a", "b", "c")) if __name__ == '__main__': unittest.main()<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code> c: int self.assertEqual(X.__match_args__,...
<vulnerable_code>from typing import Pattern, Match from typing import Annotated, ForwardRef from typing import TypeAlias from typing import ParamSpec, Concatenate import abc import typing import weakref class GetUtilitiesTestCase(TestCase): def test_get_origin(self): T = TypeVar('T') class C(Generic...
<vulnerable_code> 'no_type_check_decorator', 'NoReturn', 'overload', 'runtime_checkable', 'Text', 'TYPE_CHECKING', self.__module__ = def_mod class ParamSpec(_Final, _Immutable, _TypeVarLike, _root=True): """Parameter specification variable. __slots__ = ('__name__', '__bound...
<vulnerable_code> self.assertEqual(Union[X, int].__parameters__, (X,)) self.assertIs(Union[X, int].__origin__, Union) def test_union_constrained(self): A = TypeVar('A', str, bytes) self.assertNotEqual(Union[A, str], Union[A])<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarnin...
<vulnerable_code> def __or__(self, right): return Union[self, right] def __ror__(self, right): return Union[self, right] def __repr__(self): if self.__covariant__:<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code> d...
<vulnerable_code> self.loop = None asyncio.set_event_loop_policy(None) def test_async_gen_anext(self): async def gen(): yield 1 yield 2 g = gen() async def consume(): results = [] results.append(await anext(g)) with self...
<vulnerable_code>static PyObject * anextawaitable_iternext(anextawaitableobject *obj) { PyObject *result = PyIter_Next(obj->wrapped); if (result != NULL) { return result; }<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code> static PyObje...
<vulnerable_code> with self.subTest(f"Original: {orig!r}, Expected: {expect!r}"): result = urllib.parse.parse_qs(orig, separator=';') self.assertEqual(result, expect, "Error parsing %r" % orig) def test_parse_qsl_separator(self): with self.subTest(f"Original:...
<vulnerable_code> Returns a list, as G-d intended. """ qs, _coerce_result = _coerce_args(qs) if not separator or (not isinstance(separator, (str, bytes))): raise ValueError("Separator must be of type string or bytes.")<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (G...
<vulnerable_code> PyObject **to_merge; Py_ssize_t i, n; if (type->tp_dict == NULL) { if (PyType_Ready(type) < 0) return NULL; } return NULL; } base_i = (PyTypeObject *)base_proto; if (base_i->tp_dict == NULL) { if (PyType_Ready(base_i) ...
<vulnerable_code> getattr(func, attr)) self.assertEqual(repr(wrapper), format_str.format(func)) self.assertRaises(TypeError, wrapper, 1) def test_staticmethod(self): self.check_wrapper_attrs(staticmethod, '<staticmethod({!r})>') def test_classmethod(self): ...
<vulnerable_code> '''A static method''' ... self.assertEqual(self._get_summary_lines(X.__dict__['sm']), 'sm(...)\n' ' A static method\n') self.assertEqual(self._get_summary_lines(X.sm), """\ sm(x, y)<commit_title>[PATCH ...
<vulnerable_code> return 0; } static PyMemberDef sm_memberlist[] = { {"__func__", T_OBJECT, offsetof(staticmethod, sm_callable), READONLY}, {"__wrapped__", T_OBJECT, offsetof(staticmethod, sm_callable), READONLY}, 0, /* tp_as_sequence */ 0, ...
<vulnerable_code>import io import os import _compression from threading import RLock from _bz2 import BZ2Compressor, BZ2Decompressor If mode is 'r', the input file may be the concatenation of multiple compressed streams. """ # This lock must be recursive, so that BufferedIOBase's ...
<vulnerable_code> def test_ident_of_no_threading_threads(self): # The ident still must work for the main thread and dummy threads. self.assertIsNotNone(threading.currentThread().ident) def f(): ident.append(threading.currentThread().ident) done.set() done = th...
<vulnerable_code> """ self.notify(len(self._waiters)) notifyAll = notify_all class Semaphore: """Return true if and only if the internal flag is true.""" return self._flag isSet = is_set def set(self): """Set the internal flag to true. self._daemonic = dae...
<vulnerable_code> return encoding def open(file, mode="r", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None): "errors=None, newline=None, closefd=True)\n\n" + open.__doc__) class OpenWrapper: """Wrapper for builtins.open Trick so tha...
<vulnerable_code> return NULL; } /* Set builtins.open to io.OpenWrapper */ static PyStatus init_set_builtins_open(void) { goto error; } if (!(wrapper = PyObject_GetAttrString(iomod, "OpenWrapper"))) { goto error; } } /* Initialize sys.stdin, stdout, stderr and builtins.open */ static...
<vulnerable_code> def seclevel_workaround(*ctxs): """"Lower security level to '1' and allow all ciphers for TLS 1.0/1""" for ctx in ctxs: if ctx.minimum_version <= ssl.TLSVersion.TLSv1_1: ctx.set_ciphers("@SECLEVEL=1:ALL") else: def seclevel_workaround(*ctxs):<commit_t...
<vulnerable_code> # Start the server thread and wait for it to be listening. thread = threading.Thread(target=server) thread.setDaemon(True) thread.start() addr = q.get() <commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_...
<vulnerable_code> """ self._thread = t = threading.Thread(target=self.serve_forever, args=(self.poll_interval,)) t.setDaemon(True) t.start() def serve_forever(self, poll_interval): """ self._thread = t = threading.Thread(tar...
<vulnerable_code> self.sock.settimeout(60) # Safety net. Look issue 11812 self.port = socket_helper.bind_port(self.sock) self.thread = threading.Thread(target=server, args=(self.evt,self.sock)) self.thread.setDaemon(True) self.thread.start() self.evt.wait() <commit_title>...
<vulnerable_code> for i in range(nthreads): threads.append(threading.Thread(target=run)) for t in threads: t.setDaemon(True) t.start() # We don't want measurements to include thread startup overhead, # so we arrange for timing to start after all threads are ready. for i in...
<vulnerable_code> formatted = percent % ((value,) + additional) else: formatted = percent % value # floats and decimal ints need special action! if percent[-1] in 'eEfFgG': seps = 0 parts = formatted.split('.') if grouping: formatted = decimal_point.join(parts)...
<vulnerable_code>from test.support import verbose, is_android from test.support.warnings_helper import check_warnings import unittest self._test_atoi('50 000', 50000) if __name__ == '__main__': unittest.main()<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_descrip...
<vulnerable_code> except Exception as e: exc = e result = None if isinstance(result, cls): return result elif ( Flag is not None and issubclass(cls, Flag) and cls._boundary_ is EJECT and isinstance(result, int) ): ...
<vulnerable_code> else: raise Exception('Exception not raised.') def test_multiple_mixin(self): class MaxMixin: @classproperty<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code> else: raise Exc...
<vulnerable_code> script_name = _make_test_script(script_dir, 'script', script) exitcode, stdout, stderr = assert_python_failure(script_name) text = io.TextIOWrapper(io.BytesIO(stderr), 'ascii').read() # Confirm that the caret is located under the first 1 character ...
<vulnerable_code> ai("a = 'a\\\n") ai("a = 1","eval") ai("a = (","eval") ai("]","eval") ai("())","eval") ai("[}","eval")<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code> ai("a = 'a\\\n") ai(...
<vulnerable_code> check('[*x for x in xs]', 1, 2) check('foo(x for x in range(10), 100)', 1, 5) check('for 1 in []: pass', 1, 5) check('(yield i) = 2', 1, 2) check('def f(*):\n pass', 1, 8) @cpython_only<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io ...
<vulnerable_code> ]) def test_assignment(self): self.assertAllRaise(SyntaxError, 'invalid syntax', ["f'' = 3", "f'{0}' = x", "f'{x}' = x", f'{1:_,}' def test_syntax_error_for_s...
<vulnerable_code>>>> def f(): (yield bar) = y Traceback (most recent call last): ... SyntaxError: cannot assign to yield expression >>> def f(): (yield bar) += y Traceback (most recent call last):<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code> >>> de...
<vulnerable_code> >>> dict(a = i for i in range(10)) Traceback (most recent call last): ... SyntaxError: invalid syntax Verify that parenthesis are required when used as a keyword argument value <commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fix...
<vulnerable_code> >>> f() = 1 Traceback (most recent call last): SyntaxError: cannot assign to function call >>> yield = 1 Traceback (most recent call last): >>> a + 1 = 2 Traceback (most recent call last): SyntaxError: cannot assign to operator >>> (x for x in x) = 1 Traceback (most recent call last): >>> 1 = 1 Tr...
<vulnerable_code> >>> (*x),y = 1, 2 # doctest:+ELLIPSIS Traceback (most recent call last): ... SyntaxError: can't use starred expression here >>> (((*x))),y = 1, 2 # doctest:+ELLIPSIS Traceback (most recent call last): ... SyntaxError: can't use starred expression here >>> z,(*x...
<vulnerable_code>#define invalid_except_block_type 1196 #define invalid_match_stmt_type 1197 #define invalid_case_block_type 1198 #define _loop0_1_type 1199 #define _loop0_2_type 1200 #define _loop0_4_type 1201 #define _gather_3_type 1202 #define _loop0_6_type 1203 #define _gather_5_type 1204 #define _loop0_8_type 1205...
<vulnerable_code> return 0; } Py_ssize_t len = strlen(str); if (col_offset > len) { col_offset = len; } assert(col_offset >= 0); PyObject *text = PyUnicode_DecodeUTF8(str, col_offset, "replace"); case BoolOp_kind: case BinOp_kind: case UnaryOp_kind: ...
<vulnerable_code> {'x': int, 'y': int}) self.assertEqual(gth(mod_generics_cache.B), {'my_inner_a1': mod_generics_cache.B.A, 'my_inner_a2': mod_generics_cache.A, 'my_outer_a': mod_generics_cache.A}) def test...
<vulnerable_code> else: base_globals = globalns ann = base.__dict__.get('__annotations__', {}) for name, value in ann.items(): if value is None: value = type(None) if isinstance(value, str): value ...
<vulnerable_code> with self.assertRaises(TypeError): issubclass(int, ClassVar) class FinalTests(BaseTestCase): <commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code> with self.assertRaises(TypeError): issubclass(int, Cl...
<vulnerable_code> hints = {} for base in reversed(obj.__mro__): if globalns is None: base_globals = sys.modules[base.__module__].__dict__ else: base_globals = globalns ann = base.__dict__.get('__annotations__', {})<commit_title>[PATCH 00...
<vulnerable_code> if namespace is None: namespace = {} else: # Copy namespace since we're going to mutate it. namespace = namespace.copy() # While we're looking through the field names, validate that they # are identifiers, are not keywords, and not duplicates. seen = set() ...
<vulnerable_code> Traceback (most recent call last): SyntaxError: cannot assign to attribute here. Maybe you meant '==' instead of '='? 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...
<vulnerable_code>#define star_named_expressions_type 1091 #define star_named_expression_type 1092 #define named_expression_type 1093 #define annotated_rhs_type 1094 #define expressions_type 1095 #define expression_type 1096 #define lambdef_type 1097 #define lambda_params_type 1098 #define lambda_parameters_type 1099 #d...
<vulnerable_code> self._check_can_read() return self._buffer.readline(size) def readlines(self, size=-1): """Read a list of lines of uncompressed bytes from the file. <commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code> se...
<vulnerable_code> self._check_not_closed() return self._buffer.readline(size) class _GzipReader(_compression.DecompressReader): def __init__(self, fp):<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code> self._check_not_closed() ...
<vulnerable_code> self._check_can_read() return self._buffer.readline(size) def write(self, data): """Write a bytes object to the file. <commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code> self._check_can_read() re...
<vulnerable_code> * */ #define PY_SSIZE_T_CLEAN #include "Python.h" #include "hashlib.h" #include "pystrhex.h" /* EVP is the preferred interface to hashing in OpenSSL */ #include <openssl/evp.h> #include <openssl/hmac.h> #include <openssl/crypto.h> /* We use the object interface to discover what hashes OpenSSL sup...
<vulnerable_code> http://bugs.python.org/issue8108#msg102867 ? */ #define PY_SSIZE_T_CLEAN #include "Python.h" #include <sys/poll.h> #endif /* Don't warn about deprecated functions */ #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif #ifdef __clang__ #pragma clang diagnostic ign...
<vulnerable_code># _listener holds the server object doing the listening _listener = None def fileConfig(fname, defaults=None, disable_existing_loggers=True): """ Read the logging configuration from a ConfigParser-format file. if hasattr(fname, 'readline'): cp.read_file(fname) el...
<vulnerable_code> PyCodeObject *code; // The code object for the bounds. May be NULL. int instr_prev; // Only valid if code != NULL. PyCodeAddressRange bounds; // Only valid if code != NULL. } PyTraceInfo; static int do_raise(PyThreadState *tstate, PyObject *exc, PyObject *cause); static int unpack_iterab...
<vulnerable_code> tstate->recursion_headroom = 0; tstate->stackcheck_counter = 0; tstate->tracing = 0; tstate->use_tracing = 0; tstate->gilstate_counter = 0; tstate->async_exc = NULL; tstate->thread_id = PyThread_get_thread_ident();<commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning ...
<vulnerable_code> /* Disallow tracing in hooks unless explicitly enabled */ ts->tracing++; ts->use_tracing = 0; while ((hook = PyIter_Next(hooks)) != NULL) { _Py_IDENTIFIER(__cantrace__); PyObject *o; break; } if (canTrace) ...
<vulnerable_code> static int type_ready_set_base(PyTypeObject *type) { /* Initialize tp_base (defaults to BaseObject unless that's us) */ PyTypeObject *base = type->tp_base; if (Py_IS_TYPE(type, NULL) && base != NULL) { Py_SET_TYPE(type, Py_TYPE(base)); } return 0; } static int type_ready...
<vulnerable_code>}; /* Add the methods from tp_methods to the __dict__ in a type object */ static int add_methods(PyTypeObject *type, PyMethodDef *meth) { PyObject *dict = type->tp_dict; PyObject *name; for (; meth->ml_name != NULL; meth++) { PyObject *descr; int err; int isdescr...
<vulnerable_code> class BadModule: pass BadModule.__module__ = 'bad' # Something not in sys.modules assert(get_type_hints(BadModule), {}) class FinalTests(BaseTestCase): <commit_title>[PATCH 003/413] bpo-43651: Fix EncodingWarning in test_io (GH-25097)<commit_description><fixed_code>...
<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): def test_expression_with_assignment(self): self._check_error( "print(end1 + end2 = ' ')", ...
<vulnerable_code> return _res; } // genexp: '(' named_expression for_if_clauses ')' | invalid_comprehension static expr_ty genexp_rule(Parser *p) { UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA ma...
<vulnerable_code>""" import collections as _collections import re import sys as _sys import types as _types p(self, object, stream, indent, allowance, context, level + 1) del context[objid] return stream.write(rep) _dispatch = {} def _pprint_dict(self, ...
<vulnerable_code># -*- coding: utf-8 -*- import collections import io import itertools import pprint def __repr__(self): return '*'*len(dict.__repr__(self)) class Unorderable: def __repr__(self): return str(id(self)) lazy=7, dog=8, ) formatted = pprint.p...
<vulnerable_code> open_code = _open_code_with_warning class DocDescriptor: """Helper for builtins.open.__doc__ """ def __get__(self, obj, typ=None): return ( "open(file, mode='r', buffering=-1, encoding=None, " "errors=None, newline=None, closefd=True)\n\n" + ...
<vulnerable_code> BufferedWriter, BufferedRWPair, BufferedRandom, IncrementalNewlineDecoder, text_encoding, TextIOWrapper) OpenWrapper = _io.open # for compatibility with _pyio # Pretend this exception was created here. UnsupportedOperation.__module__ = "io"<commit_title>[PATCH 003/41...
<vulnerable_code> self.assertTrue( warnings[1].startswith(b"<string>:8: EncodingWarning: ")) class CMiscIOTest(MiscIOTest): io = io globs = globals() c_io_ns.update((x.__name__, globs["C" + x.__name__]) for x in mocks) py_io_ns.update((x.__name__, globs["Py" + x.__name__]) for x in ...