Skip to content
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

Use encode_array() in Drawable._get_struct_prop() #181

Merged
merged 1 commit into from
Nov 22, 2020

Conversation

t-wissmann
Copy link
Contributor

The Xlib/protocol/rq.py file defines an helper function encode_array()
that calls tostring() or tobytes() depending on which python version is
used.

The package maintainer Christoph Egger reported that the testsuite of
the herbstluftwm project fails[1] with the error:

      def _get_struct_prop(self, pname, ptype, pstruct):
          r = self.get_property(pname, ptype, 0, pstruct.static_size // 4)
          if r and r.format == 32:
  >           value = r.value.tostring()
  E           AttributeError: 'array.array' object has no attribute 'tostring'

    /usr/lib/python3/dist-packages/Xlib/xobject/drawable.py:782: AttributeError

Backtrace:

../tests/conftest.py:624: in is_window_urgent
    hints = window.get_wm_hints()
/usr/lib/python3/dist-packages/Xlib/xobject/drawable.py:756: in get_wm_hints
    return self._get_struct_prop(Xatom.WM_HINTS, Xatom.WM_HINTS,

I assume it should be rq.encode_array() instead of .tostring() but I'm
not terribly sure.

[1] https://pbot.rmdir.de/u/4lU98VkXkdjSypXmdekh5g

The Xlib/protocol/rq.py file defines an helper function encode_array()
that calls tostring() or tobytes() depending on which python version is
used.

The package maintainer Christoph Egger reported that the testsuite of
the herbstluftwm project fails[1] with the error:

      def _get_struct_prop(self, pname, ptype, pstruct):
          r = self.get_property(pname, ptype, 0, pstruct.static_size // 4)
          if r and r.format == 32:
  >           value = r.value.tostring()
  E           AttributeError: 'array.array' object has no attribute 'tostring'

    /usr/lib/python3/dist-packages/Xlib/xobject/drawable.py:782: AttributeError

Backtrace:

    ../tests/conftest.py:624: in is_window_urgent
        hints = window.get_wm_hints()
    /usr/lib/python3/dist-packages/Xlib/xobject/drawable.py:756: in get_wm_hints
        return self._get_struct_prop(Xatom.WM_HINTS, Xatom.WM_HINTS,

I assume it should be rq.encode_array() instead of .tostring() but I'm
not terribly sure.

[1] https://pbot.rmdir.de/u/4lU98VkXkdjSypXmdekh5g
@t-wissmann
Copy link
Contributor Author

tostring() will be removed in python 3.9 https://docs.python.org/3.8/library/array.html#array.array.tostring

@codecov-io
Copy link

Codecov Report

Merging #181 (882714a) into master (4d07023) will not change coverage.
The diff coverage is 0.00%.

@@           Coverage Diff           @@
##           master     #181   +/-   ##
=======================================
  Coverage   81.99%   81.99%           
=======================================
  Files          42       42           
  Lines        4855     4855           
=======================================
  Hits         3981     3981           
  Misses        874      874           

@vasily-v-ryabov
Copy link
Collaborator

Looks reasonable. Thanks! Will do the same fix for XInput.

@vasily-v-ryabov vasily-v-ryabov merged commit bd6dece into python-xlib:master Nov 22, 2020
@vasily-v-ryabov
Copy link
Collaborator

Released as 0.29.

@t-wissmann
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants