diff --git a/httpie/context.py b/httpie/context.py index 8dcc82ce..b0f32c26 100644 --- a/httpie/context.py +++ b/httpie/context.py @@ -119,10 +119,6 @@ class Environment: self._devnull = open(os.devnull, 'w+') return self._devnull - @devnull.setter - def devnull(self, value): - self._devnull = value - def log_error(self, msg, level='error'): assert level in ['error', 'warning'] self._orig_stderr.write(f'\n{self.program_name}: {level}: {msg}\n\n') diff --git a/httpie/downloads.py b/httpie/downloads.py index bd53684d..0ae8040c 100644 --- a/httpie/downloads.py +++ b/httpie/downloads.py @@ -2,7 +2,6 @@ Download mode implementation. """ -import errno import mimetypes import os import re @@ -150,16 +149,8 @@ def trim_filename(filename: str, max_len: int) -> str: def get_filename_max_length(directory: str) -> int: max_len = 255 - try: - pathconf = os.pathconf - except AttributeError: - pass # non-posix - else: - try: - max_len = pathconf(directory, 'PC_NAME_MAX') - except OSError as e: - if e.errno != errno.EINVAL: - raise + if hasattr(os, 'pathconf') and 'PC_NAME_MAX' in os.pathconf_names: + max_len = os.pathconf(directory, 'PC_NAME_MAX') return max_len diff --git a/httpie/output/writer.py b/httpie/output/writer.py index 94d51cb5..d239e503 100644 --- a/httpie/output/writer.py +++ b/httpie/output/writer.py @@ -39,7 +39,7 @@ def write_message( } try: if env.is_windows and 'colors' in args.prettify: - write_stream_with_colors_win_py3(**write_stream_kwargs) + write_stream_with_colors_win(**write_stream_kwargs) else: write_stream(**write_stream_kwargs) except OSError as e: @@ -69,7 +69,7 @@ def write_stream( outfile.flush() -def write_stream_with_colors_win_py3( +def write_stream_with_colors_win( stream: 'BaseStream', outfile: TextIO, flush: bool diff --git a/tests/test_sessions.py b/tests/test_sessions.py index be249292..9e4fec75 100644 --- a/tests/test_sessions.py +++ b/tests/test_sessions.py @@ -189,7 +189,7 @@ class TestSession(SessionTestBase): httpbin.url + '/get', env=self.env()) assert HTTP_OK in r2 - # FIXME: Authorization *sometimes* is not present on Python3 + # FIXME: Authorization *sometimes* is not present assert (r2.json['headers']['Authorization'] == HTTPBasicAuth.make_header('test', UNICODE)) # httpbin doesn't interpret utf8 headers