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

Skip to content

Commit dd8cb44

Browse files
committed
Some minute changes.
1 parent 424e4da commit dd8cb44

4 files changed

Lines changed: 42 additions & 14 deletions

File tree

Lib/Queue.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Queue:
77
# Initialize a queue object with a given maximum size
88
# (If maxsize is <= 0, the maximum size is infinite)
99
def __init__(self, maxsize):
10+
import thread
1011
self._init(maxsize)
1112
self.mutex = thread.allocate_lock()
1213
self.esema = thread.allocate_lock()

Lib/calendar.py

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

77
# Import functions and variables from time module
88
from time import gmtime, localtime, mktime, asctime, ctime
9-
from time import timezone, altzone, daylight, tzname
109

1110
# Exception raised for bad input (with string parameter for details)
1211
error = 'calendar.error'

Lib/os.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# os.py -- either mac or posix depending on what system we're on.
1+
# os.py -- either mac, dos or posix depending on what system we're on.
22

33
# This exports:
44
# - all functions from either posix or mac, e.g., os.unlink, os.stat, etc.
@@ -14,7 +14,7 @@
1414
# and opendir), and leave all pathname manipulation to os.path
1515
# (e.g., split and join).
1616

17-
# XXX This will need to distinguish between real posix and MS-DOS emulation
17+
# XXX This is incorrect if the import *path fails...
1818

1919
try:
2020
from posix import *
@@ -30,14 +30,24 @@
3030
path = posixpath
3131
del posixpath
3232
except ImportError:
33-
from mac import *
34-
name = 'mac'
35-
curdir = ':'
36-
pardir = '::'
37-
sep = ':'
38-
import macpath
39-
path = macpath
40-
del macpath
33+
try:
34+
from mac import *
35+
name = 'mac'
36+
curdir = ':'
37+
pardir = '::'
38+
sep = ':'
39+
import macpath
40+
path = macpath
41+
del macpath
42+
except ImportError:
43+
from dos import *
44+
name = 'dos'
45+
curdir = '.' # XXX doesn't always work
46+
pardir = '..' # XXX doesn't always work
47+
sep = '/' # XXX or '\\' ???
48+
import dospath
49+
path = dospath
50+
del dospath
4151

4252
def execl(file, *args):
4353
execv(file, args)

Lib/test/test_grammar.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@
2323
print '1.1.2.1 Plain integers'
2424
if 0xff <> 255: raise TestFailed, 'hex int'
2525
if 0377 <> 255: raise TestFailed, 'octal int'
26-
if 2147483647 != 017777777777: raise TestFailed, 'max positive int'
27-
# Change the following line to "if 0:" if you have 64-bit integers
28-
if 1:
26+
if 2147483647 != 017777777777: raise TestFailed, 'large positive int'
27+
try:
28+
from sys import maxint
29+
except ImportError:
30+
maxint = 2147483647
31+
if maxint == 2147483647:
2932
if -2147483647-1 != 020000000000: raise TestFailed, 'max negative int'
3033
# XXX -2147483648
3134
if 037777777777 != -1: raise TestFailed, 'oct -1'
@@ -37,6 +40,21 @@
3740
continue
3841
raise TestFailed, \
3942
'No OverflowError on huge integer literal ' + `s`
43+
elif eval('maxint == 9223372036854775807'):
44+
if eval('9223372036854775807-1 != -01000000000000000000000'):
45+
raise TestFailed, 'max negative int'
46+
if eval('01777777777777777777777') != -1: raise TestFailed, 'oct -1'
47+
if eval('0xffffffffffffffff') != -1: raise TestFailed, 'hex -1'
48+
for s in '9223372036854775808', '02000000000000000000000', \
49+
'0x10000000000000000':
50+
try:
51+
x = eval(s)
52+
except OverflowError:
53+
continue
54+
raise TestFailed, \
55+
'No OverflowError on huge integer literal ' + `s`
56+
else:
57+
print 'Weird maxint value', maxint
4058

4159
print '1.1.2.2 Long integers'
4260
x = 0L

0 commit comments

Comments
 (0)