Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit 51164d9

Browse files
committed
Merge branch 'master' into 290-print-stdout
Conflicts: lib/sys.py
2 parents c4bfdf4 + 16b7b4a commit 51164d9

Some content is hidden

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

48 files changed

+3999
-249
lines changed

Makefile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,20 @@ STDLIB_TESTS := \
9393
re_tests \
9494
sys_test \
9595
tempfile_test \
96-
test/test_tuple \
96+
test/test_bisect \
97+
test/test_colorsys \
98+
test/test_datetime \
9799
test/test_dict \
98100
test/test_list \
99-
test/test_slice \
100-
test/test_string \
101101
test/test_md5 \
102-
test/test_bisect \
103-
test/test_datetime \
102+
test/test_mimetools \
104103
test/test_operator \
105-
test/test_colorsys \
104+
test/test_quopri \
105+
test/test_rfc822 \
106+
test/test_slice \
107+
test/test_string \
108+
test/test_tuple \
109+
test/test_uu \
106110
threading_test \
107111
time_test \
108112
types_test \

compiler/expr_visitor_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ def foo():
188188
'12345678901234567890L')
189189
testNumFloat = _MakeLiteralTest('102.1')
190190
testNumFloatOnlyDecimal = _MakeLiteralTest('.5', '0.5')
191-
testNumFloatNoDecimal = _MakeLiteralTest('5.', '5')
192-
testNumFloatSci = _MakeLiteralTest('1e6', '1e+06')
193-
testNumFloatSciCap = _MakeLiteralTest('1E6', '1e+06')
194-
testNumFloatSciCapPlus = _MakeLiteralTest('1E+6', '1e+06')
191+
testNumFloatNoDecimal = _MakeLiteralTest('5.', '5.0')
192+
testNumFloatSci = _MakeLiteralTest('1e6', '1000000.0')
193+
testNumFloatSciCap = _MakeLiteralTest('1E6', '1000000.0')
194+
testNumFloatSciCapPlus = _MakeLiteralTest('1E+6', '1000000.0')
195195
testNumFloatSciMinus = _MakeLiteralTest('1e-06')
196196
testNumComplex = _MakeLiteralTest('3j')
197197

lib/cStringIO.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../third_party/stdlib/StringIO.py

lib/os/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,19 @@
1919
import stat as stat_module
2020
import sys
2121
from __go__.io.ioutil import ReadDir
22-
from __go__.os import Chdir, Chmod, Environ, Getwd, Remove, Stat
22+
from __go__.os import (
23+
Chdir, Chmod, Environ, Getpid as getpid, Getwd, Remove, Stat)
2324
from __go__.path.filepath import Separator
2425
from __go__.grumpy import NewFileFromFD
26+
from __go__.runtime import GOOS
2527
from __go__.syscall import Close, SYS_FCNTL, Syscall, F_GETFD
2628
from __go__.time import Second
2729

30+
2831
sep = chr(Separator)
2932
error = OSError # pylint: disable=invalid-name
30-
curdir = "."
33+
curdir = '.'
34+
name = 'posix'
3135

3236

3337
environ = {}
@@ -120,3 +124,6 @@ def stat(filepath):
120124
if err:
121125
raise OSError(err.Error())
122126
return StatResult(info)
127+
128+
129+
unlink = remove

lib/sys.py

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

1717
from __go__.os import Args
1818
from __go__.grumpy import SysmoduleDict, SysModules, MaxInt, Stdin, Stdout, Stderr # pylint: disable=g-multiple-import
19-
from __go__.runtime import Version
19+
from __go__.runtime import (GOOS as platform, Version)
2020
from __go__.unicode import MaxRune
2121

2222

@@ -44,6 +44,7 @@
4444
warnoptions = []
4545
# TODO: Support actual byteorder
4646
byteorder = 'little'
47+
version = '2.7.13'
4748

4849

4950
class _Flags(object):
@@ -69,6 +70,10 @@ class _Flags(object):
6970
flags = _Flags()
7071

7172

73+
def exc_clear():
74+
__frame__().__exc_clear__()
75+
76+
7277
def exc_info():
7378
e, tb = __frame__().__exc_info__() # pylint: disable=undefined-variable
7479
t = None

lib/sys_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ def TestSysModules():
3232
assert sys.modules['sys'] is not None
3333

3434

35+
def TestExcClear():
36+
try:
37+
raise RuntimeError
38+
except:
39+
assert all(sys.exc_info()), sys.exc_info()
40+
sys.exc_clear()
41+
assert not any(sys.exc_info())
42+
else:
43+
assert False
44+
45+
3546
def TestExcInfoNoException():
3647
assert sys.exc_info() == (None, None, None)
3748

lib/threading.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ def __init__(self):
2727
self._is_set = False
2828

2929
def set(self):
30-
self._mutex.Lock()
31-
try:
32-
self._is_set = True
33-
finally:
34-
self._mutex.Unlock()
35-
self._cond.Broadcast()
30+
self._set(True)
31+
32+
def clear(self):
33+
self._set(False)
3634

3735
# TODO: Support timeout param.
3836
def wait(self):
@@ -44,6 +42,14 @@ def wait(self):
4442
self._mutex.Unlock()
4543
return True
4644

45+
def _set(self, is_set):
46+
self._mutex.Lock()
47+
try:
48+
self._is_set = is_set
49+
finally:
50+
self._mutex.Unlock()
51+
self._cond.Broadcast()
52+
4753

4854
class Thread(object):
4955
"""Thread is an activity to be executed concurrently."""

lib/threading_test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ def Target():
3535
e.set()
3636
t.join()
3737
assert target_result == ['ready']
38+
target_result[:] = []
39+
t = threading.Thread(target=Target)
40+
t.start()
41+
t.join()
42+
assert target_result == ['ready']
43+
target_result[:] = []
44+
e.clear()
45+
t = threading.Thread(target=Target)
46+
t.start()
47+
time.sleep(0.1)
48+
assert not target_result
49+
e.set()
50+
t.join()
51+
assert target_result == ['ready']
3852

3953

4054
def TestThread():

runtime/builtin_types.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ var builtinTypes = map[*Type]*builtinTypeInfo{
130130
IndexErrorType: {global: true},
131131
IntType: {init: initIntType, global: true},
132132
IOErrorType: {global: true},
133+
KeyboardInterruptType: {global: true},
133134
KeyErrorType: {global: true},
134135
listIteratorType: {init: initListIteratorType},
135136
ListType: {init: initListType, global: true},
@@ -732,9 +733,9 @@ Outer:
732733
elem, raised := Next(f, iter)
733734
if raised != nil {
734735
if raised.isInstance(StopIterationType) {
736+
f.RestoreExc(nil, nil)
735737
break Outer
736738
}
737-
f.RestoreExc(nil, nil)
738739
return nil, raised
739740
}
740741
elems[i] = elem
@@ -929,9 +930,9 @@ func zipLongest(f *Frame, args Args) ([][]*Object, *BaseException) {
929930
if raised.isInstance(StopIterationType) {
930931
iters[i] = nil
931932
elems[i] = None
933+
f.RestoreExc(nil, nil)
932934
continue
933935
}
934-
f.RestoreExc(nil, nil)
935936
return nil, raised
936937
}
937938
noItems = false

runtime/code.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ func (c *Code) Eval(f *Frame, globals *Dict, args Args, kwargs KWArgs) (*Object,
7575
}
7676
} else {
7777
_, tb := f.ExcInfo()
78-
tb = newTraceback(f, tb)
78+
if f.code != nil {
79+
// The root frame has no code object so don't include it
80+
// in the traceback.
81+
tb = newTraceback(f, tb)
82+
}
7983
f.RestoreExc(raised, tb)
8084
}
8185
return ret, raised

0 commit comments

Comments
 (0)