Skip to content
Permalink
Browse files

2.021 fix python3.5 encode issue and >=3.6 os.rename behaviour change #…

  • Loading branch information
fffonion committed Aug 3, 2019
1 parent 2f217f6 commit bc3694f656b15b3dbd704b90632214fe450a5afa
Showing with 10 additions and 4 deletions.
  1. +2 −2 xeHentai/const.py
  2. +1 −1 xeHentai/rpc.py
  3. +1 −1 xeHentai/task.py
  4. +6 −0 xeHentai/util/logger.py
@@ -9,14 +9,14 @@
import sys
import locale

PY3K = sys.version_info[0] == 3
PY3K = sys.version_info.major == 3
IRONPYTHON = sys.platform == 'cli'
EXEBUNDLE = getattr(sys, 'frozen', False)
LOCALE = locale.getdefaultlocale()[0]
CODEPAGE = locale.getdefaultlocale()[1] or 'ascii'
ANDROID = 'ANDROID_ARGUMENT' in os.environ

__version__ = 2.020
__version__ = 2.021
DEVELOPMENT = True

SCRIPT_NAME = "xeHentai"
@@ -71,7 +71,7 @@ def gen_thumbnail(fh, args):
# returns a new file handler if resized
# and a boolean indicates there'e error
try:
from PIL import Image
import PIL.Image as Image
except:
return fh, True
if 'w' not in args and 'h' not in args:
@@ -243,7 +243,7 @@ def save_file(self, imgurl, redirect_url, binary_iter):
self._f_lock.acquire()
try:
try:
os.rename(fn_tmp, fn)
shutil.move(fn_tmp, fn)
except WindowsError as ex:
# file is used by another process
# do a copy and delete, WindowsError[32]
@@ -18,10 +18,16 @@ def utcoffset(self, dt):
def dst(self, dt):
return datetime.timedelta(0)


def safestr(s):
if (PY3K and isinstance(s, bytes)) or (not PY3K and not isinstance(s, unicode)):
s = s.decode("utf-8")
if PY3K:
# python<=3.5 hack
if sys.version_info.minor <= 5:
return s \
.encode(locale.getdefaultlocale()[1] or 'utf-8', 'replace') \
.decode(locale.getdefaultlocale()[1] or 'utf-8', 'replace')
return s
return s.encode(locale.getdefaultlocale()[1] or 'utf-8', 'replace')
#return _.decode('utf-8') if PY3K else _

0 comments on commit bc3694f

Please sign in to comment.
You can’t perform that action at this time.