Skip to content

Commit

Permalink
Fix readable_popen util.
Browse files Browse the repository at this point in the history
  • Loading branch information
riga committed Apr 2, 2023
1 parent 91de7b6 commit e9100d4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions law/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1341,10 +1341,12 @@ def readable_popen(*args, **kwargs):
p = subprocess.Popen(*args, **kwargs)

def line_gen():
for line in iter(lambda: p.stdout.readline(), ""):
if six.PY3:
line = line.decode("utf-8")
yield line.rstrip()
if six.PY2:
for line in iter(lambda: p.stdout.readline(), ""):
yield line.rstrip()
else:
for line in p.stdout:
yield line.decode("utf-8").rstrip()

# communicate in the end
p.communicate()
Expand Down

0 comments on commit e9100d4

Please sign in to comment.