inconsistent tabs and spaces

Bug #1501732 reported by Carsten Burgard
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MadGraph5_aMC@NLO
Fix Released
Undecided
Unassigned

Bug Description

In MadGraph 2.2.3 and possible other versions, some source files (most notably "iolibs/drawing_eps.py") use tabs and spaces inconsistently. When running python with the "-tt" option, this causes the error message "TabError: inconsistent use of tabs and spaces in indentation". A fix of this should be trivially possible by replacing all tabs with 8 spaces in the source code, reflecting the default behavior of the python interpreter.

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote : Re: [Bug 1501732] [NEW] inconsistent tabs and spaces

Dear Carsten,

I was not aware of that syntax, this is a cool option.
To my understanding a tab in python is not equal to 8 space. So I do not think that you can apply such change blindly.

I will try to correct one file a day but not promise.
The idea would be to force the -tt for all run in the development version in the future.

Cheers,

Olivier

On 01 Oct 2015, at 12:45, Carsten Burgard <email address hidden> wrote:

> Public bug reported:
>
> In MadGraph 2.2.3 and possible other versions, some source files (most
> notably "iolibs/drawing_eps.py") use tabs and spaces inconsistently.
> When running python with the "-tt" option, this causes the error message
> "TabError: inconsistent use of tabs and spaces in indentation". A fix of
> this should be trivially possible by replacing all tabs with 8 spaces in
> the source code, reflecting the default behavior of the python
> interpreter.
>
> ** Affects: mg5amcnlo
> Importance: Undecided
> Status: New
>
> --
> You received this bug notification because you are subscribed to
> MadGraph5_aMC@NLO.
> https://bugs.launchpad.net/bugs/1501732
>
> Title:
> inconsistent tabs and spaces
>
> Status in MadGraph5_aMC@NLO:
> New
>
> Bug description:
> In MadGraph 2.2.3 and possible other versions, some source files (most
> notably "iolibs/drawing_eps.py") use tabs and spaces inconsistently.
> When running python with the "-tt" option, this causes the error
> message "TabError: inconsistent use of tabs and spaces in
> indentation". A fix of this should be trivially possible by replacing
> all tabs with 8 spaces in the source code, reflecting the default
> behavior of the python interpreter.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/mg5amcnlo/+bug/1501732/+subscriptions

Changed in mg5amcnlo:
status: New → Won't Fix
Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote : Re: [Bug 1501732] inconsistent tabs and spaces

Actually,

the -tt option do not raise to any crashed for the iolibs/drawing_eps.py file.

It leads to some crash in some other files where a given line has both tab and space, but for line
with only space (like a couple have in iolibs/drawing_eps.py) that -tt do not make the code to crash.

Cheers,

Olivier

On 01 Oct 2015, at 13:57, Olivier Mattelaer <email address hidden> wrote:

> Dear Carsten,
>
> I was not aware of that syntax, this is a cool option.
> To my understanding a tab in python is not equal to 8 space. So I do not think that you can apply such change blindly.
>
> I will try to correct one file a day but not promise.
> The idea would be to force the -tt for all run in the development version in the future.
>
> Cheers,
>
> Olivier
>
>
> On 01 Oct 2015, at 12:45, Carsten Burgard <email address hidden> wrote:
>
>> Public bug reported:
>>
>> In MadGraph 2.2.3 and possible other versions, some source files (most
>> notably "iolibs/drawing_eps.py") use tabs and spaces inconsistently.
>> When running python with the "-tt" option, this causes the error message
>> "TabError: inconsistent use of tabs and spaces in indentation". A fix of
>> this should be trivially possible by replacing all tabs with 8 spaces in
>> the source code, reflecting the default behavior of the python
>> interpreter.
>>
>> ** Affects: mg5amcnlo
>> Importance: Undecided
>> Status: New
>>
>> --
>> You received this bug notification because you are subscribed to
>> MadGraph5_aMC@NLO.
>> https://bugs.launchpad.net/bugs/1501732
>>
>> Title:
>> inconsistent tabs and spaces
>>
>> Status in MadGraph5_aMC@NLO:
>> New
>>
>> Bug description:
>> In MadGraph 2.2.3 and possible other versions, some source files (most
>> notably "iolibs/drawing_eps.py") use tabs and spaces inconsistently.
>> When running python with the "-tt" option, this causes the error
>> message "TabError: inconsistent use of tabs and spaces in
>> indentation". A fix of this should be trivially possible by replacing
>> all tabs with 8 spaces in the source code, reflecting the default
>> behavior of the python interpreter.
>>
>> To manage notifications about this bug go to:
>> https://bugs.launchpad.net/mg5amcnlo/+bug/1501732/+subscriptions
>
>
> ** Changed in: mg5amcnlo
> Status: New => Won't Fix
>
> --
> You received this bug notification because you are subscribed to
> MadGraph5_aMC@NLO.
> https://bugs.launchpad.net/bugs/1501732
>
> Title:
> inconsistent tabs and spaces
>
> Status in MadGraph5_aMC@NLO:
> Won't Fix
>
> Bug description:
> In MadGraph 2.2.3 and possible other versions, some source files (most
> notably "iolibs/drawing_eps.py") use tabs and spaces inconsistently.
> When running python with the "-tt" option, this causes the error
> message "TabError: inconsistent use of tabs and spaces in
> indentation". A fix of this should be trivially possible by replacing
> all tabs with 8 spaces in the source code, reflecting the default
> behavior of the python interpreter.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/mg5amcnlo/+bug/1501732/+subscriptions

Revision history for this message
Carsten Burgard (cburgard) wrote :

Hi Olivier!

Thanks for the quick response. If one trusts the web, tabs are equal to 8 spaces in python2, see e.g.

http://stackoverflow.com/questions/2034517/pythons-interpretation-of-tabs-and-spaces-to-indent
https://books.google.de/books?id=6TEcaEzA8N0C&lpg=PA30&ots=mi_KgUaLiS&dq=python%20interpreter%208%20spaces&pg=PA30#v=onepage&q&f=false

Actually, this issue is of some importance, as some runtime environments (most specifically, the ATLAS environment deployed on the CERN grid) requires code to be run with the "-tt" option enabled.

Regards,
Carsten

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote : Re: [Bug 1501732] Re: inconsistent tabs and spaces

Dear Carsten,

> http://stackoverflow.com/questions/2034517/pythons-interpretation-of-tabs-and-spaces-to-indent
> https://books.google.de/books?id=6TEcaEzA8N0C&lpg=PA30&ots=mi_KgUaLiS&dq=python%20interpreter%208%20spaces&pg=PA30#v=onepage&q&f=false

Oh that was a subtleties that I was not aware of. This is really cool to know that.

I still do not trust automatic change, so I have made the change in a semi-automatic way and pushed the changed in our current development version.
I have also added -tt in some of the way to launch the code, such that this options will be checked on a more regular basis.

Thanks,

Olivier

PS: For the sanity of documentation (mainly for me)
Here is the code that I use for doing that:

find . -name ‘*.py' -type f -exec bash change.sh {}>> all_change.txt \;;

and change.sh

echo $1
perl -p -e 's/^( *)\t/\1 /g' $1 > /tmp/e1
perl -p -e 's/^( *)\t/\1 /g' /tmp/e1 > /tmp/e2
perl -p -e 's/^( *)\t/\1 /g' /tmp/e2 > /tmp/e3
perl -p -e 's/^( *)\t/\1 /g' /tmp/e3 > /tmp/e4
perl -p -e 's/^( *)\t/\1 /g' /tmp/e4 > /tmp/e5
perl -p -e 's/^( *)\t/\1 /g' /tmp/e5 > /tmp/e6
perl -p -e 's/^( *)\t/\1 /g' /tmp/e6 > /tmp/e7
diff /tmp/e7 $1
#mv /tmp/e7 $1

One point to improve if this code is reused is the right of the file who are not preserve by this operation.

On 01 Oct 2015, at 14:39, Carsten Burgard <email address hidden> wrote:

> Hi Olivier!
>
> Thanks for the quick response. If one trusts the web, tabs are equal to
> 8 spaces in python2, see e.g.
>
> http://stackoverflow.com/questions/2034517/pythons-interpretation-of-tabs-and-spaces-to-indent
> https://books.google.de/books?id=6TEcaEzA8N0C&lpg=PA30&ots=mi_KgUaLiS&dq=python%20interpreter%208%20spaces&pg=PA30#v=onepage&q&f=false
>
> Actually, this issue is of some importance, as some runtime environments
> (most specifically, the ATLAS environment deployed on the CERN grid)
> requires code to be run with the "-tt" option enabled.
>
> Regards,
> Carsten
>
> --
> You received this bug notification because you are subscribed to
> MadGraph5_aMC@NLO.
> https://bugs.launchpad.net/bugs/1501732
>
> Title:
> inconsistent tabs and spaces
>
> Status in MadGraph5_aMC@NLO:
> Won't Fix
>
> Bug description:
> In MadGraph 2.2.3 and possible other versions, some source files (most
> notably "iolibs/drawing_eps.py") use tabs and spaces inconsistently.
> When running python with the "-tt" option, this causes the error
> message "TabError: inconsistent use of tabs and spaces in
> indentation". A fix of this should be trivially possible by replacing
> all tabs with 8 spaces in the source code, reflecting the default
> behavior of the python interpreter.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/mg5amcnlo/+bug/1501732/+subscriptions

Changed in mg5amcnlo:
status: Won't Fix → Fix Committed
Changed in mg5amcnlo:
status: Fix Committed → 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.