Merge pull request #412 from cjmayo/unicode2

Remove instances of Python 2 unicode
This commit is contained in:
Chris Mayo 2020-05-24 19:20:07 +01:00 committed by GitHub
commit 6c8e88dae6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 21 deletions

View file

@ -122,14 +122,14 @@ def pp_extra_info(obj, depthlimit = 3):
s = []
if hasattr(obj, "__len__"):
try:
if type(obj) in (str,unicode,list,tuple,dict) and len(obj) <= 5:
if type(obj) in (bytes,str,list,tuple,dict) and len(obj) <= 5:
pass # don't print len in this case
else:
s += ["len = " + str(obj.__len__())]
except: pass
if depthlimit > 0 and hasattr(obj, "__getitem__"):
try:
if type(obj) in (str,unicode):
if type(obj) in (bytes,str):
pass # doesn't make sense to get subitems here
else:
subobj = obj.__getitem__(0)

View file

@ -18,15 +18,12 @@ import os
import sys
from xdg import xdg_config_home
# Windows filename encoding
nt_filename_encoding="mbcs"
def get_profile_dir():
"""Return path where all profiles of current user are stored."""
if os.name == 'nt':
if "LOCALAPPDATA" in os.environ:
basedir = unicode(os.environ["LOCALAPPDATA"], nt_filename_encoding)
basedir = os.environ["LOCALAPPDATA"]
else:
# read local appdata directory from registry
from ..winutil import get_shell_folder

View file

@ -20,15 +20,11 @@ import json
from xdg.BaseDirectory import xdg_config_home
# Windows filename encoding
nt_filename_encoding="mbcs"
def get_profile_dir():
"""Return path where all profiles of current user are stored."""
if os.name == 'nt':
if "LOCALAPPDATA" in os.environ:
basedir = unicode(os.environ["LOCALAPPDATA"], nt_filename_encoding)
basedir = os.environ["LOCALAPPDATA"]
else:
# read local appdata directory from registry
from ..winutil import get_shell_folder

View file

@ -27,13 +27,10 @@ except ImportError:
extension = re.compile(r'/places.sqlite$', re.IGNORECASE)
# Windows filename encoding
nt_filename_encoding="mbcs"
def get_profile_dir():
"""Return path where all profiles of current user are stored."""
if os.name == 'nt':
basedir = unicode(os.environ["APPDATA"], nt_filename_encoding)
basedir = os.environ["APPDATA"]
dirpath = os.path.join(basedir, "Mozilla", "Firefox", "Profiles")
elif os.name == 'posix':
dirpath = os.path.join(os.environ["HOME"], ".mozilla", "firefox")

View file

@ -15,9 +15,6 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import os
# Windows filename encoding
nt_filename_encoding="mbcs"
# List of possible Opera bookmark files.
OperaBookmarkFiles = (
"bookmarks.adr", # for Opera >= 10.0
@ -28,7 +25,7 @@ OperaBookmarkFiles = (
def get_profile_dir():
"""Return path where all profiles of current user are stored."""
if os.name == 'nt':
basedir = unicode(os.environ["APPDATA"], nt_filename_encoding)
basedir = os.environ["APPDATA"]
dirpath = os.path.join(basedir, "Opera", "Opera")
elif os.name == 'posix':
dirpath = os.path.join(os.environ["HOME"], ".opera")

View file

@ -28,8 +28,6 @@ from . import LinkCheckTest, get_file
def unzip(filename, targetdir):
"""Unzip given zipfile into targetdir."""
if isinstance(targetdir, unicode):
targetdir = str(targetdir)
zf = zipfile.ZipFile(filename)
for name in zf.namelist():
if name.endswith('/'):