8000 Adds missing magic method __nonzero__ by claudiubelu · Pull Request #1 · tjguk/wmi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Adds missing magic method __nonzero__ #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions wmi/trunk/wmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,22 @@ def watch_for (
except pywintypes.com_error:
handle_com_error ()

def __nonzero__(self):
"""This is called each time this object is an argument to a conditional
statement. If this method is not present, __getattr__ would be called
instead. That would cause an endless recursive call.
Strangely, this was not an issue before.

Error encountered running:
conn = wmi.WMI(moniker='//./root/MSCluster')
conn.MSCluster_Cluster

Also, this should improve performance as well, since it avoids useless
recursive calls.
"""

return True

def __getattr__ (self, attribute):
"""Offer WMI classes as simple attributes. Pass through any untrapped
unattribute to the underlying OLE object. This means that new or
Expand Down
0