diff options
author | Michael P. Soulier <msoulier@digitaltorque.ca> | 2021-12-03 19:43:47 -0500 |
---|---|---|
committer | Michael P. Soulier <msoulier@digitaltorque.ca> | 2021-12-03 19:43:47 -0500 |
commit | 85af4e453e647088fda50c3108dfd00e9753af3a (patch) | |
tree | 5ed373e85d2752da433e0dd34e2023bab0c02fbc | |
parent | 98fbd8c79ae871f184a3452104d9c50947deb013 (diff) | |
parent | e2d1522e7d8ab594cec65a7cb4b9ef128d4a2c2d (diff) | |
download | tftpy-85af4e453e647088fda50c3108dfd00e9753af3a.tar.gz |
Merge remote-tracking branch 'adehad/feature/remove_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 f882c2d..0a82c8d 100644 --- a/tftpy/TftpContexts.py +++ b/tftpy/TftpContexts.py @@ -16,7 +16,6 @@ import socket import sys import time -from . import compat from .TftpPacketFactory import TftpPacketFactory from .TftpPacketTypes import * from .TftpShared import * @@ -297,7 +296,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 |