From 4430620e079a9ffa33d0d6b180e14637c43b6315 Mon Sep 17 00:00:00 2001 From: markm Date: Wed, 3 Feb 2010 00:27:08 +0000 Subject: [PATCH] * Speed up dir() calls on Application and WindowSpecification isntances (by raising AttributeError for __method__ and __member__ attribute checks. --- pywinauto/application.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pywinauto/application.py b/pywinauto/application.py index 875c29a..1f37941 100644 --- a/pywinauto/application.py +++ b/pywinauto/application.py @@ -211,6 +211,13 @@ class WindowSpecification(object): sets the appropriate criteria for the control. """ + # dir (and possibly other code introspection asks for the following + # members, these are deprecated and I am not using them so just + # raise an attribute error immediately + if attr in ('__members__', '__methods__'): + raise AttributeError( + "Application object has no attribute '%s'"% attr) + from pywinauto.controls.win32_controls import DialogWrapper # if we already have 2 levels of criteria (dlg, conrol) @@ -1016,6 +1023,13 @@ class Application(object): def __getattr__(self, key): "Find the spedified dialog of the application" + # dir (and possibly other code introspection asks for the following + # members, these are deprecated and I am not using them so just + # raise an attribute error immediately + if key in ('__members__', '__methods__'): + raise AttributeError( + "Application object has no attribute '%s'"% key) + # delegate all functionality to item access return self[key]