diff options
author | Chase Sterling <chase.sterling@gmail.com> | 2022-02-03 16:47:23 -0500 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2022-02-03 22:38:37 +0000 |
commit | 222aeed2f3bfc058739835afb4007955a92dde05 (patch) | |
tree | a72dad05338e1e41458579f71ee64e3db99e8da6 | |
parent | ece31cf3cfb2ae277194f82bf35b45ea848f69c4 (diff) | |
download | deluge-222aeed2f3bfc058739835afb4007955a92dde05.tar.gz deluge-222aeed2f3bfc058739835afb4007955a92dde05.tar.bz2 deluge-222aeed2f3bfc058739835afb4007955a92dde05.zip |
Remove legacy PY2 sys.argv unicode handling
Fixed crash when sys.stdout was None
When using pythonw on windows, sys.stdout and stdin are None. We had a
legacy unicode_argv handler that was crashing in this instance. Just
removed that, since sys.argv is always unicode on python 3 to fix the
crash.
Closes: https://github.com/deluge-torrent/deluge/pull/361
-rw-r--r-- | deluge/common.py | 21 | ||||
-rw-r--r-- | deluge/ui/ui.py | 3 |
2 files changed, 2 insertions, 22 deletions
diff --git a/deluge/common.py b/deluge/common.py index 82adb0715..ad71e3bf5 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -11,7 +11,6 @@ import base64 import binascii import functools import glob -import locale import logging import numbers import os @@ -1315,26 +1314,6 @@ def set_env_variable(name, value): log.debug("Set Env Var '%s' to '%s' (msvcrt._putenv)", name, value) -def unicode_argv(): - """ Gets sys.argv as list of unicode objects on any platform.""" - # On platforms other than Windows, we have to find the likely encoding of the args and decode - # First check if sys.stdout or stdin have encoding set - encoding = getattr(sys.stdout, 'encoding') or getattr(sys.stdin, 'encoding') - # If that fails, check what the locale is set to - encoding = encoding or locale.getpreferredencoding() - # As a last resort, just default to utf-8 - encoding = encoding or 'utf-8' - - arg_list = [] - for arg in sys.argv: - try: - arg_list.append(arg.decode(encoding)) - except AttributeError: - arg_list.append(arg) - - return arg_list - - def run_profiled(func, *args, **kwargs): """ Profile a function with cProfile diff --git a/deluge/ui/ui.py b/deluge/ui/ui.py index cb92d1e07..338f8a8e0 100644 --- a/deluge/ui/ui.py +++ b/deluge/ui/ui.py @@ -7,6 +7,7 @@ # import logging +import sys import deluge.common import deluge.configmanager @@ -57,7 +58,7 @@ class UI: return self.__options def start(self, parser=None): - args = deluge.common.unicode_argv()[1:] + args = sys.argv[1:] if parser is None: parser = self.parser self.__options = self.parse_args(parser, args) |