Skip to content

Commit

Permalink
Fixed AttributeError and dict iteration errors in remove_all_servers …
Browse files Browse the repository at this point in the history
…and remove_server.

Details:

- In remove_all_servers(), fixed an AttributeError (str has no 'url' attribute).

- In remove_server() and in remove_all_servers(), fixed dictionary iteration
  errors where dictionary items were deleted but the iteration was based upon
  an iterator over the dictionary. Fixed that by making the loop based upon
  a copied list of the dictionary keys.
  • Loading branch information
andy-maier committed Dec 8, 2016
1 parent 4d630c0 commit 887fbcc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 4 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ Bug fixes
version to <=2.0.8, due to its use of unittest.case which is not available
on Python 2.6.

* Fixed an `AttributeError` in the `remove_all_servers()` method of
`WBEMSubscriptionManager` and dictionary iteration errors in its
`remove_server()` method. PR #583.


pywbem v0.9.0
-------------
Expand Down
11 changes: 5 additions & 6 deletions pywbem/_subscription_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,19 +386,19 @@ def remove_server(self, server_id):

# Delete any instances we recorded to be cleaned up

if server_id in self._owned_subscription_paths:
if server_id in list(self._owned_subscription_paths.keys()):
paths = self._owned_subscription_paths[server_id]
for path in paths:
server.conn.DeleteInstance(path)
del self._owned_subscription_paths[server_id]

if server_id in self._owned_filter_paths:
if server_id in list(self._owned_filter_paths.keys()):
paths = self._owned_filter_paths[server_id]
for path in paths:
server.conn.DeleteInstance(path)
del self._owned_filter_paths[server_id]

if server_id in self._owned_destination_paths:
if server_id in list(self._owned_destination_paths.keys()):
for path in self._owned_destination_paths[server_id]:
server.conn.DeleteInstance(path)
del self._owned_destination_paths[server_id]
Expand All @@ -420,9 +420,8 @@ def remove_all_servers(self):
Exceptions raised by :class:`~pywbem.WBEMConnection`.
"""

for server in self._servers:
# This depends on server.url same as server_id
self.remove_server(server.url)
for server_id in list(self._servers.keys()):
self.remove_server(server_id)

# pylint: disable=line-too-long
def add_listener_destinations(self, server_id, listener_urls, owned=True):
Expand Down

0 comments on commit 887fbcc

Please sign in to comment.