8000 Merged revisions 55007-55179 via svnmerge from · python/cpython@805365e · GitHub
[go: up one dir, main page]

Skip to content

Commit 805365e

Browse files
committed
Merged revisions 55007-55179 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk ........ r55077 | guido.van.rossum | 2007-05-02 11:54:37 -0700 (Wed, 02 May 2007) | 2 lines Use the new print syntax, at least. ........ r55142 | fred.drake | 2007-05-04 21:27:30 -0700 (Fri, 04 May 2007) | 1 line remove old cruftiness ........ r55143 | fred.drake | 2007-05-04 21:52:16 -0700 (Fri, 04 May 2007) | 1 line make this work with the new Python ........ r55162 | neal.norwitz | 2007-05-06 22:29:18 -0700 (Sun, 06 May 2007) | 1 line Get asdl code gen working with Python 2.3. Should continue to work with 3.0 ........ r55164 | neal.norwitz | 2007-05-07 00:00:38 -0700 (Mon, 07 May 2007) | 1 line Verify checkins to p3yk (sic) branch go to 3000 list. ........ r55166 | neal.norwitz | 2007-05-07 00:12:35 -0700 (Mon, 07 May 2007) | 1 line Fix this test so it runs again by importing warnings_test properly. ........ r55167 | neal.norwitz | 2007-05-07 01:03:22 -0700 (Mon, 07 May 2007) | 8 lines So long xrange. range() now supports values that are outside -sys.maxint to sys.maxint. floats raise a TypeError. This has been sitting for a long time. It probably has some problems and needs cleanup. Objects/rangeobject.c now uses 4-space indents since it is almost completely new. ........ r55171 | guido.van.rossum | 2007-05-07 10:21:26 -0700 (Mon, 07 May 2007) | 4 lines Fix two tests that were previously depending on significant spaces at the end of a line (and before that on Python 2.x print behavior that has no exact equivalent in 3.0). ........
1 parent 598d98a commit 805365e

File tree

150 files changed

+1424
-1332
lines changed

Some content is hidden

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

150 files changed

+1424
-1332
lines changed

Demo/tix/grid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def editnotify(self, x, y):
1818
g = MyGrid(r, name="a_grid",
1919
selectunit="cell")
2020
g.pack(fill=tk.BOTH)
21-
for x in xrange(5):
22-
for y in xrange(5):
21+
for x in range(5):
22+
for y in range(5):
2323
g.set(x,y,text=str((x,y)))
2424

2525
c = tk.Button(r, text="Close", command=r.destroy)

Doc/lib/libdbhash.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ \subsection{Database Objects \label{dbhash-objects}}
7272

7373
\begin{verbatim}
7474
print db.first()
75-
for i in xrange(1, len(db)):
75+
for i in range(1, len(db)):
7676
print db.next()
7777
\end{verbatim}
7878
\end{methoddesc}

Doc/lib/libfuncs.tex

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ \section{Built-in Functions \label{built-in-funcs}}
868868
\end{funcdesc}
869869

870870
\begin{funcdesc}{range}{\optional{start,} stop\optional{, step}}
871-
This is a versatile function to create lists containing arithmetic
871+
This is a versatile function to create sequences containing arithmetic
872872
progressions. It is most often used in \keyword{for} loops. The
873873
arguments must be plain integers. If the \var{step} argument is
874874
omitted, it defaults to \code{1}. If the \var{start} argument is
@@ -882,19 +882,19 @@ \section{Built-in Functions \label{built-in-funcs}}
882882
\exception{ValueError} is raised). Example:
883883

884884
\begin{verbatim}
885-
>>> range(10)
885+
>>> list(range(10))
886886
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
887-
>>> range(1, 11)
887+
>>> list(range(1, 11))
888888
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
889-
>>> range(0, 30, 5)
889+
>>> list(range(0, 30, 5))
890890
[0, 5, 10, 15, 20, 25]
891-
>>> range(0, 10, 3)
891+
>>> list(range(0, 10, 3))
892892
[0, 3, 6, 9]
893-
>>> range(0, -10, -1)
893+
>>> list(range(0, -10, -1))
894894
[0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
895-
>>> range(0)
895+
>>> list(range(0))
896896
[]
897-
>>> range(1, 0)
897+
>>> list(range(1, 0))
898898
[]
899899
\end{verbatim}
900900
\end{funcdesc}
@@ -1230,24 +1230,6 @@ \section{Built-in Functions \label{built-in-funcs}}
12301230
other scopes (such as modules) can be. This may change.}
12311231
\end{funcdesc}
12321232

1233-
\begin{funcdesc}{xrange}{\optional{start,} stop\optional{, step}}
1234-
This function is very similar to \function{range()}, but returns an
1235-
``xrange object'' instead of a list. This is an opaque sequence
1236-
type which yields the same values as the corresponding list, without
1237-
actually storing them all simultaneously. The advantage of
1238-
\function{xrange()} over \function{range()} is minimal (since
1239-
\function{xrange()} still has to create the values when asked for
1240-
them) except when a very large range is used on a memory-starved
1241-
machine or when all of the range's elements are never used (such as
1242-
when the loop is usually terminated with \keyword{break}).
1243-
1244-
\note{\function{xrange()} is intended to be simple and fast.
1245-
Implementations may impose restrictions to achieve this.
1246-
The C implementation of Python restricts all arguments to
1247-
native C longs ("short" Python integers), and also requires
1248-
that the number of elements fit in a native C long.}
1249-
\end{funcdesc}
1250-
12511233
\begin{funcdesc}{zip}{\optional{iterable, \moreargs}}
12521234
This function returns a list of tuples, where the \var{i}-th tuple contains
12531235
the \var{i}-th element from each of the argument sequences or iterables.

Doc/lib/libitertools.tex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ \subsection{Itertool functions \label{itertools-functions}}
161161
key = lambda x: x
162162
self.keyfunc = key
163163
self.it = iter(iterable)
164-
self.tgtkey = self.currkey = self.currvalue = xrange(0)
164+
self.tgtkey = self.currkey = self.currvalue = []
165165
def __iter__(self):
166166
return self
167167
def __next__(self):
@@ -252,7 +252,7 @@ \subsection{Itertool functions \label{itertools-functions}}
252252
\begin{verbatim}
253253
def islice(iterable, *args):
254254
s = slice(*args)
255-
it = iter(xrange(s.start or 0, s.stop or sys.maxint, s.step or 1))
255+
it = iter(range(s.start or 0, s.stop or sys.maxint, s.step or 1))
256256
nexti = next(it)
257257
for i, element in enumerate(iterable):
258258
if i == nexti:
@@ -342,7 +342,7 @@ \subsection{Itertool functions \label{itertools-functions}}
342342
while True:
343343
yield object
344344
else:
345-
for i in xrange(times):
345+
for i in range(times):
346346
yield object
347347
\end{verbatim}
348348
\end{funcdesc}
@@ -425,7 +425,7 @@ \subsection{Examples \label{itertools-example}}
425425
Check 1202 is for $823.14
426426
427427
>>> import operator
428-
>>> for cube in imap(operator.pow, xrange(1,5), repeat(3)):
428+
>>> for cube in imap(operator.pow, range(1,5), repeat(3)):
429429
... print cube
430430
...
431431
1

Doc/lib/librandom.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ \section{\module{random} ---
163163
population contains repeats, then each occurrence is a possible
164164
selection in the sample.
165165

166-
To choose a sample from a range of integers, use an \function{xrange()}
166+
To choose a sample from a range of integers, use an \function{range()}
167167
object as an argument. This is especially fast and space efficient for
168-
sampling from a large population: \code{sample(xrange(10000000), 60)}.
168+
sampling from a large population: \code{sample(range(10000000), 60)}.
169169
\end{funcdesc}
170170

171171

Doc/lib/libstdtypes.tex

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,11 @@ \section{Iterator Types \label{typeiter}}
403403

404404
\section{Sequence Types ---
405405
\class{str}, \class{unicode}, \class{list},
406-
\class{tuple}, \class{buffer}, \class{xrange}
406+
\class{tuple}, \class{buffer}, \class{range}
407407
\label{typesseq}}
408408

409409
There are six sequence types: strings, Unicode strings, lists,
410-
tuples, buffers, and xrange objects.
410+
tuples, buffers, and range objects.
411411

412412
String literals are written in single or double quotes:
413413
\code{'xyzzy'}, \code{"frobozz"}. See chapter 2 of the
@@ -433,11 +433,11 @@ \section{Sequence Types ---
433433
\obindex{buffer}
434434

435435
Xrange objects are similar to buffers in that there is no specific
436-
syntax to create them, but they are created using the \function{xrange()}
437-
function.\bifuncindex{xrange} They don't support slicing,
436+
syntax to create them, but they are created using the \function{range()}
437+
function.\bifuncindex{range} They don't support slicing,
438438
concatenation or repetition, and using \code{in}, \code{not in},
439439
\function{min()} or \function{max()} on them is inefficient.
440-
\obindex{xrange}
440+
\obindex{range}
441441

442442
Most sequence types support the following operations. The \samp{in} and
443443
\samp{not in} operations have the same priorities as the comparison
@@ -1069,11 +1069,11 @@ \subsection{String Formatting Operations \label{typesseq-strings}}
10691069
\refmodule{re}.\refstmodindex{re}
10701070

10711071

1072-
\subsection{XRange Type \label{typesseq-xrange}}
1072+
\subsection{XRange Type \label{typesseq-range}}
10731073

1074-
The \class{xrange}\obindex{xrange} type is an immutable sequence which
1075-
is commonly used for looping. The advantage of the \class{xrange}
1076-
type is that an \class{xrange} object will always take the same amount
1074+
The \class{range}\obindex{range} type is an immutable sequence which
1075+
is commonly used for looping. The advantage of the \class{range}
1076+
type is that an \class{range} object will always take the same amount
10771077
of memory, no matter the size of the range it represents. There are
10781078
no consistent performance advantages.
10791079

Doc/lib/libtimeit.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ \section{\module{timeit} ---
9898
measured. If so, GC can be re-enabled as the first statement in the
9999
\var{setup} string. For example:
100100
\begin{verbatim}
101-
timeit.Timer('for i in xrange(10): oct(i)', 'gc.enable()').timeit()
101+
timeit.Timer('for i in range(10): oct(i)', 'gc.enable()').timeit()
102102
\end{verbatim}
103103
\end{notice}
104104
\end{methoddesc}

Doc/lib/libtypes.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ \section{\module{types} ---
147147
The type of open file objects such as \code{sys.stdout}.
148148
\end{datadesc}
149149

150-
\begin{datadesc}{XRangeType}
150+
\begin{datadesc}{RangeType}
151151
The type of range objects returned by
152-
\function{xrange()}\bifuncindex{xrange}.
152+
\function{range()}\bifuncindex{range}.
153153
\end{datadesc}
154154

155155
\begin{datadesc}{SliceType}

Doc/tut/tut.tex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,7 +2260,7 @@ \section{Looping Techniques \label{loopidioms}}
22602260
function.
22612261

22622262
\begin{verbatim}
2263-
>>> for i in reversed(xrange(1,10,2)):
2263+
>>> for i in reversed(range(1,10,2)):
22642264
... print i
22652265
...
22662266
9
@@ -2700,12 +2700,12 @@ \section{The \function{dir()} Function \label{dir}}
27002700
'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod',
27012701
'enumerate', 'eval', 'exec', 'execfile', 'exit', 'file', 'filter', 'float',
27022702
'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex',
2703-
'id', 'int', 'isinstance', 'issubclass', 'iter',
2703+
'id', 'input', 'int', 'isinstance', 'issubclass', 'iter',
27042704
'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min',
27052705
'object', 'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range',
27062706
'reload', 'repr', 'reversed', 'round', 'set',
27072707
'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super',
2708-
'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip']
2708+
'tuple', 'type', 'unichr', 'unicode', 'vars', 'zip']
27092709
\end{verbatim}
27102710

27112711

@@ -4762,7 +4762,7 @@ \section{Mathematics\label{mathematics}}
47624762
>>> import random
47634763
>>> random.choice(['apple', 'pear', 'banana'])
47644764
'apple'
4765-
>>> random.sample(xrange(100), 10) # sampling without replacement
4765+
>>> random.sample(range(100), 10) # sampling without replacement
47664766
[30, 83, 16, 4, 8, 81, 41, 50, 18, 33]
47674767
>>> random.random() # random float
47684768
0.17970987693706186

Doc/whatsnew/Makefile

Lines changed: 0 additions & 3 deletions
This file was deleted.

Lib/Cookie.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ class CookieError(Exception):
305305
'\375' : '\\375', '\376' : '\\376', '\377' : '\\377'
306306
}
307307

308-
_idmap = ''.join(chr(x) for x in xrange(256))
308+
_idmap = ''.join(chr(x) for x in range(256))
309309

310310
def _quote(str, LegalChars=_LegalChars, idmap=_idmap):
311311
#

Lib/bsddb/test/test_thread.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def writerThread(self, d, howMany, writerNum):
229229
print("%s: creating records %d - %d" % (name, start, stop))
230230

231231
# create a bunch of records
232-
for x in xrange(start, stop):
232+
for x in range(start, stop):
233233
key = '%04d' % x
234234
dbutils.DeadlockWrap(d.put, key, self.makeData(key),
235235
max_retries=12)
@@ -239,7 +239,7 @@ def writerThread(self, d, howMany, writerNum):
239239

240240
# do a bit or reading too
241241
if random() <= 0.05:
242-
for y in xrange(start, x):
242+
for y in range(start, x):
243243
key = '%04d' % x
244244
data = dbutils.DeadlockWrap(d.get, key, max_retries=12)
245245
self.assertEqual(data, self.makeData(key))
@@ -252,7 +252,7 @@ def writerThread(self, d, howMany, writerNum):
252252
print("could not complete sync()...")
253253

254254
# read them back, deleting a few
255-
for x in xrange(start, stop):
255+
for x in range(start, stop):
256256
key = '%04d' % x
257257
data = dbutils.DeadlockWrap(d.get, key, max_retries=12)
258258
if verbose and x % 100 == 0:

Lib/calendar.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __str__(self):
4545

4646
class _localized_month:
4747

48-
_months = [datetime.date(2001, i+1, 1).strftime for i in xrange(12)]
48+
_months = [datetime.date(2001, i+1, 1).strftime for i in range(12)]
4949
_months.insert(0, lambda x: "")
5050

5151
def __init__(self, format):
@@ -65,7 +65,7 @@ def __len__(self):
6565
class _localized_day:
6666

6767
# January 1, 2001, was a Monday.
68-
_days = [datetime.date(2001, 1, i+1).strftime for i in xrange(7)]
68+
_days = [datetime.date(2001, 1, i+1).strftime for i in range(7)]
6969

7070
def __init__(self, format):
7171
self.format = format
@@ -144,7 +144,7 @@ def iterweekdays(self):
144144
Return a iterator for one week of weekday numbers starting with the
145145
configured first one.
146146
"""
147-
for i in xrange(self.firstweekday, self.firstweekday + 7):
147+
for i in range(self.firstweekday, self.firstweekday + 7):
148148
yield i%7
149149

150150
def itermonthdates(self, year, month):
@@ -192,7 +192,7 @@ def monthdatescalendar(self, year, month):
192192
Each row represents a week; week entries are datetime.date values.
193193
"""
194194
dates = list(self.itermonthdates(year, month))
195-
return [ dates[i:i+7] for i in xrange(0, len(dates), 7) ]
195+
return [ dates[i:i+7] for i in range(0, len(dates), 7) ]
196196

197197
def monthdays2calendar(self, year, month):
198198
"""
@@ -202,15 +202,15 @@ def monthdays2calendar(self, year, month):
202202
are zero.
203203
"""
204204
days = list(self.itermonthdays2(year, month))
205-
return [ days[i:i+7] for i in xrange(0, len(days), 7) ]
205+
return [ days[i:i+7] for i in range(0, len(days), 7) ]
206206

207207
def monthdayscalendar(self, year, month):
208208
"""
209209
Return a matrix representing a month's calendar.
210210
Each row represents a week; days outside this month are zero.
211211
"""
212212
days = list(self.itermonthdays(year, month))
213-
return [ days[i:i+7] for i in xrange(0, len(days), 7) ]
213+
return [ days[i:i+7] for i in range(0, len(days), 7) ]
214214

215215
def yeardatescalendar(self, year, width=3):
216216
"""
@@ -221,9 +221,9 @@ def yeardatescalendar(self, year, width=3):
221221
"""
222222
months = [
223223
self.monthdatescalendar(year, i)
224-
for i in xrange(January, January+12)
224+
for i in range(January, January+12)
225225
]
226-
return [months[i:i+width] for i in xrange(0, len(months), width) ]
226+
return [months[i:i+width] for i in range(0, len(months), width) ]
227227

228228
def yeardays2calendar(self, year, width=3):
229229
"""
@@ -234,9 +234,9 @@ def yeardays2calendar(self, year, width=3):
234234
"""
235235
months = [
236236
self.monthdays2calendar(year, i)
237-
for i in xrange(January, January+12)
237+
for i in range(January, January+12)
238238
]
239-
return [months[i:i+width] for i in xrange(0, len(months), width) ]
239+
return [months[i:i+width] for i in range(0, len(months), width) ]
240240

241241
def yeardayscalendar(self, year, width=3):
242242
"""
@@ -246,9 +246,9 @@ def yeardayscalendar(self, year, width=3):
246246
"""
247247
months = [
248248
self.monthdayscalendar(year, i)
249-
for i in xrange(January, January+12)
249+
for i in range(January, January+12)
250250
]
251-
return [months[i:i+width] for i in xrange(0, len(months), width) ]
251+
return [months[i:i+width] for i in range(0, len(months), width) ]
252252

253253

254254
class TextCalendar(Calendar):
@@ -341,7 +341,7 @@ def formatyear(self, theyear, w=2, l=1, c=6, m=3):
341341
header = self.formatweekheader(w)
342342
for (i, row) in enumerate(self.yeardays2calendar(theyear, m)):
343343
# months in this row
344-
months = xrange(m*i+1, min(m*(i+1)+1, 13))
344+
months = range(m*i+1 E42D , min(m*(i+1)+1, 13))
345345
a('\n'*l)
346346
names = (self.formatmonthname(theyear, k, colwidth, False)
347347
for k in months)
@@ -352,7 +352,7 @@ def formatyear(self, theyear, w=2, l=1, c=6, m=3):
352352
a('\n'*l)
353353
# max number of weeks for this row
354354
height = max(len(cal) for cal in row)
355-
for j in xrange(height):
355+
for j in range(height):
356356
weeks = []
357357
for cal in row:
358358
if j >= len(cal):
@@ -444,9 +444,9 @@ def formatyear(self, theyear, width=3):
444444
a('<table border="0" cellpadding="0" cellspacing="0" class="year">')
445445
a('\n')
446446
a('<tr><th colspan="%d" class="year">%s</th></tr>' % (width, theyear))
447-
for i in xrange(January, January+12, width):
447+
for i in range(January, January+12, width):
448448
# months in this row
449-
months = xrange(i, min(i+width, 13))
449+
months = range(i, min(i+width, 13))
450450
a('<tr>')
451451
for m in months:
452452
a('<td>')

0 commit comments

Comments
 (0)
0