Port cinder.hacking to Python 3
Fix the N325 check on Python 3: the AST changed between Python 2 and Python 3 for try/except. tox.ini: Add cinder.tests.unit.test_hacking to Python 3.4. Partial-Implements: blueprint cinder-python3 Change-Id: I7c7d1c5e52f525ade14b13ecf2dec1681997da22
This commit is contained in:
parent
76c42fc70a
commit
9eea3951c7
@ -184,6 +184,7 @@ class CheckForStrUnicodeExc(BaseASTChecker):
|
||||
self.name = []
|
||||
self.already_checked = []
|
||||
|
||||
# Python 2
|
||||
def visit_TryExcept(self, node):
|
||||
for handler in node.handlers:
|
||||
if handler.name:
|
||||
@ -193,6 +194,15 @@ class CheckForStrUnicodeExc(BaseASTChecker):
|
||||
else:
|
||||
super(CheckForStrUnicodeExc, self).generic_visit(node)
|
||||
|
||||
# Python 3
|
||||
def visit_ExceptHandler(self, node):
|
||||
if node.name:
|
||||
self.name.append(node.name)
|
||||
super(CheckForStrUnicodeExc, self).generic_visit(node)
|
||||
self.name = self.name[:-1]
|
||||
else:
|
||||
super(CheckForStrUnicodeExc, self).generic_visit(node)
|
||||
|
||||
def visit_Call(self, node):
|
||||
if self._check_call_names(node, ['str', 'unicode']):
|
||||
if node not in self.already_checked:
|
||||
|
@ -62,6 +62,7 @@ cinder.tests.unit.test_evaluator
|
||||
cinder.tests.unit.test_exception
|
||||
cinder.tests.unit.test_glusterfs
|
||||
cinder.tests.unit.test_gpfs
|
||||
cinder.tests.unit.test_hacking
|
||||
cinder.tests.unit.test_hitachi_hbsd_horcm_fc
|
||||
cinder.tests.unit.test_hitachi_hbsd_snm2_fc
|
||||
cinder.tests.unit.test_hitachi_hbsd_snm2_iscsi
|
||||
|
Loading…
x
Reference in New Issue
Block a user