[Python-modules-team] Bug#819542: python3-winrm unusable due to encoding error

Elie De Brauwer eliedebrauwer at gmail.com
Wed Mar 30 08:45:39 UTC 2016

Package: python3-winrm
Version: 0.0.3-1
Severity: grave
Justification: renders package unusable

Dear Maintainer,

After installing python3-winrm and trying to follow the getting started example on https://pypi.python.org/pypi/pywinrm

This fails:

edb at lapelidb:/tmp$ cat test.py
#!/usr/bin/env python

import winrm
s = winrm.Session("", auth=("admin", "admin"))
s.run_cmd("ipconfig", ["/all"])
edb at lapelidb:/tmp$ python3 test.py
Traceback (most recent call last):
  File "test.py", line 5, in <module>
    s.run_cmd("ipconfig", ["/all"])
  File "/usr/lib/python3/dist-packages/winrm/__init__.py", line 28, in run_cmd
    shell_id = self.protocol.open_shell()
  File "/usr/lib/python3/dist-packages/winrm/protocol.py", line 103, in open_shell
    rs = self.send_message(xmltodict.unparse(rq))
  File "/usr/lib/python3/dist-packages/winrm/protocol.py", line 173, in send_message
    return self.transport.send_message(message)
  File "/usr/lib/python3/dist-packages/winrm/transport.py", line 76, in send_message
    response = urlopen(request, timeout=self.timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 162, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 463, in open
    req = meth(req)
  File "/usr/lib/python3.5/urllib/request.py", line 1170, in do_request_
    raise TypeError(msg)
TypeError: POST data should be bytes or an iterable of bytes. It cannot be of type str.

There are some reports upstream:
 - https://github.com/diyan/pywinrm/issues/47
 - https://github.com/diyan/pywinrm/issues/80

I tested the latest upstream release (0.1.1 installed through pip3) which gave the same result.

On my system I tried to hotfix the version form the package, inspired upon this pull request https://github.com/diyan/pywinrm/pull/70

Mainly patching send_message() in protocol.py (lines 170-173) into

    def send_message(self, message):
        # TODO add message_id vs relates_to checking
        # TODO port error handling code
        return self.transport.send_message(message.encode("utf-8"))

And for me the package continued beyond this point.

So summary:
 - python3-winrm as available through apt is broken.
 - pywinrm as available today through pip (v 0.1.1) suffers from the same problem on my system.

my 2 cents

-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.2.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages python3-winrm depends on:
ii  python3-isodate    0.5.4-1
ii  python3-xmltodict  0.9.2-3
pn  python3:any        <none>

Versions of packages python3-winrm recommends:
ii  python3-kerberos  1.1.5-2+b2

python3-winrm suggests no packages.

-- no debconf information
This message is subject to the following terms and conditions: MAIL DISCLAIMER<http://www.barco.com/en/maildisclaimer>

More information about the Python-modules-team mailing list