Skip to content

Commit

Permalink
Move fcntl import to be local
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Mar 31, 2018
1 parent 1b14bbe commit 60ef759
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions click/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,13 @@ def set_binary_mode(f):
pass

try:
import fcntl

def set_binary_mode(f):
try:
fileno = f.fileno()
except Exception:
pass
else:
import fcntl
flags = fcntl.fcntl(fileno, fcntl.F_GETFL)
fcntl.fcntl(fileno, fcntl.F_SETFL, flags & ~os.O_NONBLOCK)
return f
Expand Down

3 comments on commit 60ef759

@smurfix
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Umm, that change is either wrong or incomplete. The import was at that position to potentially trigger an ImportError.

@mitsuhiko
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the import again. Too lazy to figure out how to do it locally.

@smurfix
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh. You should have a pull request for repairing that.

Please sign in to comment.