Commit f5d3befd authored by Wojciech Bielawski's avatar Wojciech Bielawski Committed by Chromium LUCI CQ

Assure python3 compatibility with 'long' type.

Python 3 doesn't define 'long', but has 'int' type capable to store
python's 2 'long' values.
In addition most of places where 'long' is used seems to be not relevant,
so 'long' can be relpacled with 'int' anyhow.

Bug: 1168119
Change-Id: I971ea9044ce6dc5f084df122ba6d2571a8bb68cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2640256Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845965}
parent a018bf65
...@@ -674,7 +674,7 @@ def make_v8_to_blink_value_variadic(blink_var_name, v8_array, ...@@ -674,7 +674,7 @@ def make_v8_to_blink_value_variadic(blink_var_name, v8_array,
""" """
assert isinstance(blink_var_name, str) assert isinstance(blink_var_name, str)
assert isinstance(v8_array, str) assert isinstance(v8_array, str)
assert isinstance(v8_array_start_index, (int, long)) assert isinstance(v8_array_start_index, int)
assert isinstance(idl_type, web_idl.IdlType) assert isinstance(idl_type, web_idl.IdlType)
pattern = ("auto&& ${{{_1}}} = " pattern = ("auto&& ${{{_1}}} = "
......
...@@ -503,13 +503,13 @@ class CompositeNode(CodeNode): ...@@ -503,13 +503,13 @@ class CompositeNode(CodeNode):
gensym_kwargs = {} gensym_kwargs = {}
template_vars = {} template_vars = {}
for arg in args: for arg in args:
assert isinstance(arg, (CodeNode, int, long, str)) assert isinstance(arg, (CodeNode, int, str))
gensym = CodeNode.gensym() gensym = CodeNode.gensym()
gensym_args.append("${{{}}}".format(gensym)) gensym_args.append("${{{}}}".format(gensym))
template_vars[gensym] = arg template_vars[gensym] = arg
for key, value in kwargs.items(): for key, value in kwargs.items():
assert isinstance(key, (int, long, str)) assert isinstance(key, (int, str))
assert isinstance(value, (CodeNode, int, long, str)) assert isinstance(value, (CodeNode, int, str))
gensym = CodeNode.gensym() gensym = CodeNode.gensym()
gensym_kwargs[key] = "${{{}}}".format(gensym) gensym_kwargs[key] = "${{{}}}".format(gensym)
template_vars[gensym] = value template_vars[gensym] = value
...@@ -602,7 +602,7 @@ class ListNode(CodeNode): ...@@ -602,7 +602,7 @@ class ListNode(CodeNode):
def insert(self, index, node): def insert(self, index, node):
if node is None: if node is None:
return return
assert isinstance(index, (int, long)) assert isinstance(index, int)
assert isinstance(node, CodeNode) assert isinstance(node, CodeNode)
assert node.outer is None and node.prev is None assert node.outer is None and node.prev is None
......
...@@ -23,7 +23,7 @@ class _TemplateFormatter(string.Formatter): ...@@ -23,7 +23,7 @@ class _TemplateFormatter(string.Formatter):
self._template_formatter_indexing_count_ = 0 self._template_formatter_indexing_count_ = 0
def get_value(self, key, args, kwargs): def get_value(self, key, args, kwargs):
if isinstance(key, (int, long)): if isinstance(key, int):
return args[key] return args[key]
assert isinstance(key, str) assert isinstance(key, str)
if not key: if not key:
......
...@@ -583,7 +583,7 @@ def _make_blink_api_call(code_node, ...@@ -583,7 +583,7 @@ def _make_blink_api_call(code_node,
overriding_args=None): overriding_args=None):
assert isinstance(code_node, SymbolScopeNode) assert isinstance(code_node, SymbolScopeNode)
assert isinstance(cg_context, CodeGenContext) assert isinstance(cg_context, CodeGenContext)
assert num_of_args is None or isinstance(num_of_args, (int, long)) assert num_of_args is None or isinstance(num_of_args, int)
assert (overriding_args is None assert (overriding_args is None
or (isinstance(overriding_args, (list, tuple)) or (isinstance(overriding_args, (list, tuple))
and all(isinstance(arg, str) for arg in overriding_args))) and all(isinstance(arg, str) for arg in overriding_args)))
...@@ -4639,7 +4639,7 @@ class _PropEntryConstructorGroup(_PropEntryBase): ...@@ -4639,7 +4639,7 @@ class _PropEntryConstructorGroup(_PropEntryBase):
def __init__(self, is_context_dependent, exposure_conditional, world, def __init__(self, is_context_dependent, exposure_conditional, world,
constructor_group, ctor_callback_name, ctor_func_length): constructor_group, ctor_callback_name, ctor_func_length):
assert isinstance(ctor_callback_name, str) assert isinstance(ctor_callback_name, str)
assert isinstance(ctor_func_length, (int, long)) assert isinstance(ctor_func_length, int)
_PropEntryBase.__init__(self, is_context_dependent, _PropEntryBase.__init__(self, is_context_dependent,
exposure_conditional, world, constructor_group) exposure_conditional, world, constructor_group)
...@@ -4667,7 +4667,7 @@ class _PropEntryOperationGroup(_PropEntryBase): ...@@ -4667,7 +4667,7 @@ class _PropEntryOperationGroup(_PropEntryBase):
op_func_length, op_func_length,
no_alloc_direct_callback_name=None): no_alloc_direct_callback_name=None):
assert isinstance(op_callback_name, str) assert isinstance(op_callback_name, str)
assert isinstance(op_func_length, (int, long)) assert isinstance(op_func_length, int)
_PropEntryBase.__init__(self, is_context_dependent, _PropEntryBase.__init__(self, is_context_dependent,
exposure_conditional, world, operation_group) exposure_conditional, world, operation_group)
......
...@@ -171,8 +171,7 @@ class OverloadGroup(WithIdentifier): ...@@ -171,8 +171,7 @@ class OverloadGroup(WithIdentifier):
Returns the effective overload set. Returns the effective overload set.
https://heycam.github.io/webidl/#compute-the-effective-overload-set https://heycam.github.io/webidl/#compute-the-effective-overload-set
""" """
assert argument_count is None or isinstance(argument_count, assert argument_count is None or isinstance(argument_count, int)
(int, long))
N = argument_count N = argument_count
S = [] S = []
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import sys
from .argument import Argument from .argument import Argument
from .ast_group import AstGroup from .ast_group import AstGroup
from .attribute import Attribute from .attribute import Attribute
...@@ -30,6 +32,11 @@ from .operation import Operation ...@@ -30,6 +32,11 @@ from .operation import Operation
from .typedef import Typedef from .typedef import Typedef
# TODO: Remove this once Python2 is obsoleted.
if sys.version_info.major != 2:
long = int
def load_and_register_idl_definitions(filepaths, register_ir, def load_and_register_idl_definitions(filepaths, register_ir,
create_ref_to_idl_def, idl_type_factory): create_ref_to_idl_def, idl_type_factory):
""" """
......
...@@ -3,6 +3,13 @@ ...@@ -3,6 +3,13 @@
# found in the LICENSE file. # found in the LICENSE file.
import sys
# TODO: Remove this once Python2 is obsoleted.
if sys.version_info.major != 2:
long = int
def make_copy(obj, memo=None): def make_copy(obj, memo=None):
""" """
Creates a copy of the given object, which should be an IR or part of IR. Creates a copy of the given object, which should be an IR or part of IR.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment