diff options
author | adehad <26027314+adehad@users.noreply.github.com> | 2021-10-24 12:16:08 +0100 |
---|---|---|
committer | adehad <26027314+adehad@users.noreply.github.com> | 2021-10-24 12:16:08 +0100 |
commit | e2d1522e7d8ab594cec65a7cb4b9ef128d4a2c2d (patch) | |
tree | a57b0b367e626d3474dfb1af42ee72a64fa7247a | |
parent | a20ffffaae25cd12b3513a930df2951cac452e4d (diff) | |
download | tftpy-e2d1522e7d8ab594cec65a7cb4b9ef128d4a2c2d.tar.gz |
remove py2/3 compat
-rw-r--r-- | tftpy/TftpContexts.py | 3 | ||||
-rw-r--r-- | tftpy/compat.py | 18 |
2 files changed, 1 insertions, 20 deletions
diff --git a/tftpy/TftpContexts.py b/tftpy/TftpContexts.py index 08927e5..e4f7a4c 100644 --- a/tftpy/TftpContexts.py +++ b/tftpy/TftpContexts.py @@ -17,7 +17,6 @@ import socket import sys import time -from . import compat from .TftpPacketFactory import TftpPacketFactory from .TftpPacketTypes import * from .TftpShared import * @@ -298,7 +297,7 @@ class TftpContextClientUpload(TftpContext): if hasattr(input, "read"): self.fileobj = input elif input == "-": - self.fileobj = compat.binary_stdin() + self.fileobj = sys.stdin.buffer else: self.fileobj = open(input, "rb") diff --git a/tftpy/compat.py b/tftpy/compat.py deleted file mode 100644 index 788c8ae..0000000 --- a/tftpy/compat.py +++ /dev/null @@ -1,18 +0,0 @@ -import sys - - -def binary_stdin(): - """ - Get a file object for reading binary bytes from stdin instead of text. - Compatible with Py2/3, POSIX & win32. - Credits: https://stackoverflow.com/a/38939320/531179 (CC BY-SA 3.0) - """ - if hasattr(sys.stdin, "buffer"): # Py3+ - return sys.stdin.buffer - else: - if sys.platform == "win32": - import msvcrt - import os - - msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) - return sys.stdin |