mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-30 05:47:59 +00:00
type_is_str(): make pyflakes3 happy
pyflakes3 doesn't check sys.version and therefore complains about 'unicode' being undefined. This patch defines unicode as alias of str to make pyflakes3 happy, and as a side effect, simplifies type_is_str(). Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk and 2.10.
This commit is contained in:
parent
9a76e33e9b
commit
c8bc128039
@ -245,11 +245,12 @@ def user_perm(prof_dir):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
if sys.version_info[0] > 2:
|
||||||
|
unicode = str # python 3 dropped the unicode type. To keep type_is_str() simple (and pyflakes3 happy), re-create it as alias of str.
|
||||||
|
|
||||||
def type_is_str(var):
|
def type_is_str(var):
|
||||||
''' returns True if the given variable is a str (or unicode string when using python 2)'''
|
''' returns True if the given variable is a str (or unicode string when using python 2)'''
|
||||||
if type(var) == str:
|
if type(var) in [str, unicode]: # python 2 sometimes uses the 'unicode' type
|
||||||
return True
|
|
||||||
elif sys.version_info[0] < 3 and type(var) == unicode: # python 2 sometimes uses the 'unicode' type
|
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user