[Patches] [ python-Patches-572113 ] Remove import string in Tools/ directory
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 12 Sep 2002 02:58:55 -0700
Patches item #572113, was opened at 2002-06-21 16:52
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=572113&group_id=5470
Category: Library (Lib)
Group: Python 2.3
>Status: Closed
Resolution: Accepted
Priority: 5
Submitted By: Walter Dörwald (doerwalter)
Assigned to: Walter Dörwald (doerwalter)
Summary: Remove import string in Tools/ directory
Initial Comment:
This patch replace string module functions with string
methods and removes the "import string" for the stuff
in the Tools directory. A few "import string"
statements are still remaining:
scripts/texi2html.py still uses string.ascii_letters,
string.digits, etc.
modulator/modulator.py still uses string.letters and
string.digits
freeze/win32.html still mentions the string module
idle/AutoExpand.py still uses string.ascii_letters and
string.digits
idle/CallTips.py still uses string.uppercase,
string.lowercase and string.digits
idle/PyShell.py still uses string.ascii_letters and
string.digits
idle/UndoDelegator.py still uses string.ascii_letters
and string.digits
idle/testcode.py still uses string.capwords()
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2002-09-12 06:39
Message:
Logged In: YES
user_id=33168
Walter, can this be closed now?
----------------------------------------------------------------------
Comment By: Walter Dörwald (doerwalter)
Date: 2002-09-11 22:48
Message:
Logged In: YES
user_id=89016
I rechecked the patch line-by-line and imported
every module that seemed to be importable
(and found a (last?) bug in bgen/bgen/scantools.py),
so I finally checked it in as:
audiopy/audiopy 1.20
bgen/bgen/bgenGenerator.py 1.14
bgen/bgen/bgenOutput.py 1.4
bgen/bgen/scantools.py 1.32
faqwiz/faqwiz.py 1.28
freeze/checkextensions.py 1.5
freeze/checkextensions_win32.py 1.7
freeze/freeze.py 1.42
freeze/makefreeze.py 1.14
freeze/makemakefile.py 1.7
freeze/modulefinder.py 1.20
freeze/parsesetup.py 1.4
freeze/winmakemakefile.py 1.12
idle/AutoIndent.py 1.20
idle/Bindings.py 1.16
idle/CallTips.py 1.12
idle/ClassBrowser.py 1.13
idle/ColorDelegator.py 1.13
idle/EditorWindow.py 1.44
idle/FormatParagraph.py 1.10
idle/GrepDialog.py 1.4
idle/IdleHistory.py 1.5
idle/MultiScrolledLists.py 1.3
idle/OldStackViewer.py 1.2
idle/ParenMatch.py 1.6
idle/PyParse.py 1.10
idle/PyShell.py 1.40
idle/ReplaceDialog.py 1.8
idle/SearchDialogBase.py 1.2
idle/SearchEngine.py 1.3
idle/StackViewer.py 1.17
idle/TreeWidget.py 1.8
idle/UndoDelegator.py 1.5
idle/eventparse.py 1.2
modulator/genmodule.py 1.5
modulator/modulator.py 1.10
modulator/varsubst.py 1.4
scripts/byteyears.py 1.8
scripts/checkappend.py 1.3
scripts/classfix.py 1.12
scripts/cvsfiles.py 1.5
scripts/dutree.py 1.11
scripts/fixcid.py 1.10
scripts/fixheader.py 1.5
scripts/ftpmirror.py 1.15
scripts/gencodec.py 1.7
scripts/ifdef.py 1.5
scripts/logmerge.py 1.8
scripts/mailerdaemon.py 1.10
scripts/methfix.py 1.7
scripts/nm2def.py 1.5
scripts/objgraph.py 1.6
scripts/pathfix.py 1.5
scripts/pdeps.py 1.6
scripts/pindent.py 1.11
scripts/rgrep.py 1.2
scripts/sum5.py 1.5
scripts/trace.py 1.9
scripts/treesync.py 1.6
scripts/untabify.py 1.3
scripts/which.py 1.10
scripts/xxci.py 1.15
unicode/makeunicodedata.py 1.12
versioncheck/checkversions.py 1.3
versioncheck/pyversioncheck.py 1.4
webchecker/tktools.py 1.3
webchecker/wcgui.py 1.9
webchecker/webchecker.py 1.28
webchecker/websucker.py 1.10
webchecker/wsgui.py 1.6
Waiting for the public floggings now...
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2002-09-10 06:57
Message:
Logged In: YES
user_id=80475
In the interests of saving time and having maximum
accuracy, I recommend reverting and then re-applying first
patch and then making the changes on my list. Try not to
make any other changes.
It took half a day to thoroughly review that 6000 line diff.
It doesn't make sense for me to re-check everything from
scratch. To keep the integrity of the review, make as few
changes as possible.
Also, it does make sense for you to give a self-review to
your final diff (remember, GvR believes in public floggings
for those who break working code).
Here are a couple of fast checks:
-- scan the diff for ''.join and make sure it came from a join
(strdata, "")
-- grep the final files for >= 0: or < 0: to see if the 'in'
operator applies.
-- grep the final files for expand( to make sure an
expandtabs( was not missed.
-- grep the final files for join("\n"), join(" "), or join(' ') to see
if there was an error moving the separator to the front
A slower self check is to read the diff file line-by-line and
mentally recompute each change and compare with the
actual change. The diff review will certainly catch
unintended changes like the merge conflict or the she-
bang change.
I know you can't run each script, but do as much as you
can by importing each script to see if it gets a compilation
error. This won't catch runtime errors but it will catch
syntax glitches.
One important group of scripts can be run. Try to give
IDLE a thorough exercise.
Then, when you're feeling brave, commit.
Good luck!
----------------------------------------------------------------------
Comment By: Walter Dörwald (doerwalter)
Date: 2002-09-09 21:54
Message:
Logged In: YES
user_id=89016
diff2.txt is a new version of the patch (against current CVS).
I rechecked the fixheader fix with:
for i in xrange(256):
c = chr(i)
if (ord(c)<=0x80 and c.isalnum()) != (c in
string.ascii_letters + string.digits):
print i,c
There are no differences.
> In file: pathfix.py
> Replace: if line.find("python") < 0:
> With: if "python" in line:
This should probably be:
if "python" not in line:
> In file: texi2html.py
> I don't understand the <<<<<< additions
Ouch, that was a merge conflict.
OK, Raymond could you recheck if the new patch diff2.txt is
OK now? These mindless changes really are tricky! ;)
Unfortunately running the scripts isn't an option in most
cases: Some require Tk, some might expect certain files and
some might even transmogrify all the source files.
I changed a few tests
line[:x] == "xxx...xxx"
to
line.startswith("xxx...xxx")
too.
I rechecked the _find = string.find cases in idle/PyParse.py
and script/gencodec.py.
If I'll get your OK I'll check this in.
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2002-09-09 06:03
Message:
Logged In: YES
user_id=80475
Whew! It takes just as long to check as 6000 line diff as it
does to create the thing in the first place.
The patch is accepted and ready to commit after the
following corrections and review notes are addressed.
Since several errors were syntactical, they could be caught
by running the script. I recommend that all of the scripts
be run one time before a final commit.
Also, anoter additional check would be useful. Everywhere
a function defined the likes of _find=string.find, re-verify
that every instance of _find was fixed-up (I cannot check
this from the diff file).
Corrections and review notes (also attached as a separate
file):
In file: AutoIndent.py
Replace: have = len(chars.expand(tabwidth))
With: have = len(chars.expandtabs(tabwidth))
In file: EditorWindow.py
Replace: line.find('python') >= 0
With: 'python' in line
In file: FormatParagraph.py
Replace: data = "\n".join("\n")
With: data = "\n".join(lines)
In file: PyParse.py
Replace: return len(str[self.stmt_start:i].expandtabs(,
With: return len(str[self.stmt_start:i].expandtabs(\
In file: byteyears.py
Replace: print file.ljust(file, maxlen),
With: print file.ljust(maxlen),
In file: fixheader.py
Reverify propriety of substitution: if ord(c)<=0x80 and
c.isalnum()
In file: mailerdaemon.py
Replace: if sub.find('warning') >= 0: return 1
With: if 'warning' in sub: return 1
In file: mailerdaemon.py
Replace: errors.append(''.join((email.strip()+': '+res.group
('reason')).split()))
With: errors.append(' '.join((email.strip()+': '+res.group
('reason')).split()))
In file: mailerdaemon.py
errors.append(''.join((email.strip()+': '+reason).split()))
errors.append(' '.join((email.strip()+': '+reason).split()))
In file: objgraph.py
Replace: ! /usr/bin/env python
With: #! /usr/bin/env python
In file: pathfix.py
Replace: if line.find("python") < 0:
With: if "python" in line:
In file: texi2html.py
I don't understand the <<<<<< additions
In file: treesync.py
Replace: split(e.split('/')
With: e.split('/')
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2002-09-08 06:57
Message:
Logged In: YES
user_id=6380
Good idea to give it a careful check. I'd suggest to let
Walter to check it in since he did the work though. Or you
two can race for it. :-)
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2002-09-08 06:53
Message:
Logged In: YES
user_id=80475
Let me know if you want this done. If so, I'll give it a
second check (line-by-line) for errors.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=572113&group_id=5470