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,
"""
assert isinstance(blink_var_name, 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)
pattern = ("auto&& ${{{_1}}} = "
......
......@@ -503,13 +503,13 @@ class CompositeNode(CodeNode):
gensym_kwargs = {}
template_vars = {}
for arg in args:
assert isinstance(arg, (CodeNode, int, long, str))
assert isinstance(arg, (CodeNode, int, str))
gensym = CodeNode.gensym()
gensym_args.append("${{{}}}".format(gensym))
template_vars[gensym] = arg
for key, value in kwargs.items():
assert isinstance(key, (int, long, str))
assert isinstance(value, (CodeNode, int, long, str))
assert isinstance(key, (int, str))
assert isinstance(value, (CodeNode, int, str))
gensym = CodeNode.gensym()
gensym_kwargs[key] = "${{{}}}".format(gensym)
template_vars[gensym] = value
......@@ -602,7 +602,7 @@ class ListNode(CodeNode):
def insert(self, index, node):
if node is None:
return
assert isinstance(index, (int, long))
assert isinstance(index, int)
assert isinstance(node, CodeNode)
assert node.outer is None and node.prev is None
......
......@@ -23,7 +23,7 @@ class _TemplateFormatter(string.Formatter):
self._template_formatter_indexing_count_ = 0
def get_value(self, key, args, kwargs):
if isinstance(key, (int, long)):
if isinstance(key, int):
return args[key]
assert isinstance(key, str)
if not key:
......
......@@ -583,7 +583,7 @@ def _make_blink_api_call(code_node,
overriding_args=None):
assert isinstance(code_node, SymbolScopeNode)
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
or (isinstance(overriding_args, (list, tuple))
and all(isinstance(arg, str) for arg in overriding_args)))
......@@ -4639,7 +4639,7 @@ class _PropEntryConstructorGroup(_PropEntryBase):
def __init__(self, is_context_dependent, exposure_conditional, world,
constructor_group, ctor_callback_name, ctor_func_length):
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,
exposure_conditional, world, constructor_group)
......@@ -4667,7 +4667,7 @@ class _PropEntryOperationGroup(_PropEntryBase):
op_func_length,
no_alloc_direct_callback_name=None):
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,
exposure_conditional, world, operation_group)
......
......@@ -171,8 +171,7 @@ class OverloadGroup(WithIdentifier):
Returns the effective overload set.
https://heycam.github.io/webidl/#compute-the-effective-overload-set
"""
assert argument_count is None or isinstance(argument_count,
(int, long))
assert argument_count is None or isinstance(argument_count, int)
N = argument_count
S = []
......
......@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import sys
from .argument import Argument
from .ast_group import AstGroup
from .attribute import Attribute
......@@ -30,6 +32,11 @@ from .operation import Operation
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,
create_ref_to_idl_def, idl_type_factory):
"""
......
......@@ -3,6 +3,13 @@
# 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):
"""
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