Changeset 28

Show
Ignore:
Timestamp:
05/22/07 13:37:09 (2 years ago)
Author:
hines
Message:

ipython gave errors on hoc array access. The work around is to look for
generic attributes whenever the hoc name does not exist. Note that ipython
looks for getitem but does not seem to use it.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/pygetsetcall/src/nrnpython/nrnpy_hoc.cpp

    r27 r28  
    202202} 
    203203 
    204 static Symbol* getsym(char* name, Object* ho) { 
     204static Symbol* getsym(char* name, Object* ho, int fail) { 
    205205        Symbol* sym = 0; 
    206206        if (ho) { 
     
    212212                } 
    213213        } 
    214         if (!sym) { 
     214        if (!sym && fail) { 
    215215                char e[200]; 
    216216                sprintf(e, "'%s' is not a hoc variable name.", name); 
     
    459459                return NULL; 
    460460        } 
    461         Symbol* sym = getsym(n, self->ho_); 
     461        Symbol* sym = getsym(n, self->ho_, 0); 
    462462        Py_DECREF(name); 
    463463        if (!sym) { 
    464           return Py_BuildValue(""); 
     464          // ipython wants to know if there is a __getitem__ 
     465          // even though it does not use it. 
     466          return PyObject_GenericGetAttr((PyObject*)self, name); 
    465467        } 
    466468        if (self->ho_) { // use the component fork. 
     
    572574        char* n = PyString_AsString(name); 
    573575//printf("hocobj_setattro %s\n", n); 
    574         Symbol* sym = getsym(n, self->ho_); 
     576        Symbol* sym = getsym(n, self->ho_, 1); 
    575577        Py_DECREF(name); 
    576578        if (!sym) {