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
10,001
parse_verbatim_block
def parse_verbatim_block(self) -> Block: lines = [] self.block_start_line_number = self.line_number while self.input: line = self._line() dsl_name = self.is_start_line(line) if dsl_name: self.dsl_name = dsl_name break ...
python
Tools/clinic/libclinic/block_parser.py
158
170
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,002
parse_clinic_block
def parse_clinic_block(self, dsl_name: str) -> Block: in_lines = [] self.block_start_line_number = self.line_number + 1 stop_line = self.language.stop_line.format(dsl_name=dsl_name) body_prefix = self.language.body_prefix.format(dsl_name=dsl_name) def is_stop_line(line: str) -> ...
python
Tools/clinic/libclinic/block_parser.py
172
256
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,003
is_stop_line
def is_stop_line(line: str) -> bool: # make sure to recognize stop line even if it # doesn't end with EOL (it could be the very end of the file) if line.startswith(stop_line): remainder = line.removeprefix(stop_line) if remainder and not remainder.issp...
python
Tools/clinic/libclinic/block_parser.py
178
190
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,004
__init__
def __init__( self, language: CLanguage, printer: BlockPrinter | None = None, *, filename: str, limited_capi: bool, verify: bool = True, ) -> None: # maps strings to Parser objects. # (instantiated from the "parsers" global.) self.parse...
python
Tools/clinic/libclinic/app.py
82
157
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,005
add_destination
def add_destination( self, name: str, type: str, *args: str ) -> None: if name in self.destinations: fail(f"Destination already exists: {name!r}") self.destinations[name] = Destination(name, type, self, args)
python
Tools/clinic/libclinic/app.py
159
167
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,006
get_destination
def get_destination(self, name: str) -> Destination: d = self.destinations.get(name) if not d: fail(f"Destination does not exist: {name!r}") return d
python
Tools/clinic/libclinic/app.py
169
173
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,007
get_destination_buffer
def get_destination_buffer( self, name: str, item: int = 0 ) -> list[str]: d = self.get_destination(name) return d.buffers[item]
python
Tools/clinic/libclinic/app.py
175
181
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,008
parse
def parse(self, input: str) -> str: printer = self.printer self.block_parser = BlockParser(input, self.language, verify=self.verify) for block in self.block_parser: dsl_name = block.dsl_name if dsl_name: if dsl_name not in self.parsers: ...
python
Tools/clinic/libclinic/app.py
183
241
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,009
_module_and_class
def _module_and_class( self, fields: Sequence[str] ) -> tuple[Module | Clinic, Class | None]: """ fields should be an iterable of field names. returns a tuple of (module, class). the module object could actually be self (a clinic object). this function is only ever us...
python
Tools/clinic/libclinic/app.py
243
268
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,010
__repr__
def __repr__(self) -> str: return "<clinic.Clinic object>"
python
Tools/clinic/libclinic/app.py
270
271
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,011
converter_init
def converter_init(self, *, accept: TypeSet = {object}) -> None: if accept == {int}: self.format_unit = 'i' elif accept != {object}: fail(f"bool_converter: illegal 'accept' argument {accept!r}") if self.default is not unspecified and self.default is not unknown: ...
python
Tools/clinic/libclinic/converters.py
26
33
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,012
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'i': return self.format_code(""" {paramname} = PyLong_AsInt({argname}); if ({paramname} == -1 && PyErr_Occurred()) {{{{ goto exit; ...
python
Tools/clinic/libclinic/converters.py
35
52
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,013
converter_init
def converter_init(self, *, type: str | None = None) -> None: self.specified_type = type
python
Tools/clinic/libclinic/converters.py
64
65
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,014
render
def render(self, parameter: Parameter, data: CRenderData) -> None: self._render_self(parameter, data)
python
Tools/clinic/libclinic/converters.py
67
68
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,015
set_template_dict
def set_template_dict(self, template_dict: TemplateDict) -> None: template_dict['defining_class_name'] = self.name
python
Tools/clinic/libclinic/converters.py
70
71
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,016
converter_init
def converter_init(self) -> None: if isinstance(self.default, self.default_type): if len(self.default) != 1: fail(f"char_converter: illegal default value {self.default!r}") self.c_default = repr(bytes(self.default))[1:] if self.c_default == '"\'"': ...
python
Tools/clinic/libclinic/converters.py
80
87
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,017
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'c': return self.format_code(""" if (PyBytes_Check({argname}) && PyBytes_GET_SIZE({argname}) == 1) {{{{ {paramname} = PyBytes_AS_STRING({argname})[0]; ...
python
Tools/clinic/libclinic/converters.py
89
106
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,018
converter_init
def converter_init(self, *, bitwise: bool = False) -> None: if bitwise: self.format_unit = 'B'
python
Tools/clinic/libclinic/converters.py
116
118
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,019
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'b': return self.format_code(""" {{{{ long ival = PyLong_AsLong({argname}); if (ival == -1 && PyErr_Occurred()) {{{{ ...
python
Tools/clinic/libclinic/converters.py
120
157
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,020
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'h': return self.format_code(""" {{{{ long ival = PyLong_AsLong({argname}); if (ival == -1 && PyErr_Occurred()) {{{{ ...
python
Tools/clinic/libclinic/converters.py
170
194
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,021
converter_init
def converter_init(self, *, bitwise: bool = False) -> None: if bitwise: self.format_unit = 'H' else: self.converter = '_PyLong_UnsignedShort_Converter'
python
Tools/clinic/libclinic/converters.py
202
206
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,022
use_converter
def use_converter(self) -> None: if self.converter == '_PyLong_UnsignedShort_Converter': self.add_include('pycore_long.h', '_PyLong_UnsignedShort_Converter()')
python
Tools/clinic/libclinic/converters.py
208
211
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,023
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'H': return self.format_code(""" {paramname} = (unsigned short)PyLong_AsUnsignedLongMask({argname}); if ({paramname} == (unsigned short)-1 && PyErr_Occurre...
python
Tools/clinic/libclinic/converters.py
213
239
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,024
converter_init
def converter_init( self, *, accept: TypeSet = {int}, type: str | None = None ) -> None: if accept == {str}: self.format_unit = 'C' elif accept != {int}: fail(f"int_converter: illegal 'accept' argument {accept!r}") if type is not None: self.type = ...
python
Tools/clinic/libclinic/converters.py
249
257
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,025
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'i': return self.format_code(""" {paramname} = PyLong_AsInt({argname}); if ({paramname} == -1 && PyErr_Occurred()) {{{{ goto exit; ...
python
Tools/clinic/libclinic/converters.py
259
283
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,026
converter_init
def converter_init(self, *, bitwise: bool = False) -> None: if bitwise: self.format_unit = 'I' else: self.converter = '_PyLong_UnsignedInt_Converter'
python
Tools/clinic/libclinic/converters.py
291
295
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,027
use_converter
def use_converter(self) -> None: if self.converter == '_PyLong_UnsignedInt_Converter': self.add_include('pycore_long.h', '_PyLong_UnsignedInt_Converter()')
python
Tools/clinic/libclinic/converters.py
297
300
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,028
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'I': return self.format_code(""" {paramname} = (unsigned int)PyLong_AsUnsignedLongMask({argname}); if ({paramname} == (unsigned int)-1 && PyErr_Occurred())...
python
Tools/clinic/libclinic/converters.py
302
328
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,029
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'l': return self.format_code(""" {paramname} = PyLong_AsLong({argname}); if ({paramname} == -1 && PyErr_Occurred()) {{{{ goto exit; ...
python
Tools/clinic/libclinic/converters.py
337
346
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,030
converter_init
def converter_init(self, *, bitwise: bool = False) -> None: if bitwise: self.format_unit = 'k' else: self.converter = '_PyLong_UnsignedLong_Converter'
python
Tools/clinic/libclinic/converters.py
354
358
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,031
use_converter
def use_converter(self) -> None: if self.converter == '_PyLong_UnsignedLong_Converter': self.add_include('pycore_long.h', '_PyLong_UnsignedLong_Converter()')
python
Tools/clinic/libclinic/converters.py
360
363
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,032
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'k': return self.format_code(""" if (!PyLong_Check({argname})) {{{{ {bad_argument} goto exit; }}}} ...
python
Tools/clinic/libclinic/converters.py
365
386
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,033
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'L': return self.format_code(""" {paramname} = PyLong_AsLongLong({argname}); if ({paramname} == -1 && PyErr_Occurred()) {{{{ goto exit;...
python
Tools/clinic/libclinic/converters.py
395
404
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,034
converter_init
def converter_init(self, *, bitwise: bool = False) -> None: if bitwise: self.format_unit = 'K' else: self.converter = '_PyLong_UnsignedLongLong_Converter'
python
Tools/clinic/libclinic/converters.py
412
416
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,035
use_converter
def use_converter(self) -> None: if self.converter == '_PyLong_UnsignedLongLong_Converter': self.add_include('pycore_long.h', '_PyLong_UnsignedLongLong_Converter()')
python
Tools/clinic/libclinic/converters.py
418
421
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,036
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'K': return self.format_code(""" if (!PyLong_Check({argname})) {{{{ {bad_argument} goto exit; }}}} ...
python
Tools/clinic/libclinic/converters.py
423
444
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,037
converter_init
def converter_init(self, *, accept: TypeSet = {int}) -> None: if accept == {int}: self.format_unit = 'n' self.default_type = int elif accept == {int, NoneType}: self.converter = '_Py_convert_optional_to_ssize_t' else: fail(f"Py_ssize_t_converter: i...
python
Tools/clinic/libclinic/converters.py
451
458
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,038
use_converter
def use_converter(self) -> None: if self.converter == '_Py_convert_optional_to_ssize_t': self.add_include('pycore_abstract.h', '_Py_convert_optional_to_ssize_t()')
python
Tools/clinic/libclinic/converters.py
460
463
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,039
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'n': if limited_capi: PyNumber_Index = 'PyNumber_Index' else: PyNumber_Index = '_PyNumber_Index' self.add_include('pycore_abstr...
python
Tools/clinic/libclinic/converters.py
465
506
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,040
converter_init
def converter_init(self, *, accept: TypeSet = {int, NoneType}) -> None: if accept == {int}: self.converter = '_PyEval_SliceIndexNotNone' self.nullable = False elif accept == {int, NoneType}: self.converter = '_PyEval_SliceIndex' self.nullable = True ...
python
Tools/clinic/libclinic/converters.py
512
520
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,041
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if not limited_capi: return super().parse_arg(argname, displayname, limited_capi=limited_capi) if self.nullable: return self.format_code(""" if (!Py_IsNone({argname})) {{{{ ...
python
Tools/clinic/libclinic/converters.py
522
558
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,042
use_converter
def use_converter(self) -> None: self.add_include('pycore_long.h', '_PyLong_Size_t_Converter()')
python
Tools/clinic/libclinic/converters.py
566
568
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,043
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'n': return self.format_code(""" {paramname} = PyNumber_AsSsize_t({argname}, PyExc_OverflowError); if ({paramname} == -1 && PyErr_Occurred()) {{{{ ...
python
Tools/clinic/libclinic/converters.py
570
588
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,044
use_converter
def use_converter(self) -> None: self.add_include('pycore_fileutils.h', '_PyLong_FileDescriptor_Converter()')
python
Tools/clinic/libclinic/converters.py
595
597
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,045
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: return self.format_code(""" {paramname} = PyObject_AsFileDescriptor({argname}); if ({paramname} < 0) {{{{ goto exit; }}}} """, argname=argname)
python
Tools/clinic/libclinic/converters.py
599
606
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,046
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'f': if not limited_capi: return self.format_code(""" if (PyFloat_CheckExact({argname})) {{{{ {paramname} = (float) (PyFloat_AS...
python
Tools/clinic/libclinic/converters.py
615
639
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,047
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'd': if not limited_capi: return self.format_code(""" if (PyFloat_CheckExact({argname})) {{{{ {paramname} = PyFloat_AS_DOUBLE({...
python
Tools/clinic/libclinic/converters.py
648
672
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,048
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'D': return self.format_code(""" {paramname} = PyComplex_AsCComplex({argname}); if (PyErr_Occurred()) {{{{ goto exit; }...
python
Tools/clinic/libclinic/converters.py
681
690
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,049
converter_init
def converter_init( self, *, converter: str | None = None, type: str | None = None, subclass_of: str | None = None ) -> None: if converter: if subclass_of: fail("object: Cannot pass in both 'converter' and 'subclass_of'") ...
python
Tools/clinic/libclinic/converters.py
697
713
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,050
str_converter_key
def str_converter_key( types: TypeSet, encoding: bool | str | None, zeroes: bool ) -> StrConverterKeyType: return (frozenset(types), bool(encoding), bool(zeroes))
python
Tools/clinic/libclinic/converters.py
734
737
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,051
converter_init
def converter_init( self, *, accept: TypeSet = {str}, encoding: str | None = None, zeroes: bool = False ) -> None: key = str_converter_key(accept, encoding, zeroes) format_unit = str_converter_argument_map.get(key) if not format_un...
python
Tools/clinic/libclinic/converters.py
747
771
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,052
post_parsing
def post_parsing(self) -> str: if self.encoding: name = self.name return f"PyMem_FREE({name});\n" else: return ""
python
Tools/clinic/libclinic/converters.py
773
778
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,053
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 's': return self.format_code(""" if (!PyUnicode_Check({argname})) {{{{ {bad_argument} goto exit; }}}} ...
python
Tools/clinic/libclinic/converters.py
780
824
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,054
r
def r(format_unit: str, *, accept: TypeSet, encoding: bool = False, zeroes: bool = False ) -> None: if not encoding and format_unit != 's': # add the legacy c converters here too. # # note: add_legacy_c_converter can't work for # es, es#, et, or et# ...
python
Tools/clinic/libclinic/converters.py
837
864
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,055
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'S': return self.format_code(""" if (!PyBytes_Check({argname})) {{{{ {bad_argument} goto exit; }}}} ...
python
Tools/clinic/libclinic/converters.py
884
896
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,056
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'Y': return self.format_code(""" if (!PyByteArray_Check({argname})) {{{{ {bad_argument} goto exit; }}}} ...
python
Tools/clinic/libclinic/converters.py
904
916
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,057
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if self.format_unit == 'U': return self.format_code(""" if (!PyUnicode_Check({argname})) {{{{ {bad_argument} goto exit; }}}} ...
python
Tools/clinic/libclinic/converters.py
924
936
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,058
converter_init
def converter_init( self, *, accept: TypeSet = {str}, zeroes: bool = False ) -> None: format_unit = 'Z' if accept=={str, NoneType} else 'u' if zeroes: format_unit += '#' self.length = True self.format_unit = format_unit ...
python
Tools/clinic/libclinic/converters.py
947
965
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,059
cleanup
def cleanup(self) -> str: if self.length: return "" else: return f"""PyMem_Free((void *){self.parser_name});\n"""
python
Tools/clinic/libclinic/converters.py
967
971
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,060
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: if not self.length: if self.accept == {str}: return self.format_code(""" if (!PyUnicode_Check({argname})) {{{{ {bad_argument} ...
python
Tools/clinic/libclinic/converters.py
973
1,008
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,061
converter_init
def converter_init(self, *, accept: TypeSet = {buffer}) -> None: if self.default not in (unspecified, None): fail("The only legal default value for Py_buffer is None.") self.c_default = self.c_ignored_default if accept == {str, buffer, NoneType}: format_unit = 'z*' ...
python
Tools/clinic/libclinic/converters.py
1,020
1,037
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,062
cleanup
def cleanup(self) -> str: name = self.name return "".join(["if (", name, ".obj) {\n PyBuffer_Release(&", name, ");\n}\n"])
python
Tools/clinic/libclinic/converters.py
1,039
1,041
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,063
parse_arg
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None: # PyBUF_SIMPLE guarantees that the format units of the buffers are C-contiguous. if self.format_unit == 'y*': return self.format_code(""" if (PyObject_GetBuffer({argname}, &{paramname}, ...
python
Tools/clinic/libclinic/converters.py
1,043
1,086
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,064
correct_name_for_self
def correct_name_for_self( f: Function ) -> tuple[str, str]: if f.kind in {CALLABLE, METHOD_INIT, GETTER, SETTER}: if f.cls: return "PyObject *", "self" return "PyObject *", "module" if f.kind is STATIC_METHOD: return "void *", "null" if f.kind in (CLASS_METHOD, M...
python
Tools/clinic/libclinic/converters.py
1,089
1,100
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,065
converter_init
def converter_init(self, *, type: str | None = None) -> None: self.specified_type = type
python
Tools/clinic/libclinic/converters.py
1,111
1,112
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,066
pre_render
def pre_render(self) -> None: f = self.function default_type, default_name = correct_name_for_self(f) self.signature_name = default_name self.type = self.specified_type or self.type or default_type kind = self.function.kind if kind is STATIC_METHOD or kind.new_or_init: ...
python
Tools/clinic/libclinic/converters.py
1,114
1,123
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,067
parser_type
def parser_type(self) -> str: assert self.type is not None if self.function.kind in {METHOD_INIT, METHOD_NEW, STATIC_METHOD, CLASS_METHOD}: tp, _ = correct_name_for_self(self.function) return tp return self.type
python
Tools/clinic/libclinic/converters.py
1,164
1,169
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,068
render
def render(self, parameter: Parameter, data: CRenderData) -> None: """ parameter is a clinic.Parameter instance. data is a CRenderData instance. """ if self.function.kind is STATIC_METHOD: return self._render_self(parameter, data) if self.type != sel...
python
Tools/clinic/libclinic/converters.py
1,171
1,188
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,069
set_template_dict
def set_template_dict(self, template_dict: TemplateDict) -> None: template_dict['self_name'] = self.name template_dict['self_type'] = self.parser_type kind = self.function.kind cls = self.function.cls if kind.new_or_init and cls and cls.typedef: if kind is METHOD_NEW...
python
Tools/clinic/libclinic/converters.py
1,190
1,211
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,070
__post_init__
def __post_init__(self) -> None: super().__init__(self.message)
python
Tools/clinic/libclinic/errors.py
12
13
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,071
report
def report(self, *, warn_only: bool = False) -> str: msg = "Warning" if warn_only else "Error" if self.filename is not None: msg += f" in file {self.filename!r}" if self.lineno is not None: msg += f" on line {self.lineno}" msg += ":\n" msg += f"{self.messa...
python
Tools/clinic/libclinic/errors.py
15
23
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,072
warn_or_fail
def warn_or_fail( *args: object, fail: Literal[True], filename: str | None = None, line_number: int | None = None, ) -> NoReturn: ...
python
Tools/clinic/libclinic/errors.py
31
36
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,073
warn_or_fail
def warn_or_fail( *args: object, fail: Literal[False] = False, filename: str | None = None, line_number: int | None = None, ) -> None: ...
python
Tools/clinic/libclinic/errors.py
39
44
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,074
warn_or_fail
def warn_or_fail( *args: object, fail: bool = False, filename: str | None = None, line_number: int | None = None, ) -> None: joined = " ".join([str(a) for a in args]) error = ClinicError(joined, filename=filename, lineno=line_number) if fail: raise error else: print(error...
python
Tools/clinic/libclinic/errors.py
46
57
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,075
warn
def warn( *args: object, filename: str | None = None, line_number: int | None = None, ) -> None: return warn_or_fail(*args, filename=filename, line_number=line_number, fail=False)
python
Tools/clinic/libclinic/errors.py
60
65
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,076
fail
def fail( *args: object, filename: str | None = None, line_number: int | None = None, ) -> NoReturn: warn_or_fail(*args, filename=filename, line_number=line_number, fail=True)
python
Tools/clinic/libclinic/errors.py
67
72
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,077
__init__
def __init__(self) -> None: # The C statements to declare variables. # Should be full lines with \n eol characters. self.declarations: list[str] = [] # The C statements required to initialize the variables before the parse call. # Should be full lines with \n eol characters. ...
python
Tools/clinic/libclinic/codegen.py
19
72
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,078
sort_key
def sort_key(self) -> tuple[str, str]: # order: '#if' comes before 'NO_CONDITION' return (self.condition or 'NO_CONDITION', self.filename)
python
Tools/clinic/libclinic/codegen.py
90
92
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,079
print_block
def print_block( self, block: Block, *, header_includes: list[Include] | None = None, ) -> None: input = block.input output = block.output dsl_name = block.dsl_name write = self.f.write assert not ((dsl_name is None) ^ (output is None)), "you ...
python
Tools/clinic/libclinic/codegen.py
103
173
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,080
write
def write(self, text: str) -> None: self.f.write(text)
python
Tools/clinic/libclinic/codegen.py
175
176
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,081
__init__
def __init__(self) -> None: self._start = 0 self._array: list[list[str]] = []
python
Tools/clinic/libclinic/codegen.py
190
192
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,082
__getitem__
def __getitem__(self, i: int) -> list[str]: i -= self._start if i < 0: self._start += i prefix: list[list[str]] = [[] for x in range(-i)] self._array = prefix + self._array i = 0 while i >= len(self._array): self._array.append([]) ...
python
Tools/clinic/libclinic/codegen.py
194
203
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,083
clear
def clear(self) -> None: for ta in self._array: ta.clear()
python
Tools/clinic/libclinic/codegen.py
205
207
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,084
dump
def dump(self) -> str: texts = ["".join(ta) for ta in self._array] self.clear() return "".join(texts)
python
Tools/clinic/libclinic/codegen.py
209
212
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,085
__post_init__
def __post_init__(self, args: tuple[str, ...]) -> None: valid_types = ('buffer', 'file', 'suppress') if self.type not in valid_types: fail( f"Invalid destination type {self.type!r} for {self.name}, " f"must be {', '.join(valid_types)}" ) ex...
python
Tools/clinic/libclinic/codegen.py
225
248
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,086
__repr__
def __repr__(self) -> str: if self.type == 'file': type_repr = f"type='file' file={self.filename!r}" else: type_repr = f"type={self.type!r}" return f"<clinic.Destination {self.name!r} {type_repr}>"
python
Tools/clinic/libclinic/codegen.py
250
255
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,087
clear
def clear(self) -> None: if self.type != 'buffer': fail(f"Can't clear destination {self.name!r}: it's not of type 'buffer'") self.buffers.clear()
python
Tools/clinic/libclinic/codegen.py
257
260
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,088
dump
def dump(self) -> str: return self.buffers.dump()
python
Tools/clinic/libclinic/codegen.py
262
263
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,089
__init__
def __init__(self, limited_capi: bool) -> None: self.limited_capi = limited_capi self._ifndef_symbols: set[str] = set() # dict: include name => Include instance self._includes: dict[str, Include] = {}
python
Tools/clinic/libclinic/codegen.py
270
274
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,090
add_ifndef_symbol
def add_ifndef_symbol(self, name: str) -> bool: if name in self._ifndef_symbols: return False self._ifndef_symbols.add(name) return True
python
Tools/clinic/libclinic/codegen.py
276
280
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,091
add_include
def add_include(self, name: str, reason: str, *, condition: str | None = None) -> None: try: existing = self._includes[name] except KeyError: pass else: if existing.condition and not condition: # If the previous include has ...
python
Tools/clinic/libclinic/codegen.py
282
298
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,092
get_includes
def get_includes(self) -> list[Include]: return sorted(self._includes.values(), key=Include.sort_key)
python
Tools/clinic/libclinic/codegen.py
300
302
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,093
__post_init__
def __post_init__(self) -> None: self.parent = self.module self.modules: ModuleDict = {} self.classes: ClassDict = {} self.functions: list[Function] = []
python
Tools/clinic/libclinic/function.py
28
32
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,094
__repr__
def __repr__(self) -> str: return "<clinic.Module " + repr(self.name) + " at " + str(id(self)) + ">"
python
Tools/clinic/libclinic/function.py
34
35
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,095
__post_init__
def __post_init__(self) -> None: self.parent = self.cls or self.module self.classes: ClassDict = {} self.functions: list[Function] = []
python
Tools/clinic/libclinic/function.py
46
49
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,096
__repr__
def __repr__(self) -> str: return "<clinic.Class " + repr(self.name) + " at " + str(id(self)) + ">"
python
Tools/clinic/libclinic/function.py
51
52
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,097
new_or_init
def new_or_init(self) -> bool: return self in {FunctionKind.METHOD_INIT, FunctionKind.METHOD_NEW}
python
Tools/clinic/libclinic/function.py
65
66
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,098
__repr__
def __repr__(self) -> str: return f"<clinic.FunctionKind.{self.name}>"
python
Tools/clinic/libclinic/function.py
68
69
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,099
__post_init__
def __post_init__(self) -> None: self.parent = self.cls or self.module self.self_converter: self_converter | None = None self.__render_parameters__: list[Parameter] | None = None
python
Tools/clinic/libclinic/function.py
114
117
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
10,100
displayname
def displayname(self) -> str: """Pretty-printable name.""" if self.kind.new_or_init: assert isinstance(self.cls, Class) return self.cls.name else: return self.name
python
Tools/clinic/libclinic/function.py
120
126
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }