[Python-modules-commits] [celery] 01/06: Improve the magic module check (Closes: #801640).

Michael Fladischer fladi at moszumanska.debian.org
Fri Oct 16 19:15:46 UTC 2015


This is an automated email from the git hooks/post-receive script.

fladi pushed a commit to branch master
in repository celery.

commit 1b459f8c94e369f2c69416347096d993ff5b5222
Author: Ionel Cristian Mărieș <contact at ionelmc.ro>
Date:   Thu Aug 20 18:49:27 2015 +0300

    Improve the magic module check (Closes: #801640).
---
 celery/tests/case.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/celery/tests/case.py b/celery/tests/case.py
index 0bc0c5d..801ff61 100644
--- a/celery/tests/case.py
+++ b/celery/tests/case.py
@@ -234,10 +234,15 @@ def _is_magic_module(m):
     # will load _tkinter and other shit when touched.
 
     # pyflakes refuses to accept 'noqa' for this isinstance.
-    cls, modtype = m.__class__, types.ModuleType
-    return (cls is not modtype and (
-        '__getattr__' in vars(m.__class__) or
-        '__getattribute__' in vars(m.__class__)))
+    cls, modtype = type(m), types.ModuleType
+    try:
+        variables = vars(cls)
+    except TypeError:
+        return True
+    else:
+        return (cls is not modtype and (
+            '__getattr__' in variables or
+            '__getattribute__' in variables))
 
 
 class _AssertWarnsContext(_AssertRaisesBaseContext):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/celery.git



More information about the Python-modules-commits mailing list