MCPcopy Index your code
hub / github.com/python/cpython / set

Method set

Parser/asdl_c.py:2133–2156  ·  view source on GitHub ↗
(self, field, value, depth)

Source from the content-addressed store, hash-verified

2131 emit("Py_DECREF(value);", 0)
2132
2133 def set(self, field, value, depth):
2134 if field.seq:
2135 if field.type in self.metadata.simple_sums:
2136 # While the sequence elements are stored as void*,
2137 # simple sums expects an enum
2138 self.emit("{", depth)
2139 self.emit("Py_ssize_t i, n = asdl_seq_LEN(%s);" % value, depth+1)
2140 self.emit("value = PyList_New(n);", depth+1)
2141 self.emit("if (!value) goto failed;", depth+1)
2142 self.emit("for(i = 0; i < n; i++)", depth+1)
2143 # This cannot fail, so no need for error handling
2144 self.emit(
2145 "PyList_SET_ITEM(value, i, ast2obj_{0}(state, ({0}_ty)asdl_seq_GET({1}, i)));".format(
2146 field.type,
2147 value
2148 ),
2149 depth + 2,
2150 reflow=False,
2151 )
2152 self.emit("}", depth)
2153 else:
2154 self.emit("value = ast2obj_list(state, (asdl_seq*)%s, ast2obj_%s);" % (value, field.type), depth)
2155 else:
2156 self.emit("value = ast2obj_%s(state, %s);" % (field.type, value), depth, reflow=False)
2157
2158
2159class PartingShots(StaticVisitor):

Callers 9

visitFieldMethod · 0.95
readAsyncFunction · 0.45
_fixup_sccdFunction · 0.45
find_or_addFunction · 0.45
add_visualFunction · 0.45
add_aliasFunction · 0.45
add_file_typeFunction · 0.45
add_registry_entriesFunction · 0.45
get_appxmanifestFunction · 0.45

Calls 2

emitMethod · 0.95
formatMethod · 0.45

Tested by

no test coverage detected