From: aq <aquynh@gmail.com>
To: Ian Pratt <m+Ian.Pratt@cl.cam.ac.uk>
Cc: xen-devel <xen-devel@lists.xensource.com>
Subject: Re: [PATCH] replace tabs with spaces of Python code
Date: Thu, 19 May 2005 10:09:18 +0900 [thread overview]
Message-ID: <9cde8bff05051818094bf1df12@mail.gmail.com> (raw)
In-Reply-To: <A95E2296287EAD4EB592B5DEEFCE0E9D1E40C9@liverpoolst.ad.cl.cam.ac.uk>
On 5/19/05, Ian Pratt <m+Ian.Pratt@cl.cam.ac.uk> wrote:
>
>
> > there are many Python codes in tools/ that mix tab and space
> > for indentation, which might introduce some silly and hidden
> > bugs. this is a serious problem and must be avoid at all cost.
> >
> > here is a patch (against cset 1.1452) to replace all tabs with spaces.
> > all the changes are pretty trivial, and i double checked everything.
> > please take a look to see if all the modifies are OK.
> >
> > Signed-off-by: Nguyen Anh Quynh <aquynh@gmail.com>
>
> Are you sure python interprets a tab as a 4 spaces? I thought it
> interpretted it as 8?
i investigated all the related code (not quite many), and they all use
4 spaces to indent. and in the above message, i didnt say that i
convert tab to 4 spaces, either. see below why.
>
> Hmm, there are a whole bunch of outstanding xend patches this this is
> going to create merge hell for, so I'm not sure we want to apply this
> straight away.
>
not many Python files mixed with tabs, and we can check to fix them
all. this should be cosidered bug, so no matter how hard it is, we
must fix it finally. we cannot avoid this.
mixing tabs and spaces is a *very* serious problem, if you care. when
i reviewed code in my editor (vim in this case), almost all lines
which have tabs dont look right to me. some even mislead me, and only
when i turn on the hidden chars (":set list" in vim), i realized that
there were tabs inside. ouch!
> Could you just post the script you used, or did you just do the obvious
> sed invocation?
>
actually, i did this job manually, with little help from one small
script. the reasons are:
- as you said, it is very dangeurous to do this kind of thing
automatically, so it is best to do it by hand
- the number of related files are not that many (21 files with nearly
150 related lines of code)
- some files use tab as 8 spaces, some use tab as 4 spaces, some even
mixed 4 and 8 spaces (checking by seeing the code structure). so it is
another reason not to do it automatically by a script.
Ian, it is a mistake if you dont get this patch. besides, the patch is
rather small, and you can check to see if it is OK.
below is a trivial script i used to indentify all tabs, so i dont miss
any thing. i post here, incase it is helpful for somebody.
regards,
aq
####
#! /usr/bin/env python
import sys, os
def main():
for filename in sys.argv[1:]:
if os.path.isdir(filename):
continue
data = open(filename, "rb").read()
if '\0' in data:
continue
if data.find("\t") != -1:
lines = data.split('\n')
print filename
n = 0
for l in lines:
n += 1
if l.find('\t') != -1:
print '\t', n, '\t', l
if __name__ == '__main__':
main()
next prev parent reply other threads:[~2005-05-19 1:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-18 20:06 [PATCH] replace tabs with spaces of Python code Ian Pratt
2005-05-18 20:21 ` Vincent Hanquez
2005-05-18 20:43 ` Anthony Liguori
2005-05-19 1:09 ` aq [this message]
-- strict thread matches above, loose matches on Subject: below --
2005-05-19 1:28 Ian Pratt
2005-05-19 2:40 ` aq
2005-05-19 9:17 ` Christian Limpach
2005-05-19 11:49 ` aq
2005-05-19 17:53 ` David Hopwood
2005-05-18 18:58 aq
2005-05-18 19:59 ` Jacob Gorm Hansen
2005-05-19 0:48 ` aq
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9cde8bff05051818094bf1df12@mail.gmail.com \
--to=aquynh@gmail.com \
--cc=m+Ian.Pratt@cl.cam.ac.uk \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.