changeset 8195:e35373106528

py3: remove safe_unicode in places where it no longer is needed because all strings (except bytes) already *are* unicode strings (The remaining safe_unicode calls are still needed and can't just be removed, generally because we in these cases still have to convert from bytes to unicode strings.)
author Mads Kiilerich <mads@kiilerich.com>
date Thu, 26 Dec 2019 15:16:29 +0100
parents 502d2fcbe434
children e51ad2cd400e
files kallithea/bin/kallithea_cli_repo.py kallithea/controllers/admin/gists.py kallithea/controllers/admin/repo_groups.py kallithea/controllers/changeset.py kallithea/controllers/feed.py kallithea/lib/auth.py kallithea/lib/auth_modules/auth_container.py kallithea/lib/auth_modules/auth_ldap.py kallithea/lib/base.py kallithea/lib/helpers.py kallithea/lib/hooks.py kallithea/lib/indexers/daemon.py kallithea/lib/middleware/pygrack.py kallithea/lib/middleware/simplegit.py kallithea/lib/middleware/simplehg.py kallithea/lib/utils.py kallithea/lib/utils2.py kallithea/lib/vcs/backends/base.py kallithea/lib/vcs/backends/git/repository.py kallithea/lib/vcs/backends/git/ssh.py kallithea/lib/vcs/backends/hg/ssh.py kallithea/lib/vcs/nodes.py kallithea/model/comment.py kallithea/model/db.py kallithea/model/gist.py kallithea/model/pull_request.py kallithea/model/repo.py kallithea/model/scm.py kallithea/model/user.py kallithea/templates/admin/gists/edit.html kallithea/templates/admin/gists/show.html kallithea/templates/changeset/changeset.html kallithea/templates/changeset/changeset_file_comment.html kallithea/templates/changeset/changeset_range.html kallithea/templates/changeset/diff_block.html kallithea/templates/compare/compare_diff.html kallithea/templates/files/diff_2way.html kallithea/templates/files/files.html kallithea/templates/files/files_browser.html kallithea/templates/pullrequests/pullrequest_show.html kallithea/tests/functional/test_admin.py kallithea/tests/functional/test_admin_repos.py kallithea/tests/functional/test_forks.py kallithea/tests/vcs/base.py kallithea/tests/vcs/test_inmemchangesets.py
diffstat 45 files changed, 141 insertions(+), 167 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/bin/kallithea_cli_repo.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/bin/kallithea_cli_repo.py	Thu Dec 26 15:16:29 2019 +0100
@@ -28,7 +28,7 @@
 
 import kallithea.bin.kallithea_cli_base as cli_base
 from kallithea.lib.utils import REMOVED_REPO_PAT, repo2db_mapper
-from kallithea.lib.utils2 import ask_ok, safe_str, safe_unicode
+from kallithea.lib.utils2 import ask_ok, safe_str
 from kallithea.model.db import Repository, Ui
 from kallithea.model.meta import Session
 from kallithea.model.scm import ScmModel
@@ -74,7 +74,7 @@
     if not repositories:
         repo_list = Repository.query().all()
     else:
-        repo_names = [safe_unicode(n.strip()) for n in repositories]
+        repo_names = [n.strip() for n in repositories]
         repo_list = list(Repository.query()
                         .filter(Repository.repo_name.in_(repo_names)))
 
--- a/kallithea/controllers/admin/gists.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/controllers/admin/gists.py	Thu Dec 26 15:16:29 2019 +0100
@@ -182,7 +182,10 @@
             log.error(traceback.format_exc())
             raise HTTPNotFound()
         if format == 'raw':
-            content = '\n\n'.join([safe_unicode(f.content) for f in c.files if (f_path is None or safe_unicode(f.path) == f_path)])
+            content = '\n\n'.join(
+                safe_unicode(f.content)
+                for f in c.files if (f_path is None or f.path == f_path)
+            )
             response.content_type = 'text/plain'
             return content
         return render('admin/gists/show.html')
--- a/kallithea/controllers/admin/repo_groups.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/controllers/admin/repo_groups.py	Thu Dec 26 15:16:29 2019 +0100
@@ -40,7 +40,7 @@
 from kallithea.lib import helpers as h
 from kallithea.lib.auth import HasPermissionAny, HasRepoGroupPermissionLevel, HasRepoGroupPermissionLevelDecorator, LoginRequired
 from kallithea.lib.base import BaseController, render
-from kallithea.lib.utils2 import safe_int, safe_unicode
+from kallithea.lib.utils2 import safe_int
 from kallithea.model.db import RepoGroup, Repository
 from kallithea.model.forms import RepoGroupForm, RepoGroupPermsForm
 from kallithea.model.meta import Session
@@ -116,7 +116,7 @@
         )
 
         for repo_gr in group_iter:
-            children_groups = [safe_unicode(g.name) for g in repo_gr.parents] + [safe_unicode(repo_gr.name)]
+            children_groups = [g.name for g in repo_gr.parents] + [repo_gr.name]
             repo_count = repo_gr.repositories.count()
             repo_groups_data.append({
                 "raw_name": repo_gr.group_name,
--- a/kallithea/controllers/changeset.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/controllers/changeset.py	Thu Dec 26 15:16:29 2019 +0100
@@ -257,7 +257,7 @@
     Session().commit()
 
     data = {
-       'target_id': h.safeid(h.safe_unicode(request.POST.get('f_path'))),
+       'target_id': h.safeid(request.POST.get('f_path')),
     }
     if comment is not None:
         c.comment = comment
--- a/kallithea/controllers/feed.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/controllers/feed.py	Thu Dec 26 15:16:29 2019 +0100
@@ -96,7 +96,7 @@
             desc_msg.append('\n\n')
             desc_msg.append(safe_unicode(raw_diff))
         desc_msg.append('</pre>')
-        return [safe_unicode(chunk) for chunk in desc_msg]
+        return desc_msg
 
     def _feed(self, repo_name, feeder):
         """Produce a simple feed"""
--- a/kallithea/lib/auth.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/lib/auth.py	Thu Dec 26 15:16:29 2019 +0100
@@ -42,7 +42,7 @@
 from kallithea.config.routing import url
 from kallithea.lib.caching_query import FromCache
 from kallithea.lib.utils import conditional_cache, get_repo_group_slug, get_repo_slug, get_user_group_slug
-from kallithea.lib.utils2 import ascii_bytes, ascii_str, safe_bytes, safe_unicode
+from kallithea.lib.utils2 import ascii_bytes, ascii_str, safe_bytes
 from kallithea.lib.vcs.utils.lazy import LazyProperty
 from kallithea.model.db import (
     Permission, RepoGroup, Repository, User, UserApiKeys, UserGroup, UserGroupMember, UserGroupRepoGroupToPerm, UserGroupRepoToPerm, UserGroupToPerm, UserGroupUserGroupToPerm, UserIpMap, UserToPerm)
@@ -817,10 +817,6 @@
         self.required_perms = set(perms)
 
     def __call__(self, authuser, repo_name, purpose=None):
-        # repo_name MUST be unicode, since we handle keys in ok
-        # dict by unicode
-        repo_name = safe_unicode(repo_name)
-
         try:
             ok = authuser.permissions['repositories'][repo_name] in self.required_perms
         except KeyError:
--- a/kallithea/lib/auth_modules/auth_container.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/lib/auth_modules/auth_container.py	Thu Dec 26 15:16:29 2019 +0100
@@ -29,7 +29,7 @@
 
 from kallithea.lib import auth_modules
 from kallithea.lib.compat import hybrid_property
-from kallithea.lib.utils2 import safe_str, safe_unicode, str2bool
+from kallithea.lib.utils2 import safe_str, str2bool
 from kallithea.model.db import Setting
 
 
@@ -199,8 +199,8 @@
 
         user_data = {
             'username': username,
-            'firstname': safe_unicode(firstname or username),
-            'lastname': safe_unicode(lastname or ''),
+            'firstname': firstname or username,
+            'lastname': lastname or '',
             'groups': [],
             'email': email or '',
             'admin': admin or False,
--- a/kallithea/lib/auth_modules/auth_ldap.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/lib/auth_modules/auth_ldap.py	Thu Dec 26 15:16:29 2019 +0100
@@ -31,7 +31,7 @@
 from kallithea.lib import auth_modules
 from kallithea.lib.compat import hybrid_property
 from kallithea.lib.exceptions import LdapConnectionError, LdapImportError, LdapPasswordError, LdapUsernameError
-from kallithea.lib.utils2 import safe_str, safe_unicode
+from kallithea.lib.utils2 import safe_str
 
 
 log = logging.getLogger(__name__)
@@ -338,8 +338,8 @@
 
             user_data = {
                 'username': username,
-                'firstname': safe_unicode(get_ldap_attr('attr_firstname') or firstname),
-                'lastname': safe_unicode(get_ldap_attr('attr_lastname') or lastname),
+                'firstname': get_ldap_attr('attr_firstname') or firstname,
+                'lastname': get_ldap_attr('attr_lastname') or lastname,
                 'groups': [],
                 'email': get_ldap_attr('attr_email') or email,
                 'admin': admin,
--- a/kallithea/lib/base.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/lib/base.py	Thu Dec 26 15:16:29 2019 +0100
@@ -553,7 +553,7 @@
                 return
 
             log.debug('Found repository in database %s with state `%s`',
-                      safe_unicode(_dbr), safe_unicode(_dbr.repo_state))
+                      _dbr, _dbr.repo_state)
             route = getattr(request.environ.get('routes.route'), 'name', '')
 
             # allow to delete repos that are somehow damages in filesystem
--- a/kallithea/lib/helpers.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/lib/helpers.py	Thu Dec 26 15:16:29 2019 +0100
@@ -205,8 +205,6 @@
 class _FilesBreadCrumbs(object):
 
     def __call__(self, repo_name, rev, paths):
-        if isinstance(paths, str):
-            paths = safe_unicode(paths)
         url_l = [link_to(repo_name, url('files_home',
                                         repo_name=repo_name,
                                         revision=rev, f_path=''),
@@ -954,7 +952,7 @@
         suf = ''
         if len(nodes) > 30:
             suf = '<br/>' + _(' and %s more') % (len(nodes) - 30)
-        return literal(pref + '<br/> '.join([safe_unicode(x.path)
+        return literal(pref + '<br/> '.join([x.path
                                              for x in nodes[:30]]) + suf)
     else:
         return ': ' + _('No files')
--- a/kallithea/lib/hooks.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/lib/hooks.py	Thu Dec 26 15:16:29 2019 +0100
@@ -34,7 +34,7 @@
 from kallithea.lib import helpers as h
 from kallithea.lib.exceptions import UserCreationError
 from kallithea.lib.utils import action_logger, make_ui
-from kallithea.lib.utils2 import HookEnvironmentError, ascii_str, get_hook_environment, safe_bytes, safe_str, safe_unicode
+from kallithea.lib.utils2 import HookEnvironmentError, ascii_str, get_hook_environment, safe_bytes, safe_str
 from kallithea.lib.vcs.backends.base import EmptyChangeset
 from kallithea.model.db import Repository, User
 
@@ -312,7 +312,6 @@
     #logging.config.fileConfig(ini_file_path) # Note: we are in a different process - don't use configured logging
     kallithea.config.middleware.make_app(kallithea.CONFIG.global_conf, **kallithea.CONFIG.local_conf)
 
-    repo_path = safe_unicode(repo_path)
     # fix if it's not a bare repo
     if repo_path.endswith(os.sep + '.git'):
         repo_path = repo_path[:-5]
--- a/kallithea/lib/indexers/daemon.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/lib/indexers/daemon.py	Thu Dec 26 15:16:29 2019 +0100
@@ -77,8 +77,7 @@
 
         # filter repo list
         if repo_list:
-            # Fix non-ascii repo names to unicode
-            repo_list = set(safe_unicode(repo_name) for repo_name in repo_list)
+            repo_list = set(repo_list)
             self.filtered_repo_paths = {}
             for repo_name, repo in self.repo_paths.items():
                 if repo_name in repo_list:
@@ -110,7 +109,7 @@
             self.initial = False
 
     def _get_index_revision(self, repo):
-        db_repo = Repository.get_by_repo_name(safe_unicode(repo.name))
+        db_repo = Repository.get_by_repo_name(repo.name)
         landing_rev = 'tip'
         if db_repo:
             _rev_type, _rev = db_repo.landing_rev
@@ -197,13 +196,12 @@
             u_content = u''
             indexed += 1
 
-        p = safe_unicode(path)
         writer.add_document(
-            fileid=p,
-            owner=unicode(repo.contact),
-            repository_rawname=safe_unicode(repo_name),
-            repository=safe_unicode(repo_name),
-            path=p,
+            fileid=path,
+            owner=repo.contact,
+            repository_rawname=repo_name,
+            repository=repo_name,
+            path=path,
             content=u_content,
             modtime=self.get_node_mtime(node),
             extension=node.extension
@@ -238,18 +236,18 @@
             indexed += 1
             log.debug('    >> %s %s/%s', cs, indexed, total)
             writer.add_document(
-                raw_id=unicode(cs.raw_id),
-                owner=unicode(repo.contact),
+                raw_id=cs.raw_id,
+                owner=repo.contact,
                 date=cs._timestamp,
-                repository_rawname=safe_unicode(repo_name),
-                repository=safe_unicode(repo_name),
+                repository_rawname=repo_name,
+                repository=repo_name,
                 author=cs.author,
                 message=cs.message,
                 last=cs.last,
-                added=u' '.join([safe_unicode(node.path) for node in cs.added]).lower(),
-                removed=u' '.join([safe_unicode(node.path) for node in cs.removed]).lower(),
-                changed=u' '.join([safe_unicode(node.path) for node in cs.changed]).lower(),
-                parents=u' '.join([cs.raw_id for cs in cs.parents]),
+                added=u' '.join(node.path for node in cs.added).lower(),
+                removed=u' '.join(node.path for node in cs.removed).lower(),
+                changed=u' '.join(node.path for node in cs.changed).lower(),
+                parents=u' '.join(cs.raw_id for cs in cs.parents),
             )
 
         return indexed
@@ -391,9 +389,7 @@
                 ri_cnt = 0   # indexed
                 riwc_cnt = 0  # indexed with content
                 for path in self.get_paths(repo):
-                    path = safe_unicode(path)
                     if path in to_index or path not in indexed_paths:
-
                         # This is either a file that's changed, or a new file
                         # that wasn't indexed before. So index it!
                         i, iwc = self.add_doc(writer, path, repo, repo_name)
--- a/kallithea/lib/middleware/pygrack.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/lib/middleware/pygrack.py	Thu Dec 26 15:16:29 2019 +0100
@@ -33,7 +33,7 @@
 from webob import Request, Response, exc
 
 import kallithea
-from kallithea.lib.utils2 import ascii_bytes, safe_unicode
+from kallithea.lib.utils2 import ascii_bytes
 from kallithea.lib.vcs import subprocessio
 
 
@@ -87,7 +87,6 @@
 
         :param path:
         """
-        path = safe_unicode(path)
         assert path.startswith('/' + self.repo_name + '/')
         return path[len(self.repo_name) + 2:].strip('/')
 
--- a/kallithea/lib/middleware/simplegit.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/lib/middleware/simplegit.py	Thu Dec 26 15:16:29 2019 +0100
@@ -35,7 +35,6 @@
 from kallithea.lib.hooks import log_pull_action
 from kallithea.lib.middleware.pygrack import make_wsgi_app
 from kallithea.lib.utils import make_ui
-from kallithea.lib.utils2 import safe_unicode
 from kallithea.model.db import Repository
 
 
@@ -64,7 +63,7 @@
 
         class parsed_request(object):
             # See https://git-scm.com/book/en/v2/Git-Internals-Transfer-Protocols#_the_smart_protocol
-            repo_name = safe_unicode(m.group(1).rstrip('/'))
+            repo_name = m.group(1).rstrip('/')
             cmd = m.group(2)
 
             query_string = environ['QUERY_STRING']
--- a/kallithea/lib/middleware/simplehg.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/lib/middleware/simplehg.py	Thu Dec 26 15:16:29 2019 +0100
@@ -36,7 +36,7 @@
 
 from kallithea.lib.base import BaseVCSController, get_path_info
 from kallithea.lib.utils import make_ui
-from kallithea.lib.utils2 import safe_bytes, safe_str, safe_unicode
+from kallithea.lib.utils2 import safe_bytes, safe_str
 
 
 log = logging.getLogger(__name__)
@@ -105,7 +105,7 @@
             return None
 
         class parsed_request(object):
-            repo_name = safe_unicode(path_info[1:].rstrip('/'))
+            repo_name = path_info[1:].rstrip('/')
 
             query_string = environ['QUERY_STRING']
 
--- a/kallithea/lib/utils.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/lib/utils.py	Thu Dec 26 15:16:29 2019 +0100
@@ -40,7 +40,7 @@
 
 import kallithea.config.conf
 from kallithea.lib.exceptions import HgsubversionImportError
-from kallithea.lib.utils2 import ascii_bytes, aslist, get_current_authuser, safe_bytes, safe_str, safe_unicode
+from kallithea.lib.utils2 import ascii_bytes, aslist, get_current_authuser, safe_bytes, safe_str
 from kallithea.lib.vcs.backends.git.repository import GitRepository
 from kallithea.lib.vcs.backends.hg.repository import MercurialRepository
 from kallithea.lib.vcs.conf import settings
@@ -150,7 +150,7 @@
     user_log = UserLog()
     user_log.user_id = user_obj.user_id
     user_log.username = user_obj.username
-    user_log.action = safe_unicode(action)
+    user_log.action = action
 
     user_log.repository = repo_obj
     user_log.repository_name = repo_name
@@ -160,7 +160,7 @@
     meta.Session().add(user_log)
 
     log.info('Logging action:%s on %s by user:%s ip:%s',
-             action, safe_unicode(repo), user_obj, ipaddr)
+             action, repo, user_obj, ipaddr)
     if commit:
         meta.Session().commit()
 
@@ -480,8 +480,7 @@
 
     for name, repo in initial_repo_dict.items():
         group = map_groups(name)
-        unicode_name = safe_unicode(name)
-        db_repo = repo_model.get_by_repo_name(unicode_name)
+        db_repo = repo_model.get_by_repo_name(name)
         # found repo that is on filesystem not in Kallithea database
         if not db_repo:
             log.info('repository %s not found, creating now', name)
@@ -517,9 +516,8 @@
 
     removed = []
     # remove from database those repositories that are not in the filesystem
-    unicode_initial_repo_names = set(safe_unicode(name) for name in initial_repo_dict)
     for repo in sa.query(Repository).all():
-        if repo.repo_name not in unicode_initial_repo_names:
+        if repo.repo_name not in initial_repo_dict:
             if remove_obsolete:
                 log.debug("Removing non-existing repository found in db `%s`",
                           repo.repo_name)
--- a/kallithea/lib/utils2.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/lib/utils2.py	Thu Dec 26 15:16:29 2019 +0100
@@ -322,19 +322,19 @@
 
 def get_clone_url(clone_uri_tmpl, prefix_url, repo_name, repo_id, username=None):
     parsed_url = urlobject.URLObject(prefix_url)
-    prefix = safe_unicode(urllib.parse.unquote(parsed_url.path.rstrip('/')))
+    prefix = urllib.parse.unquote(parsed_url.path.rstrip('/'))
     try:
         system_user = pwd.getpwuid(os.getuid()).pw_name
     except Exception: # TODO: support all systems - especially Windows
         system_user = 'kallithea' # hardcoded default value ...
     args = {
         'scheme': parsed_url.scheme,
-        'user': safe_unicode(urllib.parse.quote(safe_str(username or ''))),
+        'user': urllib.parse.quote(safe_str(username or '')),
         'netloc': parsed_url.netloc + prefix,  # like "hostname:port/prefix" (with optional ":port" and "/prefix")
         'prefix': prefix, # undocumented, empty or starting with /
         'repo': repo_name,
         'repoid': str(repo_id),
-        'system_user': safe_unicode(system_user),
+        'system_user': system_user,
         'hostname': parsed_url.hostname,
     }
     url = re.sub('{([^{}]+)}', lambda m: args.get(m.group(1), m.group(0)), clone_uri_tmpl)
@@ -344,7 +344,7 @@
     if not url_obj.username:
         url_obj = url_obj.with_username(None)
 
-    return safe_unicode(url_obj)
+    return str(url_obj)
 
 
 def get_changeset_safe(repo, rev):
--- a/kallithea/lib/vcs/backends/base.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/lib/vcs/backends/base.py	Thu Dec 26 15:16:29 2019 +0100
@@ -15,7 +15,7 @@
 from kallithea.lib.vcs.conf import settings
 from kallithea.lib.vcs.exceptions import (
     ChangesetError, EmptyRepositoryError, NodeAlreadyAddedError, NodeAlreadyChangedError, NodeAlreadyExistsError, NodeAlreadyRemovedError, NodeDoesNotExistError, NodeNotChangedError, RepositoryError)
-from kallithea.lib.vcs.utils import author_email, author_name, safe_unicode
+from kallithea.lib.vcs.utils import author_email, author_name
 from kallithea.lib.vcs.utils.helpers import get_dict_for_attrs
 from kallithea.lib.vcs.utils.lazy import LazyProperty
 
@@ -376,9 +376,9 @@
                 message=self.message,
                 date=self.date,
                 author=self.author,
-                added=[safe_unicode(el.path) for el in self.added],
-                changed=[safe_unicode(el.path) for el in self.changed],
-                removed=[safe_unicode(el.path) for el in self.removed],
+                added=[el.path for el in self.added],
+                changed=[el.path for el in self.changed],
+                removed=[el.path for el in self.removed],
             )
         else:
             return dict(
@@ -643,9 +643,9 @@
         data = get_dict_for_attrs(self, ['raw_id', 'short_id',
             'revision', 'date', 'message'])
         data['author'] = {'name': self.author_name, 'email': self.author_email}
-        data['added'] = [safe_unicode(node.path) for node in self.added]
-        data['changed'] = [safe_unicode(node.path) for node in self.changed]
-        data['removed'] = [safe_unicode(node.path) for node in self.removed]
+        data['added'] = [node.path for node in self.added]
+        data['changed'] = [node.path for node in self.changed]
+        data['removed'] = [node.path for node in self.removed]
         return data
 
     @LazyProperty
--- a/kallithea/lib/vcs/backends/git/repository.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/lib/vcs/backends/git/repository.py	Thu Dec 26 15:16:29 2019 +0100
@@ -54,7 +54,7 @@
     def __init__(self, repo_path, create=False, src_url=None,
                  update_after_clone=False, bare=False):
 
-        self.path = safe_unicode(abspath(repo_path))
+        self.path = abspath(repo_path)
         self.repo = self._get_repo(create, src_url, update_after_clone, bare)
         self.bare = self.repo.bare
 
--- a/kallithea/lib/vcs/backends/git/ssh.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/lib/vcs/backends/git/ssh.py	Thu Dec 26 15:16:29 2019 +0100
@@ -18,7 +18,7 @@
 from kallithea.lib.hooks import log_pull_action
 from kallithea.lib.utils import make_ui
 from kallithea.lib.vcs.backends.ssh import BaseSshHandler
-from kallithea.lib.vcs.utils import safe_str, safe_unicode
+from kallithea.lib.vcs.utils import safe_str
 
 
 log = logging.getLogger(__name__)
@@ -56,7 +56,7 @@
             ssh_command_parts[0] in ['git-upload-pack', 'git-receive-pack'] and
             ssh_command_parts[1].startswith('/')
         ):
-            return cls(safe_unicode(ssh_command_parts[1][1:]), ssh_command_parts[0])
+            return cls(ssh_command_parts[1][1:], ssh_command_parts[0])
 
         return None
 
--- a/kallithea/lib/vcs/backends/hg/ssh.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/lib/vcs/backends/hg/ssh.py	Thu Dec 26 15:16:29 2019 +0100
@@ -19,7 +19,7 @@
 
 from kallithea.lib.utils import make_ui
 from kallithea.lib.vcs.backends.ssh import BaseSshHandler
-from kallithea.lib.vcs.utils import safe_bytes, safe_unicode
+from kallithea.lib.vcs.utils import safe_bytes
 
 
 log = logging.getLogger(__name__)
@@ -47,7 +47,7 @@
         >>> MercurialSshHandler.make(shlex.split('git-upload-pack "/foo"')) # not handled here
         """
         if ssh_command_parts[:2] == ['hg', '-R'] and ssh_command_parts[3:] == ['serve', '--stdio']:
-            return cls(safe_unicode(ssh_command_parts[2]))
+            return cls(ssh_command_parts[2])
 
         return None
 
--- a/kallithea/lib/vcs/nodes.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/lib/vcs/nodes.py	Thu Dec 26 15:16:29 2019 +0100
@@ -126,7 +126,7 @@
         Returns name of the node so if its path
         then only last part is returned.
         """
-        return safe_unicode(self.path.rstrip('/').split('/')[-1])
+        return self.path.rstrip('/').split('/')[-1]
 
     def _get_kind(self):
         return self._kind
@@ -605,5 +605,5 @@
         Returns name of the node so if its path
         then only last part is returned.
         """
-        org = safe_unicode(self.path.rstrip('/').split('/')[-1])
+        org = self.path.rstrip('/').rsplit('/', 1)[-1]
         return u'%s @ %s' % (org, self.changeset.short_id)
--- a/kallithea/model/comment.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/model/comment.py	Thu Dec 26 15:16:29 2019 +0100
@@ -31,7 +31,7 @@
 from tg.i18n import ugettext as _
 
 from kallithea.lib import helpers as h
-from kallithea.lib.utils2 import extract_mentioned_users, safe_unicode
+from kallithea.lib.utils2 import extract_mentioned_users
 from kallithea.model.db import ChangesetComment, PullRequest, Repository, User
 from kallithea.model.meta import Session
 from kallithea.model.notification import NotificationModel
@@ -81,11 +81,10 @@
                 repo_name=repo.repo_name,
                 revision=revision,
                 anchor='comment-%s' % comment.comment_id)
-            subj = safe_unicode(
-                h.link_to('Re changeset: %(desc)s %(line)s' %
+            subj = h.link_to(
+                'Re changeset: %(desc)s %(line)s' %
                           {'desc': desc, 'line': line},
-                          comment_url)
-            )
+                 comment_url)
             # get the current participants of this changeset
             recipients = _list_changeset_commenters(revision)
             # add changeset author if it's known locally
@@ -127,13 +126,12 @@
                                                           h.canonical_hostname()))
             comment_url = pull_request.url(canonical=True,
                 anchor='comment-%s' % comment.comment_id)
-            subj = safe_unicode(
-                h.link_to('Re pull request %(pr_nice_id)s: %(desc)s %(line)s' %
+            subj = h.link_to(
+                'Re pull request %(pr_nice_id)s: %(desc)s %(line)s' %
                           {'desc': desc,
                            'pr_nice_id': comment.pull_request.nice_id(),
                            'line': line},
-                          comment_url)
-            )
+                comment_url)
             # get the current participants of this pull request
             recipients = _list_pull_request_commenters(pull_request)
             recipients.append(pull_request.owner)
--- a/kallithea/model/db.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/model/db.py	Thu Dec 26 15:16:29 2019 +0100
@@ -328,9 +328,9 @@
         info = {
             'modules': sorted(mods, key=lambda k: k[0].lower()),
             'py_version': platform.python_version(),
-            'platform': safe_unicode(platform.platform()),
+            'platform': platform.platform(),
             'kallithea_version': kallithea.__version__,
-            'git_version': safe_unicode(check_git_version()),
+            'git_version': str(check_git_version()),
             'git_path': kallithea.CONFIG.get('git_path')
         }
         return info
@@ -1162,7 +1162,7 @@
         # names in the database, but that eventually needs to be converted
         # into a valid system path
         p += self.repo_name.split(Repository.url_sep())
-        return os.path.join(*(safe_unicode(d) for d in p))
+        return os.path.join(*p)
 
     @property
     def cache_keys(self):
@@ -2282,7 +2282,7 @@
 
     @revisions.setter
     def revisions(self, val):
-        self._revisions = safe_unicode(':'.join(val))
+        self._revisions = ':'.join(val)
 
     @property
     def org_ref_parts(self):
--- a/kallithea/model/gist.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/model/gist.py	Thu Dec 26 15:16:29 2019 +0100
@@ -33,7 +33,7 @@
 import traceback
 
 from kallithea.lib import ext_json
-from kallithea.lib.utils2 import AttributeDict, ascii_bytes, safe_int, safe_unicode, time_to_datetime
+from kallithea.lib.utils2 import AttributeDict, ascii_bytes, safe_int, time_to_datetime
 from kallithea.model.db import Gist, Session, User
 from kallithea.model.repo import RepoModel
 from kallithea.model.scm import ScmModel
@@ -120,7 +120,7 @@
         gist.gist_access_id = gist_access_id
         gist.owner_id = owner.user_id
         gist.gist_expires = gist_expires
-        gist.gist_type = safe_unicode(gist_type)
+        gist.gist_type = gist_type
         Session().add(gist)
         Session().flush() # make database assign gist.gist_id
         if gist_type == Gist.GIST_PUBLIC:
--- a/kallithea/model/pull_request.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/model/pull_request.py	Thu Dec 26 15:16:29 2019 +0100
@@ -33,7 +33,7 @@
 from tg.i18n import ugettext as _
 
 from kallithea.lib import helpers as h
-from kallithea.lib.utils2 import ascii_bytes, extract_mentioned_users, safe_unicode
+from kallithea.lib.utils2 import ascii_bytes, extract_mentioned_users
 from kallithea.model.db import ChangesetStatus, PullRequest, PullRequestReviewer, User
 from kallithea.model.meta import Session
 from kallithea.model.notification import NotificationModel
@@ -68,14 +68,12 @@
         threading = ['%s-pr-%s@%s' % (pr.other_repo.repo_name,
                                       pr.pull_request_id,
                                       h.canonical_hostname())]
-        subject = safe_unicode(
-            h.link_to(
-              _('%(user)s wants you to review pull request %(pr_nice_id)s: %(pr_title)s') %
+        subject = h.link_to(
+            _('%(user)s wants you to review pull request %(pr_nice_id)s: %(pr_title)s') %
                 {'user': user.username,
                  'pr_title': pr.title,
                  'pr_nice_id': pr.nice_id()},
-                pr_url)
-            )
+            pr_url)
         body = pr.description
         _org_ref_type, org_ref_name, _org_rev = pr.org_ref.split(':')
         _other_ref_type, other_ref_name, _other_rev = pr.other_ref.split(':')
--- a/kallithea/model/repo.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/model/repo.py	Thu Dec 26 15:16:29 2019 +0100
@@ -39,7 +39,7 @@
 from kallithea.lib.exceptions import AttachedForksError
 from kallithea.lib.hooks import log_delete_repository
 from kallithea.lib.utils import is_valid_repo_uri, make_ui
-from kallithea.lib.utils2 import LazyProperty, get_current_authuser, obfuscate_url_pw, remove_prefix, safe_str, safe_unicode
+from kallithea.lib.utils2 import LazyProperty, get_current_authuser, obfuscate_url_pw, remove_prefix, safe_str
 from kallithea.lib.vcs.backends import get_backend
 from kallithea.model.db import (
     Permission, RepoGroup, Repository, RepositoryField, Session, Statistics, Ui, User, UserGroup, UserGroupRepoGroupToPerm, UserGroupRepoToPerm, UserRepoGroupToPerm, UserRepoToPerm)
@@ -337,8 +337,8 @@
         fork_of = Repository.guess_instance(fork_of)
         repo_group = RepoGroup.guess_instance(repo_group)
         try:
-            repo_name = safe_unicode(repo_name)
-            description = safe_unicode(description)
+            repo_name = repo_name
+            description = description
             # repo name is just a name of repository
             # while repo_name_full is a full qualified name that is combined
             # with name and path of group
@@ -653,7 +653,7 @@
             raise Exception('This path %s is a valid group' % repo_path)
 
         log.info('creating repo %s in %s from url: `%s`',
-            repo_name, safe_unicode(repo_path),
+            repo_name, repo_path,
             obfuscate_url_pw(clone_uri))
 
         backend = get_backend(repo_type)
@@ -674,7 +674,7 @@
             raise Exception('Not supported repo_type %s expected hg/git' % repo_type)
 
         log.debug('Created repo %s with %s backend',
-                  safe_unicode(repo_name), safe_unicode(repo_type))
+                  repo_name, repo_type)
         return repo
 
     def _rename_filesystem_repo(self, old, new):
--- a/kallithea/model/scm.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/model/scm.py	Thu Dec 26 15:16:29 2019 +0100
@@ -41,7 +41,7 @@
 from kallithea.lib.exceptions import IMCCommitError, NonRelativePathError
 from kallithea.lib.hooks import process_pushed_raw_ids
 from kallithea.lib.utils import action_logger, get_filesystem_repos, make_ui
-from kallithea.lib.utils2 import safe_bytes, safe_str, safe_unicode, set_hook_environment
+from kallithea.lib.utils2 import safe_bytes, safe_str, set_hook_environment
 from kallithea.lib.vcs import get_backend
 from kallithea.lib.vcs.backends.base import EmptyChangeset
 from kallithea.lib.vcs.exceptions import RepositoryError
@@ -401,10 +401,6 @@
         # in any other case this will throw exceptions and deny commit
         content = safe_str(content)
         path = safe_str(f_path)
-        # message and author needs to be unicode
-        # proper backend should then translate that into required type
-        message = safe_unicode(message)
-        author = safe_unicode(author)
         imc = IMC(repo)
         imc.change(FileNode(path, content, mode=cs.get_file_mode(f_path)))
         try:
@@ -491,9 +487,10 @@
                 content = content.read()
             processed_nodes.append((f_path, content))
 
-        message = safe_unicode(message)
+        message = message
         committer = user.full_contact
-        author = safe_unicode(author) if author else committer
+        if not author:
+            author = committer
 
         IMC = self._get_IMC_module(scm_instance.alias)
         imc = IMC(scm_instance)
@@ -534,9 +531,10 @@
         user = User.guess_instance(user)
         scm_instance = repo.scm_instance_no_cache()
 
-        message = safe_unicode(message)
+        message = message
         committer = user.full_contact
-        author = safe_unicode(author) if author else committer
+        if not author:
+            author = committer
 
         imc_class = self._get_IMC_module(scm_instance.alias)
         imc = imc_class(scm_instance)
@@ -614,9 +612,10 @@
             content = nodes[f_path].get('content')
             processed_nodes.append((f_path, content))
 
-        message = safe_unicode(message)
+        message = message
         committer = user.full_contact
-        author = safe_unicode(author) if author else committer
+        if not author:
+            author = committer
 
         IMC = self._get_IMC_module(scm_instance.alias)
         imc = IMC(scm_instance)
--- a/kallithea/model/user.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/model/user.py	Thu Dec 26 15:16:29 2019 +0100
@@ -38,7 +38,7 @@
 
 from kallithea.lib.caching_query import FromCache
 from kallithea.lib.exceptions import DefaultUserException, UserOwnsReposException
-from kallithea.lib.utils2 import generate_api_key, get_current_authuser, safe_unicode
+from kallithea.lib.utils2 import generate_api_key, get_current_authuser
 from kallithea.model.db import Permission, User, UserEmailMap, UserIpMap, UserToPerm
 from kallithea.model.meta import Session
 
@@ -142,10 +142,8 @@
             new_user.admin = admin
             new_user.email = email
             new_user.active = active
-            new_user.extern_name = safe_unicode(extern_name) \
-                if extern_name else None
-            new_user.extern_type = safe_unicode(extern_type) \
-                if extern_type else None
+            new_user.extern_name = extern_name
+            new_user.extern_type = extern_type
             new_user.name = firstname
             new_user.lastname = lastname
 
--- a/kallithea/templates/admin/gists/edit.html	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/templates/admin/gists/edit.html	Thu Dec 26 15:16:29 2019 +0100
@@ -67,8 +67,8 @@
             % for cnt, file in enumerate(c.files):
                 <div id="body" class="panel panel-default form-inline">
                     <div class="panel-heading">
-                        <input type="hidden" value="${h.safe_unicode(file.path)}" name="org_files">
-                        <input class="form-control" id="filename_${h.FID('f',file.path)}" name="files" size="30" type="text" value="${h.safe_unicode(file.path)}">
+                        <input type="hidden" value="${file.path}" name="org_files">
+                        <input class="form-control" id="filename_${h.FID('f',file.path)}" name="files" size="30" type="text" value="${file.path}">
                         <select class="form-control" id="mimetype_${h.FID('f',file.path)}" name="mimetypes"></select>
                     </div>
                     <div class="panel-body no-padding">
--- a/kallithea/templates/admin/gists/show.html	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/templates/admin/gists/show.html	Thu Dec 26 15:16:29 2019 +0100
@@ -76,10 +76,10 @@
               <div class="panel panel-default">
                 <div id="${h.FID('G', file.path)}" class="panel-heading clearfix">
                     <div class="pull-left">
-                      <b>${h.safe_unicode(file.path)}</b>
+                      <b>${file.path}</b>
                     </div>
                     <div class="pull-right">
-                      ${h.link_to(_('Show as raw'),h.url('formatted_gist_file', gist_id=c.gist.gist_access_id, format='raw', revision=file.changeset.raw_id, f_path=h.safe_unicode(file.path)),class_="btn btn-default btn-xs")}
+                      ${h.link_to(_('Show as raw'),h.url('formatted_gist_file', gist_id=c.gist.gist_access_id, format='raw', revision=file.changeset.raw_id, f_path=file.path),class_="btn btn-default btn-xs")}
                     </div>
                 </div>
                 <div class="panel-body no-padding">
--- a/kallithea/templates/changeset/changeset.html	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/templates/changeset/changeset.html	Thu Dec 26 15:16:29 2019 +0100
@@ -143,7 +143,7 @@
                 %for fid, url_fid, op, a_path, path, diff, stats in file_diff_data:
                     <div class="cs_${op} clearfix">
                       <span class="node">
-                          <i class="icon-diff-${op}"></i>${h.link_to(h.safe_unicode(path), '#%s' % fid)}
+                          <i class="icon-diff-${op}"></i>${h.link_to(path, '#%s' % fid)}
                       </span>
                       <div class="changes">${h.fancy_file_stats(stats)}</div>
                     </div>
--- a/kallithea/templates/changeset/changeset_file_comment.html	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/templates/changeset/changeset_file_comment.html	Thu Dec 26 15:16:29 2019 +0100
@@ -164,7 +164,7 @@
 <div class="comments inline-comments">
   %for f_path, lines in c.inline_comments:
     %for line_no, comments in lines.items():
-      <div class="comments-list-chunk" data-f_path="${f_path}" data-line_no="${line_no}" data-target-id="${h.safeid(h.safe_unicode(f_path))}_${line_no}">
+      <div class="comments-list-chunk" data-f_path="${f_path}" data-line_no="${line_no}" data-target-id="${h.safeid(f_path)}_${line_no}">
         %for co in comments:
             ${comment_block(co)}
         %endfor
--- a/kallithea/templates/changeset/changeset_range.html	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/templates/changeset/changeset_range.html	Thu Dec 26 15:16:29 2019 +0100
@@ -56,7 +56,7 @@
                             <div class="cs_${op} clearfix">
                                 <span class="node">
                                     <i class="icon-diff-${op}"></i>
-                                    ${h.link_to(h.safe_unicode(path), '#%s' % fid)}
+                                    ${h.link_to(path, '#%s' % fid)}
                                 </span>
                                 <div class="changes">${h.fancy_file_stats(stats)}</div>
                             </div>
--- a/kallithea/templates/changeset/diff_block.html	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/templates/changeset/diff_block.html	Thu Dec 26 15:16:29 2019 +0100
@@ -22,7 +22,7 @@
     <div id="${id_fid}" class="panel panel-default ${cls}">
         <div class="panel-heading clearfix">
                 <div class="pull-left">
-                    ${h.safe_unicode(cs_filename)}
+                    ${cs_filename}
                 </div>
                 <div class="pull-left diff-actions">
                   <span>
@@ -57,13 +57,13 @@
                     %endif
                   </span>
 
-                  <a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=h.safe_unicode(cs_filename),diff2=cs_rev,diff1=a_rev,diff='diff',fulldiff=1)}" data-toggle="tooltip" title="${_('Show full diff for this file')}">
+                  <a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=cs_filename,diff2=cs_rev,diff1=a_rev,diff='diff',fulldiff=1)}" data-toggle="tooltip" title="${_('Show full diff for this file')}">
                       <i class="icon-file-code"></i></a>
-                  <a href="${h.url('files_diff_2way_home',repo_name=cs_repo_name,f_path=h.safe_unicode(cs_filename),diff2=cs_rev,diff1=a_rev,diff='diff',fulldiff=1)}" data-toggle="tooltip" title="${_('Show full side-by-side diff for this file')}">
+                  <a href="${h.url('files_diff_2way_home',repo_name=cs_repo_name,f_path=cs_filename,diff2=cs_rev,diff1=a_rev,diff='diff',fulldiff=1)}" data-toggle="tooltip" title="${_('Show full side-by-side diff for this file')}">
                       <i class="icon-docs"></i></a>
-                  <a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=h.safe_unicode(cs_filename),diff2=cs_rev,diff1=a_rev,diff='raw')}" data-toggle="tooltip" title="${_('Raw diff')}">
+                  <a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=cs_filename,diff2=cs_rev,diff1=a_rev,diff='raw')}" data-toggle="tooltip" title="${_('Raw diff')}">
                       <i class="icon-diff"></i></a>
-                  <a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=h.safe_unicode(cs_filename),diff2=cs_rev,diff1=a_rev,diff='download')}" data-toggle="tooltip" title="${_('Download diff')}">
+                  <a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=cs_filename,diff2=cs_rev,diff1=a_rev,diff='download')}" data-toggle="tooltip" title="${_('Download diff')}">
                       <i class="icon-floppy"></i></a>
                   ${c.ignorews_url(request.GET, url_fid)}
                   ${c.context_url(request.GET, url_fid)}
@@ -73,7 +73,7 @@
                     ${h.checkbox('checkbox-show-inline-' + id_fid, checked="checked",class_="show-inline-comments",**{'data-id_for':id_fid})}
                 </div>
         </div>
-        <div class="no-padding panel-body" data-f_path="${h.safe_unicode(cs_filename)}">
+        <div class="no-padding panel-body" data-f_path="${cs_filename}">
             ${diff|n}
             %if op and cs_filename.rsplit('.')[-1] in ['png', 'gif', 'jpg', 'bmp']:
               <div class="btn btn-image-diff-show">Show images</div>
--- a/kallithea/templates/compare/compare_diff.html	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/templates/compare/compare_diff.html	Thu Dec 26 15:16:29 2019 +0100
@@ -72,7 +72,7 @@
                     <div class="cs_${op} clearfix">
                       <span class="node">
                           <i class="icon-diff-${op}"></i>
-                          ${h.link_to(h.safe_unicode(path), '#%s' % fid)}
+                          ${h.link_to(path, '#%s' % fid)}
                       </span>
                       <div class="changes">${h.fancy_file_stats(stats)}</div>
                     </div>
--- a/kallithea/templates/files/diff_2way.html	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/templates/files/diff_2way.html	Thu Dec 26 15:16:29 2019 +0100
@@ -34,22 +34,22 @@
         <div class="panel panel-default">
             <div class="panel-heading clearfix">
                     <div class="pull-left">
-                        ${h.link_to(h.safe_unicode(c.node1.path),h.url('files_home',repo_name=c.repo_name,
-                        revision=c.cs2.raw_id,f_path=h.safe_unicode(c.node1.path)))}
+                        ${h.link_to(c.node1.path,h.url('files_home',repo_name=c.repo_name,
+                        revision=c.cs2.raw_id,f_path=c.node1.path))}
                     </div>
                     <div class="pull-left diff-actions">
-                      <a href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(c.node1.path),diff2=c.cs2.raw_id,diff1=c.cs1.raw_id,diff='diff',fulldiff=1)}"
+                      <a href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=c.node1.path,diff2=c.cs2.raw_id,diff1=c.cs1.raw_id,diff='diff',fulldiff=1)}"
                          data-toggle="tooltip"
                          title="${_('Show full diff for this file')}">
                           <i class="icon-file-code"></i></a>
-                      <a href="${h.url('files_diff_2way_home',repo_name=c.repo_name,f_path=h.safe_unicode(c.node1.path),diff2=c.cs2.raw_id,diff1=c.cs1.raw_id,diff='diff',fulldiff=1)}"
+                      <a href="${h.url('files_diff_2way_home',repo_name=c.repo_name,f_path=c.node1.path,diff2=c.cs2.raw_id,diff1=c.cs1.raw_id,diff='diff',fulldiff=1)}"
                          data-toggle="tooltip"
                          title="${_('Show full side-by-side diff for this file')}">
                           <i class="icon-docs"></i></a>
-                      <a href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(c.node1.path),diff2=c.cs2.raw_id,diff1=c.cs1.raw_id,diff='raw')}"
+                      <a href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=c.node1.path,diff2=c.cs2.raw_id,diff1=c.cs1.raw_id,diff='raw')}"
                          data-toggle="tooltip"
                          title="${_('Raw diff')}"><i class="icon-diff"></i></a>
-                      <a href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=h.safe_unicode(c.node1.path),diff2=c.cs2.raw_id,diff1=c.cs1.raw_id,diff='download')}"
+                      <a href="${h.url('files_diff_home',repo_name=c.repo_name,f_path=c.node1.path,diff2=c.cs2.raw_id,diff1=c.cs1.raw_id,diff='download')}"
                          data-toggle="tooltip"
                          title="${_('Download diff')}"><i class="icon-floppy"></i></a>
                       ${h.checkbox('ignorews', label=_('Ignore whitespace'))}
@@ -61,8 +61,8 @@
     </div>
 
 <script>
-var orig1_url = ${h.jshtml(h.url('files_raw_home',repo_name=c.repo_name,f_path=h.safe_unicode(c.node1.path),revision=c.cs1.raw_id))};
-var orig2_url = ${h.jshtml(h.url('files_raw_home',repo_name=c.repo_name,f_path=h.safe_unicode(c.node2.path),revision=c.cs2.raw_id))};
+var orig1_url = ${h.jshtml(h.url('files_raw_home',repo_name=c.repo_name,f_path=c.node1.path,revision=c.cs1.raw_id))};
+var orig2_url = ${h.jshtml(h.url('files_raw_home',repo_name=c.repo_name,f_path=c.node2.path,revision=c.cs2.raw_id))};
 
 $(document).ready(function () {
     $('#compare').mergely({
--- a/kallithea/templates/files/files.html	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/templates/files/files.html	Thu Dec 26 15:16:29 2019 +0100
@@ -3,7 +3,7 @@
 <%block name="title">
     ${_('%s Files') % c.repo_name}
     %if hasattr(c,'file'):
-        &middot; ${h.safe_unicode(c.file.path) or '/'}
+        &middot; ${c.file.path or '/'}
     %endif
 </%block>
 
@@ -217,12 +217,12 @@
     });
 
     // init the search filter
-    var _node_list_url = node_list_url.replace('__REV__', ${h.js(c.changeset.raw_id)}).replace('__FPATH__', ${h.js(h.safe_unicode(c.file.path))});
+    var _node_list_url = node_list_url.replace('__REV__', ${h.js(c.changeset.raw_id)}).replace('__FPATH__', ${h.js(c.file.path)});
     var _url_base = url_base.replace('__REV__', ${h.js(c.changeset.raw_id)});
     fileBrowserListeners(_node_list_url, _url_base);
 
     var initial_state = {url:window.location.href, title:document.title, url_base:_url_base,
-         node_list_url:_node_list_url, rev:${h.js(c.changeset.raw_id)}, f_path:${h.js(h.safe_unicode(c.file.path))}};
+         node_list_url:_node_list_url, rev:${h.js(c.changeset.raw_id)}, f_path:${h.js(c.file.path)}};
 
     // change branch filter
     $("#branch_selector").select2({
@@ -234,7 +234,7 @@
     $("#branch_selector").change(function(e){
         var selected = e.currentTarget.options[e.currentTarget.selectedIndex].value;
         if(selected && selected != ${h.js(c.changeset.raw_id)}){
-            window.location = pyroutes.url('files_home', {'repo_name': ${h.js(h.safe_unicode(c.repo_name))}, 'revision': selected, 'f_path': ${h.js(h.safe_unicode(c.file.path))}});
+            window.location = pyroutes.url('files_home', {'repo_name': ${h.js(c.repo_name)}, 'revision': selected, 'f_path': ${h.js(c.file.path)}});
             $("#body").hide();
         } else {
             $("#branch_selector").val(${h.js(c.changeset.raw_id)});
@@ -242,7 +242,7 @@
     });
     $('#show_authors').on('click', function(){
         $.ajax({
-            url: pyroutes.url('files_authors_home', {'revision': ${h.js(c.changeset.raw_id)}, 'f_path': ${h.js(h.safe_unicode(c.file.path))}}),
+            url: pyroutes.url('files_authors_home', {'revision': ${h.js(c.changeset.raw_id)}, 'f_path': ${h.js(c.file.path)}}),
             success: function(data) {
                 $('#file_authors').html(data);
                 $('#file_authors').show();
--- a/kallithea/templates/files/files_browser.html	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/templates/files/files_browser.html	Thu Dec 26 15:16:29 2019 +0100
@@ -13,7 +13,7 @@
     %if node.is_submodule():
         <%return node.url or '#'%>
     %else:
-        <%return h.url('files_home', repo_name=c.repo_name, revision=c.changeset.raw_id, f_path=h.safe_unicode(node.path))%>
+        <%return h.url('files_home', repo_name=c.repo_name, revision=c.changeset.raw_id, f_path=node.path)%>
     %endif
 </%def>
 <%def name="_file_name(iconclass, name)">
--- a/kallithea/templates/pullrequests/pullrequest_show.html	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/templates/pullrequests/pullrequest_show.html	Thu Dec 26 15:16:29 2019 +0100
@@ -300,7 +300,7 @@
                     <div class="cs_${op} clearfix">
                       <span class="node">
                           <i class="icon-diff-${op}"></i>
-                          ${h.link_to(h.safe_unicode(path), '#%s' % fid)}
+                          ${h.link_to(path, '#%s' % fid)}
                       </span>
                       <div class="changes">${h.fancy_file_stats(stats)}</div>
                     </div>
--- a/kallithea/tests/functional/test_admin.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/tests/functional/test_admin.py	Thu Dec 26 15:16:29 2019 +0100
@@ -3,7 +3,6 @@
 import os
 from os.path import dirname
 
-from kallithea.lib.utils2 import safe_unicode
 from kallithea.model.db import UserLog
 from kallithea.model.meta import Session
 from kallithea.tests import base
@@ -35,7 +34,6 @@
             for row in csv.DictReader(f):
                 ul = UserLog()
                 for k, v in row.items():
-                    v = safe_unicode(v)
                     if k == 'action_date':
                         v = strptime(v)
                     if k in ['user_id', 'repository_id']:
--- a/kallithea/tests/functional/test_admin_repos.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/tests/functional/test_admin_repos.py	Thu Dec 26 15:16:29 2019 +0100
@@ -7,7 +7,7 @@
 import pytest
 
 from kallithea.lib import vcs
-from kallithea.lib.utils2 import safe_str, safe_unicode
+from kallithea.lib.utils2 import safe_str
 from kallithea.model.db import Permission, RepoGroup, Repository, Ui, User, UserRepoToPerm
 from kallithea.model.meta import Session
 from kallithea.model.repo import RepoModel
@@ -396,9 +396,7 @@
         self.log_user()
         non_ascii = "ąęł"
         repo_name = "%s%s" % (safe_str(self.NEW_REPO), non_ascii)
-        repo_name_unicode = safe_unicode(repo_name)
         description = 'description for newly created repo' + non_ascii
-        description_unicode = safe_unicode(description)
         response = self.app.post(base.url('repos'),
                         fixture._get_repo_create_params(repo_private=False,
                                                 repo_name=repo_name,
@@ -410,13 +408,13 @@
         assert response.json == {u'result': True}
         self.checkSessionFlash(response,
                                u'Created repository <a href="/%s">%s</a>'
-                               % (urllib.parse.quote(repo_name), repo_name_unicode))
+                               % (urllib.parse.quote(repo_name), repo_name))
         # test if the repo was created in the database
         new_repo = Session().query(Repository) \
-            .filter(Repository.repo_name == repo_name_unicode).one()
+            .filter(Repository.repo_name == repo_name).one()
 
-        assert new_repo.repo_name == repo_name_unicode
-        assert new_repo.description == description_unicode
+        assert new_repo.repo_name == repo_name
+        assert new_repo.description == description
 
         # test if the repository is visible in the list ?
         response = self.app.get(base.url('summary_home', repo_name=repo_name))
@@ -425,22 +423,22 @@
 
         # test if the repository was created on filesystem
         try:
-            vcs.get_repo(safe_str(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name_unicode)))
+            vcs.get_repo(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name))
         except vcs.exceptions.VCSError:
             pytest.fail('no repo %s in filesystem' % repo_name)
 
         response = self.app.post(base.url('delete_repo', repo_name=repo_name),
             params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
-        self.checkSessionFlash(response, 'Deleted repository %s' % (repo_name_unicode))
+        self.checkSessionFlash(response, 'Deleted repository %s' % (repo_name))
         response.follow()
 
         # check if repo was deleted from db
         deleted_repo = Session().query(Repository) \
-            .filter(Repository.repo_name == repo_name_unicode).scalar()
+            .filter(Repository.repo_name == repo_name).scalar()
 
         assert deleted_repo is None
 
-        assert os.path.isdir(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name_unicode)) == False
+        assert os.path.isdir(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name)) == False
 
     def test_delete_repo_with_group(self):
         # TODO:
--- a/kallithea/tests/functional/test_forks.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/tests/functional/test_forks.py	Thu Dec 26 15:16:29 2019 +0100
@@ -2,7 +2,7 @@
 
 import urllib.parse
 
-from kallithea.lib.utils2 import safe_str, safe_unicode
+from kallithea.lib.utils2 import safe_str
 from kallithea.model.db import Repository, User
 from kallithea.model.meta import Session
 from kallithea.model.repo import RepoModel
@@ -161,7 +161,7 @@
         response.mustcontain(
             """<a href="/%s">%s</a>""" % (urllib.parse.quote(fork_name), fork_name)
         )
-        fork_repo = Repository.get_by_repo_name(safe_unicode(fork_name))
+        fork_repo = Repository.get_by_repo_name(fork_name)
         assert fork_repo
 
         # fork the fork
--- a/kallithea/tests/vcs/base.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/tests/vcs/base.py	Thu Dec 26 15:16:29 2019 +0100
@@ -79,8 +79,8 @@
             for node in commit.get('removed', []):
                 cls.imc.remove(FileNode(node.path))
 
-            cls.tip = cls.imc.commit(message=unicode(commit['message']),
-                                     author=unicode(commit['author']),
+            cls.tip = cls.imc.commit(message=commit['message'],
+                                     author=commit['author'],
                                      date=commit['date'])
 
     @pytest.fixture(autouse=True)
--- a/kallithea/tests/vcs/test_inmemchangesets.py	Tue Dec 31 15:39:17 2019 +0100
+++ b/kallithea/tests/vcs/test_inmemchangesets.py	Thu Dec 26 15:16:29 2019 +0100
@@ -10,7 +10,6 @@
 from kallithea.lib.vcs.exceptions import (
     EmptyRepositoryError, NodeAlreadyAddedError, NodeAlreadyChangedError, NodeAlreadyExistsError, NodeAlreadyRemovedError, NodeDoesNotExistError, NodeNotChangedError)
 from kallithea.lib.vcs.nodes import DirNode, FileNode
-from kallithea.lib.vcs.utils import safe_unicode
 from kallithea.tests.vcs.base import _BackendTestMixin
 
 
@@ -169,13 +168,11 @@
         # Change node's content
         node = FileNode('żółwik/zwierzątko', content='My **changed** content')
         self.imc.change(node)
-        self.imc.commit(u'Changed %s' % safe_unicode(node.path),
-                        u'joe.doe@example.com')
+        self.imc.commit(u'Changed %s' % node.path, u'joe.doe@example.com')
 
         node = FileNode(u'żółwik/zwierzątko_uni', content=u'My **changed** content')
         self.imc.change(node)
-        self.imc.commit(u'Changed %s' % safe_unicode(node.path),
-                        u'joe.doe@example.com')
+        self.imc.commit(u'Changed %s' % node.path, u'joe.doe@example.com')
 
         newtip = self.repo.get_changeset()
         assert tip != newtip