MCPcopy Create free account
hub / github.com/catboost/catboost / field

Method field

contrib/tools/cython/Cython/Debugger/libpython.py:187–215  ·  view source on GitHub ↗

Get the gdb.Value for the given field within the PyObject, coping with some python 2 versus python 3 differences. Various libpython types are defined using the "PyObject_HEAD" and "PyObject_VAR_HEAD" macros. In Python 2, this these are defined so that "ob_t

(self, name)

Source from the content-addressed store, hash-verified

185 self._gdbval = gdbval
186
187 def field(self, name):
188 '''
189 Get the gdb.Value for the given field within the PyObject, coping with
190 some python 2 versus python 3 differences.
191
192 Various libpython types are defined using the "PyObject_HEAD" and
193 "PyObject_VAR_HEAD" macros.
194
195 In Python 2, this these are defined so that "ob_type" and (for a var
196 object) "ob_size" are fields of the type in question.
197
198 In Python 3, this is defined as an embedded PyVarObject type thus:
199 PyVarObject ob_base;
200 so that the "ob_size" field is located insize the "ob_base" field, and
201 the "ob_type" is most easily accessed by casting back to a (PyObject*).
202 '''
203 if self.is_null():
204 raise NullPyObjectPtr(self)
205
206 if name == 'ob_type':
207 pyo_ptr = self._gdbval.cast(PyObjectPtr.get_gdb_type())
208 return pyo_ptr.dereference()[name]
209
210 if name == 'ob_size':
211 pyo_ptr = self._gdbval.cast(PyVarObjectPtr.get_gdb_type())
212 return pyo_ptr.dereference()[name]
213
214 # General case: look it up inside the object:
215 return self._gdbval.dereference()[name]
216
217 def pyop_field(self, name):
218 '''

Callers 15

pyop_fieldMethod · 0.95
typeMethod · 0.95
TMessageExtGeneratorMethod · 0.80
safe_tp_nameMethod · 0.80
subclass_from_typeMethod · 0.80
_PyObject_VAR_SIZEFunction · 0.80
get_attr_dictMethod · 0.80
proxyvalMethod · 0.80
addr2lineMethod · 0.80
iteritemsMethod · 0.80

Calls 5

is_nullMethod · 0.95
NullPyObjectPtrClass · 0.85
get_gdb_typeMethod · 0.80
castMethod · 0.45
dereferenceMethod · 0.45

Tested by

no test coverage detected