[pylint] - Fix a potential AttributeError when checking for `reversed` arguments. https://bitbucket.org/log
Brian C. Lane
bcl at fedoraproject.org
Sat May 10 01:20:03 UTC 2014
commit 72897eab233f49cee88c4f709f406250736d817b
Author: Brian C. Lane <bcl at redhat.com>
Date: Fri May 9 18:20:11 2014 -0700
- Fix a potential AttributeError when checking for `reversed` arguments.
https://bitbucket.org/logilab/pylint/commits/93babaf6bffc59a49c75319d9850086b4935edbc
fix-attributeerror.patch | 48 ++++++++++++++++++++++++++++++++++++++++++++++
pylint.spec | 8 ++++++-
2 files changed, 55 insertions(+), 1 deletions(-)
---
diff --git a/fix-attributeerror.patch b/fix-attributeerror.patch
new file mode 100644
index 0000000..8fb5a6e
--- /dev/null
+++ b/fix-attributeerror.patch
@@ -0,0 +1,48 @@
+# HG changeset patch
+# User cpopa
+# Date 1398421037 -10800
+# Node ID 93babaf6bffc59a49c75319d9850086b4935edbc
+# Parent 0b8a45e6ff1a73e2b4dbbf4d2b7b45c596d95e9a
+Fix a potential AttributeError when checking for `reversed` arguments.
+
+diff --git a/checkers/base.py b/checkers/base.py
+--- a/checkers/base.py
++++ b/checkers/base.py
+@@ -785,11 +785,14 @@
+ if argument is None:
+ # nothing was infered
+ # try to see if we have iter()
+- if (isinstance(node.args[0], astroid.CallFunc) and
+- node.args[0].func.name == 'iter'):
+- func = node.args[0].func.infer().next()
+- if is_builtin_object(func):
+- self.add_message('bad-reversed-sequence', node=node)
++ if isinstance(node.args[0], astroid.CallFunc):
++ try:
++ func = node.args[0].func.infer().next()
++ except InferenceError:
++ return
++ if (getattr(func, 'name', None) == 'iter' and
++ is_builtin_object(func)):
++ self.add_message('bad-reversed-sequence', node=node)
+ return
+
+ if isinstance(argument, astroid.Instance):
+diff --git a/test/input/func_bad_reversed_sequence.py b/test/input/func_bad_reversed_sequence.py
+--- a/test/input/func_bad_reversed_sequence.py
++++ b/test/input/func_bad_reversed_sequence.py
+@@ -37,7 +37,7 @@
+ """
+ return reversed(seq)
+
+-def test():
++def test(path):
+ """ test function """
+ seq = reversed()
+ seq = reversed(None)
+@@ -56,4 +56,5 @@
+ seq = reversed(deque([]))
+ seq = reversed("123")
+ seq = uninferable([1, 2, 3])
++ seq = reversed(path.split("/"))
+ return seq
diff --git a/pylint.spec b/pylint.spec
index c2c61c8..2d4bd06 100644
--- a/pylint.spec
+++ b/pylint.spec
@@ -10,7 +10,7 @@
Name: pylint
Version: 1.2
-Release: 3%{?dist}
+Release: 4%{?dist}
Summary: Analyzes Python code looking for bugs and signs of poor quality
Group: Development/Debuggers
License: GPLv2+
@@ -18,6 +18,7 @@ URL: http://www.pylint.org/
Source0: https://bitbucket.org/logilab/pylint/get/pylint-%{version}.tar.bz2
Patch0: init_hook.patch
Patch1: fix-explicit-check-of-python-script.patch
+Patch2: fix-attributeerror.patch
BuildArch: noarch
BuildRequires: python-devel python-setuptools python-tools
@@ -82,6 +83,7 @@ This package provides a gui tool for pylint written in tkinter.
%setup -q -n logilab-pylint-%{commit}
%patch0 -p1
%patch1 -p1
+%patch2 -p1
%if 0%{?with_python3}
rm -rf %{py3dir}
@@ -164,6 +166,10 @@ popd
%endif # with_python3
%changelog
+* Fri May 09 2014 Brian C. Lane <bcl at redhat.com> 1.2-4
+- Fix a potential AttributeError when checking for `reversed` arguments.
+ https://bitbucket.org/logilab/pylint/commits/93babaf6bffc59a49c75319d9850086b4935edbc
+
* Thu May 08 2014 Brian C. Lane <bcl at redhat.com> 1.2-3
- fix explicit check of python script
https://bitbucket.org/logilab/pylint/issue/219/
More information about the scm-commits
mailing list