You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
We've integrated your pep8 module in the unit tests of our Django CMS application.
The module is very convenient but we've found a bug with the --exclude option on the version 0.6.1 of pep8.
It occurs when we try to exclude two dirs which are alphabetically next to each other.
This is because the dirs.remove(subdir) of the input_dir method is modifying the sequence being iterated.
This isn't safe as stated in the Python documentation: http://docs.python.org/tutorial/controlflow.html#for-statements
This example illustrate the bug, where "dir2" doesn't get ignored like it should:
$ find . -type f
./dir1/invalid.py
./dir2/invalid.py
$ pep8 .
./dir1/invalid.py:1:1: W391 blank line at end of file
./dir1/invalid.py:1:1: W293 blank line contains whitespace
$ pep8 --exclude dir1,dir2 .
./dir2/invalid.py:1:1: W391 blank line at end of file
./dir2/invalid.py:1:1: W293 blank line contains whitespace
$
Making a slice copy of the entire list as suggested in the above documentation works as a patch.
--- pep8.py 2012-01-19 00:23:57.790219545 +0100
+++ pep8.py.new 2012-01-19 00:25:30.094222777 +0100
@@ -1041,7 +1041,7 @@
message('directory ' + root)
options.counters['directories'] += 1
dirs.sort()
- for subdir in dirs:
+ for subdir in dirs[:]:
if excluded(subdir):
dirs.remove(subdir)
files.sort()
After applying the patch both dir1 and dir2 get ignored as expected:
$ pep8 --exclude dir1,dir2 .
$
The text was updated successfully, but these errors were encountered:
Hi,
We've integrated your pep8 module in the unit tests of our Django CMS application.
The module is very convenient but we've found a bug with the
--exclude
option on the version 0.6.1 of pep8.It occurs when we try to exclude two dirs which are alphabetically next to each other.
This is because the
dirs.remove(subdir)
of theinput_dir
method is modifying the sequence being iterated.This isn't safe as stated in the Python documentation:
http://docs.python.org/tutorial/controlflow.html#for-statements
This example illustrate the bug, where "dir2" doesn't get ignored like it should:
Making a slice copy of the entire list as suggested in the above documentation works as a patch.
After applying the patch both dir1 and dir2 get ignored as expected:
The text was updated successfully, but these errors were encountered: