Mercurial > cpython-lru_cache-weakref
annotate Tools/scripts/fixnotice.py @ 25838:8540887bcec6 2.2
Backport of 2.183:
Fix memory leak in add_subclass() found by NealN with valgrind.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 18 Oct 2002 13:42:21 +0000 |
| parents | 1881b968989b |
| children | 4c1ccf36025c |
| rev | line source |
|---|---|
| 4567 | 1 #! /usr/bin/env python |
| 2 | |
|
14375
6f6f965c5e2d
REMOVED all CWI, CNRI and BeOpen copyright markings.
Guido van Rossum <guido@python.org>
parents:
13255
diff
changeset
|
3 OLD_NOTICE = """/*********************************************************** |
|
13255
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
7735
diff
changeset
|
4 Copyright (c) 2000, BeOpen.com. |
|
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
7735
diff
changeset
|
5 Copyright (c) 1995-2000, Corporation for National Research Initiatives. |
|
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
7735
diff
changeset
|
6 Copyright (c) 1990-1995, Stichting Mathematisch Centrum. |
|
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
7735
diff
changeset
|
7 All rights reserved. |
| 4567 | 8 |
|
13255
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
7735
diff
changeset
|
9 See the file "Misc/COPYRIGHT" for information on usage and |
|
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
7735
diff
changeset
|
10 redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
|
14375
6f6f965c5e2d
REMOVED all CWI, CNRI and BeOpen copyright markings.
Guido van Rossum <guido@python.org>
parents:
13255
diff
changeset
|
11 ******************************************************************/ |
| 4567 | 12 """ |
| 13 | |
|
14375
6f6f965c5e2d
REMOVED all CWI, CNRI and BeOpen copyright markings.
Guido van Rossum <guido@python.org>
parents:
13255
diff
changeset
|
14 NEW_NOTICE = "" |
|
6f6f965c5e2d
REMOVED all CWI, CNRI and BeOpen copyright markings.
Guido van Rossum <guido@python.org>
parents:
13255
diff
changeset
|
15 |
| 4567 | 16 # " <-- Help Emacs |
| 17 | |
| 18 import os, sys, string | |
| 19 | |
| 20 def main(): | |
| 21 args = sys.argv[1:] | |
| 22 if not args: | |
| 7735 | 23 print "No arguments." |
| 4567 | 24 for arg in args: |
| 7735 | 25 process(arg) |
| 4567 | 26 |
| 27 def process(arg): | |
| 28 f = open(arg) | |
| 29 data = f.read() | |
| 30 f.close() | |
| 31 i = string.find(data, OLD_NOTICE) | |
| 32 if i < 0: | |
|
15932
1881b968989b
Hand repair of cases where reindent changed lines of the form
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
33 ## print "No old notice in", arg |
| 7735 | 34 return |
| 4567 | 35 data = data[:i] + NEW_NOTICE + data[i+len(OLD_NOTICE):] |
| 36 new = arg + ".new" | |
| 37 backup = arg + ".bak" | |
| 38 print "Replacing notice in", arg, "...", | |
| 39 sys.stdout.flush() | |
| 40 f = open(new, "w") | |
| 41 f.write(data) | |
| 42 f.close() | |
| 43 os.rename(arg, backup) | |
| 44 os.rename(new, arg) | |
| 45 print "done" | |
| 46 | |
| 47 if __name__ == '__main__': | |
| 48 main() |
