Documentation
¶
Overview ¶
Package modules provides the io module for M28
Package modules provides Go-implemented standard library modules for M28.
Package modules provides the sys module for M28 ¶
Package modules provides the warnings module for M28 Implements Python's warning system for deprecations and other warnings
Index ¶
- Constants
- func GetBuiltinModule(name string) (*core.DictValue, bool)
- func InitAbcModule() *core.DictValue
- func InitCodecsModule() *core.DictValue
- func InitCollectionsModule() *core.DictValue
- func InitEnumModule() *core.DictValue
- func InitErrnoModule() *core.DictValue
- func InitIOModule() *core.DictValue
- func InitItertoolsModule() *core.DictValue
- func InitMarshalModule() *core.DictValue
- func InitMathModule() *core.DictValue
- func InitOSModule() *core.DictValue
- func InitOpcodeModule() *core.DictValue
- func InitOperatorModule() *core.DictValue
- func InitPosixModule() *core.DictValue
- func InitStatModule() *core.DictValue
- func InitStructModule() *core.DictValue
- func InitSysModule() *core.DictValue
- func InitThreadModule() *core.DictValue
- func InitTimeModule() *core.DictValue
- func InitUnicodedataModule() *core.DictValue
- func InitWarningsModule() *core.DictValue
- func InitWeakrefModule() *core.DictValue
- func Init_ASTModule() *core.DictValue
- func Init_CompatPickleModule() *core.DictValue
- func Init_FunctoolsModule() *core.DictValue
- func Init_ImpModule() *core.DictValue
- func Init_REParserModule() *core.DictValue
- func Init_SREModule() *core.DictValue
- func Init_SignalModule() *core.DictValue
- func Init_StringModule() *core.DictValue
- func Init_TokenizeModule() *core.DictValue
- func Init_WarningsModule() *core.DictValue
- func IsBuiltinModule(name string) bool
- func ListBuiltinModules() []string
- func LoadPythonModule(name string, ctx *core.Context, ...) (*core.DictValue, error)
- func Warn(message string, category string, ctx *core.Context) error
- type BytesIO
- type CatchWarnings
- type Counter
- func (c *Counter) Elements() core.Value
- func (c *Counter) GetAttr(name string) (core.Value, bool)
- func (c *Counter) MostCommon(n int) core.Value
- func (c *Counter) SetAttr(name string, value core.Value) error
- func (c *Counter) String() string
- func (c *Counter) Total() core.Value
- func (c *Counter) Type() core.Type
- func (c *Counter) Update(args []core.Value)
- type DefaultDict
- type Deque
- func (dq *Deque) Append(item core.Value)
- func (dq *Deque) AppendLeft(item core.Value)
- func (dq *Deque) GetAttr(name string) (core.Value, bool)
- func (dq *Deque) Pop() (core.Value, error)
- func (dq *Deque) PopLeft() (core.Value, error)
- func (dq *Deque) Rotate(n int)
- func (dq *Deque) SetAttr(name string, value core.Value) error
- func (dq *Deque) String() string
- func (dq *Deque) Type() core.Type
- type DequeIterator
- type KwargsOSStat
- type KwargsPosixStat
- func (f *KwargsPosixStat) Call(args []core.Value, ctx *core.Context) (core.Value, error)
- func (f *KwargsPosixStat) CallWithKeywords(args []core.Value, kwargs map[string]core.Value, ctx *core.Context) (core.Value, error)
- func (f *KwargsPosixStat) String() string
- func (f *KwargsPosixStat) Type() core.Type
- type ModuleInitializer
- type OrderedDict
- type PythonModuleFinder
- type PythonModuleTranspiler
- type StringIO
- type TextIOWrapper
- type ThreadLock
- type TokenizerIter
- type TupleGetter
- type WarningFilter
- type WarningRegistry
Constants ¶
const ( TYPE_NULL = '0' TYPE_NONE = 'N' TYPE_FALSE = 'F' TYPE_TRUE = 'T' TYPE_INT = 'i' TYPE_FLOAT = 'f' TYPE_STRING = 's' TYPE_TUPLE = '(' TYPE_LIST = '[' TYPE_DICT = '{' TYPE_CODE = 'c' TYPE_UNICODE = 'u' TYPE_BYTES = 's' // Same as string in marshal TYPE_SHORT_ASCII = 'z' TYPE_SMALL_TUPLE = ')' )
Marshal format type codes (matching CPython's marshal.c)
Variables ¶
This section is empty.
Functions ¶
func GetBuiltinModule ¶
GetBuiltinModule returns a builtin module by name if it exists
func InitAbcModule ¶ added in v0.3.0
InitAbcModule creates the _abc module This provides C-level support for abstract base classes
func InitCodecsModule ¶ added in v0.3.0
InitCodecsModule initializes the _codecs C extension stub module This provides minimal codec support for Python stdlib modules
func InitCollectionsModule ¶ added in v0.3.0
InitCollectionsModule creates and returns the collections module
func InitEnumModule ¶ added in v0.3.0
InitEnumModule initializes a stub enum module This provides minimal enum support for Python stdlib modules like re
func InitErrnoModule ¶ added in v0.3.0
InitErrnoModule creates the errno module with error codes
func InitIOModule ¶ added in v0.3.0
InitIOModule registers the io module
func InitItertoolsModule ¶ added in v0.3.0
InitItertoolsModule creates and returns the itertools module
func InitMarshalModule ¶ added in v0.3.0
InitMarshalModule creates and returns the marshal module Implements Python's marshal module for bytecode serialization
func InitMathModule ¶
InitMathModule creates and returns the math module with comprehensive CPython compatibility This C extension module provides mathematical functions as defined in CPython's mathmodule.c
func InitOSModule ¶
InitOSModule creates and initializes the os module
func InitOpcodeModule ¶ added in v0.3.0
InitOpcodeModule creates the _opcode module with bytecode opcodes
func InitOperatorModule ¶ added in v0.3.0
InitOperatorModule creates the _operator module Note: Most operator functionality is in the pure Python operator.py module This C extension just provides a few optimized functions
func InitPosixModule ¶ added in v0.3.0
InitPosixModule creates the posix C extension module stub This is used by Python's os.py to get platform-specific functions
func InitStatModule ¶ added in v0.3.0
InitStatModule creates the _stat module with file mode constants
func InitStructModule ¶ added in v0.3.0
InitStructModule creates and returns the _struct module This implements Python's _struct C extension for binary data packing/unpacking
func InitSysModule ¶ added in v0.3.0
InitSysModule registers the sys module
func InitThreadModule ¶ added in v0.3.0
InitThreadModule initializes the _thread C extension module This provides threading support for Python stdlib modules
func InitTimeModule ¶
RegisterTimeModule registers the time module
func InitUnicodedataModule ¶ added in v0.3.0
InitUnicodedataModule creates a minimal stub for the unicodedata C extension module This is needed by test.support.os_helper for filename normalization on macOS We provide minimal stubs to allow test imports to work
func InitWarningsModule ¶ added in v0.3.0
InitWarningsModule registers the warnings module
func InitWeakrefModule ¶ added in v0.3.0
InitWeakrefModule initializes the _weakref C extension stub module This provides minimal weak reference support for Python stdlib modules
func Init_ASTModule ¶ added in v0.3.0
Init_ASTModule creates and returns the _ast module stub This is a minimal stub implementation of Python's _ast C extension module It provides empty classes for AST node types to allow ast.py to import
func Init_CompatPickleModule ¶ added in v0.3.0
Init_CompatPickleModule creates a stub for _compat_pickle that bypasses assertions This module is used by pickle to map Python 2 names to Python 3 names
func Init_FunctoolsModule ¶ added in v0.3.0
Init_FunctoolsModule creates and returns the _functools C extension stub This provides the C functions that Python's functools.py imports
func Init_ImpModule ¶ added in v0.3.0
Init_ImpModule creates and returns the _imp module stub This is a minimal stub implementation of Python's _imp C extension module It provides the internal import machinery
func Init_REParserModule ¶ added in v0.3.0
Init_REParserModule initializes the re._parser stub module This provides minimal regex parser support for the re module
func Init_SREModule ¶ added in v0.3.0
Init_SREModule initializes the _sre C extension stub module This provides minimal regex engine support for Python stdlib modules
func Init_SignalModule ¶ added in v0.3.0
Init_SignalModule creates and returns the _signal C extension stub This provides signal constants and basic signal handling functions
func Init_StringModule ¶ added in v0.3.0
Init_StringModule creates the _string C extension module stub This provides C-accelerated string functions for Python's string.py
func Init_TokenizeModule ¶ added in v0.3.0
Init_TokenizeModule creates and returns the _tokenize module
func Init_WarningsModule ¶ added in v0.3.0
Init_WarningsModule creates and returns the _warnings module stub This is a minimal stub implementation of Python's _warnings C extension module
func IsBuiltinModule ¶
IsBuiltinModule checks if a name corresponds to a builtin module
func ListBuiltinModules ¶
func ListBuiltinModules() []string
ListBuiltinModules returns a list of all available builtin module names
func LoadPythonModule ¶ added in v0.3.0
func LoadPythonModule(name string, ctx *core.Context, evalFunc func(core.Value, *core.Context) (core.Value, error), partialModule *core.DictValue) (*core.DictValue, error)
LoadPythonModule attempts to load a Python module by name Returns (*DictValue, error) to match ModuleLoader interface If partialModule is provided, it will be populated during evaluation for circular import support
Types ¶
type BytesIO ¶ added in v0.3.0
type BytesIO struct {
// contains filtered or unexported fields
}
BytesIO is an in-memory bytes stream
type CatchWarnings ¶ added in v0.3.0
type CatchWarnings struct {
// contains filtered or unexported fields
}
CatchWarnings implements the catch_warnings context manager
type Counter ¶ added in v0.3.0
type Counter struct {
// contains filtered or unexported fields
}
Counter is a dict subclass for counting hashable objects
func (*Counter) Elements ¶ added in v0.3.0
Elements returns an iterator over elements repeating each as many times as its count
func (*Counter) MostCommon ¶ added in v0.3.0
MostCommon returns a list of the n most common elements and their counts
type DefaultDict ¶ added in v0.3.0
type DefaultDict struct {
// contains filtered or unexported fields
}
DefaultDict is a dict subclass that calls a factory function for missing keys
func NewDefaultDict ¶ added in v0.3.0
func NewDefaultDict(factory core.Value) *DefaultDict
NewDefaultDict creates a new defaultdict
func (*DefaultDict) Get ¶ added in v0.3.0
Get returns the value for a key, calling the factory if missing
func (*DefaultDict) GetAttr ¶ added in v0.3.0
func (dd *DefaultDict) GetAttr(name string) (core.Value, bool)
GetAttr implements attribute access
func (*DefaultDict) SetAttr ¶ added in v0.3.0
func (dd *DefaultDict) SetAttr(name string, value core.Value) error
SetAttr implements attribute setting
func (*DefaultDict) String ¶ added in v0.3.0
func (dd *DefaultDict) String() string
String implements Value.String
func (*DefaultDict) Type ¶ added in v0.3.0
func (dd *DefaultDict) Type() core.Type
Type implements Value.Type
type Deque ¶ added in v0.3.0
type Deque struct {
// contains filtered or unexported fields
}
Deque is a double-ended queue
func (*Deque) AppendLeft ¶ added in v0.3.0
AppendLeft adds an element to the left side
func (*Deque) Rotate ¶ added in v0.3.0
Rotate rotates the deque n steps to the right (negative for left)
type DequeIterator ¶ added in v0.3.0
type DequeIterator struct {
// contains filtered or unexported fields
}
DequeIterator is an iterator over deque elements
func NewDequeIterator ¶ added in v0.3.0
func NewDequeIterator(dq *Deque) *DequeIterator
NewDequeIterator creates a new deque iterator
func (*DequeIterator) Iterator ¶ added in v0.3.0
func (di *DequeIterator) Iterator() core.Iterator
Iterator implements Iterable.Iterator
func (*DequeIterator) Next ¶ added in v0.3.0
func (di *DequeIterator) Next() (core.Value, bool)
Next implements Iterator.Next
func (*DequeIterator) Reset ¶ added in v0.3.0
func (di *DequeIterator) Reset()
Reset implements Iterator.Reset
func (*DequeIterator) String ¶ added in v0.3.0
func (di *DequeIterator) String() string
String implements Value.String
func (*DequeIterator) Type ¶ added in v0.3.0
func (di *DequeIterator) Type() core.Type
Type implements Value.Type
type KwargsOSStat ¶ added in v0.3.0
type KwargsOSStat struct {
core.BaseObject
}
KwargsOSStat implements os.stat with follow_symlinks keyword argument support
func (*KwargsOSStat) CallWithKeywords ¶ added in v0.3.0
func (f *KwargsOSStat) CallWithKeywords(args []core.Value, kwargs map[string]core.Value, ctx *core.Context) (core.Value, error)
CallWithKeywords implements keyword argument support
func (*KwargsOSStat) String ¶ added in v0.3.0
func (f *KwargsOSStat) String() string
func (*KwargsOSStat) Type ¶ added in v0.3.0
func (f *KwargsOSStat) Type() core.Type
type KwargsPosixStat ¶ added in v0.3.0
type KwargsPosixStat struct {
core.BaseObject
// contains filtered or unexported fields
}
KwargsPosixStat implements posix.stat with follow_symlinks keyword argument support
func (*KwargsPosixStat) CallWithKeywords ¶ added in v0.3.0
func (f *KwargsPosixStat) CallWithKeywords(args []core.Value, kwargs map[string]core.Value, ctx *core.Context) (core.Value, error)
CallWithKeywords implements keyword argument support
func (*KwargsPosixStat) String ¶ added in v0.3.0
func (f *KwargsPosixStat) String() string
func (*KwargsPosixStat) Type ¶ added in v0.3.0
func (f *KwargsPosixStat) Type() core.Type
type ModuleInitializer ¶
ModuleInitializer is a function that creates and returns a module dictionary
type OrderedDict ¶ added in v0.3.0
type OrderedDict struct {
// contains filtered or unexported fields
}
OrderedDict is a dictionary that maintains insertion order Since M28's DictValue already maintains order, this is essentially a wrapper
func NewOrderedDict ¶ added in v0.3.0
func NewOrderedDict() *OrderedDict
NewOrderedDict creates a new OrderedDict
func (*OrderedDict) GetAttr ¶ added in v0.3.0
func (od *OrderedDict) GetAttr(name string) (core.Value, bool)
GetAttr implements attribute access
func (*OrderedDict) SetAttr ¶ added in v0.3.0
func (od *OrderedDict) SetAttr(name string, value core.Value) error
SetAttr implements attribute setting
func (*OrderedDict) String ¶ added in v0.3.0
func (od *OrderedDict) String() string
String implements Value.String
func (*OrderedDict) Type ¶ added in v0.3.0
func (od *OrderedDict) Type() core.Type
Type implements Value.Type
type PythonModuleFinder ¶ added in v0.3.0
type PythonModuleFinder struct {
// contains filtered or unexported fields
}
PythonModuleFinder locates Python modules in the standard library
func GetPythonFinder ¶ added in v0.3.0
func GetPythonFinder() (*PythonModuleFinder, error)
GetPythonFinder returns the global PythonModuleFinder instance
func NewPythonModuleFinder ¶ added in v0.3.0
func NewPythonModuleFinder() (*PythonModuleFinder, error)
NewPythonModuleFinder creates a new Python module finder
func (*PythonModuleFinder) Find ¶ added in v0.3.0
func (f *PythonModuleFinder) Find(moduleName string) (string, bool, error)
Find locates a Python module by name Returns (path, isPackage, error) - path: full path to .py file or __init__.py - isPackage: true if module is a package (has __init__.py)
func (*PythonModuleFinder) FindWithExtraPaths ¶ added in v0.3.0
func (f *PythonModuleFinder) FindWithExtraPaths(moduleName string, extraPaths []string) (string, bool, error)
FindWithExtraPaths locates a Python module, checking extraPaths first, then default paths
func (*PythonModuleFinder) GetSearchPaths ¶ added in v0.3.0
func (f *PythonModuleFinder) GetSearchPaths() []string
GetSearchPaths returns the list of Python search paths
type PythonModuleTranspiler ¶ added in v0.3.0
type PythonModuleTranspiler struct {
// contains filtered or unexported fields
}
PythonModuleTranspiler transpiles Python source to M28 AST
func GetPythonTranspiler ¶ added in v0.3.0
func GetPythonTranspiler() *PythonModuleTranspiler
GetPythonTranspiler returns the global transpiler instance
func (*PythonModuleTranspiler) ClearCache ¶ added in v0.3.0
func (t *PythonModuleTranspiler) ClearCache()
ClearCache clears the transpiler cache
func (*PythonModuleTranspiler) RemoveFromCache ¶ added in v0.3.0
func (t *PythonModuleTranspiler) RemoveFromCache(pyPath string)
RemoveFromCache removes a specific file from the cache
type StringIO ¶ added in v0.3.0
type StringIO struct {
// contains filtered or unexported fields
}
StringIO is an in-memory text stream
type TextIOWrapper ¶ added in v0.3.0
type TextIOWrapper struct {
// contains filtered or unexported fields
}
TextIOWrapper wraps a binary stream and provides text I/O
type ThreadLock ¶ added in v0.3.0
type ThreadLock struct {
// contains filtered or unexported fields
}
ThreadLock represents a lock object
func (*ThreadLock) GetAttr ¶ added in v0.3.0
func (l *ThreadLock) GetAttr(name string) (core.Value, bool)
Implement methods for the lock
func (*ThreadLock) Repr ¶ added in v0.3.0
func (l *ThreadLock) Repr() string
func (*ThreadLock) SetAttr ¶ added in v0.3.0
func (l *ThreadLock) SetAttr(name string, value core.Value) error
func (*ThreadLock) String ¶ added in v0.3.0
func (l *ThreadLock) String() string
func (*ThreadLock) Type ¶ added in v0.3.0
func (l *ThreadLock) Type() core.Type
type TokenizerIter ¶ added in v0.3.0
type TokenizerIter struct {
// contains filtered or unexported fields
}
TokenizerIter implements the _tokenize.TokenizerIter class This is a stub implementation that provides basic tokenization for Python code
func (*TokenizerIter) GetAttr ¶ added in v0.3.0
func (t *TokenizerIter) GetAttr(name string) (core.Value, bool)
func (*TokenizerIter) String ¶ added in v0.3.0
func (t *TokenizerIter) String() string
func (*TokenizerIter) Type ¶ added in v0.3.0
func (t *TokenizerIter) Type() core.Type
type TupleGetter ¶ added in v0.3.0
type TupleGetter struct {
// contains filtered or unexported fields
}
TupleGetter is a callable that retrieves a specific index from a tuple This is used by namedtuple for field access
func NewTupleGetter ¶ added in v0.3.0
func NewTupleGetter(index int, doc string) *TupleGetter
NewTupleGetter creates a new TupleGetter
func (*TupleGetter) GetAttr ¶ added in v0.3.0
func (tg *TupleGetter) GetAttr(name string) (core.Value, bool)
GetAttr implements attribute access
func (*TupleGetter) SetAttr ¶ added in v0.3.0
func (tg *TupleGetter) SetAttr(name string, value core.Value) error
SetAttr implements attribute setting
func (*TupleGetter) String ¶ added in v0.3.0
func (tg *TupleGetter) String() string
String implements Value.String
func (*TupleGetter) Type ¶ added in v0.3.0
func (tg *TupleGetter) Type() core.Type
Type implements Value.Type
type WarningFilter ¶ added in v0.3.0
type WarningFilter struct {
Action string // "default", "error", "ignore", "always", "module", "once"
Category core.Value
Module string
Lineno int
}
WarningFilter represents a single warning filter
type WarningRegistry ¶ added in v0.3.0
type WarningRegistry struct {
// contains filtered or unexported fields
}
WarningRegistry manages warning filters and state
Source Files
¶
- c_abc.go
- c_ast.go
- c_codecs.go
- c_collections.go
- c_compat_pickle.go
- c_enum.go
- c_imp.go
- c_opcode.go
- c_operator.go
- c_re_parser.go
- c_sre.go
- c_stat.go
- c_string.go
- c_struct.go
- c_thread.go
- c_tokenize.go
- c_warnings.go
- c_weakref.go
- errno.go
- functools.go
- io.go
- itertools.go
- marshal.go
- math.go
- os.go
- os_extended.go
- posix.go
- python_finder.go
- python_loader.go
- python_transpiler.go
- registry.go
- signal.go
- sys.go
- sys_extended.go
- time.go
- unicodedata.go
- warnings.go