LiteLDev / LeviLamina

A lightweight, modular and versatile mod loader for Minecraft Bedrock Edition, formerly known as LiteLoaderBDS
https://levimc.org/software/levilamina
GNU Lesser General Public License v3.0
1.14k stars 116 forks source link

llse往py引擎注入的全局变量无法与其他被import的模块共享 #1140

Closed lgc2333 closed 1 year ago

lgc2333 commented 1 year ago

Exceptions module

ScriptEngine

Operating System

Windows 11

LiteLoader version

https://github.com/LiteLDev/LiteLoaderBDS/actions/runs/4470232939

BDS version

1.19.71.02

What happened?

image

Steps to reproduce?

image

Relevant log output

No response

Plugin list

No response

lgc2333 commented 1 year ago

写了段测试代码,应该能反映问题 image

这是运行结果

```json { "__name__": "__main__", "__doc__": "None", "__package__": "None", "__loader__": "", "__spec__": "None", "__annotations__": "{}", "__builtins__": "", "_llse_py_sys_module": "", "log": "", "colorLog": "", "fastLog": "", "setTimeout": "", "setInterval": "", "clearInterval": "", "mc": "", "system": "", "logger": "", "data": "", "money": "", "network": "", "ll": "", "Version": "", "NBT": "", "Format": "", "ParticleColor": "", "Direction": "", "ActorDamageCause": "", "PermType": "", "ParamType": "", "ParamOption": "", "OriginType": "", "DamageCause": "", "Permission": "", "i18n": "", "IntPos": "", "FloatPos": "", "DirectionAngle": "", "LLSE_Block": "", "KVDatabase": "", "DBSession": "", "DBStmt": "", "JsonConfigFile": "", "IniConfigFile": "", "LLSE_Device": "", "LLSE_Container": "", "LLSE_Entity": "", "File": "", "WSClient": "", "LLSE_BlockEntity": "", "LLSE_SimpleForm": "", "LLSE_CustomForm": "", "LLSE_Item": "", "LLSE_Player": "", "LLSE_Objective": "", "LLSE_Packet": "", "NbtEnd": "", "NbtByte": "", "NbtShort": "", "NbtInt": "", "NbtLong": "", "NbtFloat": "", "NbtDouble": "", "NbtString": "", "NbtByteArray": "", "NbtList": "", "NbtCompound": "", "LLSE_Command": "", "LLSE_CommandOrigin": "", "LLSE_CommandOutput": "", "HttpServer": "", "HttpRequest": "", "HttpResponse": "", "BinaryStream": "", "Role": "", "ParticleSpawner": "", "NativeTypes": "", "NativePointer": "", "NativeFunction": "", "NativeStdString": "", "NativeHook": "", "NativePatch": "", "GlobalPointer": "", "json": "" } ``` ```json { "__name__": "src", "__doc__": "None", "__package__": "src", "__loader__": "<_frozen_importlib_external.SourceFileLoader object at 0x000001C683AAF610>", "__spec__": "ModuleSpec(name='src', loader=<_frozen_importlib_external.SourceFileLoader object at 0x000001C683AAF610>, origin='D:\\\\Coding\\\\bds\\\\testllpy\\\\plugins\\\\python\\\\testpy\\\\src\\\\__init__.py', submodule_search_locations=['D:\\\\Coding\\\\bds\\\\testllpy\\\\plugins\\\\python\\\\testpy\\\\src'])", "__path__": "['D:\\\\Coding\\\\bds\\\\testllpy\\\\plugins\\\\python\\\\testpy\\\\src']", "__file__": "D:\\Coding\\bds\\testllpy\\plugins\\python\\testpy\\src\\__init__.py", "__cached__": "D:\\Coding\\bds\\testllpy\\plugins\\python\\testpy\\src\\__pycache__\\__init__.cpython-310.pyc", "__builtins__": "{'__name__': 'builtins', '__doc__': \"Built-in functions, exceptions, and other objects.\\n\\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.\", '__package__': '', '__loader__': , '__spec__': ModuleSpec(name='builtins', loader=, origin='built-in'), '__build_class__': , '__import__': , 'abs': , 'all': , 'any': , 'ascii': , 'bin': , 'breakpoint': , 'callable': , 'chr': , 'compile': , 'delattr': , 'dir': , 'divmod': , 'eval': , 'exec': , 'format': , 'getattr': , 'globals': , 'hasattr': , 'hash': , 'hex': , 'id': , 'input': , 'isinstance': , 'issubclass': , 'iter': , 'aiter': , 'len': , 'locals': , 'max': , 'min': , 'next': , 'anext': , 'oct': , 'ord': , 'pow': , 'print': , 'repr': , 'round': , 'setattr': , 'sorted': , 'sum': , 'vars': , 'None': None, 'Ellipsis': Ellipsis, 'NotImplemented': NotImplemented, 'False': False, 'True': True, 'bool': , 'memoryview': , 'bytearray': , 'bytes': , 'classmethod': , 'complex': , 'dict': , 'enumerate': , 'filter': , 'float': , 'frozenset': , 'property': , 'int': , 'list': , 'map': , 'object': , 'range': , 'reversed': , 'set': , 'slice': , 'staticmethod': , 'str': , 'super': , 'tuple': , 'type': , 'zip': , '__debug__': True, 'BaseException': , 'Exception': , 'TypeError': , 'StopAsyncIteration': , 'StopIteration': , 'GeneratorExit': , 'SystemExit': , 'KeyboardInterrupt': , 'ImportError': , 'ModuleNotFoundError': , 'OSError': , 'EnvironmentError': , 'IOError': , 'WindowsError': , 'EOFError': , 'RuntimeError': , 'RecursionError': , 'NotImplementedError': , 'NameError': , 'UnboundLocalError': , 'AttributeError': , 'SyntaxError': , 'IndentationError': , 'TabError': , 'LookupError': , 'IndexError': , 'KeyError': , 'ValueError': , 'UnicodeError': , 'UnicodeEncodeError': , 'UnicodeDecodeError': , 'UnicodeTranslateError': , 'AssertionError': , 'ArithmeticError': , 'FloatingPointError': , 'OverflowError': , 'ZeroDivisionError': , 'SystemError': , 'ReferenceError': , 'MemoryError': , 'BufferError': , 'Warning': , 'UserWarning': , 'EncodingWarning': , 'DeprecationWarning': , 'PendingDeprecationWarning': , 'SyntaxWarning': , 'RuntimeWarning': , 'FutureWarning': , 'ImportWarning': , 'UnicodeWarning': , 'BytesWarning': , 'ResourceWarning': , 'ConnectionError': , 'BlockingIOError': , 'BrokenPipeError': , 'ChildProcessError': , 'ConnectionAbortedError': , 'ConnectionRefusedError': , 'ConnectionResetError': , 'FileExistsError': , 'FileNotFoundError': , 'IsADirectoryError': , 'NotADirectoryError': , 'InterruptedError': , 'PermissionError': , 'ProcessLookupError': , 'TimeoutError': , 'open': , 'quit': Use quit() or Ctrl-Z plus Return to exit, 'exit': Use exit() or Ctrl-Z plus Return to exit, 'copyright': Copyright (c) 2001-2022 Python Software Foundation.\nAll Rights Reserved.\n\nCopyright (c) 2000 BeOpen.com.\nAll Rights Reserved.\n\nCopyright (c) 1995-2001 Corporation for National Research Initiatives.\nAll Rights Reserved.\n\nCopyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\nAll Rights Reserved., 'credits': Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands\n for supporting Python development. See www.python.org for more information., 'license': Type license() to see the full license text, 'help': Type help() for interactive help, or help(object) for help about object.}", "json": "" } ```
lgc2333 commented 1 year ago

我有个想法,可以把py引擎提供的函数什么的,扔进builtins模块里面

yqs112358 commented 1 year ago

已修复,等待最新actions构建完成即可