From 6f8e06a4660709ab44398d8b1a18738aa407b1c3 Mon Sep 17 00:00:00 2001 From: Drew O'Meara <35852900+drew-512@users.noreply.github.com> Date: Wed, 5 Oct 2022 02:25:39 -0500 Subject: [PATCH] all: minor comment and typos cleanups Co-authored-by: Drew O'Meara --- py/bigint.go | 4 ++-- py/bool.go | 2 +- py/bytes.go | 2 +- py/complex.go | 2 +- py/float.go | 2 +- py/int.go | 2 +- py/none.go | 2 +- py/run.go | 3 +++ py/string.go | 2 +- stdlib/stdlib.go | 10 +++++++--- 10 files changed, 19 insertions(+), 12 deletions(-) diff --git a/py/bigint.go b/py/bigint.go index 0b72804c..bb195888 100644 --- a/py/bigint.go +++ b/py/bigint.go @@ -55,7 +55,7 @@ func BigIntCheckExact(obj Object) (*BigInt, error) { return bigInt, nil } -// Checks that obj is exactly a bigInd and returns an error if not +// Checks that obj is exactly a BigInt and returns an error if not func BigIntCheck(obj Object) (*BigInt, error) { // FIXME should be checking subclasses return BigIntCheckExact(obj) @@ -65,7 +65,7 @@ func BigIntCheck(obj Object) (*BigInt, error) { // Convert an Object to an BigInt // -// Retrurns ok as to whether the conversion worked or not +// Returns ok as to whether the conversion worked or not func ConvertToBigInt(other Object) (*BigInt, bool) { switch b := other.(type) { case Int: diff --git a/py/bool.go b/py/bool.go index 82547754..413b25d4 100644 --- a/py/bool.go +++ b/py/bool.go @@ -52,7 +52,7 @@ func (a Bool) M__repr__() (Object, error) { // Convert an Object to an Bool // -// Retrurns ok as to whether the conversion worked or not +// Returns ok as to whether the conversion worked or not func convertToBool(other Object) (Bool, bool) { switch b := other.(type) { case Bool: diff --git a/py/bytes.go b/py/bytes.go index 55a69681..787807ec 100644 --- a/py/bytes.go +++ b/py/bytes.go @@ -187,7 +187,7 @@ func (a Bytes) M__repr__() (Object, error) { // Convert an Object to an Bytes // -// Retrurns ok as to whether the conversion worked or not +// Returns ok as to whether the conversion worked or not func convertToBytes(other Object) (Bytes, bool) { switch b := other.(type) { case Bytes: diff --git a/py/complex.go b/py/complex.go index e39f2f64..33c09fb3 100644 --- a/py/complex.go +++ b/py/complex.go @@ -42,7 +42,7 @@ func ComplexNew(metatype *Type, args Tuple, kwargs StringDict) (Object, error) { // Convert an Object to an Complex // -// Retrurns ok as to whether the conversion worked or not +// Returns ok as to whether the conversion worked or not func convertToComplex(other Object) (Complex, bool) { switch b := other.(type) { case Complex: diff --git a/py/float.go b/py/float.go index 4f47759b..c4bb96fd 100644 --- a/py/float.go +++ b/py/float.go @@ -118,7 +118,7 @@ var floatDivisionByZero = ExceptionNewf(ZeroDivisionError, "float division by ze // Convert an Object to an Float // -// Retrurns ok as to whether the conversion worked or not +// Returns ok as to whether the conversion worked or not func convertToFloat(other Object) (Float, bool) { switch b := other.(type) { case Float: diff --git a/py/int.go b/py/int.go index d3c84ab8..dde6993e 100644 --- a/py/int.go +++ b/py/int.go @@ -216,7 +216,7 @@ func cantConvert(a Object, to string) (Object, error) { // Convert an Object to an Int // -// Retrurns ok as to whether the conversion worked or not +// Returns ok as to whether the conversion worked or not func convertToInt(other Object) (Int, bool) { switch b := other.(type) { case Int: diff --git a/py/none.go b/py/none.go index 63a9952b..6c453b6c 100644 --- a/py/none.go +++ b/py/none.go @@ -33,7 +33,7 @@ func (a NoneType) M__repr__() (Object, error) { // Convert an Object to an NoneType // -// Retrurns ok as to whether the conversion worked or not +// Returns ok as to whether the conversion worked or not func convertToNoneType(other Object) (NoneType, bool) { switch b := other.(type) { case NoneType: diff --git a/py/run.go b/py/run.go index 5659232b..427cdbe6 100644 --- a/py/run.go +++ b/py/run.go @@ -135,8 +135,11 @@ func RunSrc(ctx Context, pySrc string, pySrcDesc string, inModule interface{}) ( } // RunCode executes the given code object within the given module and returns the Module to indicate success. +// // If inModule is a *Module, then the code is run in that module. +// // If inModule is nil, the code is run in a new __main__ module (and the new Module is returned). +// // If inModule is a string, the code is run in a new module with the given name (and the new Module is returned). func RunCode(ctx Context, code *Code, codeDesc string, inModule interface{}) (*Module, error) { var ( diff --git a/py/string.go b/py/string.go index 2c9854bc..d1c0c6f1 100644 --- a/py/string.go +++ b/py/string.go @@ -300,7 +300,7 @@ func (a String) M__imul__(other Object) (Object, error) { // Convert an Object to an String // -// Retrurns ok as to whether the conversion worked or not +// Returns ok as to whether the conversion worked or not func convertToString(other Object) (String, bool) { switch b := other.(type) { case String: diff --git a/stdlib/stdlib.go b/stdlib/stdlib.go index 7061f486..d945c382 100644 --- a/stdlib/stdlib.go +++ b/stdlib/stdlib.go @@ -47,7 +47,7 @@ type context struct { // NewContext creates a new gpython interpreter instance context. // -// See type Context interface for info. +// See interface py.Context defined in py/run.go func NewContext(opts py.ContextOpts) py.Context { ctx := &context{ opts: opts, @@ -109,6 +109,7 @@ func (ctx *context) ModuleInit(impl *py.ModuleImpl) (*py.Module, error) { return module, nil } +// See interface py.Context defined in py/run.go func (ctx *context) ResolveAndCompile(pathname string, opts py.CompileOpts) (py.CompileOut, error) { err := ctx.pushBusy() defer ctx.popBusy() @@ -202,7 +203,7 @@ func (ctx *context) popBusy() { ctx.running.Done() } -// Close -- see type py.Context +// See interface py.Context defined in py/run.go func (ctx *context) Close() error { ctx.closeOnce.Do(func() { ctx.closing = true @@ -216,7 +217,7 @@ func (ctx *context) Close() error { return nil } -// Done -- see type py.Context +// See interface py.Context defined in py/run.go func (ctx *context) Done() <-chan struct{} { return ctx.done } @@ -274,6 +275,7 @@ func resolveRunPath(runPath string, opts py.CompileOpts, pathObjs []py.Object, t return err } +// See interface py.Context defined in py/run.go func (ctx *context) RunCode(code *py.Code, globals, locals py.StringDict, closure py.Tuple) (py.Object, error) { err := ctx.pushBusy() defer ctx.popBusy() @@ -284,10 +286,12 @@ func (ctx *context) RunCode(code *py.Code, globals, locals py.StringDict, closur return vm.EvalCode(ctx, code, globals, locals, nil, nil, nil, nil, closure) } +// See interface py.Context defined in py/run.go func (ctx *context) GetModule(moduleName string) (*py.Module, error) { return ctx.store.GetModule(moduleName) } +// See interface py.Context defined in py/run.go func (ctx *context) Store() *py.ModuleStore { return ctx.store }