diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2007-08-21 06:58:53 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2007-08-21 06:58:53 +0000 |
commit | 859439e5ebcdab8f5a5ced4dd42be537e4b037e5 (patch) | |
tree | 00a578dba801bdc87f6b3ed896b29691eb2a9380 /numpy/core/records.py | |
parent | 47221fe49a26140a57c6af6569afbaf055db15c8 (diff) | |
download | numpy-859439e5ebcdab8f5a5ced4dd42be537e4b037e5.tar.gz |
Fix record assignment (based on a patch by Sameer DCosta).
Diffstat (limited to 'numpy/core/records.py')
-rw-r--r-- | numpy/core/records.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/numpy/core/records.py b/numpy/core/records.py index 38d6410d1..ed5b55408 100644 --- a/numpy/core/records.py +++ b/numpy/core/records.py @@ -152,17 +152,16 @@ class record(nt.void): def __setattr__(self, attr, val): if attr in ['setfield', 'getfield', 'dtype']: raise AttributeError, "Cannot set '%s' attribute" % attr - try: - return nt.void.__setattr__(self, attr, val) - except AttributeError: - pass fielddict = nt.void.__getattribute__(self, 'dtype').fields res = fielddict.get(attr, None) if res: return self.setfield(val, *res[:2]) else: - raise AttributeError, "'record' object has no "\ - "attribute '%s'" % attr + if getattr(self,attr,None): + return nt.void.__setattr__(self, attr, val) + else: + raise AttributeError, "'record' object has no "\ + "attribute '%s'" % attr def pprint(self): # pretty-print all fields |