Commit e7113b6b authored by Guido van Rossum's avatar Guido van Rossum

* 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!]
parent 04321d1e
...@@ -17,7 +17,8 @@ empty = (0, 0), (0, 0) ...@@ -17,7 +17,8 @@ empty = (0, 0), (0, 0)
# Check if a rectangle is empty. # Check if a rectangle is empty.
# #
def is_empty((left, top), (right, bottom)): def is_empty(r):
(left, top), (right, bottom) = r
return left >= right or top >= bottom return left >= right or top >= bottom
...@@ -36,7 +37,7 @@ def intersect(list): ...@@ -36,7 +37,7 @@ def intersect(list):
if top < t: top = t if top < t: top = t
if right > r: right = r if right > r: right = r
if bottom > b: bottom = b if bottom > b: bottom = b
if is_empty((left, top), (right, bottom)): if is_empty(((left, top), (right, bottom))):
return empty return empty
return (left, top), (right, bottom) return (left, top), (right, bottom)
...@@ -47,7 +48,7 @@ def intersect(list): ...@@ -47,7 +48,7 @@ def intersect(list):
def union(list): def union(list):
(left, top), (right, bottom) = empty (left, top), (right, bottom) = empty
for (l, t), (r, b) in list[1:]: for (l, t), (r, b) in list[1:]:
if not is_empty((l, t), (r, b)): if not is_empty(((l, t), (r, b))):
if l < left: left = l if l < left: left = l
if t < top: top = t if t < top: top = t
if r > right: right = r if r > right: right = r
......
...@@ -17,7 +17,8 @@ empty = (0, 0), (0, 0) ...@@ -17,7 +17,8 @@ empty = (0, 0), (0, 0)
# Check if a rectangle is empty. # Check if a rectangle is empty.
# #
def is_empty((left, top), (right, bottom)): def is_empty(r):
(left, top), (right, bottom) = r
return left >= right or top >= bottom return left >= right or top >= bottom
...@@ -36,7 +37,7 @@ def intersect(list): ...@@ -36,7 +37,7 @@ def intersect(list):
if top < t: top = t if top < t: top = t
if right > r: right = r if right > r: right = r
if bottom > b: bottom = b if bottom > b: bottom = b
if is_empty((left, top), (right, bottom)): if is_empty(((left, top), (right, bottom))):
return empty return empty
return (left, top), (right, bottom) return (left, top), (right, bottom)
...@@ -47,7 +48,7 @@ def intersect(list): ...@@ -47,7 +48,7 @@ def intersect(list):
def union(list): def union(list):
(left, top), (right, bottom) = empty (left, top), (right, bottom) = empty
for (l, t), (r, b) in list[1:]: for (l, t), (r, b) in list[1:]:
if not is_empty((l, t), (r, b)): if not is_empty(((l, t), (r, b))):
if l < left: left = l if l < left: left = l
if t < top: top = t if t < top: top = t
if r > right: right = r if r > right: right = r
......
# module 'string' -- A collection of string operations # module 'string' -- A collection of string operations
# XXX Some of these operations are incredibly slow and should be built in # Warning: most of the code you see here isn't normally used nowadays.
# At the end of this file most functions are replaced by built-in
# functions imported from built-in module "strop".
# Some strings for ctype-style character classification # Some strings for ctype-style character classification
whitespace = ' \t\n' whitespace = ' \t\n'
......
# module 'string' -- A collection of string operations # module 'string' -- A collection of string operations
# XXX Some of these operations are incredibly slow and should be built in # Warning: most of the code you see here isn't normally used nowadays.
# At the end of this file most functions are replaced by built-in
# functions imported from built-in module "strop".
# Some strings for ctype-style character classification # Some strings for ctype-style character classification
whitespace = ' \t\n' whitespace = ' \t\n'
......
...@@ -123,6 +123,41 @@ if repr(()) <> '()': raise TestFailed, 'repr(())' ...@@ -123,6 +123,41 @@ if repr(()) <> '()': raise TestFailed, 'repr(())'
if repr([]) <> '[]': raise TestFailed, 'repr([])' if repr([]) <> '[]': raise TestFailed, 'repr([])'
if repr({}) <> '{}': raise TestFailed, 'repr({})' if repr({}) <> '{}': raise TestFailed, 'repr({})'
print 'round'
if round(0.0) <> 0.0: raise TestFailed, 'round(0.0)'
if round(1.0) <> 1.0: raise TestFailed, 'round(1.0)'
if round(10.0) <> 10.0: raise TestFailed, 'round(10.0)'
if round(1000000000.0) <> 1000000000.0:
raise TestFailed, 'round(1000000000.0)'
if round(1e20) <> 1e20: raise TestFailed, 'round(1e20)'
if round(-1.0) <> -1.0: raise TestFailed, 'round(-1.0)'
if round(-10.0) <> -10.0: raise TestFailed, 'round(-10.0)'
if round(-1000000000.0) <> -1000000000.0:
raise TestFailed, 'round(-1000000000.0)'
if round(-1e20) <> -1e20: raise TestFailed, 'round(-1e20)'
if round(0.1) <> 0.0: raise TestFailed, 'round(0.0)'
if round(1.1) <> 1.0: raise TestFailed, 'round(1.0)'
if round(10.1) <> 10.0: raise TestFailed, 'round(10.0)'
if round(1000000000.1) <> 1000000000.0:
raise TestFailed, 'round(1000000000.0)'
if round(-1.1) <> -1.0: raise TestFailed, 'round(-1.0)'
if round(-10.1) <> -10.0: raise TestFailed, 'round(-10.0)'
if round(-1000000000.1) <> -1000000000.0:
raise TestFailed, 'round(-1000000000.0)'
if round(0.9) <> 1.0: raise TestFailed, 'round(0.9)'
if round(9.9) <> 10.0: raise TestFailed, 'round(9.9)'
if round(999999999.9) <> 1000000000.0:
raise TestFailed, 'round(999999999.9)'
if round(-0.9) <> -1.0: raise TestFailed, 'round(-0.9)'
if round(-9.9) <> -10.0: raise TestFailed, 'round(-9.9)'
if round(-999999999.9) <> -1000000000.0:
raise TestFailed, 'round(-999999999.9)'
print 'setattr' print 'setattr'
import sys import sys
setattr(sys, 'foobar', 1) setattr(sys, 'foobar', 1)
......
...@@ -92,6 +92,7 @@ testing ...@@ -92,6 +92,7 @@ testing
testing testing
reload reload
repr repr
round
setattr setattr
str str
type type
......
...@@ -40,7 +40,7 @@ def tzset(): ...@@ -40,7 +40,7 @@ def tzset():
tzstr = os.environ['TZ'] tzstr = os.environ['TZ']
tzparams = tzparse(tzstr) tzparams = tzparse(tzstr)
timezone = tzparams[1] * 3600 timezone = tzparams[1] * 3600
altzone = timezone + 3600 altzone = timezone - 3600
daylight = 1 daylight = 1
tzname = tzparams[0], tzparams[2] tzname = tzparams[0], tzparams[2]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment