Skip to content

Commit d7b0328

Browse files
committed
Merged revisions 66394,66404,66412,66414,66424-66436 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r66394 | benjamin.peterson | 2008-09-11 17:04:02 -0500 (Thu, 11 Sep 2008) | 1 line fix typo ........ r66404 | gerhard.haering | 2008-09-12 08:54:06 -0500 (Fri, 12 Sep 2008) | 2 lines sqlite3 module: Mark iterdump() method as "Non-standard" like all the other methods not found in DB-API. ........ r66412 | gerhard.haering | 2008-09-12 13:58:57 -0500 (Fri, 12 Sep 2008) | 2 lines Fixes issue python#3103. In the sqlite3 module, made one more function static. All renaming public symbos now have the pysqlite prefix to avoid name clashes. This at least once created problems where the same symbol name appeared somewhere in Apache and the sqlite3 module was used from mod_python. ........ r66414 | gerhard.haering | 2008-09-12 17:33:22 -0500 (Fri, 12 Sep 2008) | 2 lines Issue python#3846: Release GIL during calls to sqlite3_prepare. This improves concurrent access to the same database file from multiple threads/processes. ........ r66424 | andrew.kuchling | 2008-09-12 20:22:08 -0500 (Fri, 12 Sep 2008) | 1 line #687648 from Robert Schuppenies: use classic division. (RM Barry gave permission to update the demos.) ........ r66425 | andrew.kuchling | 2008-09-12 20:27:33 -0500 (Fri, 12 Sep 2008) | 1 line #687648 from Robert Schuppenies: use classic division. From me: don't use string exception; flush stdout after printing ........ r66426 | andrew.kuchling | 2008-09-12 20:34:41 -0500 (Fri, 12 Sep 2008) | 1 line #687648 from Robert Schuppenies: use classic division. From me: don't use string exception; add __main__ section ........ r66427 | andrew.kuchling | 2008-09-12 20:42:55 -0500 (Fri, 12 Sep 2008) | 1 line #687648 from Robert Schuppenies: use classic division. From me: remove two stray semicolons ........ r66428 | andrew.kuchling | 2008-09-12 20:43:28 -0500 (Fri, 12 Sep 2008) | 1 line #687648 from Robert Schuppenies: use classic division. ........ r66429 | andrew.kuchling | 2008-09-12 20:47:02 -0500 (Fri, 12 Sep 2008) | 1 line Remove semicolon ........ r66430 | andrew.kuchling | 2008-09-12 20:48:36 -0500 (Fri, 12 Sep 2008) | 1 line Subclass exception ........ r66431 | andrew.kuchling | 2008-09-12 20:56:56 -0500 (Fri, 12 Sep 2008) | 1 line Fix SyntaxError ........ r66432 | andrew.kuchling | 2008-09-12 20:57:25 -0500 (Fri, 12 Sep 2008) | 1 line Update uses of string exceptions ........ r66433 | andrew.kuchling | 2008-09-12 21:08:30 -0500 (Fri, 12 Sep 2008) | 1 line Use title case ........ r66434 | andrew.kuchling | 2008-09-12 21:09:15 -0500 (Fri, 12 Sep 2008) | 1 line Remove extra 'the'; the following title includes it ........ r66435 | andrew.kuchling | 2008-09-12 21:11:51 -0500 (Fri, 12 Sep 2008) | 1 line python#3288: Document as_integer_ratio ........ r66436 | andrew.kuchling | 2008-09-12 21:14:15 -0500 (Fri, 12 Sep 2008) | 1 line Use title case ........
1 parent e40a213 commit d7b0328

File tree

33 files changed

+120
-91
lines changed

33 files changed

+120
-91
lines changed

Demo/classes/Dates.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _days_in_year(year): # number of days in year
6868
return 365 + _is_leap(year)
6969

7070
def _days_before_year(year): # number of days before year
71-
return year*365 + (year+3)/4 - (year+99)/100 + (year+399)/400
71+
return year*365 + (year+3)//4 - (year+99)//100 + (year+399)//400
7272

7373
def _days_in_month(month, year): # number of days in month of year
7474
if month == 2 and _is_leap(year): return 29
@@ -92,9 +92,9 @@ def _num2date(n): # return date with ordinal n
9292
del ans.ord, ans.month, ans.day, ans.year # un-initialize it
9393
ans.ord = n
9494

95-
n400 = (n-1)/_DI400Y # # of 400-year blocks preceding
95+
n400 = (n-1)//_DI400Y # # of 400-year blocks preceding
9696
year, n = 400 * n400, n - _DI400Y * n400
97-
more = n / 365
97+
more = n // 365
9898
dby = _days_before_year(more)
9999
if dby >= n:
100100
more = more - 1
@@ -104,7 +104,7 @@ def _num2date(n): # return date with ordinal n
104104
try: year = int(year) # chop to int, if it fits
105105
except (ValueError, OverflowError): pass
106106

107-
month = min(n/29 + 1, 12)
107+
month = min(n//29 + 1, 12)
108108
dbm = _days_before_month(month, year)
109109
if dbm >= n:
110110
month = month - 1
@@ -174,7 +174,9 @@ def today():
174174
local = time.localtime(time.time())
175175
return Date(local[1], local[2], local[0])
176176

177-
DateTestError = 'DateTestError'
177+
class DateTestError(Exception):
178+
pass
179+
178180
def test(firstyear, lastyear):
179181
a = Date(9,30,1913)
180182
b = Date(9,30,1914)
@@ -220,3 +222,6 @@ def test(firstyear, lastyear):
220222
(fd.month,fd.day,fd.year,ld.month,ld.day,ld.year):
221223
raise DateTestError('num->date failed', y)
222224
y = y + 1
225+
226+
if __name__ == '__main__':
227+
test(1850, 2150)

Demo/classes/bitvec.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
import sys; rprt = sys.stderr.write #for debugging
88

9-
error = 'bitvec.error'
9+
class error(Exception):
10+
pass
1011

1112

1213
def _check_value(value):

Demo/md5test/md5driver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def MDTimeTrial():
3232

3333
filsiz = 1 << 8
3434
filler = makestr(0, filsiz-1)
35-
data = filler * (TEST_BLOCK_SIZE / filsiz);
35+
data = filler * (TEST_BLOCK_SIZE // filsiz)
3636
data = data + filler[:(TEST_BLOCK_SIZE % filsiz)]
3737

3838
del filsiz, filler
@@ -62,7 +62,7 @@ def MDString(str):
6262

6363

6464
def MDFile(filename):
65-
f = open(filename, 'rb');
65+
f = open(filename, 'rb')
6666
mdContext = md5.new()
6767

6868
while 1:

Demo/pdist/cmptree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def recvfile_real(local, remote, name):
202202
dt = t2-t1
203203
print(size, "bytes in", round(dt), "seconds", end=' ')
204204
if dt:
205-
print("i.e.", int(size/dt), "bytes/sec", end=' ')
205+
print("i.e.", int(size//dt), "bytes/sec", end=' ')
206206
print()
207207
remote._recv(id) # ignored
208208

Demo/rpc/nfsclient.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ def test():
194194
fh = sf[1]
195195
if fh:
196196
ncl = NFSClient(host)
197-
print(ncl.Getattr(fh))
197+
attrstat = ncl.Getattr(fh)
198+
print(attrstat)
198199
list = ncl.Listdir(fh)
199200
for item in list: print(item)
200201
mcl.Umnt(filesys)

Demo/rpc/rpc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ def pack_replyheader(self, xid, verf):
8080

8181

8282
# Exceptions
83-
BadRPCFormat = 'rpc.BadRPCFormat'
84-
BadRPCVersion = 'rpc.BadRPCVersion'
85-
GarbageArgs = 'rpc.GarbageArgs'
83+
class BadRPCFormat(Exception): pass
84+
class BadRPCVersion(Exception): pass
85+
class GarbageArgs(Exception): pass
8686

8787
class Unpacker(xdr.Unpacker):
8888

Demo/rpc/xdr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def pack_double(self, x):
5757
def pack_fstring(self, n, s):
5858
if n < 0:
5959
raise ValueError('fstring size must be nonnegative')
60-
n = ((n+3)/4)*4
60+
n = ((n + 3)//4)*4
6161
data = s[:n]
6262
data = data + (n - len(data)) * '\0'
6363
self.buf = self.buf + data
@@ -164,7 +164,7 @@ def unpack_fstring(self, n):
164164
if n < 0:
165165
raise ValueError('fstring size must be nonnegative')
166166
i = self.pos
167-
j = i + (n+3)/4*4
167+
j = i + (n+3)//4*4
168168
if j > len(self.buf):
169169
raise EOFError
170170
self.pos = j

Demo/scripts/fact.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,21 @@
88
import sys
99
from math import sqrt
1010

11-
error = 'fact.error' # exception
12-
1311
def fact(n):
14-
if n < 1: raise error # fact() argument should be >= 1
12+
if n < 1: raise ValueError # fact() argument should be >= 1
1513
if n == 1: return [] # special case
1614
res = []
1715
# Treat even factors special, so we can use i = i+2 later
1816
while n%2 == 0:
1917
res.append(2)
20-
n = n/2
18+
n = n//2
2119
# Try odd numbers up to sqrt(n)
2220
limit = sqrt(float(n+1))
2321
i = 3
2422
while i <= limit:
2523
if n%i == 0:
2624
res.append(i)
27-
n = n/i
25+
n = n//i
2826
limit = sqrt(n+1)
2927
else:
3028
i = i+2

Demo/scripts/ftpstats.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def main():
104104

105105
def showbar(dict, title):
106106
n = len(title)
107-
print('='*((70-n)/2), title, '='*((71-n)/2))
107+
print('='*((70-n)//2), title, '='*((71-n)//2))
108108
list = []
109109
for key in sorted(dict.keys()):
110110
n = len(str(key))
@@ -124,7 +124,7 @@ def show(dict, title, maxitems):
124124
if len(dict) > maxitems:
125125
title = title + ' (first %d)'%maxitems
126126
n = len(title)
127-
print('='*((70-n)/2), title, '='*((71-n)/2))
127+
print('='*((70-n)//2), title, '='*((71-n)//2))
128128
list = []
129129
for key in dict.keys():
130130
list.append((-len(dict[key]), key))

Demo/scripts/lpwatch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def makestatus(name, thisuser):
8383
lines.append(line)
8484
#
8585
if totaljobs:
86-
line = '%d K' % ((totalbytes+1023)/1024)
86+
line = '%d K' % ((totalbytes+1023)//1024)
8787
if totaljobs != len(users):
8888
line = line + ' (%d jobs)' % totaljobs
8989
if len(users) == 1:
@@ -95,7 +95,7 @@ def makestatus(name, thisuser):
9595
line = line + ' (%s first)' % thisuser
9696
else:
9797
line = line + ' (%d K before %s)' % (
98-
(aheadbytes+1023)/1024, thisuser)
98+
(aheadbytes+1023)//1024, thisuser)
9999
lines.append(line)
100100
#
101101
sts = pipe.close()

0 commit comments

Comments
 (0)