about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2021-09-01 15:44:42 +0200
committertoonn <toonn@toonn.io>2021-09-01 17:57:15 +0200
commitad082b831d87de2dd97d4a053a8a5e5d9ad7cc92 (patch)
tree27f4e1927ea0ee581bba1961bd5a1af7a4ca89fd /ranger
parent5279ac8b9101f0778cc6f4859249685191c4923c (diff)
downloadranger-ad082b831d87de2dd97d4a053a8a5e5d9ad7cc92.tar.gz
open23: Drop in favor of io.open
The @contextmanager decorator wrapped the file object in a
`_GeneratorContextManager` object. This means you cannot access the same
members on such an object and the stdlib expects to be able to do so.

Fixes #2442
Diffstat (limited to 'ranger')
-rw-r--r--ranger/ext/open23.py50
1 files changed, 0 insertions, 50 deletions
diff --git a/ranger/ext/open23.py b/ranger/ext/open23.py
deleted file mode 100644
index 912f9829..00000000
--- a/ranger/ext/open23.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# This file is part of ranger, the console file manager.
-# License: GNU GPL version 3, see the file "AUTHORS" for details.
-
-from __future__ import absolute_import
-
-from contextlib import contextmanager
-
-from ranger import PY3
-
-
-# COMPAT: We use the pattern of opening a file differently depending on the
-#         python version in multiple places. Having calls to open in multiple
-#         branches makes it impossible to use a with-statement instead. This
-#         contextmanager hides away the lack of an errors keyword argument for
-#         python 2 and is now preferred. This can be safely dropped once we
-#         ditch python 2 support.
-# TODO: The unspecified-encoding lint should only be disabled for the Python 2
-#       case but Pylint is failing to parse the second disable properly.
-# pylint: disable=too-many-arguments,unspecified-encoding
-@contextmanager
-def open23(
-    file,
-    mode="r",
-    buffering=-1,
-    encoding="UTF-8",
-    errors=None,
-    newline=None,
-    closefd=True,
-    opener=None,
-):
-    if PY3:
-        fobj = open(
-            file=file,
-            mode=mode,
-            buffering=buffering,
-            encoding=encoding,
-            errors=errors,
-            newline=newline,
-            closefd=closefd,
-            opener=opener,
-        )
-    else:
-        if buffering is None:
-            fobj = open(name=file, mode=mode)
-        else:
-            fobj = open(name=file, mode=mode, buffering=buffering)
-    try:
-        yield fobj
-    finally:
-        fobj.close()