Skip to content

Commit 8aeec23

Browse files
committed
Don't compare against 'sys.stdout'
In Python 3, 'click.File' returns an instance of 'io.BufferedWriter' which is not comparable against 'sys.stdout'. Instead of doing this, compare the 'fileno'. Signed-off-by: Stephen Finucane <stephen@that.guru> Closes: #48
1 parent ee93afc commit 8aeec23

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

git_pw/bundle.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import logging
6+
import pty
67
import sys
78

89
import click
@@ -76,7 +77,7 @@ def download_cmd(bundle_id, output):
7677

7778
output.write(content)
7879

79-
if output != sys.stdout:
80+
if output.fileno() != pty.STDOUT_FILENO:
8081
path = output.name
8182
else:
8283
path = api.download(bundle['mbox'])

git_pw/patch.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import logging
6+
import pty
67
import sys
78

89
import arrow
@@ -76,7 +77,7 @@ def download_cmd(patch_id, output, fmt):
7677

7778
output.write(content)
7879

79-
if output != sys.stdout:
80+
if output.fileno() != pty.STDOUT_FILENO:
8081
path = output.name
8182
else:
8283
if fmt == 'diff':

git_pw/series.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import logging
6-
import sys
6+
import pty
77

88
import arrow
99
import click
@@ -56,7 +56,7 @@ def download_cmd(series_id, output):
5656

5757
output.write(content)
5858

59-
if output != sys.stdout:
59+
if output.fileno() != pty.STDOUT_FILENO:
6060
path = output.name
6161
else:
6262
path = api.download(series['mbox'])
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
An info-level log is now correctly skipped when downloading patches,
5+
bundles or series to ``STDOUT`` on Python 3.

0 commit comments

Comments
 (0)