summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-01-24 22:20:06 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2017-01-24 22:20:06 +0100
commiteb4b66c9553ebf6137e28f87d6729c11375e1144 (patch)
tree40ea229afd462cfc0790e60a7f1e3ef325c05eb0
parent8e81948e711e693536d98c229158cbda2c080bca (diff)
downloadpsutil-eb4b66c9553ebf6137e28f87d6729c11375e1144.tar.gz
small refactoring
-rw-r--r--psutil/_pslinux.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py
index ad95e39a..85647bb2 100644
--- a/psutil/_pslinux.py
+++ b/psutil/_pslinux.py
@@ -282,13 +282,14 @@ def set_scputimes_ntuple(procfs_path):
def cat(fname, fallback=_DEFAULT, binary=True):
"""Return file content."""
try:
- with open_binary(fname) if binary else open_text(fname) as f:
- return f.read()
+ f = open_binary(fname) if binary else open_text(fname)
except IOError:
if fallback != _DEFAULT:
return fallback
- else:
- raise
+ raise
+ else:
+ with f:
+ return f.read().strip()
try: