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

gevent.subprocess communicate suppresses UnicodeDecodeError and returns empty string instead #1510

koreno opened this issue Jan 14, 2020 · 0 comments


Copy link

@koreno koreno commented Jan 14, 2020

  • gevent version: 1.4.0
  • Python version: cPython 3.7.5 (default, Dec 18 2019, 12:57:24) \n[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
  • Operating System: CentOS Linux release 7.7.1908 (Core)


Running gevent.subprocess.Popen.communicate(), where text is expected but fails to decode, results in a traceback from the greenlet that is not propagated to the caller. Instead, the call returns an empty string:

import gevent
import gevent.monkey
from gevent import subprocess

out, _ = subprocess.Popen(['printf', r'\xff'], 
assert out == b'\xff'

out, _ = subprocess.Popen(['printf', r'\xff'], 
assert out, "Why is there no output?"

the console shows this traceback, which the Hub writes on greenlets that raised unhandled exceptions:

Traceback (most recent call last):
  File "src/gevent/", line 766, in
  File "/usr/local/lib/python3.7/site-packages/gevent/", line 725, in _read
    data =
  File "/usr/local/lib/python3.7/", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 0-1: invalid continuation byte
2020-01-14T10:08:13Z <Greenlet at 0x7ff576becdd0: _read> failed with UnicodeDecodeError
@jamadden jamadden added the Type: Bug label Jan 14, 2020
@jamadden jamadden closed this in acc67c3 Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.