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

Method get_var_by_name

Tools/gdb/libpython.py:1179–1195  ·  view source on GitHub ↗

Look for the named local variable, returning a (PyObjectPtr, scope) pair where scope is a string 'local', 'global', 'builtin' If not found, return (None, None)

(self, name)

Source from the content-addressed store, hash-verified

1177 return pyop_builtins.iteritems()
1178
1179 def get_var_by_name(self, name):
1180 '''
1181 Look for the named local variable, returning a (PyObjectPtr, scope) pair
1182 where scope is a string 'local', 'global', 'builtin'
1183
1184 If not found, return (None, None)
1185 '''
1186 for pyop_name, pyop_value in self.iter_locals():
1187 if name == pyop_name.proxyval(set()):
1188 return pyop_value, 'local'
1189 for pyop_name, pyop_value in self.iter_globals():
1190 if name == pyop_name.proxyval(set()):
1191 return pyop_value, 'global'
1192 for pyop_name, pyop_value in self.iter_builtins():
1193 if name == pyop_name.proxyval(set()):
1194 return pyop_value, 'builtin'
1195 return None, None
1196
1197 def filename(self):
1198 '''Get the path of the current Python source file, as a string'''

Callers 2

get_var_by_nameMethod · 0.45
invokeMethod · 0.45

Calls 5

iter_localsMethod · 0.95
iter_globalsMethod · 0.95
iter_builtinsMethod · 0.95
setFunction · 0.85
proxyvalMethod · 0.45

Tested by

no test coverage detected