Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility issues with Python 2.6 #2942

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions ranger/ext/img_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,13 @@ def __init__(self):

def _clear_cache(self, path):
if os.path.exists(path):
self.cache = {
ce: cd
# pylint: disable=consider-using-dict-comprehension
# COMPAT Dictionary comprehensions didn't exist before 2.7
self.cache = dict([
(ce, cd)
for ce, cd in self.cache.items()
if ce.inode != os.stat(path).st_ino
}
])

def _sixel_cache(self, path, width, height):
stat = os.stat(path)
Expand All @@ -478,8 +480,7 @@ def _sixel_cache(self, path, width, height):
environ.setdefault("MAGICK_OCL_DEVICE", "true")
try:
check_call(
[
*MAGICK_CONVERT_CMD_BASE,
list(MAGICK_CONVERT_CMD_BASE) + [
path + "[0]",
"-geometry",
"{0}x{1}>".format(fit_width, fit_height),
Expand Down
11 changes: 5 additions & 6 deletions ranger/ext/popen_forked.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ def Popen_forked(*args, **kwargs): # pylint: disable=invalid-name
return False
if pid == 0:
os.setsid()
with open(os.devnull, 'r', encoding="utf-8") as null_r, open(
os.devnull, 'w', encoding="utf-8"
) as null_w:
kwargs['stdin'] = null_r
kwargs['stdout'] = kwargs['stderr'] = null_w
Popen(*args, **kwargs) # pylint: disable=consider-using-with
with open(os.devnull, 'r', encoding="utf-8") as null_r:
with open(os.devnull, 'w', encoding="utf-8") as null_w:
kwargs['stdin'] = null_r
kwargs['stdout'] = kwargs['stderr'] = null_w
Popen(*args, **kwargs) # pylint: disable=consider-using-with
os._exit(0) # pylint: disable=protected-access
else:
os.wait()
Expand Down
11 changes: 5 additions & 6 deletions ranger/ext/rifle.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,11 @@ def Popen_forked(*args, **kwargs): # pylint: disable=invalid-name
if pid == 0:
os.setsid()
# pylint: disable=unspecified-encoding
with open(os.devnull, "r") as null_r, open(
os.devnull, "w"
) as null_w:
kwargs["stdin"] = null_r
kwargs["stdout"] = kwargs["stderr"] = null_w
Popen(*args, **kwargs) # pylint: disable=consider-using-with
with open(os.devnull, "r") as null_r:
with open(os.devnull, "w") as null_w:
kwargs["stdin"] = null_r
kwargs["stdout"] = kwargs["stderr"] = null_w
Popen(*args, **kwargs) # pylint: disable=consider-using-with
os._exit(0) # pylint: disable=protected-access
return True

Expand Down
2 changes: 1 addition & 1 deletion ranger/ext/which.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from __future__ import (absolute_import, division, print_function)

import shutil
from subprocess import check_output, CalledProcessError
from ranger.ext.spawn import check_output, CalledProcessError
from ranger import PY3


Expand Down