[entropy.const] add const_get_int() and use it in const_convert_to_unicode
This commit is contained in:
@@ -1258,7 +1258,7 @@ def const_convert_to_unicode(obj, enctype = 'raw_unicode_escape'):
|
||||
return unicode("None")
|
||||
|
||||
# int support
|
||||
if isinstance(obj, int):
|
||||
if isinstance(obj, const_get_int()):
|
||||
if sys.hexversion >= 0x3000000:
|
||||
return str(obj)
|
||||
else:
|
||||
@@ -1319,6 +1319,17 @@ def const_get_buffer():
|
||||
else:
|
||||
return buffer
|
||||
|
||||
def const_get_int():
|
||||
"""
|
||||
Return generic int object (supporting both Python 2.x and Python 3.x).
|
||||
For Python 2.x a (long, int) tuple is returned.
|
||||
For Python 3.x a (int,) tuple is returned.
|
||||
"""
|
||||
if sys.hexversion >= 0x3000000:
|
||||
return (int,)
|
||||
else:
|
||||
return (long, int,)
|
||||
|
||||
def const_isfileobj(obj):
|
||||
"""
|
||||
Return whether obj is a file object
|
||||
|
||||
Reference in New Issue
Block a user