AttributeError: 'Checker' object has no attribute 'blank_before'

Bug #1429521 reported by Nobuto Murata
24
This bug affects 5 people
Affects Status Importance Assigned to Milestone
One Hundred Papercuts
Fix Released
High
Unassigned
pep8 (Debian)
Fix Released
Unknown
pep8 (Ubuntu)
Fix Released
High
Unassigned

Bug Description

If python3-hacking package is installed, python3-flake8 always returns AttributeError: 'Checker' object has no attribute 'blank_before'.

$ cat foo.py
#!/usr/bin/python3

pass

$ python3 -m flake8 -vv foo.py
checking foo.py
pass
Traceback (most recent call last):
  File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3/dist-packages/flake8/__main__.py", line 4, in <module>
    main()
  File "/usr/lib/python3/dist-packages/flake8/main.py", line 32, in main
    report = flake8_style.check_files()
  File "/usr/lib/python3/dist-packages/pep8.py", line 1624, in check_files
    runner(path)
  File "/usr/lib/python3/dist-packages/flake8/engine.py", line 83, in input_file
    return fchecker.check_all(expected=expected, line_offset=line_offset)
  File "/usr/lib/python3/dist-packages/pep8.py", line 1393, in check_all
    self.check_logical()
  File "/usr/lib/python3/dist-packages/pep8.py", line 1327, in check_logical
    for result in self.run_check(check, argument_names):
  File "/usr/lib/python3/dist-packages/pep8.py", line 1256, in run_check
    arguments.append(getattr(self, name))
AttributeError: 'Checker' object has no attribute 'blank_before'

ProblemType: Bug
DistroRelease: Ubuntu 15.04
Package: python3-flake8 2.2.2-1ubuntu1
ProcVersionSignature: Ubuntu 3.19.0-7.7-generic 3.19.0
Uname: Linux 3.19.0-7-generic x86_64
ApportVersion: 2.16.2-0ubuntu1
Architecture: amd64
CurrentDesktop: Unity
Date: Sun Mar 8 15:15:00 2015
EcryptfsInUse: Yes
InstallationDate: Installed on 2015-02-28 (7 days ago)
InstallationMedia: Ubuntu 15.04 "Vivid Vervet" - Alpha amd64 (20150228)
SourcePackage: python-flake8
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Nobuto Murata (nobuto) wrote :
Revision history for this message
Hans Joachim Desserud (hjd) wrote :

Thanks for taking your time to report this issue and help making Ubuntu better.

I was not able to reproduce this issue when I tested on an up-to-date Vivid system:
$ python3 -m flake8 -vv foo.py
checking foo.py
pass

Looks like the underlying problem occurs when it calls pep8, which version of pep8 do you have installed?

$ apt-cache policy python3-flake8
python3-flake8:
  Installed: 2.2.2-1ubuntu1
  Candidate: 2.2.2-1ubuntu1
  Version table:
 *** 2.2.2-1ubuntu1 0
        500 http://no.archive.ubuntu.com/ubuntu/ vivid/main amd64 Packages
        100 /var/lib/dpkg/status

$ apt-cache policy python3-pep8
python3-pep8:
  Installed: 1.5.7-2
  Candidate: 1.5.7-2
  Version table:
 *** 1.5.7-2 0
        500 http://no.archive.ubuntu.com/ubuntu/ vivid/main amd64 Packages
        100 /var/lib/dpkg/status

Revision history for this message
Nobuto Murata (nobuto) wrote :

Hi,
I've checked it again with a fresh LXC container of vivid. The issue is still reproducible with the same version as you posted.
python3-flake8: 2.2.2-1ubuntu1
python3-pep8: 1.5.7-2

Interestingly executing pep8 alone does not output any errors.

$ python3 -m pep8 -vv foo.py
checking foo.py
pass

$ python3 -m flake8 -vv foo.py
<the same traceback>

Revision history for this message
Nobuto Murata (nobuto) wrote :

ah, the traceback occurs only if python3-hacking package is installed.

description: updated
description: updated
affects: python-flake8 (Ubuntu) → python-hacking (Ubuntu)
Revision history for this message
Hans Joachim Desserud (hjd) wrote :

Thanks for investigating. After installing python3-hacking I get the same stack trace.

Changed in python-flake8 (Ubuntu):
status: New → Confirmed
Changed in python-hacking (Ubuntu):
status: New → Confirmed
Changed in hundredpapercuts:
status: New → Confirmed
Changed in python-hacking (Ubuntu):
importance: Undecided → High
Changed in python-flake8 (Ubuntu):
importance: Undecided → High
Changed in hundredpapercuts:
importance: Undecided → High
Revision history for this message
Felipe Reyes (freyes) wrote :

Hi,

I'm hitting this problem and started troubleshooting to find a root cause, and I found something I don't understand. This is the output I receive in a clean Vivid environment:

root@vivid:~# dpkg -l python3-pep8 pep8
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-====================-===============-===============-==============================================
ii pep8 1.5.7-2 all Python PEP 8 code style checker - python2
ii python3-pep8 1.5.7-2 all Python PEP 8 code style checker - python3
root@vivid:~# python -c "import pep8; print(pep8.__version__)"
1.5.7
root@vivid:~# python -c "import pep8; print(pep8.__file__)"
/usr/lib/python2.7/dist-packages/pep8.pyc
root@vivid:~# python3 -c "import pep8; print(pep8.__version__)"
1.4.6
root@vivid:~# python3 -c "import pep8; print(pep8.__file__)"
/usr/lib/python3/dist-packages/pep8.py

Why pep8 for python3 is version 1.4.6 while for python2 is 1.5.7?

Here is the output of "diff -u /usr/lib/python3/dist-packages/pep8.py /usr/lib/python2.7/dist-packages/pep8.py" (see attachment) which I would expect to be just a few lines (the shebang, maybe a timestamp and that's it), but it's not, files are completely different.

$ diffstat /tmp/py3-py2.diff
 pep8.py | 700 ++++++++++++++++++++++++++++++++++------------------------------
 1 file changed, 382 insertions(+), 318 deletions(-)

Revision history for this message
Felipe Reyes (freyes) wrote :
Revision history for this message
Felipe Reyes (freyes) wrote :

This bug is debian is related https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=788132 , I provided a patch to fix the issue in debian. Using the patched version I could run without problems the test cases provided by Nobuto

Basically a file is being added (build/lib/pep8.py) by the debian diff and that version seems to be a leftover from a previous version.

Nobuto Murata (nobuto)
affects: python-flake8 (Ubuntu) → pep8 (Ubuntu)
no longer affects: python-hacking (Ubuntu)
Changed in pep8 (Debian):
status: Unknown → New
Changed in pep8 (Debian):
status: New → Fix Released
Revision history for this message
Hans Joachim Desserud (hjd) wrote :

Looks like the Debian bug resolved this issue. I'm no longer able to reproduce it with pep8 1.6.2-0.1 on Ubuntu 15.10 or later versions.

Changed in pep8 (Ubuntu):
status: Confirmed → Fix Released
Changed in hundredpapercuts:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.