Skip to content

Commit

Permalink
Fix devnull error on python2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
sildar authored Oct 30, 2019
1 parent acca8d5 commit 3d5e597
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nltk/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ def java(cmd, classpath=None, stdin=None, stdout=None, stderr=None, blocking=Tru
:raise OSError: If the java command returns a nonzero return code.
"""

subprocess_output_dict = {'pipe': subprocess.PIPE, 'stdout': subprocess.STDOUT, 'devnull': subprocess.DEVNULL}
try:
from subprocess import DEVNULL
except ImportError:
DEVNULL = open(os.devnull, 'wb')
subprocess_output_dict = {'pipe': subprocess.PIPE, 'stdout': subprocess.STDOUT, 'devnull': DEVNULL}

stdin = subprocess_output_dict.get(stdin, stdin)
stdout = subprocess_output_dict.get(stdout, stdout)
Expand Down

0 comments on commit 3d5e597

Please sign in to comment.