Mic92 / python-mpd2

Python library which provides a client interface for the Music Player Daemon.
GNU Lesser General Public License v3.0
352 stars 119 forks source link

AttributeError in _MPDClient__idle_consumers #157

Closed mweinelt closed 3 years ago

mweinelt commented 3 years ago

During a disconnect self.__in_idle is accessed before it is defined.

Traceback (most recent call last):
  File "/nix/store/3ysvvcki412x5r20crs04p1g07bdgbmp-homeassistant-2021.1.1/lib/python3.8/site-packages/homeassistant/helpers/entity_platform.py", line 359, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/nix/store/3ysvvcki412x5r20crs04p1g07bdgbmp-homeassistant-2021.1.1/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 466, in async_device_update
    await task
  File "/nix/store/3ysvvcki412x5r20crs04p1g07bdgbmp-homeassistant-2021.1.1/lib/python3.8/site-packages/homeassistant/components/mpd/media_player.py", line 190, in async_update
    self._disconnect()
  File "/nix/store/3ysvvcki412x5r20crs04p1g07bdgbmp-homeassistant-2021.1.1/lib/python3.8/site-packages/homeassistant/components/mpd/media_player.py", line 145, in _disconnect
    self._client.disconnect()
  File "/nix/store/28ivwj9j53bvmyrxrn9rg78c5jnlk650-python3.8-python-mpd2-3.0.2/lib/python3.8/site-packages/mpd/asyncio.py", line 210, in disconnect
    for subsystems, callback in list(self.__idle_consumers):
AttributeError: 'MPDClient' object has no attribute '_MPDClient__idle_consumers'

@chrysn

chrysn commented 3 years ago

Disconnecting without even having connected was not anticipated -- but given the documentation for all the other members conveniently initializes things (in the typical pre-PEP526 way), that's easy to be fixed, see #158.