Commit c88b58ee authored by Stefan Behnel's avatar Stefan Behnel

fix some pylint findings

parent 3d47a980
...@@ -40,7 +40,7 @@ try: ...@@ -40,7 +40,7 @@ try:
except ImportError: except ImportError:
from builtins import str as basestring from builtins import str as basestring
KEYWORDS_MUST_BE_BYTES = sys.version_info < (2,7) KEYWORDS_MUST_BE_BYTES = sys.version_info < (2, 7)
non_portable_builtins_map = { non_portable_builtins_map = {
...@@ -392,12 +392,12 @@ class UtilityCode(UtilityCodeBase): ...@@ -392,12 +392,12 @@ class UtilityCode(UtilityCodeBase):
requires = [r.specialize(data) for r in self.requires] requires = [r.specialize(data) for r in self.requires]
s = self._cache[key] = UtilityCode( s = self._cache[key] = UtilityCode(
self.none_or_sub(self.proto, data), self.none_or_sub(self.proto, data),
self.none_or_sub(self.impl, data), self.none_or_sub(self.impl, data),
self.none_or_sub(self.init, data), self.none_or_sub(self.init, data),
self.none_or_sub(self.cleanup, data), self.none_or_sub(self.cleanup, data),
requires, requires,
self.proto_block) self.proto_block)
self.specialize_list.append(s) self.specialize_list.append(s)
return s return s
...@@ -481,7 +481,7 @@ class UtilityCode(UtilityCodeBase): ...@@ -481,7 +481,7 @@ class UtilityCode(UtilityCodeBase):
is_specialised1, impl = self.inject_string_constants(impl, output) is_specialised1, impl = self.inject_string_constants(impl, output)
is_specialised2, impl = self.inject_unbound_methods(impl, output) is_specialised2, impl = self.inject_unbound_methods(impl, output)
writer = output['utility_code_def'] writer = output['utility_code_def']
writer.putln("/* %s */" % self.name); writer.putln("/* %s */" % self.name)
if not (is_specialised1 or is_specialised2): if not (is_specialised1 or is_specialised2):
# no module specific adaptations => can be reused # no module specific adaptations => can be reused
writer.put_or_include(impl, '%s_impl' % self.name) writer.put_or_include(impl, '%s_impl' % self.name)
...@@ -773,8 +773,8 @@ class FunctionState(object): ...@@ -773,8 +773,8 @@ class FunctionState(object):
"""Return a list of (cname, type) tuples of refcount-managed Python objects. """Return a list of (cname, type) tuples of refcount-managed Python objects.
""" """
return [(cname, type) return [(cname, type)
for cname, type, manage_ref, static in self.temps_allocated for cname, type, manage_ref, static in self.temps_allocated
if manage_ref] if manage_ref]
def all_free_managed_temps(self): def all_free_managed_temps(self):
"""Return a list of (cname, type) tuples of refcount-managed Python """Return a list of (cname, type) tuples of refcount-managed Python
...@@ -849,7 +849,7 @@ class StringConst(object): ...@@ -849,7 +849,7 @@ class StringConst(object):
def add_py_version(self, version): def add_py_version(self, version):
if not version: if not version:
self.py_versions = [2,3] self.py_versions = [2, 3]
elif version not in self.py_versions: elif version not in self.py_versions:
self.py_versions.append(version) self.py_versions.append(version)
...@@ -1280,8 +1280,8 @@ class GlobalState(object): ...@@ -1280,8 +1280,8 @@ class GlobalState(object):
self.generate_object_constant_decls() self.generate_object_constant_decls()
def generate_object_constant_decls(self): def generate_object_constant_decls(self):
consts = [ (len(c.cname), c.cname, c) consts = [(len(c.cname), c.cname, c)
for c in self.py_constants ] for c in self.py_constants]
consts.sort() consts.sort()
decls_writer = self.parts['decls'] decls_writer = self.parts['decls']
for _, cname, c in consts: for _, cname, c in consts:
...@@ -1345,12 +1345,11 @@ class GlobalState(object): ...@@ -1345,12 +1345,11 @@ class GlobalState(object):
py_strings.sort() py_strings.sort()
w = self.parts['pystring_table'] w = self.parts['pystring_table']
w.putln("") w.putln("")
w.putln("static __Pyx_StringTabEntry %s[] = {" % w.putln("static __Pyx_StringTabEntry %s[] = {" % Naming.stringtab_cname)
Naming.stringtab_cname)
for c_cname, _, py_string in py_strings: for c_cname, _, py_string in py_strings:
if not py_string.is_str or not py_string.encoding or \ if not py_string.is_str or not py_string.encoding or \
py_string.encoding in ('ASCII', 'USASCII', 'US-ASCII', py_string.encoding in ('ASCII', 'USASCII', 'US-ASCII',
'UTF8', 'UTF-8'): 'UTF8', 'UTF-8'):
encoding = '0' encoding = '0'
else: else:
encoding = '"%s"' % py_string.encoding.lower() encoding = '"%s"' % py_string.encoding.lower()
...@@ -1359,8 +1358,7 @@ class GlobalState(object): ...@@ -1359,8 +1358,7 @@ class GlobalState(object):
"static PyObject *%s;" % py_string.cname) "static PyObject *%s;" % py_string.cname)
if py_string.py3str_cstring: if py_string.py3str_cstring:
w.putln("#if PY_MAJOR_VERSION >= 3") w.putln("#if PY_MAJOR_VERSION >= 3")
w.putln( w.putln("{&%s, %s, sizeof(%s), %s, %d, %d, %d}," % (
"{&%s, %s, sizeof(%s), %s, %d, %d, %d}," % (
py_string.cname, py_string.cname,
py_string.py3str_cstring.cname, py_string.py3str_cstring.cname,
py_string.py3str_cstring.cname, py_string.py3str_cstring.cname,
...@@ -1368,8 +1366,7 @@ class GlobalState(object): ...@@ -1368,8 +1366,7 @@ class GlobalState(object):
py_string.intern py_string.intern
)) ))
w.putln("#else") w.putln("#else")
w.putln( w.putln("{&%s, %s, sizeof(%s), %s, %d, %d, %d}," % (
"{&%s, %s, sizeof(%s), %s, %d, %d, %d}," % (
py_string.cname, py_string.cname,
c_cname, c_cname,
c_cname, c_cname,
......
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