diff --git a/rhodecode/lib/auth.py b/rhodecode/lib/auth.py --- a/rhodecode/lib/auth.py +++ b/rhodecode/lib/auth.py @@ -1346,7 +1346,7 @@ class AuthUser(object): def _cached_repo_acl(perm_def, _name_filter): qry = Repository.query() if _name_filter: - ilike_expression = u'%{}%'.format(safe_unicode(_name_filter)) + ilike_expression = '%{}%'.format(_name_filter) qry = qry.filter( Repository.repo_name.ilike(ilike_expression)) @@ -1397,7 +1397,7 @@ class AuthUser(object): def _cached_repo_group_acl(perm_def, _name_filter): qry = RepoGroup.query() if _name_filter: - ilike_expression = u'%{}%'.format(safe_unicode(_name_filter)) + ilike_expression = '%{}%'.format(_name_filter) qry = qry.filter( RepoGroup.group_name.ilike(ilike_expression)) @@ -1446,7 +1446,7 @@ class AuthUser(object): def _cached_user_group_acl(perm_def, _name_filter): qry = UserGroup.query() if _name_filter: - ilike_expression = u'%{}%'.format(safe_unicode(_name_filter)) + ilike_expression = '%{}%'.format(_name_filter) qry = qry.filter( UserGroup.users_group_name.ilike(ilike_expression)) @@ -2323,9 +2323,11 @@ class HasPermissionAnyMiddleware(object) self.required_perms = set(perms) def __call__(self, auth_user, repo_name): - # repo_name MUST be unicode, since we handle keys in permission - # dict by unicode - repo_name = safe_unicode(repo_name) + # # repo_name MUST be unicode, since we handle keys in permission + # # dict by unicode + #TODO: verify + # repo_name = safe_unicode(repo_name) + log.debug( 'Checking VCS protocol permissions %s for user:%s repo:`%s`', self.required_perms, auth_user, repo_name) @@ -2495,10 +2497,11 @@ def check_ip_access(source_ip, allowed_i :param allowed_ips: list of allowed ips together with mask """ log.debug('checking if ip:%s is subnet of %s', source_ip, allowed_ips) - source_ip_address = ipaddress.ip_address(safe_unicode(source_ip)) + source_ip_address = ipaddress.ip_address(source_ip) if isinstance(allowed_ips, (tuple, list, set)): for ip in allowed_ips: - ip = safe_unicode(ip) + #TODO: verify + #ip = safe_unicode(ip) try: network_address = ipaddress.ip_network(ip, strict=False) if source_ip_address in network_address: diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py --- a/rhodecode/lib/base.py +++ b/rhodecode/lib/base.py @@ -86,7 +86,7 @@ def _filter_port(ip): else: # fallback to ipaddress try: - ipaddress.IPv6Address(safe_unicode(ip_addr)) + ipaddress.IPv6Address(safe_str(ip_addr)) except Exception: return False return True diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -1086,7 +1086,7 @@ def style_metatag(tag_type, value): pat, replace_html = tag_data # convert to plain `unicode` instead of a markup tag to be used in # regex expressions. safe_unicode doesn't work here - html_value = pat.sub(replace_html, unicode(value)) + html_value = pat.sub(replace_html, value) return html_value @@ -1223,10 +1223,10 @@ class InitialsGravatar(object): def normalize_email(self, email_address): import unicodedata # default host used to fill in the fake/missing email - default_host = u'localhost' + default_host = 'localhost' if not email_address: - email_address = u'%s@%s' % (User.DEFAULT_USER, default_host) + email_address = '%s@%s' % (User.DEFAULT_USER, default_host) email_address = safe_unicode(email_address) diff --git a/rhodecode/lib/vcs/backends/hg/repository.py b/rhodecode/lib/vcs/backends/hg/repository.py --- a/rhodecode/lib/vcs/backends/hg/repository.py +++ b/rhodecode/lib/vcs/backends/hg/repository.py @@ -467,8 +467,9 @@ class MercurialRepository(BaseRepository else: commit_id = "tip" - if isinstance(commit_id, unicode): - commit_id = safe_str(commit_id) + #TODO: decide if we pass bytes or str into lookup ? + # if isinstance(commit_id, unicode): + # commit_id = safe_str(commit_id) try: raw_id, idx = self._remote.lookup(commit_id, both=True) diff --git a/rhodecode/lib/vcs/nodes.py b/rhodecode/lib/vcs/nodes.py --- a/rhodecode/lib/vcs/nodes.py +++ b/rhodecode/lib/vcs/nodes.py @@ -47,10 +47,10 @@ class NodeKind: class NodeState: - ADDED = u'added' - CHANGED = u'changed' - NOT_CHANGED = u'not changed' - REMOVED = u'removed' + ADDED = 'added' + CHANGED = 'changed' + NOT_CHANGED = 'not changed' + REMOVED = 'removed' class NodeGeneratorBase(object): @@ -115,7 +115,7 @@ class Node(object): only. Moreover, every single node is identified by the ``path`` attribute, so it cannot end with slash, too. Otherwise, path could lead to mistakes. """ - RTLO_MARKER = u"\u202E" # RTLO marker allows swapping text, and certain + RTLO_MARKER = "\u202E" # RTLO marker allows swapping text, and certain # security attacks could be used with this commit = None @@ -173,7 +173,7 @@ class Node(object): _parts = self.path.rstrip('/').rsplit('/', 1) if len(_parts) == 2: return safe_unicode(_parts[0]) - return u'' + return '' @LazyProperty def name(self): @@ -829,7 +829,7 @@ class SubModuleNode(Node): then only last part is returned. """ org = safe_unicode(self.path.rstrip('/').split('/')[-1]) - return u'%s @ %s' % (org, self.commit.short_id) + return '%s @ %s' % (org, self.commit.short_id) class LargeFileNode(FileNode): diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -346,7 +346,7 @@ class RhodeCodeSetting(Base, BaseModel): @validates('_app_settings_value') def validate_settings_value(self, key, val): - assert type(val) == unicode + assert type(val) == str return val @hybrid_property @@ -487,7 +487,7 @@ class RepoRhodeCodeSetting(Base, BaseMod @validates('_app_settings_value') def validate_settings_value(self, key, val): - assert type(val) == unicode + assert type(val) == str return val @hybrid_property