Python 3: use __code__ instead of func_code

The former works with both Python 2 and 3.

Change-Id: Id2f6d313bf90777e02b20b7f6f4fb99e79e85aff
Blueprint: neutron-python3
This commit is contained in:
Cyril Roelandt 2015-08-21 11:20:27 +02:00
parent 40576ae09c
commit 4af5ee82e3
3 changed files with 5 additions and 4 deletions

View File

@ -50,7 +50,7 @@ def filter_fields(f):
fields = kwargs.get('fields')
if not fields:
try:
pos = f.func_code.co_varnames.index('fields')
pos = f.__code__.co_varnames.index('fields')
fields = args[pos]
except (IndexError, ValueError):
return result

View File

@ -160,9 +160,9 @@ class L2DevicePluginBase(object):
fn_obj = base.__dict__[method]
if inspect.isfunction(fn_obj):
abstract_fn_obj = cls.__dict__[method]
arg_count = fn_obj.func_code.co_argcount
arg_count = fn_obj.__code__.co_argcount
expected_arg_count = \
abstract_fn_obj.func_code.co_argcount
abstract_fn_obj.__code__.co_argcount
method_ok = arg_count == expected_arg_count
if method_ok:
continue

View File

@ -253,7 +253,8 @@ commands = python -m testtools.run \
neutron.tests.unit.ipam.test_requests \
neutron.tests.unit.notifiers.test_nova \
neutron.tests.unit.notifiers.test_batch_notifier \
neutron.tests.unit.api.test_extensions
neutron.tests.unit.api.test_extensions \
neutron.tests.unit.db.test_db_base_plugin_common
[flake8]
# E125 continuation line does not distinguish itself from next logical line