Skip to content

Commit 312e57e

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents f261296 + f7ea0a4 commit 312e57e

File tree

6 files changed

+40
-11
lines changed

6 files changed

+40
-11
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,14 @@ Lots!
7777

7878
* [grumpy](https://github.com/grumpyhome/grumpy) - a python to go transpiler
7979

80+
## Community
81+
82+
You can chat with the go-python community (or which gpython is part)
83+
at [go-python@googlegroups.com](https://groups.google.com/forum/#!forum/go-python)
84+
or on the [Gophers Slack](https://gophers.slack.com/) in the `#go-python` channel.
85+
8086
## License
8187

8288
This is licensed under the MIT licence, however it contains code which
8389
was ported fairly directly directly from the cpython source code under
84-
the (PSF LICENSE)[https://github.com/python/cpython/blob/master/LICENSE].
90+
the [PSF LICENSE](https://github.com/python/cpython/blob/master/LICENSE).

parser/make_grammar_test.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import sys
1212
import ast
13+
import datetime
1314
import subprocess
1415

1516
inp = [
@@ -57,6 +58,7 @@
5758
("[1,]", "eval"),
5859
("[1,2]", "eval"),
5960
("[1,2,]", "eval"),
61+
("[e for e in (1,2,3)]", "eval"),
6062

6163
# tuple
6264
("( a for a in ab )", "eval"),
@@ -375,6 +377,9 @@
375377
("a, b = *a", "exec"),
376378
("a = yield a", "exec"),
377379
('''a.b = 1''', "exec"),
380+
("[e for e in [1, 2, 3]] = 3", "exec", SyntaxError),
381+
("{e for e in [1, 2, 3]} = 3", "exec", SyntaxError),
382+
("{e: e**2 for e in [1, 2, 3]} = 3", "exec", SyntaxError),
378383
('''f() = 1''', "exec", SyntaxError),
379384
('''lambda: x = 1''', "exec", SyntaxError),
380385
('''(a + b) = 1''', "exec", SyntaxError),
@@ -493,21 +498,26 @@ def escape(x):
493498
def main():
494499
"""Write grammar_data_test.go"""
495500
path = "grammar_data_test.go"
496-
out = ["""// Test data generated by make_grammar_test.py - do not edit
501+
year = datetime.datetime.now().year
502+
out = ["""// Copyright {year} The go-python Authors. All rights reserved.
503+
// Use of this source code is governed by a BSD-style
504+
// license that can be found in the LICENSE file.
505+
506+
// Test data generated by make_grammar_test.py - do not edit
497507
498508
package parser
499509
500510
import (
501511
"github.com/go-python/gpython/py"
502512
)
503513
504-
var grammarTestData = []struct {
514+
var grammarTestData = []struct {{
505515
in string
506516
mode string
507517
out string
508518
exceptionType *py.Type
509519
errString string
510-
}{"""]
520+
}}{{""".format(year=year)]
511521
for x in inp:
512522
source, mode = x[:2]
513523
if len(x) > 2:

py/exception.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,7 @@ func (exc *ExceptionInfo) TracebackDump(w io.Writer) {
158158
}
159159
fmt.Fprintf(w, "Traceback (most recent call last):\n")
160160
exc.Traceback.TracebackDump(w)
161-
name := "<nil>"
162-
if exc.Type != nil {
163-
name = exc.Type.Name
164-
}
165-
fmt.Fprintf(w, "%v: %v\n", name, exc.Value)
161+
fmt.Fprintf(w, "%v\n", exc.Value)
166162
}
167163

168164
// Test for being set

py/sequence.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,13 @@ func Iterate(obj Object, fn func(Object) bool) error {
9393
return err
9494
}
9595
for {
96-
item, finished := Next(iterator)
97-
if finished != nil {
96+
item, err := Next(iterator)
97+
if err == StopIteration {
9898
break
9999
}
100+
if err != nil {
101+
return err
102+
}
100103
if fn(item) {
101104
break
102105
}

repl/web/wasm_exec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
// Slightly modified by ncw to:
6+
// * add empty implementation of fsyncSync
7+
// See wasm_exec.js.patch for details
8+
59
(() => {
610
// Map web browser API and Node.js API to a single common API (preferring web standards over Node.js API).
711
const isNodeJS = typeof process !== "undefined";
@@ -59,6 +63,8 @@
5963
err.code = "ENOSYS";
6064
callback(err);
6165
},
66+
fsyncSync(fd) {
67+
},
6268
};
6369
}
6470

vm/tests/generators.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ def g2():
2525
yield i
2626
assert tuple(g2()) == (0,1,2,3,4)
2727

28+
doc="generator 3"
29+
ok = False
30+
try:
31+
list(ax for x in range(10))
32+
except NameError:
33+
ok = True
34+
assert ok, "NameError not raised"
35+
2836
doc="yield from"
2937
def g3():
3038
yield "potato"

0 commit comments

Comments
 (0)