diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1daf04ba..1adebcbc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,8 @@ jobs: - name: Checkout code uses: actions/checkout@v2 + with: + fetch-depth: 1 - name: Cache-Go uses: actions/cache@v1 @@ -90,6 +92,12 @@ jobs: if: matrix.platform == 'macos-latest' run: | go run ./ci/run-tests.go $TAGS -race + - name: static-check + uses: dominikh/staticcheck-action@v1.2.0 + with: + install-go: false + cache-key: ${{ matrix.platform }} + version: "2022.1" - name: Upload-Coverage if: matrix.platform == 'ubuntu-latest' uses: codecov/codecov-action@v1 diff --git a/compile/compile.go b/compile/compile.go index 6b9d926d..76d46c1a 100644 --- a/compile/compile.go +++ b/compile/compile.go @@ -435,9 +435,11 @@ func (c *compiler) Jump(Op vm.OpCode, Dest *Label) { c.OpCodes.Add(instr) } -/* The test for LOCAL must come before the test for FREE in order to - handle classes where name is both local and free. The local var is - a method and the free var is a free var referenced within a method. +/* +The test for LOCAL must come before the test for FREE in order to + + handle classes where name is both local and free. The local var is + a method and the free var is a free var referenced within a method. */ func (c *compiler) getRefType(name string) symtable.Scope { if c.scopeType == compilerScopeClass && name == "__class__" { @@ -666,27 +668,31 @@ func (c *compiler) class(Ast ast.Ast, class *ast.ClassDef) { } /* - Implements the with statement from PEP 343. - - The semantics outlined in that PEP are as follows: - - with EXPR as VAR: - BLOCK - - It is implemented roughly as: - - context = EXPR - exit = context.__exit__ # not calling it - value = context.__enter__() - try: - VAR = value # if VAR present in the syntax - BLOCK - finally: - if an exception was raised: - exc = copy of (exception, instance, traceback) - else: - exc = (None, None, None) - exit(*exc) +Implements the with statement from PEP 343. + +The semantics outlined in that PEP are as follows: + +with EXPR as VAR: + + BLOCK + +It is implemented roughly as: + +context = EXPR +exit = context.__exit__ # not calling it +value = context.__enter__() +try: + + VAR = value # if VAR present in the syntax + BLOCK + +finally: + + if an exception was raised: + exc = copy of (exception, instance, traceback) + else: + exc = (None, None, None) + exit(*exc) */ func (c *compiler) with(node *ast.With, pos int) { item := node.Items[pos] @@ -728,37 +734,38 @@ func (c *compiler) with(node *ast.With, pos int) { c.Op(vm.END_FINALLY) } -/* Code generated for "try:
finally:
- POP_BLOCK
- LOAD_CONST
- L:
- END_FINALLY
-
- The special instructions use the block stack. Each block
- stack entry contains the instruction that created it (here
- SETUP_FINALLY), the level of the value stack at the time the
- block stack entry was created, and a label (here L).
-
- SETUP_FINALLY:
- Pushes the current value stack level and the label
- onto the block stack.
- POP_BLOCK:
- Pops en entry from the block stack, and pops the value
- stack until its level is the same as indicated on the
- block stack. (The label is ignored.)
- END_FINALLY:
- Pops a variable number of entries from the *value* stack
- and re-raises the exception they specify. The number of
- entries popped depends on the (pseudo) exception type.
-
- The block stack is unwound when an exception is raised:
- when a SETUP_FINALLY entry is found, the exception is pushed
- onto the value stack (and the exception condition is cleared),
- and the interpreter jumps to the label gotten from the block
- stack.
+/*
+Code generated for "try: finally: " is as follows:
+
+ SETUP_FINALLY L
+
+ POP_BLOCK
+ LOAD_CONST
+ L:
+ END_FINALLY
+
+ The special instructions use the block stack. Each block
+ stack entry contains the instruction that created it (here
+ SETUP_FINALLY), the level of the value stack at the time the
+ block stack entry was created, and a label (here L).
+
+ SETUP_FINALLY:
+ Pushes the current value stack level and the label
+ onto the block stack.
+ POP_BLOCK:
+ Pops en entry from the block stack, and pops the value
+ stack until its level is the same as indicated on the
+ block stack. (The label is ignored.)
+ END_FINALLY:
+ Pops a variable number of entries from the *value* stack
+ and re-raises the exception they specify. The number of
+ entries popped depends on the (pseudo) exception type.
+
+ The block stack is unwound when an exception is raised:
+ when a SETUP_FINALLY entry is found, the exception is pushed
+ onto the value stack (and the exception condition is cleared),
+ and the interpreter jumps to the label gotten from the block
+ stack.
*/
func (c *compiler) tryFinally(node *ast.Try) {
end := new(Label)
@@ -780,35 +787,36 @@ func (c *compiler) tryFinally(node *ast.Try) {
}
/*
- Code generated for "try: S except E1 as V1: S1 except E2 as V2: S2 ...":
- (The contents of the value stack is shown in [], with the top
- at the right; 'tb' is trace-back info, 'val' the exception's
- associated value, and 'exc' the exception.)
-
- Value stack Label Instruction Argument
- [] SETUP_EXCEPT L1
- []
- [] POP_BLOCK
- [] JUMP_FORWARD L0
-
- [tb, val, exc] L1: DUP )
- [tb, val, exc, exc] )
- [tb, val, exc, exc, E1] COMPARE_OP EXC_MATCH ) only if E1
- [tb, val, exc, 1-or-0] POP_JUMP_IF_FALSE L2 )
- [tb, val, exc] POP
- [tb, val] (or POP if no V1)
- [tb] POP
- []
- JUMP_FORWARD L0
-
- [tb, val, exc] L2: DUP
- .............................etc.......................
-
- [tb, val, exc] Ln+1: END_FINALLY # re-raise exception
-
- [] L0:
-
- Of course, parts are not generated if Vi or Ei is not present.
+Code generated for "try: S except E1 as V1: S1 except E2 as V2: S2 ...":
+(The contents of the value stack is shown in [], with the top
+at the right; 'tb' is trace-back info, 'val' the exception's
+associated value, and 'exc' the exception.)
+
+Value stack Label Instruction Argument
+[] SETUP_EXCEPT L1
+[]
+[] POP_BLOCK
+[] JUMP_FORWARD L0
+
+[tb, val, exc] L1: DUP )
+[tb, val, exc, exc] )
+[tb, val, exc, exc, E1] COMPARE_OP EXC_MATCH ) only if E1
+[tb, val, exc, 1-or-0] POP_JUMP_IF_FALSE L2 )
+[tb, val, exc] POP
+[tb, val] (or POP if no V1)
+[tb] POP
+[]
+
+ JUMP_FORWARD L0
+
+[tb, val, exc] L2: DUP
+.............................etc.......................
+
+[tb, val, exc] Ln+1: END_FINALLY # re-raise exception
+
+[] L0:
+
+Of course, parts are not generated if Vi or Ei is not present.
*/
func (c *compiler) tryExcept(node *ast.Try) {
c.loops.Push(loop{Type: exceptLoop})
@@ -897,11 +905,13 @@ func (c *compiler) try(node *ast.Try) {
}
}
-/* The IMPORT_NAME opcode was already generated. This function
- merely needs to bind the result to a name.
+/*
+The IMPORT_NAME opcode was already generated. This function
+
+ merely needs to bind the result to a name.
- If there is a dot in name, we need to split it and emit a
- LOAD_ATTR for each name.
+ If there is a dot in name, we need to split it and emit a
+ LOAD_ATTR for each name.
*/
func (c *compiler) importAs(name ast.Identifier, asname ast.Identifier) {
attrs := strings.Split(string(name), ".")
@@ -913,12 +923,14 @@ func (c *compiler) importAs(name ast.Identifier, asname ast.Identifier) {
c.NameOp(string(asname), ast.Store)
}
-/* The Import node stores a module name like a.b.c as a single
- string. This is convenient for all cases except
- import a.b.c as d
- where we need to parse that string to extract the individual
- module names.
- XXX Perhaps change the representation to make this case simpler?
+/*
+The Import node stores a module name like a.b.c as a single
+
+ string. This is convenient for all cases except
+ import a.b.c as d
+ where we need to parse that string to extract the individual
+ module names.
+ XXX Perhaps change the representation to make this case simpler?
*/
func (c *compiler) import_(node *ast.Import) {
//n = asdl_seq_LEN(s.v.Import.names);
@@ -1207,6 +1219,7 @@ func (c *compiler) Stmt(stmt ast.Stmt) {
l := c.loops.Top()
if l == nil {
c.panicSyntaxErrorf(node, loopError)
+ panic("impossible")
}
switch l.Type {
case loopLoop:
@@ -1393,7 +1406,9 @@ func (c *compiler) callHelper(n int, Args []ast.Expr, Keywords []*ast.Keyword, S
c.OpArg(op, uint32(args+kwargs<<8))
}
-/* List and set comprehensions and generator expressions work by creating a
+/*
+ List and set comprehensions and generator expressions work by creating a
+
nested function to perform the actual iteration. This means that the
iteration variables don't leak into the current scope.
The defined function is called immediately following its definition, with the
diff --git a/main.go b/main.go
index 4598a62d..8be7ea2e 100644
--- a/main.go
+++ b/main.go
@@ -21,10 +21,7 @@ import (
_ "github.com/go-python/gpython/stdlib"
)
-// Globals
var (
- // Flags
- debug = flag.Bool("d", false, "Print lots of debugging")
cpuprofile = flag.String("cpuprofile", "", "Write cpu profile to file")
)
diff --git a/parser/lexer_test.go b/parser/lexer_test.go
index ab252088..9971c2d7 100644
--- a/parser/lexer_test.go
+++ b/parser/lexer_test.go
@@ -7,8 +7,6 @@ package parser
import (
"bytes"
"fmt"
- "log"
- "math"
"testing"
"github.com/go-python/gpython/ast"
@@ -569,19 +567,6 @@ func TestLexerReadOperator(t *testing.T) {
}
}
-// Whether two floats are more or less the same
-func approxEq(a, b float64) bool {
- log.Printf("ApproxEq(a = %#v, b = %#v)", a, b)
- diff := a - b
- log.Printf("ApproxEq(diff = %e)", diff)
- if math.Abs(diff) > 1e-10 {
- log.Printf("ApproxEq(false)")
- return false
- }
- log.Printf("ApproxEq(true)")
- return true
-}
-
func TestLexerReadNumber(t *testing.T) {
x := yyLex{}
for _, test := range []struct {
@@ -710,10 +695,10 @@ func TestLexerReadString(t *testing.T) {
if testValueBytes, ok := test.value.(py.Bytes); !ok {
t.Error("Expecting py.Bytes")
} else {
- equal = (bytes.Compare(valueBytes, testValueBytes) == 0)
+ equal = bytes.Equal(valueBytes, testValueBytes)
}
} else {
- equal = (value == test.value)
+ equal = value == test.value
}
if token != test.token || !equal || x.line != test.out {
diff --git a/parser/y.go b/parser/y.go
index 1f5bba73..39027c98 100644
--- a/parser/y.go
+++ b/parser/y.go
@@ -3,6 +3,7 @@
// license that can be found in the LICENSE file.
// Code generated by goyacc -v y.output grammar.y. DO NOT EDIT.
+//
//line grammar.y:6
package parser
diff --git a/py/complex.go b/py/complex.go
index 8f42a480..e39f2f64 100644
--- a/py/complex.go
+++ b/py/complex.go
@@ -152,13 +152,6 @@ func complexFloor(a Complex) Complex {
return Complex(complex(math.Floor(real(a)), math.Floor(imag(a))))
}
-// Floor divide two complex numbers
-func complexFloorDiv(a, b Complex) Complex {
- q := complexFloor(a / b)
- r := a - q*b
- return Complex(r)
-}
-
func (a Complex) M__floordiv__(other Object) (Object, error) {
if b, ok := convertToComplex(other); ok {
return complexFloor(a / b), nil
diff --git a/py/exception.go b/py/exception.go
index 8dde2e67..a2abbcac 100644
--- a/py/exception.go
+++ b/py/exception.go
@@ -330,7 +330,7 @@ func ExceptionGivenMatches(err, exc Object) bool {
// IsException matches the result of recover to an exception
//
-// For use to catch a single python exception from go code
+// # For use to catch a single python exception from go code
//
// It can be an instance or the class itself
func IsException(exception *Type, r interface{}) bool {
diff --git a/py/frame.go b/py/frame.go
index ce595d8a..3e5c9f99 100644
--- a/py/frame.go
+++ b/py/frame.go
@@ -158,17 +158,18 @@ func (f *Frame) PopBlock() {
}
}
-/* Convert between "fast" version of locals and dictionary version.
+/*
+Convert between "fast" version of locals and dictionary version.
- map and values are input arguments. map is a tuple of strings.
- values is an array of PyObject*. At index i, map[i] is the name of
- the variable with value values[i]. The function copies the first
- nmap variable from map/values into dict. If values[i] is NULL,
- the variable is deleted from dict.
+ map and values are input arguments. map is a tuple of strings.
+ values is an array of PyObject*. At index i, map[i] is the name of
+ the variable with value values[i]. The function copies the first
+ nmap variable from map/values into dict. If values[i] is NULL,
+ the variable is deleted from dict.
- If deref is true, then the values being copied are cell variables
- and the value is extracted from the cell variable before being put
- in dict.
+ If deref is true, then the values being copied are cell variables
+ and the value is extracted from the cell variable before being put
+ in dict.
*/
func map_to_dict(mapping []string, nmap int, dict StringDict, values []Object, deref bool) {
for j := nmap - 1; j >= 0; j-- {
@@ -189,25 +190,26 @@ func map_to_dict(mapping []string, nmap int, dict StringDict, values []Object, d
}
}
-/* Copy values from the "locals" dict into the fast locals.
+/*
+Copy values from the "locals" dict into the fast locals.
- dict is an input argument containing string keys representing
- variables names and arbitrary PyObject* as values.
+ dict is an input argument containing string keys representing
+ variables names and arbitrary PyObject* as values.
- mapping and values are input arguments. mapping is a tuple of strings.
- values is an array of PyObject*. At index i, mapping[i] is the name of
- the variable with value values[i]. The function copies the first
- nmap variable from mapping/values into dict. If values[i] is nil,
- the variable is deleted from dict.
+ mapping and values are input arguments. mapping is a tuple of strings.
+ values is an array of PyObject*. At index i, mapping[i] is the name of
+ the variable with value values[i]. The function copies the first
+ nmap variable from mapping/values into dict. If values[i] is nil,
+ the variable is deleted from dict.
- If deref is true, then the values being copied are cell variables
- and the value is extracted from the cell variable before being put
- in dict. If clear is true, then variables in mapping but not in dict
- are set to nil in mapping; if clear is false, variables missing in
- dict are ignored.
+ If deref is true, then the values being copied are cell variables
+ and the value is extracted from the cell variable before being put
+ in dict. If clear is true, then variables in mapping but not in dict
+ are set to nil in mapping; if clear is false, variables missing in
+ dict are ignored.
- Exceptions raised while modifying the dict are silently ignored,
- because there is no good way to report them.
+ Exceptions raised while modifying the dict are silently ignored,
+ because there is no good way to report them.
*/
func dict_to_map(mapping []string, nmap int, dict StringDict, values []Object, deref bool, clear bool) {
for j := nmap - 1; j >= 0; j-- {
diff --git a/py/gen.go b/py/gen.go
index 4b32a883..16db6ad8 100644
--- a/py/gen.go
+++ b/py/gen.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build ignore
// +build ignore
package main
diff --git a/py/import.go b/py/import.go
index 0eaae921..709a4468 100644
--- a/py/import.go
+++ b/py/import.go
@@ -272,7 +272,7 @@ func XImportModuleLevelObject(ctx Context, nameObj, given_globals, locals, given
if err != nil {
return nil, err
}
- } else {
+ // } else { // not initializing
// FIXME locking
// if _PyImport_ReleaseLock() < 0 {
// return nil, ExceptionNewf(RuntimeError, "not holding the import lock")
diff --git a/py/py.go b/py/py.go
index 59d0737a..2ebd5fcd 100644
--- a/py/py.go
+++ b/py/py.go
@@ -39,7 +39,7 @@ var (
// If __new__() does not return an instance of cls, then the new instance’s __init__() method will not be invoked.
//
// __new__() is intended mainly to allow subclasses of immutable types (like int, str, or tuple) to customize instance creation. It is also commonly overridden in custom metaclasses in order to customize class creation.
-//object.__new__(cls[, ...])
+// object.__new__(cls[, ...])
type I__new__ interface {
M__new__(cls, args, kwargs Object) (Object, error)
}
@@ -52,7 +52,7 @@ type I__new__ interface {
// [args...]). As a special constraint on constructors, no value may
// be returned; doing so will cause a TypeError to be raised at
// runtime.
-//object.__init__(self[, ...])
+// object.__init__(self[, ...])
type I__init__ interface {
M__init__(self, args, kwargs Object) (Object, error)
}
@@ -101,7 +101,7 @@ type I__init__ interface {
// globals are deleted; if no other references to such globals exist,
// this may help in assuring that imported modules are still available
// at the time when the __del__() method is called.
-//object.__del__(self)
+// object.__del__(self)
type I__del__ interface {
M__del__() (Object, error)
}
@@ -118,7 +118,7 @@ type I__del__ interface {
//
// This is typically used for debugging, so it is important that the
// representation is information-rich and unambiguous.
-//object.__repr__(self)
+// object.__repr__(self)
type I__repr__ interface {
M__repr__() (Object, error)
}
@@ -134,14 +134,14 @@ type I__repr__ interface {
//
// The default implementation defined by the built-in type object
// calls object.__repr__().
-//object.__str__(self)
+// object.__str__(self)
type I__str__ interface {
M__str__() (Object, error)
}
// Called by bytes() to compute a byte-string representation of an
// object. This should return a bytes object.
-//object.__bytes__(self)
+// object.__bytes__(self)
type I__bytes__ interface {
M__bytes__() (Object, error)
}
@@ -159,7 +159,7 @@ type I__bytes__ interface {
// standard formatting syntax.
//
// The return value must be a string object.
-//object.__format__(self, format_spec)
+// object.__format__(self, format_spec)
type I__format__ interface {
M__format__(format_spec Object) (Object, error)
}
@@ -196,32 +196,32 @@ type I__format__ interface {
//
// To automatically generate ordering operations from a single root
// operation, see functools.total_ordering().
-//object.__lt__(self, other)
+// object.__lt__(self, other)
type I__lt__ interface {
M__lt__(other Object) (Object, error)
}
-//object.__le__(self, other)
+// object.__le__(self, other)
type I__le__ interface {
M__le__(other Object) (Object, error)
}
-//object.__eq__(self, other)
+// object.__eq__(self, other)
type I__eq__ interface {
M__eq__(other Object) (Object, error)
}
-//object.__ne__(self, other)
+// object.__ne__(self, other)
type I__ne__ interface {
M__ne__(other Object) (Object, error)
}
-//object.__gt__(self, other)
+// object.__gt__(self, other)
type I__gt__ interface {
M__gt__(other Object) (Object, error)
}
-//object.__ge__(self, other)
+// object.__ge__(self, other)
type I__ge__ interface {
M__ge__(other Object) (Object, error)
}
@@ -300,8 +300,8 @@ type richComparison interface {
//
// See also PYTHONHASHSEED.
//
-//Changed in version 3.3: Hash randomization is enabled by default.
-//object.__hash__(self)
+// Changed in version 3.3: Hash randomization is enabled by default.
+// object.__hash__(self)
type I__hash__ interface {
M__hash__() (Object, error)
}
@@ -312,7 +312,7 @@ type I__hash__ interface {
// considered true if its result is nonzero. If a class defines
// neither __len__() nor __bool__(), all its instances are considered
// true.
-//object.__bool__(self)
+// object.__bool__(self)
type I__bool__ interface {
M__bool__() (Object, error)
}
@@ -335,7 +335,7 @@ type I__bool__ interface {
// instead inserting them in another object). See the
// __getattribute__() method below for a way to actually get total
// control over attribute access.
-//object.__getattr__(self, name)
+// object.__getattr__(self, name)
type I__getattr__ interface {
M__getattr__(name string) (Object, error)
}
@@ -350,10 +350,10 @@ type I__getattr__ interface {
// same name to access any attributes it needs, for example,
// object.__getattribute__(self, name).
//
-//Note This method may still be bypassed when looking up special
-//methods as the result of implicit invocation via language syntax or
-//built-in functions. See Special method lookup.
-//object.__getattribute__(self, name)
+// Note This method may still be bypassed when looking up special
+// methods as the result of implicit invocation via language syntax or
+// built-in functions. See Special method lookup.
+// object.__getattribute__(self, name)
type I__getattribute__ interface {
M__getattribute__(name string) (Object, error)
}
@@ -366,7 +366,7 @@ type I__getattribute__ interface {
// If __setattr__() wants to assign to an instance attribute, it
// should call the base class method with the same name, for example,
// object.__setattr__(self, name, value).
-//object.__setattr__(self, name, value)
+// object.__setattr__(self, name, value)
type I__setattr__ interface {
M__setattr__(name string, value Object) (Object, error)
}
@@ -374,7 +374,7 @@ type I__setattr__ interface {
// Like __setattr__() but for attribute deletion instead of
// assignment. This should only be implemented if del obj.name is
// meaningful for the object.
-//object.__delattr__(self, name)
+// object.__delattr__(self, name)
type I__delattr__ interface {
M__delattr__(name string) (Object, error)
}
@@ -382,7 +382,7 @@ type I__delattr__ interface {
// Called when dir() is called on the object. A sequence must be
// returned. dir() converts the returned sequence to a list and sorts
// it.
-//object.__dir__(self)
+// object.__dir__(self)
type I__dir__ interface {
M__dir__() (Object, error)
}
@@ -401,21 +401,21 @@ type I__dir__ interface {
// attribute is accessed through the owner. This method should return
// the (computed) attribute value or raise an AttributeError
// exception.
-//object.__get__(self, instance, owner)
+// object.__get__(self, instance, owner)
type I__get__ interface {
M__get__(instance, owner Object) (Object, error)
}
// Called to set the attribute on an instance of the owner
// class to a new value.
-//object.__set__(self, instance, value)
+// object.__set__(self, instance, value)
type I__set__ interface {
M__set__(instance, value Object) (Object, error)
}
// Called to delete the attribute on an instance instance of the owner
// class.
-//object.__delete__(self, instance)
+// object.__delete__(self, instance)
type I__delete__ interface {
M__delete__(instance Object) (Object, error)
}
@@ -437,7 +437,7 @@ type I__delete__ interface {
// Return true if instance should be considered a (direct or indirect)
// instance of class. If defined, called to implement
// isinstance(instance, class).
-//object.__instancecheck__(self, instance)
+// object.__instancecheck__(self, instance)
type I__instancecheck__ interface {
M__instancecheck__(instance Object) (Object, error)
}
@@ -445,7 +445,7 @@ type I__instancecheck__ interface {
// Return true if subclass should be considered a (direct or indirect)
// subclass of class. If defined, called to implement
// issubclass(subclass, class).
-//object.__subclasscheck__(self, subclass)
+// object.__subclasscheck__(self, subclass)
type I__subclasscheck__ interface {
M__subclasscheck__(subclass Object) (Object, error)
}
@@ -453,7 +453,7 @@ type I__subclasscheck__ interface {
// Called when the instance is “called” as a function; if this method
// is defined, x(arg1, arg2, ...) is a shorthand for x.__call__(arg1,
// arg2, ...).
-//object.__call__(self[, args...])
+// object.__call__(self[, args...])
type I__call__ interface {
M__call__(args Tuple, kwargs StringDict) (Object, error)
}
@@ -491,7 +491,7 @@ type I__call__ interface {
// length of the object, an integer >= 0. Also, an object that doesn’t
// define a __bool__() method and whose __len__() method returns zero
// is considered to be false in a Boolean context.
-//object.__len__(self)
+// object.__len__(self)
type I__len__ interface {
M__len__() (Object, error)
}
@@ -502,7 +502,7 @@ type I__len__ interface {
// is purely an optimization and is never required for correctness.
//
// New in version 3.4.
-//object.__length_hint__(self)
+// object.__length_hint__(self)
type I__length_hint__ interface {
M__length_hint__() (Object, error)
}
@@ -525,7 +525,7 @@ type I__length_hint__ interface {
//
// Note for loops expect that an IndexError will be raised for illegal
// indexes to allow proper detection of the end of the sequence.
-//object.__getitem__(self, key)
+// object.__getitem__(self, key)
type I__getitem__ interface {
M__getitem__(key Object) (Object, error)
}
@@ -546,7 +546,7 @@ type I__setitem__ interface {
// objects support removal of keys, or for sequences if elements can
// be removed from the sequence. The same exceptions should be raised
// for improper key values as for the __getitem__() method.
-//object.__delitem__(self, key)
+// object.__delitem__(self, key)
type I__delitem__ interface {
M__delitem__(key Object) (Object, error)
}
@@ -560,7 +560,7 @@ type I__delitem__ interface {
// Iterator objects also need to implement this method; they are
// required to return themselves. For more information on iterator
// objects, see Iterator Types.
-//object.__iter__(self)
+// object.__iter__(self)
type I__iter__ interface {
M__iter__() (Object, error)
}
@@ -605,7 +605,7 @@ type I_generator interface {
// should only provide __reversed__() if they can provide an
// implementation that is more efficient than the one provided by
// reversed().
-//object.__reversed__(self)
+// object.__reversed__(self)
type I__reversed__ interface {
M__reversed__() (Object, error)
}
@@ -625,7 +625,7 @@ type I__reversed__ interface {
// first tries iteration via __iter__(), then the old sequence
// iteration protocol via __getitem__(), see this section in the
// language reference.
-//object.__contains__(self, item)
+// object.__contains__(self, item)
type I__contains__ interface {
M__contains__(item Object) (Object, error)
}
@@ -1011,7 +1011,7 @@ type sequenceArithmetic interface {
// Enter the runtime context related to this object. The with
// statement will bind this method’s return value to the target(s)
// specified in the as clause of the statement, if any.
-//object.__enter__(self)
+// object.__enter__(self)
type I__enter__ interface {
M__enter__() (Object, error)
}
@@ -1028,7 +1028,7 @@ type I__enter__ interface {
//
// Note that __exit__() methods should not reraise the passed-in
// exception; this is the caller’s responsibility.
-//object.__exit__(self, exc_type, exc_value, traceback)
+// object.__exit__(self, exc_type, exc_value, traceback)
type I__exit__ interface {
M__exit__(exc_type, exc_value, traceback Object) (Object, error)
}
diff --git a/py/range_repr110.go b/py/range_repr110.go
index dfe4ee8c..2092ff30 100644
--- a/py/range_repr110.go
+++ b/py/range_repr110.go
@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build go1.10
// +build go1.10
+
// Range object
package py
diff --git a/py/range_repr19.go b/py/range_repr19.go
index 0fd8b791..38c5d6d2 100644
--- a/py/range_repr19.go
+++ b/py/range_repr19.go
@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !go1.10
// +build !go1.10
+
// Range object
package py
diff --git a/py/sequence.go b/py/sequence.go
index 430471c8..9a2a57f2 100644
--- a/py/sequence.go
+++ b/py/sequence.go
@@ -65,7 +65,7 @@ func SequenceSet(v Object) (*Set, error) {
// Call __next__ for the python object
//
-// Returns the next object
+// # Returns the next object
//
// err == StopIteration or subclass when finished
func Next(self Object) (obj Object, err error) {
diff --git a/py/string.go b/py/string.go
index e3b25dd5..58ab7ad0 100644
--- a/py/string.go
+++ b/py/string.go
@@ -334,7 +334,6 @@ func (a String) M__ge__(other Object) (Object, error) {
// % operator
/*
-
4.7.2. printf-style String Formatting
Note The formatting operations described here exhibit a variety of
diff --git a/py/type.go b/py/type.go
index a9f835a4..be6d19af 100644
--- a/py/type.go
+++ b/py/type.go
@@ -458,7 +458,7 @@ func (t *Type) Lookup(name string) Object {
//
// Doesn't call __getattr__ etc
//
-// Returns nil if not found
+// # Returns nil if not found
//
// Doesn't look in the instance dictionary
//
@@ -478,7 +478,7 @@ func (t *Type) NativeGetAttrOrNil(name string) Object {
//
// Doesn't call __getattr__ etc
//
-// Returns nil if not found
+// # Returns nil if not found
//
// FIXME this isn't totally correct!
// as we are ignoring getattribute etc
@@ -552,7 +552,8 @@ func TypeCall2(self Object, name string, arg1, arg2 Object) (Object, bool, error
// Two variants:
//
// - lookup_maybe() returns nil without raising an exception
-// when the _PyType_Lookup() call fails;
+//
+// when the _PyType_Lookup() call fails;
//
// - lookup_method() always raises an exception upon errors.
func lookup_maybe(self Object, attr string) Object {
@@ -569,14 +570,14 @@ func lookup_maybe(self Object, attr string) Object {
return res
}
-func lookup_method(self Object, attr string) Object {
- res := lookup_maybe(self, attr)
- if res == nil {
- // FIXME PyErr_SetObject(PyExc_AttributeError, attrid->object);
- return ExceptionNewf(AttributeError, "'%s' object has no attribute '%s'", self.Type().Name, attr)
- }
- return res
-}
+// func lookup_method(self Object, attr string) Object {
+// res := lookup_maybe(self, attr)
+// if res == nil {
+// // FIXME PyErr_SetObject(PyExc_AttributeError, attrid->object);
+// return ExceptionNewf(AttributeError, "'%s' object has no attribute '%s'", self.Type().Name, attr)
+// }
+// return res
+// }
// Method resolution order algorithm C3 described in
// "A Monotonic Superclass Linearization for Dylan",
@@ -954,26 +955,26 @@ func add_subclass(base, t *Type) {
// return result;
}
-func remove_subclass(base, t *Type) {
- // Py_ssize_t i;
- // PyObject *list, *ref;
-
- // list = base->tp_subclasses;
- // if (list == nil) {
- // return;
- // }
- // assert(PyList_Check(list));
- // i = PyList_GET_SIZE(list);
- // while (--i >= 0) {
- // ref = PyList_GET_ITEM(list, i);
- // assert(PyWeakref_CheckRef(ref));
- // if (PyWeakref_GET_OBJECT(ref) == (PyObject*)type) {
- // /* this can't fail, right? */
- // PySequence_DelItem(list, i);
- // return;
- // }
- // }
-}
+// func remove_subclass(base, t *Type) {
+// // Py_ssize_t i;
+// // PyObject *list, *ref;
+//
+// // list = base->tp_subclasses;
+// // if (list == nil) {
+// // return;
+// // }
+// // assert(PyList_Check(list));
+// // i = PyList_GET_SIZE(list);
+// // while (--i >= 0) {
+// // ref = PyList_GET_ITEM(list, i);
+// // assert(PyWeakref_CheckRef(ref));
+// // if (PyWeakref_GET_OBJECT(ref) == (PyObject*)type) {
+// // /* this can't fail, right? */
+// // PySequence_DelItem(list, i);
+// // return;
+// // }
+// // }
+// }
// Ready the type for use
//
diff --git a/py/util.go b/py/util.go
index 43028bce..56558cac 100644
--- a/py/util.go
+++ b/py/util.go
@@ -88,7 +88,7 @@ func LoadIntsFromList(list Object) ([]int64, error) {
if N <= 0 {
return nil, nil
}
-
+
intList := make([]int64, N)
for i := Int(0); i < N; i++ {
item, err := getter.M__getitem__(i)
diff --git a/py/zip.go b/py/zip.go
index 2626ec01..eee9dc27 100644
--- a/py/zip.go
+++ b/py/zip.go
@@ -10,10 +10,10 @@ type Zip struct {
size int
}
-// A python ZipIterator iterator
-type ZipIterator struct {
- zip Zip
-}
+// // A python ZipIterator iterator
+// type ZipIterator struct {
+// zip Zip
+// }
var ZipType = NewTypeX("zip", `zip(iter1 [,iter2 [...]]) --> zip object
diff --git a/repl/cli/cli.go b/repl/cli/cli.go
index 90f1463b..6648094a 100644
--- a/repl/cli/cli.go
+++ b/repl/cli/cli.go
@@ -12,7 +12,6 @@ import (
"os/user"
"path/filepath"
- "github.com/go-python/gpython/py"
"github.com/go-python/gpython/repl"
"github.com/peterh/liner"
)
@@ -36,7 +35,6 @@ type readline struct {
*liner.State
repl *repl.REPL
historyFile string
- module *py.Module
prompt string
}
diff --git a/repl/web/serve.go b/repl/web/serve.go
index ee9a6b78..30e38e44 100644
--- a/repl/web/serve.go
+++ b/repl/web/serve.go
@@ -1,4 +1,5 @@
-//+build none
+//go:build none
+// +build none
package main
diff --git a/stdlib/math/math.go b/stdlib/math/math.go
index 63ecec00..6c6c32d9 100644
--- a/stdlib/math/math.go
+++ b/stdlib/math/math.go
@@ -62,59 +62,57 @@ raised for division by zero and mod by zero.
*/
/*
- In general, on an IEEE-754 platform the aim is to follow the C99
- standard, including Annex 'F', whenever possible. Where the
- standard recommends raising the 'divide-by-zero' or 'invalid'
- floating-point exceptions, Python should raise a ValueError. Where
- the standard recommends raising 'overflow', Python should raise an
- OverflowError. In all other circumstances a value should be
- returned.
+In general, on an IEEE-754 platform the aim is to follow the C99
+standard, including Annex 'F', whenever possible. Where the
+standard recommends raising the 'divide-by-zero' or 'invalid'
+floating-point exceptions, Python should raise a ValueError. Where
+the standard recommends raising 'overflow', Python should raise an
+OverflowError. In all other circumstances a value should be
+returned.
*/
var (
EDOM = py.ExceptionNewf(py.ValueError, "math domain error")
ERANGE = py.ExceptionNewf(py.OverflowError, "math range error")
)
-// panic if ok is false
-func assert(ok bool) {
- if !ok {
- panic("assertion failed")
- }
-}
-
// isFinite is true if x is not Nan or +/-Inf
func isFinite(x float64) bool {
return !(math.IsInf(x, 0) || math.IsNaN(x))
}
/*
- math_1 is used to wrap a libm function f that takes a float64
- arguments and returns a float64.
-
- The error reporting follows these rules, which are designed to do
- the right thing on C89/C99 platforms and IEEE 754/non IEEE 754
- platforms.
-
- - a NaN result from non-NaN inputs causes ValueError to be raised
- - an infinite result from finite inputs causes OverflowError to be
- raised if can_overflow is 1, or raises ValueError if can_overflow
- is 0.
- - if the result is finite and errno == EDOM then ValueError is
- raised
- - if the result is finite and nonzero and errno == ERANGE then
- OverflowError is raised
-
- The last rule is used to catch overflow on platforms which follow
- C89 but for which HUGE_VAL is not an infinity.
-
- For the majority of one-argument functions these rules are enough
- to ensure that Python's functions behave as specified in 'Annex F'
- of the C99 standard, with the 'invalid' and 'divide-by-zero'
- floating-point exceptions mapping to Python's ValueError and the
- 'overflow' floating-point exception mapping to OverflowError.
- math_1 only works for functions that don't have singularities *and*
- the possibility of overflow; fortunately, that covers everything we
- care about right now.
+math_1 is used to wrap a libm function f that takes a float64
+arguments and returns a float64.
+
+The error reporting follows these rules, which are designed to do
+the right thing on C89/C99 platforms and IEEE 754/non IEEE 754
+platforms.
+
+- a NaN result from non-NaN inputs causes ValueError to be raised
+- an infinite result from finite inputs causes OverflowError to be
+
+ raised if can_overflow is 1, or raises ValueError if can_overflow
+ is 0.
+
+- if the result is finite and errno == EDOM then ValueError is
+
+ raised
+
+- if the result is finite and nonzero and errno == ERANGE then
+
+ OverflowError is raised
+
+The last rule is used to catch overflow on platforms which follow
+C89 but for which HUGE_VAL is not an infinity.
+
+For the majority of one-argument functions these rules are enough
+to ensure that Python's functions behave as specified in 'Annex F'
+of the C99 standard, with the 'invalid' and 'divide-by-zero'
+floating-point exceptions mapping to Python's ValueError and the
+'overflow' floating-point exception mapping to OverflowError.
+math_1 only works for functions that don't have singularities *and*
+the possibility of overflow; fortunately, that covers everything we
+care about right now.
*/
func math_1_to_whatever(arg py.Object, fn func(float64) float64, can_overflow bool) (float64, error) {
x, err := py.FloatAsFloat64(arg)
@@ -140,9 +138,12 @@ func checkResult(x, r float64, can_overflow bool) (float64, error) {
return r, nil
}
-/* variant of math_1, to be used when the function being wrapped is known to
- set errno properly (that is, errno = EDOM for invalid or divide-by-zero,
- errno = ERANGE for overflow). */
+/*
+variant of math_1, to be used when the function being wrapped is known to
+
+ set errno properly (that is, errno = EDOM for invalid or divide-by-zero,
+ errno = ERANGE for overflow).
+*/
func math_1a(arg py.Object, fn func(float64) float64) (py.Object, error) {
x, err := py.FloatAsFloat64(arg)
if err != nil {
@@ -153,30 +154,35 @@ func math_1a(arg py.Object, fn func(float64) float64) (py.Object, error) {
}
/*
- math_2 is used to wrap a libm function f that takes two float64
- arguments and returns a float64.
-
- The error reporting follows these rules, which are designed to do
- the right thing on C89/C99 platforms and IEEE 754/non IEEE 754
- platforms.
-
- - a NaN result from non-NaN inputs causes ValueError to be raised
- - an infinite result from finite inputs causes OverflowError to be
- raised.
- - if the result is finite and errno == EDOM then ValueError is
- raised
- - if the result is finite and nonzero and errno == ERANGE then
- OverflowError is raised
-
- The last rule is used to catch overflow on platforms which follow
- C89 but for which HUGE_VAL is not an infinity.
-
- For most two-argument functions (copysign, fmod, hypot, atan2)
- these rules are enough to ensure that Python's functions behave as
- specified in 'Annex F' of the C99 standard, with the 'invalid' and
- 'divide-by-zero' floating-point exceptions mapping to Python's
- ValueError and the 'overflow' floating-point exception mapping to
- OverflowError.
+math_2 is used to wrap a libm function f that takes two float64
+arguments and returns a float64.
+
+The error reporting follows these rules, which are designed to do
+the right thing on C89/C99 platforms and IEEE 754/non IEEE 754
+platforms.
+
+- a NaN result from non-NaN inputs causes ValueError to be raised
+- an infinite result from finite inputs causes OverflowError to be
+
+ raised.
+
+- if the result is finite and errno == EDOM then ValueError is
+
+ raised
+
+- if the result is finite and nonzero and errno == ERANGE then
+
+ OverflowError is raised
+
+The last rule is used to catch overflow on platforms which follow
+C89 but for which HUGE_VAL is not an infinity.
+
+For most two-argument functions (copysign, fmod, hypot, atan2)
+these rules are enough to ensure that Python's functions behave as
+specified in 'Annex F' of the C99 standard, with the 'invalid' and
+'divide-by-zero' floating-point exceptions mapping to Python's
+ValueError and the 'overflow' floating-point exception mapping to
+OverflowError.
*/
func math_1(arg py.Object, fn func(float64) float64, can_overflow bool) (py.Object, error) {
f, err := math_1_to_whatever(arg, fn, can_overflow)
@@ -446,34 +452,35 @@ const math_tanh_doc = "tanh(x)\n\nReturn the hyperbolic tangent of x."
accurate result returned by sum(itertools.chain(seq1, seq2)).
*/
-/* Full precision summation of a sequence of floats.
-
- def msum(iterable):
- partials = [] # sorted, non-overlapping partial sums
- for x in iterable:
- i = 0
- for y in partials:
- if abs(x) < abs(y):
- x, y = y, x
- hi = x + y
- lo = y - (hi - x)
- if lo:
- partials[i] = lo
- i += 1
- x = hi
- partials[i:] = [x]
- return sum_exact(partials)
-
- Rounded x+y stored in hi with the roundoff stored in lo. Together hi+lo
- are exactly equal to x+y. The inner loop applies hi/lo summation to each
- partial so that the list of partial sums remains exact.
-
- Sum_exact() adds the partial sums exactly and correctly rounds the final
- result (using the round-half-to-even rule). The items in partials remain
- non-zero, non-special, non-overlapping and strictly increasing in
- magnitude, but possibly not all having the same sign.
-
- Depends on IEEE 754 arithmetic guarantees and half-even rounding.
+/*
+Full precision summation of a sequence of floats.
+
+ def msum(iterable):
+ partials = [] # sorted, non-overlapping partial sums
+ for x in iterable:
+ i = 0
+ for y in partials:
+ if abs(x) < abs(y):
+ x, y = y, x
+ hi = x + y
+ lo = y - (hi - x)
+ if lo:
+ partials[i] = lo
+ i += 1
+ x = hi
+ partials[i:] = [x]
+ return sum_exact(partials)
+
+ Rounded x+y stored in hi with the roundoff stored in lo. Together hi+lo
+ are exactly equal to x+y. The inner loop applies hi/lo summation to each
+ partial so that the list of partial sums remains exact.
+
+ Sum_exact() adds the partial sums exactly and correctly rounds the final
+ result (using the round-half-to-even rule). The items in partials remain
+ non-zero, non-special, non-overlapping and strictly increasing in
+ magnitude, but possibly not all having the same sign.
+
+ Depends on IEEE 754 arithmetic guarantees and half-even rounding.
*/
func math_fsum(self py.Object, seq py.Object) (py.Object, error) {
const NUM_PARTIALS = 32 /* initial partials array size, on stack */
@@ -939,14 +946,17 @@ const math_modf_doc = `modf(x)
Return the fractional and integer parts of x. Both results carry the sign
of x and are floats.`
-/* A decent logarithm is easy to compute even for huge ints, but libm can't
- do that by itself -- loghelper can. func is log or log10, and name is
- "log" or "log10". Note that overflow of the result isn't possible: an int
- can contain no more than INT_MAX * SHIFT bits, so has value certainly less
- than 2**(2**64 * 2**16) == 2**2**80, and log2 of that is 2**80, which is
- small enough to fit in an IEEE single. log and log10 are even smaller.
- However, intermediate overflow is possible for an int if the number of bits
- in that int is larger than PY_SSIZE_T_MAX. */
+/*
+A decent logarithm is easy to compute even for huge ints, but libm can't
+
+ do that by itself -- loghelper can. func is log or log10, and name is
+ "log" or "log10". Note that overflow of the result isn't possible: an int
+ can contain no more than INT_MAX * SHIFT bits, so has value certainly less
+ than 2**(2**64 * 2**16) == 2**2**80, and log2 of that is 2**80, which is
+ small enough to fit in an IEEE single. log and log10 are even smaller.
+ However, intermediate overflow is possible for an int if the number of bits
+ in that int is larger than PY_SSIZE_T_MAX.
+*/
func loghelper(arg py.Object, fn func(float64) float64, fnname string) (py.Object, error) {
/* If it is int, do it ourselves. */
if xBig, err := py.BigIntCheck(arg); err == nil {
@@ -1087,10 +1097,12 @@ func math_hypot(self py.Object, args py.Tuple) (py.Object, error) {
const math_hypot_doc = `hypot(x, y)
Return the Euclidean distance, sqrt(x*x + y*y).`
-/* pow can't use math_2, but needs its own wrapper: the problem is
- that an infinite result can arise either as a result of overflow
- (in which case OverflowError should be raised) or as a result of
- e.g. 0.**-5. (for which ValueError needs to be raised.)
+/*
+pow can't use math_2, but needs its own wrapper: the problem is
+
+ that an infinite result can arise either as a result of overflow
+ (in which case OverflowError should be raised) or as a result of
+ e.g. 0.**-5. (for which ValueError needs to be raised.)
*/
func math_pow(self py.Object, args py.Tuple) (py.Object, error) {
var ox, oy py.Object
diff --git a/stdlib/sys/sys.go b/stdlib/sys/sys.go
index b8aa3dc2..52d733b6 100644
--- a/stdlib/sys/sys.go
+++ b/stdlib/sys/sys.go
@@ -347,10 +347,10 @@ func sys_setrecursionlimit(self py.Object, args py.Tuple) (py.Object, error) {
return nil, py.NotImplementedError
}
-const hash_info_doc = `hash_info
-
-A struct sequence providing parameters used for computing
-numeric hashes. The attributes are read only.`
+// const hash_info_doc = `hash_info
+//
+// A struct sequence providing parameters used for computing
+// numeric hashes. The attributes are read only.`
// PyStructSequence_Field hash_info_fields[] = {
// {"width", "width of the type used for hashing, in bits"},
@@ -539,9 +539,9 @@ func sys_clear_type_cache(self py.Object, args py.Tuple) (py.Object, error) {
return nil, py.NotImplementedError
}
-const flags__doc__ = `sys.flags
-
-Flags provided through command line arguments or environment vars.`
+// const flags__doc__ = `sys.flags
+//
+// Flags provided through command line arguments or environment vars.`
// PyTypeObject FlagsType;
@@ -603,9 +603,9 @@ Flags provided through command line arguments or environment vars.`
// return seq;
// }
-const version_info__doc__ = `sys.version_info
-
-Version information as a named tuple.`
+//const version_info__doc__ = `sys.version_info
+//
+//Version information as a named tuple.`
// PyStructSequence_Field version_info_fields[] = {
// {"major", "Major release number"},
diff --git a/symtable/symtable.go b/symtable/symtable.go
index 1513f698..b7d36b4d 100644
--- a/symtable/symtable.go
+++ b/symtable/symtable.go
@@ -551,11 +551,12 @@ func (s StringSet) Contains(k string) bool {
global: set of all symbol names explicitly declared as global
*/
-/* Decide on scope of name, given flags.
+/*
+Decide on scope of name, given flags.
- The namespace dictionaries may be modified to record information
- about the new name. For example, a new global will add an entry to
- global. A name that was global can be changed to local.
+ The namespace dictionaries may be modified to record information
+ about the new name. For example, a new global will add an entry to
+ global. A name that was global can be changed to local.
*/
func (st *SymTable) AnalyzeName(scopes Scopes, name string, symbol Symbol, bound, local, free, global StringSet) {
flags := symbol.Flags
@@ -618,12 +619,14 @@ func (st *SymTable) AnalyzeName(scopes Scopes, name string, symbol Symbol, bound
scopes[name] = ScopeGlobalImplicit
}
-/* If a name is defined in free and also in locals, then this block
- provides the binding for the free variable. The name should be
- marked CELL in this block and removed from the free list.
+/*
+If a name is defined in free and also in locals, then this block
- Note that the current block's free variables are included in free.
- That's safe because no name can be free and local in the same scope.
+ provides the binding for the free variable. The name should be
+ marked CELL in this block and removed from the free list.
+
+ Note that the current block's free variables are included in free.
+ That's safe because no name can be free and local in the same scope.
*/
func AnalyzeCells(scopes Scopes, free StringSet) {
for name, scope := range scopes {
@@ -691,24 +694,25 @@ func (symbols Symbols) Update(scopes Scopes, bound, free StringSet, classflag bo
}
}
-/* Make final symbol table decisions for block of ste.
-
- Arguments:
- st -- current symtable entry (input/output)
- bound -- set of variables bound in enclosing scopes (input). bound
- is nil for module blocks.
- free -- set of free variables in enclosed scopes (output)
- globals -- set of declared global variables in enclosing scopes (input)
-
- The implementation uses two mutually recursive functions,
- analyze_block() and analyze_child_block(). analyze_block() is
- responsible for analyzing the individual names defined in a block.
- analyze_child_block() prepares temporary namespace dictionaries
- used to evaluated nested blocks.
-
- The two functions exist because a child block should see the name
- bindings of its enclosing blocks, but those bindings should not
- propagate back to a parent block.
+/*
+Make final symbol table decisions for block of ste.
+
+ Arguments:
+ st -- current symtable entry (input/output)
+ bound -- set of variables bound in enclosing scopes (input). bound
+ is nil for module blocks.
+ free -- set of free variables in enclosed scopes (output)
+ globals -- set of declared global variables in enclosing scopes (input)
+
+ The implementation uses two mutually recursive functions,
+ analyze_block() and analyze_child_block(). analyze_block() is
+ responsible for analyzing the individual names defined in a block.
+ analyze_child_block() prepares temporary namespace dictionaries
+ used to evaluated nested blocks.
+
+ The two functions exist because a child block should see the name
+ bindings of its enclosing blocks, but those bindings should not
+ propagate back to a parent block.
*/
func (st *SymTable) AnalyzeBlock(bound, free, global StringSet) {
local := make(StringSet) // collect new names bound in block
diff --git a/vm/eval.go b/vm/eval.go
index 94bf6d1e..d32cf734 100644
--- a/vm/eval.go
+++ b/vm/eval.go
@@ -1609,7 +1609,7 @@ func callInternal(fn py.Object, args py.Tuple, kwargs py.StringDict, f *py.Frame
// Implements a function call - see CALL_FUNCTION for a description of
// how the arguments are arranged.
//
-// Optionally pass in args and kwargs
+// # Optionally pass in args and kwargs
//
// The result is put on the stack
func (vm *Vm) Call(argc int32, starArgs py.Object, starKwargs py.Object) error {
@@ -2036,7 +2036,7 @@ func tooManyPositional(co *py.Code, given, defcount int, fastlocals []py.Object)
// EvalCode runs a new virtual machine on a Code object.
//
-// Any parameters are expected to have been decoded into locals
+// # Any parameters are expected to have been decoded into locals
//
// Returns an Object and an error. The error will be a py.ExceptionInfo
//