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 <r...@nicira.com>
---
 python/ovs/daemon.py  |    3 +--
 python/ovs/db/idl.py  |    6 +++---
 python/ovs/process.py |    2 +-
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/python/ovs/daemon.py b/python/ovs/daemon.py
index 3d46deb..149c8a1 100644
--- a/python/ovs/daemon.py
+++ b/python/ovs/daemon.py
@@ -266,8 +266,7 @@ def _should_restart(status):
     if os.WIFSIGNALED(status):
         for signame in ("SIGABRT", "SIGALRM", "SIGBUS", "SIGFPE", "SIGILL",
                         "SIGPIPE", "SIGSEGV", "SIGXCPU", "SIGXFSZ"):
-            if (signame in signal.__dict__ and
-                os.WTERMSIG(status) == signal.__dict__[signame]):
+            if os.WTERMSIG(status) == getattr(signal, signame, None):
                 return True
     return False
 
diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py
index 5260d98..1ee330e 100644
--- a/python/ovs/db/idl.py
+++ b/python/ovs/db/idl.py
@@ -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):
diff --git a/python/ovs/process.py b/python/ovs/process.py
index 094e085..7367f79 100644
--- a/python/ovs/process.py
+++ b/python/ovs/process.py
@@ -18,7 +18,7 @@ import signal
 def _signal_status_msg(type, signr):
     s = "%s by signal %d" % (type, signr)
     for name in signal.__dict__:
-        if name.startswith("SIG") and signal.__dict__[name] == signr:
+        if name.startswith("SIG") and getattr(signal, name) == signr:
             return "%s (%s)" % (s, name)
     return s
     
-- 
1.7.4.4

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to