Author: Wim Lavrijsen <wlavrij...@lbl.gov> Branch: cling-support Changeset: r89033:b446d39f9f70 Date: 2016-12-12 10:36 -0800 http://bitbucket.org/pypy/pypy/changeset/b446d39f9f70/
Log: check and protect against lookup failures diff --git a/pypy/module/cppyy/interp_cppyy.py b/pypy/module/cppyy/interp_cppyy.py --- a/pypy/module/cppyy/interp_cppyy.py +++ b/pypy/module/cppyy/interp_cppyy.py @@ -842,6 +842,8 @@ def _make_datamember(self, dm_name, dm_idx): type_name = capi.c_datamember_type(self.space, self, dm_idx) offset = capi.c_datamember_offset(self.space, self, dm_idx) + if offset == -1: + raise self.missing_attribute_error(dm_name) datamember = W_CPPStaticData(self.space, self, type_name, offset) self.datamembers[dm_name] = datamember return datamember @@ -941,6 +943,8 @@ datamember_name = capi.c_datamember_name(self.space, self, i) type_name = capi.c_datamember_type(self.space, self, i) offset = capi.c_datamember_offset(self.space, self, i) + if offset == -1: + continue # dictionary problem; raises AttributeError on use is_static = bool(capi.c_is_staticdata(self.space, self, i)) if is_static: datamember = W_CPPStaticData(self.space, self, type_name, offset) diff --git a/pypy/module/cppyy/src/clingcwrapper.cxx b/pypy/module/cppyy/src/clingcwrapper.cxx --- a/pypy/module/cppyy/src/clingcwrapper.cxx +++ b/pypy/module/cppyy/src/clingcwrapper.cxx @@ -1063,10 +1063,11 @@ TClassRef& cr = type_from_handle( scope ); if ( cr.GetClass() ) { TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At( idata ); - return (ptrdiff_t)m->GetOffsetCint(); // yes, CINT ... + return (ptrdiff_t)m->GetOffsetCint(); // yes, CINT (GetOffset() is both wrong + // and caches that wrong result! } - return (ptrdiff_t)0; + return (ptrdiff_t)-1; } Cppyy::TCppIndex_t Cppyy::GetDatamemberIndex( TCppScope_t scope, const std::string& name ) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit