id int64 1 6.07M | name stringlengths 1 295 | code stringlengths 12 426k | language stringclasses 1
value | source_file stringlengths 5 202 | start_line int64 1 158k | end_line int64 1 158k | repo dict |
|---|---|---|---|---|---|---|---|
15,601 | load_ext4 | def load_ext4(self):
code, = unpack('<i', self.read(4))
self.get_extension(code) | python | Lib/pickle.py | 1,545 | 1,547 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,602 | get_extension | def get_extension(self, code):
nil = []
obj = _extension_cache.get(code, nil)
if obj is not nil:
self.append(obj)
return
key = _inverted_registry.get(code)
if not key:
if code <= 0: # note that 0 is forbidden
# Corrupt or hostil... | python | Lib/pickle.py | 1,550 | 1,564 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,603 | find_class | def find_class(self, module, name):
# Subclasses may override this.
sys.audit('pickle.find_class', module, name)
if self.proto < 3 and self.fix_imports:
if (module, name) in _compat_pickle.NAME_MAPPING:
module, name = _compat_pickle.NAME_MAPPING[(module, name)]
... | python | Lib/pickle.py | 1,566 | 1,578 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,604 | load_reduce | def load_reduce(self):
stack = self.stack
args = stack.pop()
func = stack[-1]
stack[-1] = func(*args) | python | Lib/pickle.py | 1,580 | 1,584 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,605 | load_pop | def load_pop(self):
if self.stack:
del self.stack[-1]
else:
self.pop_mark() | python | Lib/pickle.py | 1,587 | 1,591 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,606 | load_pop_mark | def load_pop_mark(self):
self.pop_mark() | python | Lib/pickle.py | 1,594 | 1,595 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,607 | load_dup | def load_dup(self):
self.append(self.stack[-1]) | python | Lib/pickle.py | 1,598 | 1,599 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,608 | load_get | def load_get(self):
i = int(self.readline()[:-1])
try:
self.append(self.memo[i])
except KeyError:
msg = f'Memo value not found at index {i}'
raise UnpicklingError(msg) from None | python | Lib/pickle.py | 1,602 | 1,608 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,609 | load_binget | def load_binget(self):
i = self.read(1)[0]
try:
self.append(self.memo[i])
except KeyError as exc:
msg = f'Memo value not found at index {i}'
raise UnpicklingError(msg) from None | python | Lib/pickle.py | 1,611 | 1,617 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,610 | load_long_binget | def load_long_binget(self):
i, = unpack('<I', self.read(4))
try:
self.append(self.memo[i])
except KeyError as exc:
msg = f'Memo value not found at index {i}'
raise UnpicklingError(msg) from None | python | Lib/pickle.py | 1,620 | 1,626 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,611 | load_put | def load_put(self):
i = int(self.readline()[:-1])
if i < 0:
raise ValueError("negative PUT argument")
self.memo[i] = self.stack[-1] | python | Lib/pickle.py | 1,629 | 1,633 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,612 | load_binput | def load_binput(self):
i = self.read(1)[0]
if i < 0:
raise ValueError("negative BINPUT argument")
self.memo[i] = self.stack[-1] | python | Lib/pickle.py | 1,636 | 1,640 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,613 | load_long_binput | def load_long_binput(self):
i, = unpack('<I', self.read(4))
if i > maxsize:
raise ValueError("negative LONG_BINPUT argument")
self.memo[i] = self.stack[-1] | python | Lib/pickle.py | 1,643 | 1,647 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,614 | load_memoize | def load_memoize(self):
memo = self.memo
memo[len(memo)] = self.stack[-1] | python | Lib/pickle.py | 1,650 | 1,652 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,615 | load_append | def load_append(self):
stack = self.stack
value = stack.pop()
list = stack[-1]
list.append(value) | python | Lib/pickle.py | 1,655 | 1,659 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,616 | load_appends | def load_appends(self):
items = self.pop_mark()
list_obj = self.stack[-1]
try:
extend = list_obj.extend
except AttributeError:
pass
else:
extend(items)
return
# Even if the PEP 307 requires extend() and append() methods,
... | python | Lib/pickle.py | 1,662 | 1,677 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,617 | load_setitem | def load_setitem(self):
stack = self.stack
value = stack.pop()
key = stack.pop()
dict = stack[-1]
dict[key] = value | python | Lib/pickle.py | 1,680 | 1,685 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,618 | load_setitems | def load_setitems(self):
items = self.pop_mark()
dict = self.stack[-1]
for i in range(0, len(items), 2):
dict[items[i]] = items[i + 1] | python | Lib/pickle.py | 1,688 | 1,692 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,619 | load_additems | def load_additems(self):
items = self.pop_mark()
set_obj = self.stack[-1]
if isinstance(set_obj, set):
set_obj.update(items)
else:
add = set_obj.add
for item in items:
add(item) | python | Lib/pickle.py | 1,695 | 1,703 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,620 | load_build | def load_build(self):
stack = self.stack
state = stack.pop()
inst = stack[-1]
setstate = getattr(inst, "__setstate__", _NoValue)
if setstate is not _NoValue:
setstate(state)
return
slotstate = None
if isinstance(state, tuple) and len(state)... | python | Lib/pickle.py | 1,706 | 1,727 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,621 | load_mark | def load_mark(self):
self.metastack.append(self.stack)
self.stack = []
self.append = self.stack.append | python | Lib/pickle.py | 1,730 | 1,733 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,622 | load_stop | def load_stop(self):
value = self.stack.pop()
raise _Stop(value) | python | Lib/pickle.py | 1,736 | 1,738 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,623 | _dump | def _dump(obj, file, protocol=None, *, fix_imports=True, buffer_callback=None):
_Pickler(file, protocol, fix_imports=fix_imports,
buffer_callback=buffer_callback).dump(obj) | python | Lib/pickle.py | 1,744 | 1,746 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,624 | _dumps | def _dumps(obj, protocol=None, *, fix_imports=True, buffer_callback=None):
f = io.BytesIO()
_Pickler(f, protocol, fix_imports=fix_imports,
buffer_callback=buffer_callback).dump(obj)
res = f.getvalue()
assert isinstance(res, bytes_types)
return res | python | Lib/pickle.py | 1,748 | 1,754 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,625 | _load | def _load(file, *, fix_imports=True, encoding="ASCII", errors="strict",
buffers=None):
return _Unpickler(file, fix_imports=fix_imports, buffers=buffers,
encoding=encoding, errors=errors).load() | python | Lib/pickle.py | 1,756 | 1,759 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,626 | _loads | def _loads(s, /, *, fix_imports=True, encoding="ASCII", errors="strict",
buffers=None):
if isinstance(s, str):
raise TypeError("Can't load pickle from unicode string")
file = io.BytesIO(s)
return _Unpickler(file, fix_imports=fix_imports, buffers=buffers,
encoding=enc... | python | Lib/pickle.py | 1,761 | 1,767 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,627 | _test | def _test():
import doctest
return doctest.testmod() | python | Lib/pickle.py | 1,787 | 1,789 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,628 | openpty | def openpty():
"""openpty() -> (master_fd, slave_fd)
Open a pty master/slave pair, using os.openpty() if possible."""
try:
return os.openpty()
except (AttributeError, OSError):
pass
master_fd, slave_name = _open_terminal()
slave_fd = slave_open(slave_name)
return master_fd, ... | python | Lib/pty.py | 26 | 36 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,629 | master_open | def master_open():
"""master_open() -> (master_fd, slave_name)
Open a pty master and return the fd, and the filename of the slave end.
Deprecated, use openpty() instead."""
import warnings
warnings.warn("Use pty.openpty() instead.", DeprecationWarning, stacklevel=2) # Remove API in 3.14
try:
... | python | Lib/pty.py | 38 | 55 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,630 | _open_terminal | def _open_terminal():
"""Open pty master and return (master_fd, tty_name)."""
for x in 'pqrstuvwxyzPQRST':
for y in '0123456789abcdef':
pty_name = '/dev/pty' + x + y
try:
fd = os.open(pty_name, os.O_RDWR)
except OSError:
continue
... | python | Lib/pty.py | 57 | 67 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,631 | slave_open | def slave_open(tty_name):
"""slave_open(tty_name) -> slave_fd
Open the pty slave and acquire the controlling terminal, returning
opened filedescriptor.
Deprecated, use openpty() instead."""
import warnings
warnings.warn("Use pty.openpty() instead.", DeprecationWarning, stacklevel=2) # Remove A... | python | Lib/pty.py | 69 | 88 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,632 | fork | def fork():
"""fork() -> (pid, master_fd)
Fork and make the child a session leader with a controlling terminal."""
try:
pid, fd = os.forkpty()
except (AttributeError, OSError):
pass
else:
if pid == CHILD:
try:
os.setsid()
except OSErro... | python | Lib/pty.py | 90 | 116 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,633 | _read | def _read(fd):
"""Default read function."""
return os.read(fd, 1024) | python | Lib/pty.py | 118 | 120 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,634 | _copy | def _copy(master_fd, master_read=_read, stdin_read=_read):
"""Parent copy loop.
Copies
pty master -> standard output (master_read)
standard input -> pty master (stdin_read)"""
if os.get_blocking(master_fd):
# If we write more than tty/ndisc is willing to buffer, we may b... | python | Lib/pty.py | 122 | 185 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,635 | spawn | def spawn(argv, master_read=_read, stdin_read=_read):
"""Create a spawned process."""
if isinstance(argv, str):
argv = (argv,)
sys.audit('pty.spawn', argv)
pid, master_fd = fork()
if pid == CHILD:
os.execlp(argv[0], *argv)
try:
mode = tcgetattr(STDIN_FILENO)
set... | python | Lib/pty.py | 187 | 211 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,636 | __enter__ | def __enter__(self):
"""Return `self` upon entering the runtime context."""
return self | python | Lib/contextlib.py | 25 | 27 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,637 | __exit__ | def __exit__(self, exc_type, exc_value, traceback):
"""Raise any exception triggered within the runtime context."""
return None | python | Lib/contextlib.py | 30 | 32 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,638 | __subclasshook__ | def __subclasshook__(cls, C):
if cls is AbstractContextManager:
return _collections_abc._check_methods(C, "__enter__", "__exit__")
return NotImplemented | python | Lib/contextlib.py | 35 | 38 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,639 | __aenter__ | async def __aenter__(self):
"""Return `self` upon entering the runtime context."""
return self | python | Lib/contextlib.py | 49 | 51 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,640 | __aexit__ | async def __aexit__(self, exc_type, exc_value, traceback):
"""Raise any exception triggered within the runtime context."""
return None | python | Lib/contextlib.py | 54 | 56 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,641 | __subclasshook__ | def __subclasshook__(cls, C):
if cls is AbstractAsyncContextManager:
return _collections_abc._check_methods(C, "__aenter__",
"__aexit__")
return NotImplemented | python | Lib/contextlib.py | 59 | 63 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,642 | _recreate_cm | def _recreate_cm(self):
"""Return a recreated instance of self.
Allows an otherwise one-shot context manager like
_GeneratorContextManager to support use as
a decorator via implicit recreation.
This is a private interface just for _GeneratorContextManager.
See issue #11... | python | Lib/contextlib.py | 69 | 79 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,643 | __call__ | def __call__(self, func):
@wraps(func)
def inner(*args, **kwds):
with self._recreate_cm():
return func(*args, **kwds)
return inner | python | Lib/contextlib.py | 81 | 86 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,644 | inner | def inner(*args, **kwds):
with self._recreate_cm():
return func(*args, **kwds) | python | Lib/contextlib.py | 83 | 85 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,645 | _recreate_cm | def _recreate_cm(self):
"""Return a recreated instance of self.
"""
return self | python | Lib/contextlib.py | 92 | 95 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,646 | __call__ | def __call__(self, func):
@wraps(func)
async def inner(*args, **kwds):
async with self._recreate_cm():
return await func(*args, **kwds)
return inner | python | Lib/contextlib.py | 97 | 102 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,647 | inner | async def inner(*args, **kwds):
async with self._recreate_cm():
return await func(*args, **kwds) | python | Lib/contextlib.py | 99 | 101 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,648 | __init__ | def __init__(self, func, args, kwds):
self.gen = func(*args, **kwds)
self.func, self.args, self.kwds = func, args, kwds
# Issue 19330: ensure context manager instances have good docstrings
doc = getattr(func, "__doc__", None)
if doc is None:
doc = type(self).__doc__
... | python | Lib/contextlib.py | 108 | 120 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,649 | _recreate_cm | def _recreate_cm(self):
# _GCMB instances are one-shot context managers, so the
# CM must be recreated each time a decorated function is
# called
return self.__class__(self.func, self.args, self.kwds) | python | Lib/contextlib.py | 122 | 126 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,650 | __enter__ | def __enter__(self):
# do not keep args and kwds alive unnecessarily
# they are only needed for recreation, which is not possible anymore
del self.args, self.kwds, self.func
try:
return next(self.gen)
except StopIteration:
raise RuntimeError("generator did... | python | Lib/contextlib.py | 136 | 143 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,651 | __exit__ | def __exit__(self, typ, value, traceback):
if typ is None:
try:
next(self.gen)
except StopIteration:
return False
else:
try:
raise RuntimeError("generator didn't stop")
finally:
... | python | Lib/contextlib.py | 145 | 200 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,652 | __aenter__ | async def __aenter__(self):
# do not keep args and kwds alive unnecessarily
# they are only needed for recreation, which is not possible anymore
del self.args, self.kwds, self.func
try:
return await anext(self.gen)
except StopAsyncIteration:
raise RuntimeE... | python | Lib/contextlib.py | 209 | 216 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,653 | __aexit__ | async def __aexit__(self, typ, value, traceback):
if typ is None:
try:
await anext(self.gen)
except StopAsyncIteration:
return False
else:
try:
raise RuntimeError("generator didn't stop")
fina... | python | Lib/contextlib.py | 218 | 273 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,654 | contextmanager | def contextmanager(func):
"""@contextmanager decorator.
Typical usage:
@contextmanager
def some_generator(<arguments>):
<setup>
try:
yield <value>
finally:
<cleanup>
This makes this:
with some_generator(<argument... | python | Lib/contextlib.py | 276 | 306 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,655 | helper | def helper(*args, **kwds):
return _GeneratorContextManager(func, args, kwds) | python | Lib/contextlib.py | 304 | 305 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,656 | asynccontextmanager | def asynccontextmanager(func):
"""@asynccontextmanager decorator.
Typical usage:
@asynccontextmanager
async def some_async_generator(<arguments>):
<setup>
try:
yield <value>
finally:
<cleanup>
This makes this:
as... | python | Lib/contextlib.py | 309 | 339 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,657 | helper | def helper(*args, **kwds):
return _AsyncGeneratorContextManager(func, args, kwds) | python | Lib/contextlib.py | 337 | 338 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,658 | __init__ | def __init__(self, thing):
self.thing = thing | python | Lib/contextlib.py | 359 | 360 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,659 | __enter__ | def __enter__(self):
return self.thing | python | Lib/contextlib.py | 361 | 362 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,660 | __exit__ | def __exit__(self, *exc_info):
self.thing.close() | python | Lib/contextlib.py | 363 | 364 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,661 | __init__ | def __init__(self, thing):
self.thing = thing | python | Lib/contextlib.py | 385 | 386 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,662 | __aenter__ | async def __aenter__(self):
return self.thing | python | Lib/contextlib.py | 387 | 388 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,663 | __aexit__ | async def __aexit__(self, *exc_info):
await self.thing.aclose() | python | Lib/contextlib.py | 389 | 390 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,664 | __init__ | def __init__(self, new_target):
self._new_target = new_target
# We use a list of old targets to make this CM re-entrant
self._old_targets = [] | python | Lib/contextlib.py | 397 | 400 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,665 | __enter__ | def __enter__(self):
self._old_targets.append(getattr(sys, self._stream))
setattr(sys, self._stream, self._new_target)
return self._new_target | python | Lib/contextlib.py | 402 | 405 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,666 | __exit__ | def __exit__(self, exctype, excinst, exctb):
setattr(sys, self._stream, self._old_targets.pop()) | python | Lib/contextlib.py | 407 | 408 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,667 | __init__ | def __init__(self, *exceptions):
self._exceptions = exceptions | python | Lib/contextlib.py | 444 | 445 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,668 | __enter__ | def __enter__(self):
pass | python | Lib/contextlib.py | 447 | 448 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,669 | __exit__ | def __exit__(self, exctype, excinst, exctb):
# Unlike isinstance and issubclass, CPython exception handling
# currently only looks at the concrete type hierarchy (ignoring
# the instance and subclass checking hooks). While Guido considers
# that a bug rather than a feature, it's a fairly... | python | Lib/contextlib.py | 450 | 469 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,670 | _create_exit_wrapper | def _create_exit_wrapper(cm, cm_exit):
return MethodType(cm_exit, cm) | python | Lib/contextlib.py | 476 | 477 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,671 | _create_cb_wrapper | def _create_cb_wrapper(callback, /, *args, **kwds):
def _exit_wrapper(exc_type, exc, tb):
callback(*args, **kwds)
return _exit_wrapper | python | Lib/contextlib.py | 480 | 483 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,672 | _exit_wrapper | def _exit_wrapper(exc_type, exc, tb):
callback(*args, **kwds) | python | Lib/contextlib.py | 481 | 482 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,673 | __init__ | def __init__(self):
self._exit_callbacks = deque() | python | Lib/contextlib.py | 485 | 486 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,674 | pop_all | def pop_all(self):
"""Preserve the context stack by transferring it to a new instance."""
new_stack = type(self)()
new_stack._exit_callbacks = self._exit_callbacks
self._exit_callbacks = deque()
return new_stack | python | Lib/contextlib.py | 488 | 493 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,675 | push | def push(self, exit):
"""Registers a callback with the standard __exit__ method signature.
Can suppress exceptions the same way __exit__ method can.
Also accepts any object with an __exit__ method (registering a call
to the method instead of the object itself).
"""
# We ... | python | Lib/contextlib.py | 495 | 513 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,676 | enter_context | def enter_context(self, cm):
"""Enters the supplied context manager.
If successful, also pushes its __exit__ method as a callback and
returns the result of the __enter__ method.
"""
# We look up the special methods on the type to match the with
# statement.
cls =... | python | Lib/contextlib.py | 515 | 532 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,677 | callback | def callback(self, callback, /, *args, **kwds):
"""Registers an arbitrary callback and arguments.
Cannot suppress exceptions.
"""
_exit_wrapper = self._create_cb_wrapper(callback, *args, **kwds)
# We changed the signature, so using @wraps is not appropriate, but
# setti... | python | Lib/contextlib.py | 534 | 545 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,678 | _push_cm_exit | def _push_cm_exit(self, cm, cm_exit):
"""Helper to correctly register callbacks to __exit__ methods."""
_exit_wrapper = self._create_exit_wrapper(cm, cm_exit)
self._push_exit_callback(_exit_wrapper, True) | python | Lib/contextlib.py | 547 | 550 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,679 | _push_exit_callback | def _push_exit_callback(self, callback, is_sync=True):
self._exit_callbacks.append((is_sync, callback)) | python | Lib/contextlib.py | 552 | 553 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,680 | __enter__ | def __enter__(self):
return self | python | Lib/contextlib.py | 568 | 569 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,681 | __exit__ | def __exit__(self, *exc_details):
exc = exc_details[1]
received_exc = exc is not None
# We manipulate the exception state so it behaves as though
# we were actually nesting multiple with statements
frame_exc = sys.exception()
def _fix_exception_context(new_exc, old_exc):... | python | Lib/contextlib.py | 571 | 623 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,682 | _fix_exception_context | def _fix_exception_context(new_exc, old_exc):
# Context may not be correct, so find the end of the chain
while 1:
exc_context = new_exc.__context__
if exc_context is None or exc_context is old_exc:
# Context is already set correctly (see issue ... | python | Lib/contextlib.py | 578 | 590 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,683 | close | def close(self):
"""Immediately unwind the context stack."""
self.__exit__(None, None, None) | python | Lib/contextlib.py | 625 | 627 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,684 | _create_async_exit_wrapper | def _create_async_exit_wrapper(cm, cm_exit):
return MethodType(cm_exit, cm) | python | Lib/contextlib.py | 645 | 646 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,685 | _create_async_cb_wrapper | def _create_async_cb_wrapper(callback, /, *args, **kwds):
async def _exit_wrapper(exc_type, exc, tb):
await callback(*args, **kwds)
return _exit_wrapper | python | Lib/contextlib.py | 649 | 652 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,686 | _exit_wrapper | async def _exit_wrapper(exc_type, exc, tb):
await callback(*args, **kwds) | python | Lib/contextlib.py | 650 | 651 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,687 | enter_async_context | async def enter_async_context(self, cm):
"""Enters the supplied async context manager.
If successful, also pushes its __aexit__ method as a callback and
returns the result of the __aenter__ method.
"""
cls = type(cm)
try:
_enter = cls.__aenter__
_... | python | Lib/contextlib.py | 654 | 670 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,688 | push_async_exit | def push_async_exit(self, exit):
"""Registers a coroutine function with the standard __aexit__ method
signature.
Can suppress exceptions the same way __aexit__ method can.
Also accepts any object with an __aexit__ method (registering a call
to the method instead of the object it... | python | Lib/contextlib.py | 672 | 688 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,689 | push_async_callback | def push_async_callback(self, callback, /, *args, **kwds):
"""Registers an arbitrary coroutine function and arguments.
Cannot suppress exceptions.
"""
_exit_wrapper = self._create_async_cb_wrapper(callback, *args, **kwds)
# We changed the signature, so using @wraps is not appro... | python | Lib/contextlib.py | 690 | 701 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,690 | aclose | async def aclose(self):
"""Immediately unwind the context stack."""
await self.__aexit__(None, None, None) | python | Lib/contextlib.py | 703 | 705 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,691 | _push_async_cm_exit | def _push_async_cm_exit(self, cm, cm_exit):
"""Helper to correctly register coroutine function to __aexit__
method."""
_exit_wrapper = self._create_async_exit_wrapper(cm, cm_exit)
self._push_exit_callback(_exit_wrapper, False) | python | Lib/contextlib.py | 707 | 711 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,692 | __aenter__ | async def __aenter__(self):
return self | python | Lib/contextlib.py | 713 | 714 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,693 | __aexit__ | async def __aexit__(self, *exc_details):
exc = exc_details[1]
received_exc = exc is not None
# We manipulate the exception state so it behaves as though
# we were actually nesting multiple with statements
frame_exc = sys.exception()
def _fix_exception_context(new_exc, ol... | python | Lib/contextlib.py | 716 | 772 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,694 | _fix_exception_context | def _fix_exception_context(new_exc, old_exc):
# Context may not be correct, so find the end of the chain
while 1:
exc_context = new_exc.__context__
if exc_context is None or exc_context is old_exc:
# Context is already set correctly (see issue ... | python | Lib/contextlib.py | 723 | 735 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,695 | __init__ | def __init__(self, enter_result=None):
self.enter_result = enter_result | python | Lib/contextlib.py | 786 | 787 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,696 | __enter__ | def __enter__(self):
return self.enter_result | python | Lib/contextlib.py | 789 | 790 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,697 | __exit__ | def __exit__(self, *excinfo):
pass | python | Lib/contextlib.py | 792 | 793 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,698 | __aenter__ | async def __aenter__(self):
return self.enter_result | python | Lib/contextlib.py | 795 | 796 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,699 | __aexit__ | async def __aexit__(self, *excinfo):
pass | python | Lib/contextlib.py | 798 | 799 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
15,700 | __init__ | def __init__(self, path):
self.path = path
self._old_cwd = [] | python | Lib/contextlib.py | 805 | 807 | {
"name": "PublicHealthInformationTechnology/cpython",
"url": "https://github.com/PublicHealthInformationTechnology/cpython.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.