Hey I was recently using this to check /proc//net/tcp in a nice pythonic manner and found that when iterating over the entries it would consistently error out... not quite sure of the root cause, not too much time on my hands to troubleshoot but i did make a slight change which prevents it from throwing an error, instead returns None...
diff --git a/procfs/core.py b/procfs/core.py
index a486ca7..a13930d 100644
--- a/procfs/core.py
+++ b/procfs/core.py
@@ -54,9 +54,11 @@ class BaseFile(object):
data = self._read()
if isinstance(data, dict) and attr in data:
return data[attr]
- if hasattr(data, attr):
- return getattr(data, attr)
- raise AttributeError(attr)
+ if isinstance(attr, basestring):
+ if hasattr(data, attr):
+ return getattr(data, attr)
+ raise AttributeError(attr)
+ return None
raise AttributeError(attr)
__getitem__ = __getattr__
Hey I was recently using this to check /proc//net/tcp in a nice pythonic manner and found that when iterating over the entries it would consistently error out... not quite sure of the root cause, not too much time on my hands to troubleshoot but i did make a slight change which prevents it from throwing an error, instead returns None...