lsprof: use getattr instead of hasattr
authorAugie Fackler <durin42@gmail.com>
Mon, 25 Jul 2011 15:41:46 -0500
changeset 14959 b1dcc5ab86cd
parent 14958 fd246aefedd3
child 14960 497819817307
lsprof: use getattr instead of hasattr
mercurial/lsprof.py
--- a/mercurial/lsprof.py	Mon Jul 25 20:36:59 2011 -0500
+++ b/mercurial/lsprof.py	Mon Jul 25 15:41:46 2011 -0500
@@ -86,9 +86,7 @@
         for k, v in list(sys.modules.iteritems()):
             if v is None:
                 continue
-            if not hasattr(v, '__file__'):
-                continue
-            if not isinstance(v.__file__, str):
+            if not isinstance(getattr(v, '__file__', None), str):
                 continue
             if v.__file__.startswith(code.co_filename):
                 mname = _fn2mod[code.co_filename] = k