Skip to content

Commit eb450db

Browse files
committed
Test commit. Add 2011 to copyright line (merge from 2.6).
2 parents d261a49 + 7be6326 commit eb450db

2,126 files changed

Lines changed: 329229 additions & 199175 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.bzrignore

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,22 @@ platform
1414
pyconfig.h
1515
libpython*.a
1616
python.exe
17-
CP936.TXT
18-
SHIFT_JISX0213.TXT
19-
JOHAB.TXT
20-
EUC-JP.TXT
21-
NormalizationTest-3.2.0.txt
22-
NormalizationTest.txt
23-
BIG5.TXT
24-
BIG5HKSCS-2004.TXT
25-
CP949.TXT
26-
EUC-CN.TXT
27-
BIG5HKSCS.TXT
28-
SHIFTJIS.TXT
29-
EUC-KR.TXT
30-
EUC-JISX0213.TXT
31-
CP932.TXT
32-
CP950.TXT
17+
python-gdb.py
3318
reflog.txt
34-
gb-18030-2000.xml
3519
tags
3620
TAGS
3721
.gdb_history
3822
Doc/tools/sphinx
3923
Doc/tools/jinja
24+
Doc/tools/jinja2
4025
Doc/tools/pygments
4126
Doc/tools/docutils
27+
Misc/python.pc
4228
Modules/Setup
4329
Modules/Setup.config
4430
Modules/Setup.local
4531
Modules/config.c
4632
Parser/pgen
33+
Lib/test/data/*
4734
Lib/lib2to3/Grammar*.pickle
4835
Lib/lib2to3/PatternGrammar*.pickle

.hgignore

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,44 @@
11
.gdb_history
22
.purify
3-
.svn
4-
BIG5.TXT
5-
BIG5HKSCS-2004.TXT
6-
BIG5HKSCS.TXT
7-
CP932.TXT
8-
CP936.TXT
9-
CP949.TXT
10-
CP950.TXT
11-
EUC-CN.TXT
12-
EUC-JISX0213.TXT
13-
EUC-JP.TXT
14-
EUC-KR.TXT
15-
JOHAB.TXT
3+
.svn/
164
Makefile$
175
Makefile.pre$
18-
NormalizationTest-3.2.0.txt
19-
NormalizationTest.txt
20-
SHIFTJIS.TXT
21-
SHIFT_JISX0213.TXT
22-
TAGS
23-
autom4te.cache
24-
build
25-
buildno
6+
TAGS$
7+
autom4te.cache$
8+
build/
9+
buildno$
2610
config.cache
2711
config.log
2812
config.status
2913
config.status.lineno
3014
db_home
31-
gb-18030-2000.xml
32-
platform
33-
pyconfig.h
34-
python
35-
python.exe
36-
reflog.txt
37-
tags
15+
platform$
16+
pyconfig.h$
17+
python$
18+
python.exe$
19+
reflog.txt$
20+
tags$
3821
Lib/plat-mac/errors.rsrc.df.rsrc
3922
Doc/tools/sphinx/
4023
Doc/tools/docutils/
4124
Doc/tools/jinja/
25+
Doc/tools/jinja2/
4226
Doc/tools/pygments/
43-
Modules/Setup
27+
Misc/python.pc
28+
Modules/Setup$
4429
Modules/Setup.config
4530
Modules/Setup.local
4631
Modules/config.c
47-
Parser/pgen
48-
core
32+
Modules/ld_so_aix$
33+
Parser/pgen$
34+
Parser/pgen.stamp$
35+
^core
36+
^python-gdb.py
4937

5038
syntax: glob
39+
python.exe-gdb.py
5140
libpython*.a
41+
*.swp
5242
*.o
5343
*.pyc
5444
*.pyo
@@ -58,6 +48,11 @@ libpython*.a
5848
*.rej
5949
*~
6050
Lib/lib2to3/*.pickle
51+
Lib/test/data/*
52+
Misc/*.wpu
53+
PC/python_nt*.h
54+
PC/pythonnt_rc*.h
55+
PC/*.obj
6156
PCbuild/*.exe
6257
PCbuild/*.dll
6358
PCbuild/*.pdb

Demo/cgi/cgi1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/local/bin/python
1+
#!/usr/bin/env python
22

33
"""CGI test 1 - check server setup."""
44

Demo/cgi/cgi2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/local/bin/python
1+
#!/usr/bin/env python
22

33
"""CGI test 2 - basic use of cgi module."""
44

Demo/cgi/cgi3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/local/bin/python
1+
#!/usr/bin/env python
22

33
"""CGI test 3 (persistent data)."""
44

Demo/classes/Vec.py

100755100644
Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,41 @@
1-
# A simple vector class
1+
class Vec:
2+
""" A simple vector class
23
4+
Instances of the Vec class can be constructed from numbers
35
4-
def vec(*v):
5-
return Vec(*v)
6+
>>> a = Vec(1, 2, 3)
7+
>>> b = Vec(3, 2, 1)
68
9+
added
10+
>>> a + b
11+
Vec(4, 4, 4)
712
8-
class Vec:
13+
subtracted
14+
>>> a - b
15+
Vec(-2, 0, 2)
16+
17+
and multiplied by a scalar on the left
18+
>>> 3.0 * a
19+
Vec(3.0, 6.0, 9.0)
920
21+
or on the right
22+
>>> a * 3.0
23+
Vec(3.0, 6.0, 9.0)
24+
"""
1025
def __init__(self, *v):
1126
self.v = list(v)
1227

13-
def fromlist(self, v):
28+
@classmethod
29+
def fromlist(cls, v):
1430
if not isinstance(v, list):
1531
raise TypeError
16-
self.v = v[:]
17-
return self
32+
inst = cls()
33+
inst.v = v
34+
return inst
1835

1936
def __repr__(self):
20-
return 'vec(' + repr(self.v)[1:-1] + ')'
37+
args = ', '.join(repr(x) for x in self.v)
38+
return 'Vec({0})'.format(args)
2139

2240
def __len__(self):
2341
return len(self.v)
@@ -27,28 +45,24 @@ def __getitem__(self, i):
2745

2846
def __add__(self, other):
2947
# Element-wise addition
30-
v = map(lambda x, y: x+y, self, other)
31-
return Vec().fromlist(v)
48+
v = [x + y for x, y in zip(self.v, other.v)]
49+
return Vec.fromlist(v)
3250

3351
def __sub__(self, other):
3452
# Element-wise subtraction
35-
v = map(lambda x, y: x-y, self, other)
36-
return Vec().fromlist(v)
53+
v = [x - y for x, y in zip(self.v, other.v)]
54+
return Vec.fromlist(v)
3755

3856
def __mul__(self, scalar):
3957
# Multiply by scalar
40-
v = map(lambda x: x*scalar, self.v)
41-
return Vec().fromlist(v)
58+
v = [x * scalar for x in self.v]
59+
return Vec.fromlist(v)
4260

61+
__rmul__ = __mul__
4362

4463

4564
def test():
46-
a = vec(1, 2, 3)
47-
b = vec(3, 2, 1)
48-
print a
49-
print b
50-
print a+b
51-
print a-b
52-
print a*3.0
65+
import doctest
66+
doctest.testmod()
5367

5468
test()

Demo/embed/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Makefile for embedded Python use demo.
2-
# (This version tailored for my Red Hat Linux 6.1 setup;
2+
# (This version originally written on Red Hat Linux 6.1;
33
# edit lines marked with XXX.)
44

55
# XXX The compiler you are using
@@ -10,7 +10,7 @@ blddir= ../..
1010
srcdir= ../..
1111

1212
# Python version
13-
VERSION= 2.6
13+
VERSION= 2.7
1414

1515
# Compiler flags
1616
OPT= -g
@@ -21,7 +21,7 @@ CPPFLAGS= $(INCLUDES)
2121
# The Python library
2222
LIBPYTHON= $(blddir)/libpython$(VERSION).a
2323

24-
# XXX edit LIBS (in particular) to match $(blddir)/Modules/Makefile
24+
# XXX edit LIBS (in particular) to match $(blddir)/Makefile
2525
LIBS= -lnsl -ldl -lreadline -ltermcap -lieee -lpthread -lutil
2626
LDFLAGS= -Xlinker -export-dynamic
2727
SYSLIBS= -lm

Demo/embed/demo.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,19 @@ main(int argc, char **argv)
1616
initxyzzy();
1717

1818
/* Define sys.argv. It is up to the application if you
19-
want this; you can also let it undefined (since the Python
19+
want this; you can also leave it undefined (since the Python
2020
code is generally not a main program it has no business
21-
touching sys.argv...) */
22-
PySys_SetArgv(argc, argv);
21+
touching sys.argv...)
22+
23+
If the third argument is true, sys.path is modified to include
24+
either the directory containing the script named by argv[0], or
25+
the current working directory. This can be risky; if you run
26+
an application embedding Python in a directory controlled by
27+
someone else, attackers could put a Trojan-horse module in the
28+
directory (say, a file named os.py) that your application would
29+
then import and run.
30+
*/
31+
PySys_SetArgvEx(argc, argv, 0);
2332

2433
/* Do some application specific code */
2534
printf("Hello, brave new world\n\n");

0 commit comments

Comments
 (0)