Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e7113b6

Browse files
committed
* Fix bug in tzparse.py for DST timezone
* Added whatis command to pdb.py * new module GET.py (GL definitions from <gl/get.h>) * rect.py: is_empty takes a rect as argument, not two points. * Added tests for builtin round() [XXX not yet complete!]
1 parent 04321d1 commit e7113b6

7 files changed

Lines changed: 51 additions & 9 deletions

File tree

Lib/lib-stdwin/rect.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
# Check if a rectangle is empty.
1919
#
20-
def is_empty((left, top), (right, bottom)):
20+
def is_empty(r):
21+
(left, top), (right, bottom) = r
2122
return left >= right or top >= bottom
2223

2324

@@ -36,7 +37,7 @@ def intersect(list):
3637
if top < t: top = t
3738
if right > r: right = r
3839
if bottom > b: bottom = b
39-
if is_empty((left, top), (right, bottom)):
40+
if is_empty(((left, top), (right, bottom))):
4041
return empty
4142
return (left, top), (right, bottom)
4243

@@ -47,7 +48,7 @@ def intersect(list):
4748
def union(list):
4849
(left, top), (right, bottom) = empty
4950
for (l, t), (r, b) in list[1:]:
50-
if not is_empty((l, t), (r, b)):
51+
if not is_empty(((l, t), (r, b))):
5152
if l < left: left = l
5253
if t < top: top = t
5354
if r > right: right = r

Lib/stdwin/rect.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
# Check if a rectangle is empty.
1919
#
20-
def is_empty((left, top), (right, bottom)):
20+
def is_empty(r):
21+
(left, top), (right, bottom) = r
2122
return left >= right or top >= bottom
2223

2324

@@ -36,7 +37,7 @@ def intersect(list):
3637
if top < t: top = t
3738
if right > r: right = r
3839
if bottom > b: bottom = b
39-
if is_empty((left, top), (right, bottom)):
40+
if is_empty(((left, top), (right, bottom))):
4041
return empty
4142
return (left, top), (right, bottom)
4243

@@ -47,7 +48,7 @@ def intersect(list):
4748
def union(list):
4849
(left, top), (right, bottom) = empty
4950
for (l, t), (r, b) in list[1:]:
50-
if not is_empty((l, t), (r, b)):
51+
if not is_empty(((l, t), (r, b))):
5152
if l < left: left = l
5253
if t < top: top = t
5354
if r > right: right = r

Lib/string.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# module 'string' -- A collection of string operations
22

3-
# XXX Some of these operations are incredibly slow and should be built in
3+
# Warning: most of the code you see here isn't normally used nowadays.
4+
# At the end of this file most functions are replaced by built-in
5+
# functions imported from built-in module "strop".
46

57
# Some strings for ctype-style character classification
68
whitespace = ' \t\n'

Lib/stringold.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# module 'string' -- A collection of string operations
22

3-
# XXX Some of these operations are incredibly slow and should be built in
3+
# Warning: most of the code you see here isn't normally used nowadays.
4+
# At the end of this file most functions are replaced by built-in
5+
# functions imported from built-in module "strop".
46

57
# Some strings for ctype-style character classification
68
whitespace = ' \t\n'

Lib/test/test_b2.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,41 @@
123123
if repr([]) <> '[]': raise TestFailed, 'repr([])'
124124
if repr({}) <> '{}': raise TestFailed, 'repr({})'
125125

126+
print 'round'
127+
if round(0.0) <> 0.0: raise TestFailed, 'round(0.0)'
128+
if round(1.0) <> 1.0: raise TestFailed, 'round(1.0)'
129+
if round(10.0) <> 10.0: raise TestFailed, 'round(10.0)'
130+
if round(1000000000.0) <> 1000000000.0:
131+
raise TestFailed, 'round(1000000000.0)'
132+
if round(1e20) <> 1e20: raise TestFailed, 'round(1e20)'
133+
134+
if round(-1.0) <> -1.0: raise TestFailed, 'round(-1.0)'
135+
if round(-10.0) <> -10.0: raise TestFailed, 'round(-10.0)'
136+
if round(-1000000000.0) <> -1000000000.0:
137+
raise TestFailed, 'round(-1000000000.0)'
138+
if round(-1e20) <> -1e20: raise TestFailed, 'round(-1e20)'
139+
140+
if round(0.1) <> 0.0: raise TestFailed, 'round(0.0)'
141+
if round(1.1) <> 1.0: raise TestFailed, 'round(1.0)'
142+
if round(10.1) <> 10.0: raise TestFailed, 'round(10.0)'
143+
if round(1000000000.1) <> 1000000000.0:
144+
raise TestFailed, 'round(1000000000.0)'
145+
146+
if round(-1.1) <> -1.0: raise TestFailed, 'round(-1.0)'
147+
if round(-10.1) <> -10.0: raise TestFailed, 'round(-10.0)'
148+
if round(-1000000000.1) <> -1000000000.0:
149+
raise TestFailed, 'round(-1000000000.0)'
150+
151+
if round(0.9) <> 1.0: raise TestFailed, 'round(0.9)'
152+
if round(9.9) <> 10.0: raise TestFailed, 'round(9.9)'
153+
if round(999999999.9) <> 1000000000.0:
154+
raise TestFailed, 'round(999999999.9)'
155+
156+
if round(-0.9) <> -1.0: raise TestFailed, 'round(-0.9)'
157+
if round(-9.9) <> -10.0: raise TestFailed, 'round(-9.9)'
158+
if round(-999999999.9) <> -1000000000.0:
159+
raise TestFailed, 'round(-999999999.9)'
160+
126161
print 'setattr'
127162
import sys
128163
setattr(sys, 'foobar', 1)

Lib/test/testall.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ testing
9292
testing
9393
reload
9494
repr
95+
round
9596
setattr
9697
str
9798
type

Lib/tzparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def tzset():
4040
tzstr = os.environ['TZ']
4141
tzparams = tzparse(tzstr)
4242
timezone = tzparams[1] * 3600
43-
altzone = timezone + 3600
43+
altzone = timezone - 3600
4444
daylight = 1
4545
tzname = tzparams[0], tzparams[2]
4646

0 commit comments

Comments
 (0)