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
8,201
get_pyop
def get_pyop(self): try: frame = self._gdbframe.read_var('frame') frame = PyFramePtr(frame) if not frame.is_optimized_out(): return frame cframe = self._gdbframe.read_var('cframe') if cframe is None: return None ...
python
Tools/gdb/libpython.py
1,770
1,784
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,202
get_selected_frame
def get_selected_frame(cls): _gdbframe = gdb.selected_frame() if _gdbframe: return Frame(_gdbframe) return None
python
Tools/gdb/libpython.py
1,787
1,791
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,203
get_selected_python_frame
def get_selected_python_frame(cls): '''Try to obtain the Frame for the python-related code in the selected frame, or None''' try: frame = cls.get_selected_frame() except gdb.error: # No frame: Python didn't start yet return None while frame: ...
python
Tools/gdb/libpython.py
1,794
1,809
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,204
get_selected_bytecode_frame
def get_selected_bytecode_frame(cls): '''Try to obtain the Frame for the python bytecode interpreter in the selected GDB frame, or None''' frame = cls.get_selected_frame() while frame: if frame.is_evalframe(): return frame frame = frame.older() ...
python
Tools/gdb/libpython.py
1,812
1,823
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,205
print_summary
def print_summary(self): if self.is_evalframe(): interp_frame = self.get_pyop() while True: if interp_frame: if interp_frame.is_shim(): break line = interp_frame.get_truncated_repr(MAX_OUTPUT_LEN) ...
python
Tools/gdb/libpython.py
1,825
1,847
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,206
print_traceback
def print_traceback(self): if self.is_evalframe(): interp_frame = self.get_pyop() while True: if interp_frame: if interp_frame.is_shim(): break interp_frame.print_traceback() if not interp...
python
Tools/gdb/libpython.py
1,849
1,870
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,207
__init__
def __init__(self): gdb.Command.__init__ (self, "py-list", gdb.COMMAND_FILES, gdb.COMPLETE_NONE)
python
Tools/gdb/libpython.py
1,884
1,888
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,208
invoke
def invoke(self, args, from_tty): import re start = None end = None m = re.match(r'\s*(\d+)\s*', args) if m: start = int(m.group(0)) end = start + 10 m = re.match(r'\s*(\d+)\s*,\s*(\d+)\s*', args) if m: start, end = map(int, ...
python
Tools/gdb/libpython.py
1,891
1,946
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,209
move_in_stack
def move_in_stack(move_up): '''Move up or down the stack (for the py-up/py-down command)''' # Important: # The amount of frames that are printed out depends on how many frames are inlined # in the same evaluation loop. As this command links directly the C stack with the # Python stack, the results a...
python
Tools/gdb/libpython.py
1,952
1,983
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,210
__init__
def __init__(self): gdb.Command.__init__ (self, "py-up", gdb.COMMAND_STACK, gdb.COMPLETE_NONE)
python
Tools/gdb/libpython.py
1,988
1,992
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,211
invoke
def invoke(self, args, from_tty): move_in_stack(move_up=True)
python
Tools/gdb/libpython.py
1,995
1,996
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,212
__init__
def __init__(self): gdb.Command.__init__ (self, "py-down", gdb.COMMAND_STACK, gdb.COMPLETE_NONE)
python
Tools/gdb/libpython.py
2,000
2,004
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,213
invoke
def invoke(self, args, from_tty): move_in_stack(move_up=False)
python
Tools/gdb/libpython.py
2,007
2,008
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,214
__init__
def __init__(self): gdb.Command.__init__ (self, "py-bt-full", gdb.COMMAND_STACK, gdb.COMPLETE_NONE)
python
Tools/gdb/libpython.py
2,017
2,021
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,215
invoke
def invoke(self, args, from_tty): frame = Frame.get_selected_python_frame() if not frame: print('Unable to locate python frame') return while frame: if frame.is_python_frame(): frame.print_summary() frame = frame.older()
python
Tools/gdb/libpython.py
2,024
2,033
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,216
__init__
def __init__(self): gdb.Command.__init__ (self, "py-bt", gdb.COMMAND_STACK, gdb.COMPLETE_NONE)
python
Tools/gdb/libpython.py
2,039
2,043
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,217
invoke
def invoke(self, args, from_tty): frame = Frame.get_selected_python_frame() if not frame: print('Unable to locate python frame') return sys.stdout.write('Traceback (most recent call first):\n') while frame: if frame.is_python_frame(): ...
python
Tools/gdb/libpython.py
2,046
2,056
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,218
__init__
def __init__(self): gdb.Command.__init__ (self, "py-print", gdb.COMMAND_DATA, gdb.COMPLETE_NONE)
python
Tools/gdb/libpython.py
2,062
2,066
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,219
invoke
def invoke(self, args, from_tty): name = str(args) frame = Frame.get_selected_python_frame() if not frame: print('Unable to locate python frame') return pyop_frame = frame.get_pyop() if not pyop_frame: print(UNABLE_READ_INFO_PYTHON_FRAME) ...
python
Tools/gdb/libpython.py
2,069
2,090
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,220
__init__
def __init__(self): gdb.Command.__init__ (self, "py-locals", gdb.COMMAND_DATA, gdb.COMPLETE_NONE)
python
Tools/gdb/libpython.py
2,096
2,100
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,221
invoke
def invoke(self, args, from_tty): name = str(args) frame = Frame.get_selected_python_frame() if not frame: print('Unable to locate python frame') return pyop_frame = frame.get_pyop() while True: if not pyop_frame: print(UNABLE...
python
Tools/gdb/libpython.py
2,103
2,127
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,222
get_custom_entry_point
def get_custom_entry_point(subsystem): try: return subsystem_details[subsystem][:2] except KeyError: raise ValueError("The subsystem %s is not known" % subsystem) from None
python
Tools/freeze/winmakemakefile.py
38
42
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,223
makemakefile
def makemakefile(outfp, vars, files, target): save = sys.stdout try: sys.stdout = outfp realwork(vars, files, target) finally: sys.stdout = save
python
Tools/freeze/winmakemakefile.py
45
51
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,224
realwork
def realwork(vars, moddefns, target): version_suffix = "%r%r" % sys.version_info[:2] print("# Makefile for Microsoft Visual C++ generated by freeze.py script") print() print('target = %s' % target) print('pythonhome = %s' % vars['prefix']) print() print('DEBUG=0 # Set to 1 to use the _d vers...
python
Tools/freeze/winmakemakefile.py
53
148
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,225
makemakefile
def makemakefile(outfp, makevars, files, target): outfp.write("# Makefile generated by freeze.py script\n\n") keys = sorted(makevars.keys()) for key in keys: outfp.write("%s=%s\n" % (key, makevars[key])) outfp.write("\nall: %s\n\n" % target) deps = [] for i in range(len(files)): ...
python
Tools/freeze/makemakefile.py
5
28
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,226
get_module_code
def get_module_code(filename): """Compile 'filename' and return the module code as a marshalled byte string. """ with open(filename, 'r') as fp: src = fp.read() co = compile(src, 'none', 'exec') co_bytes = marshal.dumps(co) return co_bytes
python
Tools/freeze/regen_frozen.py
14
22
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,227
gen_c_code
def gen_c_code(fp, co_bytes): """Generate C code for the module code in 'co_bytes', write it to 'fp'. """ def write(*args, **kwargs): print(*args, **kwargs, file=fp) write('/* Generated with Tools/freeze/regen_frozen.py */') write('static unsigned char %s[] = {' % SYMBOL, end='') bytes_p...
python
Tools/freeze/regen_frozen.py
25
40
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,228
write
def write(*args, **kwargs): print(*args, **kwargs, file=fp)
python
Tools/freeze/regen_frozen.py
28
29
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,229
main
def main(): out_filename = sys.argv[1] co_bytes = get_module_code(FILE) with open(out_filename, 'w') as fp: gen_c_code(fp, co_bytes)
python
Tools/freeze/regen_frozen.py
43
47
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,230
getmakevars
def getmakevars(filename): variables = {} fp = open(filename) pendingline = "" try: while 1: line = fp.readline() if pendingline: line = pendingline + line pendingline = "" if not line: break if line....
python
Tools/freeze/parsesetup.py
12
38
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,231
getsetupinfo
def getsetupinfo(filename): modules = {} variables = {} fp = open(filename) pendingline = "" try: while 1: line = fp.readline() if pendingline: line = pendingline + line pendingline = "" if not line: break ...
python
Tools/freeze/parsesetup.py
48
78
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,232
test
def test(): import sys import os if not sys.argv[1:]: print('usage: python parsesetup.py Makefile*|Setup* ...') sys.exit(2) for arg in sys.argv[1:]: base = os.path.basename(arg) if base[:8] == 'Makefile': print('Make style parsing:', arg) v = getma...
python
Tools/freeze/parsesetup.py
83
102
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,233
prdict
def prdict(d): keys = sorted(d.keys()) for key in keys: value = d[key] print("%-15s" % key, str(value))
python
Tools/freeze/parsesetup.py
104
108
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,234
makefreeze
def makefreeze(base, dict, debug=0, entry_point=None, fail_import=()): if entry_point is None: entry_point = default_entry_point done = [] files = [] mods = sorted(dict.keys()) for mod in mods: m = dict[mod] mangled = "__".join(mod.split(".")) if m.__code__: file ...
python
Tools/freeze/makefreeze.py
32
70
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,235
writecode
def writecode(fp, mod, data): print('unsigned char M_%s[] = {' % mod, file=fp) indent = ' ' * 4 for i in range(0, len(data), 16): print(indent, file=fp, end='') for c in bytes(data[i:i+16]): print('%d,' % c, file=fp, end='') print('', file=fp) print('};', file=fp)
python
Tools/freeze/makefreeze.py
77
85
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,236
open
def open(file, mode='r', bufsize=-1): if 'w' not in mode: return _orig_open(file, mode, bufsize) import os backup = file + '~' try: os.unlink(backup) except OSError: pass try: os.rename(file, backup) except OSError: return _orig_open(file, mode, bufsiz...
python
Tools/freeze/bkfile.py
3
26
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,237
close
def close(): _orig_close() import filecmp if filecmp.cmp(backup, file, shallow=False): import os os.unlink(file) os.rename(backup, file)
python
Tools/freeze/bkfile.py
18
24
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,238
main
def main(): # overridable context prefix = None # settable with -p option exec_prefix = None # settable with -P option extensions = [] exclude = [] # settable with -x option addn_link = [] # settable with -l, but only honored und...
python
Tools/freeze/freeze.py
111
482
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,239
usage
def usage(msg): sys.stdout = sys.stderr print("Error:", msg) print("Use ``%s -h'' for help" % sys.argv[0]) sys.exit(2)
python
Tools/freeze/freeze.py
487
491
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,240
__init__
def __init__(self, name, sourceFiles): self.name = name # A list of strings defining additional compiler options. self.sourceFiles = sourceFiles # A list of special compiler options to be applied to # all source modules in this extension. self.compilerOptions = [] ...
python
Tools/freeze/checkextensions_win32.py
34
42
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,241
GetSourceFiles
def GetSourceFiles(self): return self.sourceFiles
python
Tools/freeze/checkextensions_win32.py
44
45
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,242
AddCompilerOption
def AddCompilerOption(self, option): self.compilerOptions.append(option)
python
Tools/freeze/checkextensions_win32.py
47
48
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,243
GetCompilerOptions
def GetCompilerOptions(self): return self.compilerOptions
python
Tools/freeze/checkextensions_win32.py
49
50
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,244
AddLinkerLib
def AddLinkerLib(self, lib): self.linkerLibs.append(lib)
python
Tools/freeze/checkextensions_win32.py
52
53
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,245
GetLinkerLibs
def GetLinkerLibs(self): return self.linkerLibs
python
Tools/freeze/checkextensions_win32.py
54
55
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,246
checkextensions
def checkextensions(unknown, extra_inis, prefix): # Create a table of frozen extensions defaultMapName = os.path.join( os.path.split(sys.argv[0])[0], "extensions_win32.ini") if not os.path.isfile(defaultMapName): sys.stderr.write("WARNING: %s can not be found - standard extensions may not be found\...
python
Tools/freeze/checkextensions_win32.py
57
80
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,247
get_extension_defn
def get_extension_defn(moduleName, mapFileName, prefix): if win32api is None: return None os.environ['PYTHONPREFIX'] = prefix dsp = win32api.GetProfileVal(moduleName, "dsp", "", mapFileName) if dsp=="": return None # We allow environment variables in the file name dsp = win32api.ExpandE...
python
Tools/freeze/checkextensions_win32.py
82
123
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,248
parse_dsp
def parse_dsp(dsp): # print "Processing", dsp # For now, only support ret = [] dsp_path, dsp_name = os.path.split(dsp) try: with open(dsp, "r") as fp: lines = fp.readlines() except IOError as msg: sys.stderr.write("%s: %s\n" % (dsp, msg)) return None for...
python
Tools/freeze/checkextensions_win32.py
127
143
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,249
write_extension_table
def write_extension_table(fname, modules): fp = open(fname, "w") try: fp.write (ext_src_header) # Write fn protos for module in modules: # bit of a hack for .pyd's as part of packages. name = module.name.split('.')[-1] fp.write('extern void init%s(void...
python
Tools/freeze/checkextensions_win32.py
145
163
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,250
checkextensions
def checkextensions(unknown, extensions): files = [] modules = [] edict = {} for e in extensions: setup = os.path.join(e, 'Setup') liba = os.path.join(e, 'lib.a') if not os.path.isfile(liba): liba = None edict[e] = parsesetup.getsetupinfo(setup), liba for ...
python
Tools/freeze/checkextensions.py
8
37
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,251
select
def select(e, mods, vars, mod, skipofiles): files = [] for w in mods[mod]: w = treatword(w) if not w: continue w = expandvars(w, vars) for w in w.split(): if skipofiles and w[-2:] == '.o': continue # Assume $var expands to absol...
python
Tools/freeze/checkextensions.py
39
55
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,252
treatword
def treatword(w): if w[:2] in cc_flags: return None if w[:1] == '-': return w # Assume loader flag head, tail = os.path.split(w) base, ext = os.path.splitext(tail) if ext in cc_exts: tail = base + '.o' w = os.path.join(head, tail) return w
python
Tools/freeze/checkextensions.py
60
70
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,253
expandvars
def expandvars(str, vars): i = 0 while i < len(str): i = k = str.find('$', i) if i < 0: break i = i+1 var = str[i:i+1] i = i+1 if var == '(': j = str.find(')', i) if j < 0: break var = str[i:j] ...
python
Tools/freeze/checkextensions.py
72
90
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,254
makeconfig
def makeconfig(infp, outfp, modules, with_ifdef=0): m1 = re.compile('-- ADDMODULE MARKER 1 --') m2 = re.compile('-- ADDMODULE MARKER 2 --') for line in infp: outfp.write(line) if m1 and m1.search(line): m1 = None for mod in modules: if mod in never: ...
python
Tools/freeze/makeconfig.py
9
34
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,255
test
def test(): if not sys.argv[3:]: print('usage: python makeconfig.py config.c.in outputfile', end=' ') print('modulename ...') sys.exit(2) if sys.argv[1] == '-': infp = sys.stdin else: infp = open(sys.argv[1]) if sys.argv[2] == '-': outfp = sys.stdout e...
python
Tools/freeze/makeconfig.py
39
56
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,256
parse_args
def parse_args(argv=sys.argv[1:]): import argparse from c_common.scriptutil import ( add_verbosity_cli, add_traceback_cli, process_args_by_key, ) from cpython.__main__ import _cli_check parser = argparse.ArgumentParser() processors = [ add_verbosity_cli(parser), ...
python
Tools/c-analyzer/check-c-globals.py
6
33
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,257
iter_clean_lines
def iter_clean_lines(lines): lines = iter(lines) for rawline in lines: line = rawline.strip() if line.startswith('#') and not rawline.startswith('##'): continue yield line, rawline
python
Tools/c-analyzer/table-file.py
10
16
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,258
parse_table_lines
def parse_table_lines(lines): lines = iter_clean_lines(lines) group = None prev = '' for line, rawline in lines: if line.startswith('## '): assert not rawline.startswith(' '), (line, rawline) if group: assert prev, (line, rawline) kind, af...
python
Tools/c-analyzer/table-file.py
19
56
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,259
iter_sections
def iter_sections(lines): header = None section = [] for kind, value in parse_table_lines(lines): if kind == 'row': if not section: if header is None: header = value continue raise NotImplementedError(repr(value)) ...
python
Tools/c-analyzer/table-file.py
59
74
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,260
collect_sections
def collect_sections(lines): sections = {} for section, row in iter_sections(lines): if section not in sections: sections[section] = [row] else: sections[section].append(row) return sections
python
Tools/c-analyzer/table-file.py
77
84
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,261
collate_sections
def collate_sections(lines): collated = {} for section, rows in collect_sections(lines).items(): parent = collated current = () for name in section: current += (name,) try: child, secrows, totalrows = parent[name] except KeyError: ...
python
Tools/c-analyzer/table-file.py
87
105
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,262
cmd_count_by_section
def cmd_count_by_section(lines): div = ' ' + '-' * 50 total = 0 def render_tree(root, depth=0): nonlocal total indent = ' ' * depth for name, data in root.items(): subroot, rows, totalrows = data sectotal = f'({len(totalrows)})' if totalrows != rows else ''...
python
Tools/c-analyzer/table-file.py
111
129
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,263
render_tree
def render_tree(root, depth=0): nonlocal total indent = ' ' * depth for name, data in root.items(): subroot, rows, totalrows = data sectotal = f'({len(totalrows)})' if totalrows != rows else '' count = len(rows) if rows else '' if depth == 0: ...
python
Tools/c-analyzer/table-file.py
114
125
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,264
parse_args
def parse_args(argv=None, prog=None): import argparse parser = argparse.ArgumentParser(prog=prog) parser.add_argument('filename') args = parser.parse_args(argv) ns = vars(args) return ns
python
Tools/c-analyzer/table-file.py
135
143
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,265
main
def main(filename): with open(filename) as infile: for line in cmd_count_by_section(infile): print(line)
python
Tools/c-analyzer/table-file.py
146
149
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,266
_find_vc2015
def _find_vc2015(): try: key = winreg.OpenKeyEx( winreg.HKEY_LOCAL_MACHINE, r"Software\Microsoft\VisualStudio\SxS\VC7", access=winreg.KEY_READ | winreg.KEY_WOW64_32KEY ) except OSError: log.debug("Visual C++ is not registered") return None, Non...
python
Tools/c-analyzer/distutils/_msvccompiler.py
26
52
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,267
_find_vc2017
def _find_vc2017(): """Returns "15, path" based on the result of invoking vswhere.exe If no install is found, returns "None, None" The version is returned to avoid unnecessarily changing the function result. It may be ignored when the path is not None. If vswhere.exe is not available, by definitio...
python
Tools/c-analyzer/distutils/_msvccompiler.py
54
84
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,268
_find_vcvarsall
def _find_vcvarsall(plat_spec): # bpo-38597: Removed vcruntime return value _, best_dir = _find_vc2017() if not best_dir: best_version, best_dir = _find_vc2015() if not best_dir: log.debug("No suitable Visual C++ version found") return None, None vcvarsall = os.path.join(b...
python
Tools/c-analyzer/distutils/_msvccompiler.py
93
109
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,269
_get_vc_env
def _get_vc_env(plat_spec): if os.getenv("DISTUTILS_USE_SDK"): return { key.lower(): value for key, value in os.environ.items() } vcvarsall, _ = _find_vcvarsall(plat_spec) if not vcvarsall: raise DistutilsPlatformError("Unable to find vcvarsall.bat") try...
python
Tools/c-analyzer/distutils/_msvccompiler.py
111
139
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,270
_find_exe
def _find_exe(exe, paths=None): """Return path to an MSVC executable program. Tries to find the program in several places: first, one of the MSVC program search paths from the registry; next, the directories in the PATH environment variable. If any of those work, return an absolute path that is kn...
python
Tools/c-analyzer/distutils/_msvccompiler.py
141
156
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,271
__init__
def __init__(self, verbose=0, dry_run=0, force=0): CCompiler.__init__ (self, verbose, dry_run, force) # target platform (.plat_name is consistent with 'bdist') self.plat_name = None self.initialized = False
python
Tools/c-analyzer/distutils/_msvccompiler.py
199
203
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,272
preprocess
def preprocess(self, source, output_file=None, macros=None, include_dirs=None, extra_preargs=None, extra_postargs=None): fixed_args = self._fix_compile_args(None, macros, include_dirs) ignore, macros, include_dirs = fixed_args pp_opts = gen_preprocess_options(macros, include_d...
python
Tools/c-analyzer/distutils/unixccompiler.py
78
102
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,273
__init__
def __init__(self, verbose=0, dry_run=0, force=0): self.dry_run = dry_run self.force = force self.verbose = verbose # 'output_dir': a common output directory for object, library, # shared object, and shared library files self.output_dir = None # 'macros': a list...
python
Tools/c-analyzer/distutils/ccompiler.py
82
116
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,274
set_executables
def set_executables(self, **kwargs): """Define the executables (and options for them) that will be run to perform the various stages of compilation. The exact set of executables that may be specified here depends on the compiler class (via the 'executables' class attribute), but most wi...
python
Tools/c-analyzer/distutils/ccompiler.py
118
148
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,275
set_executable
def set_executable(self, key, value): if isinstance(value, str): setattr(self, key, split_quoted(value)) else: setattr(self, key, value)
python
Tools/c-analyzer/distutils/ccompiler.py
150
154
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,276
_find_macro
def _find_macro(self, name): i = 0 for defn in self.macros: if defn[0] == name: return i i += 1 return None
python
Tools/c-analyzer/distutils/ccompiler.py
156
162
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,277
_check_macro_definitions
def _check_macro_definitions(self, definitions): """Ensures that every element of 'definitions' is a valid macro definition, ie. either (name,value) 2-tuple or a (name,) tuple. Do nothing if all definitions are OK, raise TypeError otherwise. """ for defn in definitions: ...
python
Tools/c-analyzer/distutils/ccompiler.py
164
176
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,278
define_macro
def define_macro(self, name, value=None): """Define a preprocessor macro for all compilations driven by this compiler object. The optional parameter 'value' should be a string; if it is not supplied, then the macro will be defined without an explicit value and the exact outcome depends ...
python
Tools/c-analyzer/distutils/ccompiler.py
181
194
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,279
undefine_macro
def undefine_macro(self, name): """Undefine a preprocessor macro for all compilations driven by this compiler object. If the same macro is defined by 'define_macro()' and undefined by 'undefine_macro()' the last call takes precedence (including multiple redefinitions or undefini...
python
Tools/c-analyzer/distutils/ccompiler.py
196
212
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,280
add_include_dir
def add_include_dir(self, dir): """Add 'dir' to the list of directories that will be searched for header files. The compiler is instructed to search directories in the order in which they are supplied by successive calls to 'add_include_dir()'. """ self.include_dirs.appe...
python
Tools/c-analyzer/distutils/ccompiler.py
214
220
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,281
set_include_dirs
def set_include_dirs(self, dirs): """Set the list of directories that will be searched to 'dirs' (a list of strings). Overrides any preceding calls to 'add_include_dir()'; subsequence calls to 'add_include_dir()' add to the list passed to 'set_include_dirs()'. This does not affect ...
python
Tools/c-analyzer/distutils/ccompiler.py
222
230
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,282
_fix_compile_args
def _fix_compile_args(self, output_dir, macros, include_dirs): """Typecheck and fix-up some of the arguments to the 'compile()' method, and return fixed-up values. Specifically: if 'output_dir' is None, replaces it with 'self.output_dir'; ensures that 'macros' is a list, and augments it...
python
Tools/c-analyzer/distutils/ccompiler.py
238
268
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,283
preprocess
def preprocess(self, source, output_file=None, macros=None, include_dirs=None, extra_preargs=None, extra_postargs=None): """Preprocess a single C/C++ source file, named in 'source'. Output will be written to file named 'output_file', or stdout if 'output_file' not supplied. '...
python
Tools/c-analyzer/distutils/ccompiler.py
274
285
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,284
spawn
def spawn(self, cmd): raise NotImplementedError
python
Tools/c-analyzer/distutils/ccompiler.py
323
324
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,285
get_default_compiler
def get_default_compiler(osname=None, platform=None): """Determine the default compiler to use for the given platform. osname should be one of the standard Python OS names (i.e. the ones returned by os.name) and platform the common value returned by sys.platform for the platform in question. ...
python
Tools/c-analyzer/distutils/ccompiler.py
345
364
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,286
new_compiler
def new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0): """Generate an instance of some CCompiler subclass for the supplied platform/compiler combination. 'plat' defaults to 'os.name' (eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler for that platform. Currently o...
python
Tools/c-analyzer/distutils/ccompiler.py
382
425
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,287
gen_preprocess_options
def gen_preprocess_options(macros, include_dirs): """Generate C pre-processor options (-D, -U, -I) as used by at least two types of compilers: the typical Unix compiler and Visual C++. 'macros' is the usual thing, a list of 1- or 2-tuples, where (name,) means undefine (-U) macro 'name', and (name,value)...
python
Tools/c-analyzer/distutils/ccompiler.py
428
470
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,288
get_value
def get_value(cls, path, key): for base in HKEYS: d = cls.read_values(base, path) if d and key in d: return d[key] raise KeyError(key)
python
Tools/c-analyzer/distutils/msvc9compiler.py
61
66
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,289
read_keys
def read_keys(cls, base, key): """Return list of registry keys.""" try: handle = RegOpenKeyEx(base, key) except RegError: return None L = [] i = 0 while True: try: k = RegEnumKey(handle, i) except RegError: ...
python
Tools/c-analyzer/distutils/msvc9compiler.py
69
84
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,290
read_values
def read_values(cls, base, key): """Return dict of registry keys and values. All names are converted to lowercase. """ try: handle = RegOpenKeyEx(base, key) except RegError: return None d = {} i = 0 while True: try: ...
python
Tools/c-analyzer/distutils/msvc9compiler.py
87
106
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,291
convert_mbcs
def convert_mbcs(s): dec = getattr(s, "decode", None) if dec is not None: try: s = dec("mbcs") except UnicodeError: pass return s
python
Tools/c-analyzer/distutils/msvc9compiler.py
109
116
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,292
__init__
def __init__(self, version): self.macros = {} self.vsbase = VS_BASE % version self.load_macros(version)
python
Tools/c-analyzer/distutils/msvc9compiler.py
121
124
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,293
set_macro
def set_macro(self, macro, path, key): self.macros["$(%s)" % macro] = Reg.get_value(path, key)
python
Tools/c-analyzer/distutils/msvc9compiler.py
126
127
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,294
load_macros
def load_macros(self, version): self.set_macro("VCInstallDir", self.vsbase + r"\Setup\VC", "productdir") self.set_macro("VSInstallDir", self.vsbase + r"\Setup\VS", "productdir") self.set_macro("FrameworkDir", NET_BASE, "installroot") try: if version >= 8.0: se...
python
Tools/c-analyzer/distutils/msvc9compiler.py
129
158
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,295
sub
def sub(self, s): for k, v in self.macros.items(): s = s.replace(k, v) return s
python
Tools/c-analyzer/distutils/msvc9compiler.py
160
163
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,296
get_build_version
def get_build_version(): """Return the version of MSVC that was used to build Python. For Python 2.3 and up, the version number is included in sys.version. For earlier versions, assume the compiler is MSVC 6. """ prefix = "MSC v." i = sys.version.find(prefix) if i == -1: return 6 ...
python
Tools/c-analyzer/distutils/msvc9compiler.py
165
188
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,297
normalize_and_reduce_paths
def normalize_and_reduce_paths(paths): """Return a list of normalized paths with duplicates removed. The current order of paths is maintained. """ # Paths are normalized so things like: /a and /a/ aren't both preserved. reduced_paths = [] for p in paths: np = os.path.normpath(p) ...
python
Tools/c-analyzer/distutils/msvc9compiler.py
190
202
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,298
removeDuplicates
def removeDuplicates(variable): """Remove duplicate values of an environment variable. """ oldList = variable.split(os.pathsep) newList = [] for i in oldList: if i not in newList: newList.append(i) newVariable = os.pathsep.join(newList) return newVariable
python
Tools/c-analyzer/distutils/msvc9compiler.py
204
213
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,299
find_vcvarsall
def find_vcvarsall(version): """Find the vcvarsall.bat file At first it tries to find the productdir of VS 2008 in the registry. If that fails it falls back to the VS90COMNTOOLS env var. """ vsbase = VS_BASE % version try: productdir = Reg.get_value(r"%s\Setup\VC" % vsbase, ...
python
Tools/c-analyzer/distutils/msvc9compiler.py
215
248
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
8,300
query_vcvarsall
def query_vcvarsall(version, arch="x86"): """Launch vcvarsall.bat and read the settings from its environment """ vcvarsall = find_vcvarsall(version) interesting = {"include", "lib", "libpath", "path"} result = {} if vcvarsall is None: raise DistutilsPlatformError("Unable to find vcvarsa...
python
Tools/c-analyzer/distutils/msvc9compiler.py
250
288
{ "name": "PublicHealthInformationTechnology/cpython", "url": "https://github.com/PublicHealthInformationTechnology/cpython.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }