Skip to content

Commit

Permalink
Python 3 changed the TypeError to a ValueError
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Dec 8, 2021
1 parent 2f1590e commit 66f13fc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/gevent/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,12 +1279,13 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,

# PyPy 2.7 7.3.6 is now producing these errors. This happens automatically
# on Posix platforms.
def _check_nul(s):
def _check_nul(s, err_kind=(ValueError if PY3 else TypeError)):
if not s:
return
nul = b'\0' if isinstance(s, bytes) else '\0'
if nul in s:
raise TypeError("argument must be a string without NUL characters")
# PyPy 2 expects a TypeError; Python 3 raises ValueError always.
raise err_kind("argument must be a string without NUL characters")
def _check_env():
if not env:
return
Expand Down

0 comments on commit 66f13fc

Please sign in to comment.