mirror of
https://github.com/openvswitch/ovs
synced 2025-10-25 15:07:05 +00:00
python: Use getattr() and setattr() instead of __dict__.
This leaves one use of __dict__ used for iterating through attributes.
I could use dir() instead, but I was put off by this note in its
documentation in the Python Library Reference:
Because dir() is supplied primarily as a convenience for use at an
interactive prompt, it tries to supply an interesting set of names more
than it tries to supply a rigorously or consistently defined set of names,
and its detailed behavior may change across releases. For example,
metaclass attributes are not in the result list when the argument is a
class.
Suggested-by: Reid Price <reid@nicira.com>
This commit is contained in:
@@ -271,8 +271,8 @@ class Idl:
|
||||
% (column_name, table_name, e))
|
||||
continue
|
||||
|
||||
if datum != row.__dict__[column_name]:
|
||||
row.__dict__[column_name] = datum
|
||||
if datum != getattr(row, column_name):
|
||||
setattr(row, column_name, datum)
|
||||
changed = True
|
||||
else:
|
||||
# Didn't really change but the OVSDB monitor protocol always
|
||||
@@ -296,7 +296,7 @@ class Idl:
|
||||
pass
|
||||
row = self.data[table.name][uuid] = Row()
|
||||
for column in table.columns.itervalues():
|
||||
row.__dict__[column.name] = ovs.db.data.Datum.default(column.type)
|
||||
setattr(row, column.name, ovs.db.data.Datum.default(column.type))
|
||||
return row
|
||||
|
||||
def force_reconnect(self):
|
||||
|
||||
Reference in New Issue
Block a user