summaryrefslogtreecommitdiff
path: root/odoo/modules/module.py
diff options
context:
space:
mode:
authorxmo-odoo <xmo@odoo.com>2017-05-10 09:39:55 +0200
committerGitHub <noreply@github.com>2017-05-10 09:39:55 +0200
commitfffaf735f58f1ac57781c095eb552de6d1fcdc47 (patch)
tree88ab0ab65430d871862a836524e0ecc890d1674d /odoo/modules/module.py
parent10eee18a047d35305dc46282e610e88936d81ffc (diff)
[FIX] P3: list -> iterable builtins (#16811)
In Python 3: * various builtins and dict methods were changed to return view/iterable objects rather than lists * and the separate Python 2 view/iterable builtins and methods were removed altogether This is problematic when using these items as list (which the happens repeatedly in Odoo), but more viciously when iterating *multiple times* over them (which also happens, which I've messed up multiple times while writing this, and which is a pain to debug even when you've just created the issue). Convert all code using these to semantics-matching cross-version helper functions to get the LCD behaviour between P2 and P3, and forbid the builtins via lint. issue #8530
Diffstat (limited to 'odoo/modules/module.py')
-rw-r--r--odoo/modules/module.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/odoo/modules/module.py b/odoo/modules/module.py
index dd1485e1d8a..e6194a5fb10 100644
--- a/odoo/modules/module.py
+++ b/odoo/modules/module.py
@@ -23,6 +23,7 @@ import odoo
import odoo.tools as tools
import odoo.release as release
from odoo import SUPERUSER_ID, api
+from odoo.tools import pycompat
MANIFEST_NAMES = ('__manifest__.py', '__openerp__.py')
README = ['README.rst', 'README.md', 'README.txt']
@@ -323,7 +324,7 @@ def load_information_from_description_file(module, mod_path=None):
'sequence': 100,
'summary': '',
}
- info.update(itertools.izip(
+ info.update(pycompat.izip(
'depends data demo test init_xml update_xml demo_xml'.split(),
iter(list, None)))
@@ -395,7 +396,11 @@ def get_modules():
for mname in MANIFEST_NAMES:
if os.path.isfile(opj(dir, name, mname)):
return True
- return map(clean, filter(is_really_module, os.listdir(dir)))
+ return [
+ clean(it)
+ for it in os.listdir(dir)
+ if is_really_module(it)
+ ]
plist = []
initialize_sys_path()
@@ -492,7 +497,7 @@ def run_unit_tests(module_name, dbname, position=runs_at_install):
r = True
for m in mods:
tests = unwrap_suite(unittest.TestLoader().loadTestsFromModule(m))
- suite = unittest.TestSuite(itertools.ifilter(position, tests))
+ suite = unittest.TestSuite(t for t in tests if position(t))
if suite.countTestCases():
t0 = time.time()
@@ -532,5 +537,5 @@ def unwrap_suite(test):
return
for item in itertools.chain.from_iterable(
- itertools.imap(unwrap_suite, subtests)):
+ unwrap_suite(t) for t in subtests):
yield item