pyscript-programming-language 1.12.7__tar.gz → 1.12.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/PKG-INFO +1 -1
- pyscript_programming_language-1.12.8/changelog.md +7 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyproject.toml +1 -1
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/interpreter.py +5 -4
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/objects.py +7 -5
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/pysbuiltins.py +9 -9
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/results.py +8 -4
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/runner.py +7 -6
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/shell.py +41 -14
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/symtab.py +1 -1
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/utils/debug.py +3 -3
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/version.py +2 -2
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/ast/ast_literal_eval.py +3 -2
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/ast/ast_unparse.py +2 -2
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/history.pys +5 -7
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript_programming_language.egg-info/PKG-INFO +1 -1
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/setup.py +1 -1
- pyscript_programming_language-1.12.7/changelog.md +0 -12
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/MANIFEST.in +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/README.md +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/__init__.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/__init__.pyi +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/__main__.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/__init__.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/analyzer.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/bases.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/buffer.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/cache.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/checks.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/constants.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/context.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/editor/__init__.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/editor/bases.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/editor/gui.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/editor/terminal.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/exceptions.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/handlers.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/highlight.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/lexer.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/mapping.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/nodes.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/parser.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/position.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/token.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/utils/__init__.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/utils/ansi.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/utils/decorators.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/utils/generic.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/utils/jsdict.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/utils/module.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/utils/path.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/utils/similarity.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/utils/string.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/__hello__.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/ansi.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/ast/__init__.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/ast/ast_dump.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/ast/ast_walk.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/brainfuck.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/dis.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/explorer.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/fpstimer/__init__.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/fpstimer/py_fpstimer.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/getch/__init__.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/getch/py_getch.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/inspect.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/jsdict.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/keyword.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/opcode.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/parser.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/pdisplay.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/site.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/symtable.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/token.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/tokenize/__init__.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/tokenize/tok_untokenize.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/other/.nomedia +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/other/PyScript.ico +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/other/copyright +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/other/credits +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/other/license +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/site-packages/this.pys +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/this.py +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript_programming_language.egg-info/SOURCES.txt +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript_programming_language.egg-info/dependency_links.txt +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript_programming_language.egg-info/requires.txt +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript_programming_language.egg-info/top_level.txt +0 -0
- {pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/setup.cfg +0 -0
{pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyproject.toml
RENAMED
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pyscript-programming-language"
|
|
7
|
-
version = "1.12.
|
|
7
|
+
version = "1.12.8"
|
|
8
8
|
description = "PyScript Programming Language"
|
|
9
9
|
readme = { file = "README.md", content-type = "text/markdown" }
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -10,12 +10,12 @@ from .objects import PysFunction
|
|
|
10
10
|
from .pysbuiltins import ce, nce, increment, decrement
|
|
11
11
|
from .results import PysRunTimeResult
|
|
12
12
|
from .symtab import PysClassSymbolTable, find_closest
|
|
13
|
-
from .utils.debug import
|
|
13
|
+
from .utils.debug import get_traceback_info
|
|
14
14
|
from .utils.generic import getattribute, setimuattr, dkeys, is_object_of
|
|
15
15
|
from .utils.similarity import get_closest
|
|
16
16
|
|
|
17
17
|
from collections.abc import Iterable
|
|
18
|
-
from typing import Any
|
|
18
|
+
from typing import Any, Callable
|
|
19
19
|
|
|
20
20
|
T_KEYWORD = TOKENS['KEYWORD']
|
|
21
21
|
T_STRING = TOKENS['STRING']
|
|
@@ -785,7 +785,7 @@ def visit_WithNode(node: PysWithNode, context: PysContext) -> PysRunTimeResult:
|
|
|
785
785
|
for exit, ncontext_position in reversed(exit_functions):
|
|
786
786
|
with result(context, ncontext_position):
|
|
787
787
|
handle_call(exit, context, ncontext_position)
|
|
788
|
-
if exit(*
|
|
788
|
+
if exit(*get_traceback_info(error)):
|
|
789
789
|
failure(None)
|
|
790
790
|
error = None
|
|
791
791
|
|
|
@@ -1055,6 +1055,7 @@ def visit_ClassNode(node: PysClassNode, context: PysContext) -> PysRunTimeResult
|
|
|
1055
1055
|
with result(context, nposition):
|
|
1056
1056
|
cls = type(name, tuple(bases), class_context.symbol_table.symbols)
|
|
1057
1057
|
cls.__qualname__ = class_context.qualname
|
|
1058
|
+
cls.__module__ = 'pyscript'
|
|
1058
1059
|
|
|
1059
1060
|
if should_return():
|
|
1060
1061
|
return result
|
|
@@ -1505,7 +1506,7 @@ def visit_declaration_AssignmentNode(
|
|
|
1505
1506
|
|
|
1506
1507
|
return result.success(None)
|
|
1507
1508
|
|
|
1508
|
-
get_visitor = {
|
|
1509
|
+
get_visitor: Callable[[type[PysNode]], Callable[[PysNode, PysContext], PysRunTimeResult]] = {
|
|
1509
1510
|
class_node: globals()['visit_' + class_node.__name__.removeprefix('Pys')]
|
|
1510
1511
|
for class_node in PysNode.__subclasses__()
|
|
1511
1512
|
}.__getitem__
|
|
@@ -58,6 +58,7 @@ class PysFunction(PysObject):
|
|
|
58
58
|
|
|
59
59
|
self.__name__ = name = '<function>' if name is None else name
|
|
60
60
|
self.__qualname__ = name if qualname is None else f'{qualname}.{name}'
|
|
61
|
+
self.__module__ = 'pyscript'
|
|
61
62
|
self.__code__ = PysCode(
|
|
62
63
|
parameters=tuple(parameters),
|
|
63
64
|
body=body,
|
|
@@ -81,16 +82,13 @@ class PysFunction(PysObject):
|
|
|
81
82
|
|
|
82
83
|
def __call__(self, *args, **kwargs) -> Any:
|
|
83
84
|
code = self.__code__
|
|
84
|
-
code_body = code.body
|
|
85
|
-
code_parameters_length = code.parameters_length
|
|
86
|
-
code_parameter_names = code.parameter_names
|
|
87
85
|
|
|
88
86
|
result = PysRunTimeResult()
|
|
89
87
|
symbol_table = PysSymbolTable(code.closure_symbol_table)
|
|
90
88
|
registered_arguments = set()
|
|
91
89
|
|
|
92
|
-
add_argument = registered_arguments.add
|
|
93
90
|
set_symbol = symbol_table.set
|
|
91
|
+
add_argument = registered_arguments.add
|
|
94
92
|
|
|
95
93
|
for name, arg in zip(code.argument_names, args):
|
|
96
94
|
set_symbol(name, arg)
|
|
@@ -104,6 +102,8 @@ class PysFunction(PysObject):
|
|
|
104
102
|
add_argument(name)
|
|
105
103
|
pop_keyword_arguments(name, None)
|
|
106
104
|
|
|
105
|
+
code_parameter_names = code.parameter_names
|
|
106
|
+
|
|
107
107
|
for name, value in combined_keyword_arguments.items():
|
|
108
108
|
|
|
109
109
|
if name in registered_arguments:
|
|
@@ -136,6 +136,7 @@ class PysFunction(PysObject):
|
|
|
136
136
|
set_symbol(name, value)
|
|
137
137
|
add_argument(name)
|
|
138
138
|
|
|
139
|
+
code_parameters_length = code.parameters_length
|
|
139
140
|
arguments_length = len(args)
|
|
140
141
|
total_registered = len(registered_arguments)
|
|
141
142
|
|
|
@@ -175,7 +176,7 @@ class PysFunction(PysObject):
|
|
|
175
176
|
)
|
|
176
177
|
|
|
177
178
|
result.register(
|
|
178
|
-
code.get_visitor(code_body.__class__)(
|
|
179
|
+
code.get_visitor((code_body := code.body).__class__)(
|
|
179
180
|
code_body,
|
|
180
181
|
PysContext(
|
|
181
182
|
file=code.file,
|
|
@@ -202,6 +203,7 @@ class PysPythonFunction(PysFunction):
|
|
|
202
203
|
self.__func__ = func
|
|
203
204
|
self.__name__ = getattr(func, '__name__', '<function>')
|
|
204
205
|
self.__qualname__ = getattr(func, '__qualname__', '<function>')
|
|
206
|
+
self.__module__ = getattr(func, '__module__', 'pyscript')
|
|
205
207
|
self.__doc__ = getattr(func, '__doc__', None)
|
|
206
208
|
self.__code__ = PysCode(
|
|
207
209
|
context=None,
|
|
@@ -83,7 +83,7 @@ def _unpack_comprehension_function(pyfunc: PysPythonFunction, function: Callable
|
|
|
83
83
|
handle_call(function, code.context, code.position)
|
|
84
84
|
return final
|
|
85
85
|
|
|
86
|
-
class
|
|
86
|
+
class PysPrinter(Pys):
|
|
87
87
|
|
|
88
88
|
def __init__(self, name: str, text: str | Any) -> None:
|
|
89
89
|
self.name = name
|
|
@@ -95,7 +95,7 @@ class _Printer(Pys):
|
|
|
95
95
|
def __call__(self) -> None:
|
|
96
96
|
print(self.text)
|
|
97
97
|
|
|
98
|
-
class
|
|
98
|
+
class PysHelper(PysPrinter):
|
|
99
99
|
|
|
100
100
|
def __init__(self) -> None:
|
|
101
101
|
super().__init__('help', None)
|
|
@@ -120,15 +120,15 @@ try:
|
|
|
120
120
|
open(normpath(OTHER_PATH, 'credits', absolute=False)) as credits,
|
|
121
121
|
open(normpath(OTHER_PATH, 'license', absolute=False)) as license
|
|
122
122
|
):
|
|
123
|
-
copyright =
|
|
124
|
-
credits =
|
|
125
|
-
license =
|
|
123
|
+
copyright = PysPrinter('copyright', copyright.read())
|
|
124
|
+
credits = PysPrinter('credits', credits.read())
|
|
125
|
+
license = PysPrinter('license', license.read())
|
|
126
126
|
except:
|
|
127
|
-
copyright =
|
|
128
|
-
credits =
|
|
129
|
-
license =
|
|
127
|
+
copyright = PysPrinter('copyright', '')
|
|
128
|
+
credits = PysPrinter('credits', '')
|
|
129
|
+
license = PysPrinter('license', '')
|
|
130
130
|
|
|
131
|
-
help =
|
|
131
|
+
help = PysHelper()
|
|
132
132
|
|
|
133
133
|
@PysBuiltinFunction
|
|
134
134
|
def require(pyfunc, name):
|
|
@@ -5,7 +5,7 @@ from .context import PysContext
|
|
|
5
5
|
from .exceptions import PysTraceback, PysSignal
|
|
6
6
|
from .nodes import PysNode
|
|
7
7
|
from .position import PysPosition
|
|
8
|
-
from .utils.debug import print_traceback,
|
|
8
|
+
from .utils.debug import print_traceback, get_traceback_info
|
|
9
9
|
|
|
10
10
|
from types import TracebackType
|
|
11
11
|
from typing import Any, Literal, Union
|
|
@@ -169,8 +169,10 @@ class PysExecuteResult(PysResult):
|
|
|
169
169
|
|
|
170
170
|
def end_process(self) -> tuple[int | Any, bool]:
|
|
171
171
|
result = PysRunTimeResult()
|
|
172
|
+
context = self.context
|
|
173
|
+
position = PysPosition(self.context.file, -1, -1)
|
|
172
174
|
|
|
173
|
-
with result(
|
|
175
|
+
with result(context, position):
|
|
174
176
|
|
|
175
177
|
if self.error:
|
|
176
178
|
if self.error.exception is SystemExit:
|
|
@@ -178,12 +180,14 @@ class PysExecuteResult(PysResult):
|
|
|
178
180
|
elif type(self.error.exception) is SystemExit:
|
|
179
181
|
return self.error.exception.code, True
|
|
180
182
|
elif (excepthook := pys_sys.excepthook) is not None:
|
|
181
|
-
|
|
183
|
+
from .handlers import handle_call
|
|
184
|
+
handle_call(excepthook, context, position)
|
|
185
|
+
excepthook(*get_traceback_info(self.error))
|
|
182
186
|
return 1, False
|
|
183
187
|
|
|
184
188
|
if result.should_return():
|
|
185
189
|
if result.error:
|
|
186
|
-
print_traceback(*
|
|
190
|
+
print_traceback(*get_traceback_info(result.error))
|
|
187
191
|
return 1, False
|
|
188
192
|
|
|
189
193
|
return 0, False
|
|
@@ -146,15 +146,16 @@ def pys_runner(
|
|
|
146
146
|
result.parser_flags = parser.parser_flags
|
|
147
147
|
pys_sys.flags = context.flags
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
visitor_result = get_visitor(node.__class__)(node, context)
|
|
150
150
|
|
|
151
|
-
if
|
|
152
|
-
return result.failure(
|
|
151
|
+
if visitor_result.error:
|
|
152
|
+
return result.failure(visitor_result.error)
|
|
153
153
|
|
|
154
154
|
if mode == 'single' and (displayhook := pys_sys.displayhook) is not None:
|
|
155
|
-
displayhook
|
|
155
|
+
handle_call(displayhook, context, position)
|
|
156
|
+
displayhook(visitor_result.value)
|
|
156
157
|
|
|
157
|
-
return result.success(
|
|
158
|
+
return result.success(visitor_result.value)
|
|
158
159
|
|
|
159
160
|
return result.failure(runtime_result.error) if runtime_result.error else result
|
|
160
161
|
|
|
@@ -348,7 +349,7 @@ def pys_shell(
|
|
|
348
349
|
if text == 0:
|
|
349
350
|
return 0
|
|
350
351
|
elif text == 1:
|
|
351
|
-
symtab = _normalize_namespace(
|
|
352
|
+
symtab = _normalize_namespace(undefined, file)
|
|
352
353
|
parser_flags = default_parser_flags
|
|
353
354
|
line = 0
|
|
354
355
|
continue
|
{pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/shell.py
RENAMED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
from .bases import Pys
|
|
2
2
|
from .cache import pys_sys
|
|
3
3
|
from .constants import ENV_PYSCRIPT_HISTORY_PATH, ENV_PYSCRIPT_MAXIMUM_HISTORY_LINE
|
|
4
|
+
from .exceptions import PysSignal
|
|
4
5
|
from .mapping import BRACKETS_MAP
|
|
6
|
+
from .utils.debug import print_traceback
|
|
5
7
|
from .utils.decorators import singleton
|
|
6
8
|
from .utils.path import normpath
|
|
7
9
|
|
|
@@ -140,13 +142,23 @@ class PysLineShell(PysIncompleteHandler):
|
|
|
140
142
|
def _process_command(self, text: str) -> Literal[-1, 0, 1] | None:
|
|
141
143
|
if text == '/exit':
|
|
142
144
|
return 0
|
|
145
|
+
|
|
143
146
|
elif text == '/clean':
|
|
144
147
|
return 1
|
|
148
|
+
|
|
145
149
|
elif text == '/clear':
|
|
146
150
|
try:
|
|
147
151
|
pys_sys.clearhook()
|
|
148
|
-
except
|
|
149
|
-
|
|
152
|
+
except:
|
|
153
|
+
try:
|
|
154
|
+
exc_type, exc_value, exc_tb = sys.exc_info()
|
|
155
|
+
print('An exception occurred while calling clearhook function:', file=sys.stderr)
|
|
156
|
+
if exc_type is PysSignal and (exc_tb := exc_value.result.error) is not None:
|
|
157
|
+
print_traceback(None, None, exc_tb)
|
|
158
|
+
else:
|
|
159
|
+
sys.excepthook(exc_type, exc_value, exc_tb)
|
|
160
|
+
except:
|
|
161
|
+
pass
|
|
150
162
|
return -1
|
|
151
163
|
|
|
152
164
|
def prompt(self) -> Literal[0]:
|
|
@@ -155,11 +167,13 @@ class PysLineShell(PysIncompleteHandler):
|
|
|
155
167
|
class PysClassicLineShell(PysLineShell):
|
|
156
168
|
|
|
157
169
|
def prompt(self) -> str | Literal[0, 1]:
|
|
170
|
+
reset = self.reset
|
|
158
171
|
is_multiline = self._is_multiline
|
|
159
172
|
process_line = self._process_line
|
|
160
173
|
process_command = self._process_command
|
|
161
174
|
|
|
162
175
|
multiline = False
|
|
176
|
+
reset()
|
|
163
177
|
|
|
164
178
|
while True:
|
|
165
179
|
|
|
@@ -188,12 +202,10 @@ class PysClassicLineShell(PysLineShell):
|
|
|
188
202
|
multiline = True
|
|
189
203
|
else:
|
|
190
204
|
text = self.text
|
|
191
|
-
|
|
205
|
+
reset()
|
|
192
206
|
return text
|
|
193
207
|
|
|
194
208
|
try:
|
|
195
|
-
from threading import RLock
|
|
196
|
-
|
|
197
209
|
from prompt_toolkit.formatted_text import ANSI
|
|
198
210
|
from prompt_toolkit.history import History, InMemoryHistory
|
|
199
211
|
from prompt_toolkit.layout.processors import TabsProcessor
|
|
@@ -228,15 +240,21 @@ try:
|
|
|
228
240
|
return super().__new__(cls)
|
|
229
241
|
raise NotImplementedError('not using file history')
|
|
230
242
|
|
|
243
|
+
def __init__(self):
|
|
244
|
+
from threading import RLock
|
|
245
|
+
|
|
246
|
+
super().__init__()
|
|
247
|
+
self.lock = RLock()
|
|
248
|
+
|
|
231
249
|
def update_history(self, append_string: Optional[str] = None) -> list[str]:
|
|
232
250
|
try:
|
|
233
251
|
|
|
234
|
-
with
|
|
252
|
+
with self.lock:
|
|
235
253
|
strings = []
|
|
236
254
|
lines = []
|
|
237
255
|
update = False
|
|
238
256
|
|
|
239
|
-
if os.path.
|
|
257
|
+
if os.path.isfile(HISTORY_PATH):
|
|
240
258
|
|
|
241
259
|
def add_to_string():
|
|
242
260
|
if line := '\n'.join(lines):
|
|
@@ -288,15 +306,11 @@ try:
|
|
|
288
306
|
self._loaded_strings.insert(0, string)
|
|
289
307
|
self.update_history(string)
|
|
290
308
|
|
|
291
|
-
history_lock = RLock()
|
|
292
309
|
history = (PysHistory if USE_FILE_HISTORY else InMemoryHistory)()
|
|
293
310
|
|
|
294
311
|
class PysPromptToolkitLineShell(PysLineShell, PromptSession):
|
|
295
312
|
|
|
296
313
|
def __init__(self, ps1: str = '>>> ', ps2: str = '... ', colored: bool = True) -> None:
|
|
297
|
-
# circular import problem solved
|
|
298
|
-
from .highlight import PYGMENTS, PygmentsPyScriptStyle, PygmentsPyScriptShellLexer
|
|
299
|
-
|
|
300
314
|
PysLineShell.__init__(self, ps1, ps2, colored)
|
|
301
315
|
|
|
302
316
|
key_bindings = KeyBindings()
|
|
@@ -330,24 +344,31 @@ try:
|
|
|
330
344
|
@key_bindings.add('enter', eager=True)
|
|
331
345
|
def _(event):
|
|
332
346
|
buffer = self.default_buffer
|
|
347
|
+
document = buffer.document
|
|
333
348
|
reset = self.reset
|
|
349
|
+
is_multiline = self._is_multiline
|
|
334
350
|
process_line = self._process_line
|
|
335
351
|
|
|
336
352
|
reset()
|
|
337
353
|
|
|
338
354
|
# Ctrl + Z
|
|
339
|
-
if
|
|
355
|
+
if document.current_line_before_cursor.startswith('\x1a'):
|
|
340
356
|
self.app.exit(exception=EOFError)
|
|
341
357
|
return
|
|
342
358
|
|
|
343
|
-
|
|
359
|
+
row = document.cursor_position_row
|
|
360
|
+
should_process_lines = True
|
|
361
|
+
|
|
362
|
+
for i, line in enumerate((buffer.text + '\n').splitlines()):
|
|
344
363
|
process_line(line)
|
|
345
364
|
if self._must_break:
|
|
346
365
|
reset()
|
|
347
366
|
buffer.validate_and_handle()
|
|
348
367
|
return
|
|
368
|
+
if i == row and is_multiline():
|
|
369
|
+
should_process_lines = False
|
|
349
370
|
|
|
350
|
-
if not
|
|
371
|
+
if should_process_lines and not is_multiline():
|
|
351
372
|
reset()
|
|
352
373
|
buffer.validate_and_handle()
|
|
353
374
|
return
|
|
@@ -357,11 +378,15 @@ try:
|
|
|
357
378
|
other_keyword = {}
|
|
358
379
|
|
|
359
380
|
if colored:
|
|
381
|
+
# circular import problem solved
|
|
382
|
+
from .highlight import PYGMENTS, PygmentsPyScriptStyle, PygmentsPyScriptShellLexer
|
|
383
|
+
|
|
360
384
|
if PYGMENTS:
|
|
361
385
|
other_keyword.update({
|
|
362
386
|
'lexer': PygmentsLexer(PygmentsPyScriptShellLexer),
|
|
363
387
|
'style': style_from_pygments_cls(PygmentsPyScriptStyle)
|
|
364
388
|
})
|
|
389
|
+
|
|
365
390
|
else:
|
|
366
391
|
other_keyword.update({
|
|
367
392
|
'color_depth': ColorDepth.DEPTH_1_BIT
|
|
@@ -380,6 +405,8 @@ try:
|
|
|
380
405
|
prompt = PromptSession.prompt
|
|
381
406
|
process_command = self._process_command
|
|
382
407
|
|
|
408
|
+
self.reset()
|
|
409
|
+
|
|
383
410
|
while True:
|
|
384
411
|
|
|
385
412
|
try:
|
|
@@ -4,7 +4,7 @@ from .constants import TOKENS
|
|
|
4
4
|
from .cache import PysUndefined, undefined
|
|
5
5
|
from .mapping import GET_BINARY_FUNCTIONS_MAP, EMPTY_MAP
|
|
6
6
|
from .utils.decorators import immutable
|
|
7
|
-
from .utils.generic import setimuattr, dcontains, dgetitem, dsetitem, ddelitem, dget, dkeys
|
|
7
|
+
from .utils.generic import setimuattr, delimuattr, dcontains, dgetitem, dsetitem, ddelitem, dget, dkeys
|
|
8
8
|
from .utils.similarity import get_closest
|
|
9
9
|
|
|
10
10
|
from types import ModuleType
|
|
@@ -66,9 +66,9 @@ else:
|
|
|
66
66
|
except:
|
|
67
67
|
return False
|
|
68
68
|
|
|
69
|
-
def
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
def get_traceback_info(traceback: PysTraceback | None) -> tuple[type[BaseException] | None,
|
|
70
|
+
BaseException | None,
|
|
71
|
+
PysTraceback | None]:
|
|
72
72
|
return (None, None, None) if traceback is None else (
|
|
73
73
|
(exception, None, traceback)
|
|
74
74
|
if isinstance(exception := traceback.exception, type) else
|
|
@@ -7,8 +7,8 @@ from types import MappingProxyType
|
|
|
7
7
|
|
|
8
8
|
version_match = re_compile(r'^(\d+)\.(\d+)\.(\d+)((?:a|b|rc)(\d+)|\.(dev|post)(\d+))?$').match
|
|
9
9
|
|
|
10
|
-
__version__ = '1.12.
|
|
11
|
-
__date__ = '
|
|
10
|
+
__version__ = '1.12.8'
|
|
11
|
+
__date__ = '19 March 2026, 20:10 UTC+7'
|
|
12
12
|
__author__ = ('azzammuhyala',)
|
|
13
13
|
|
|
14
14
|
version = pys_sys.version = f'{__version__} ({__date__})'
|
|
@@ -6,9 +6,10 @@ from pyscript.core.nodes import (
|
|
|
6
6
|
PysListNode, PysTupleNode, PysCallNode, PysUnaryOperatorNode, PysBinaryOperatorNode, PysEllipsisNode
|
|
7
7
|
)
|
|
8
8
|
from pyscript.core.pysbuiltins import pys_builtins
|
|
9
|
+
from pyscript.core.results import PysRunTimeResult
|
|
9
10
|
|
|
10
11
|
from types import EllipsisType
|
|
11
|
-
from typing import Any
|
|
12
|
+
from typing import Any, Callable
|
|
12
13
|
|
|
13
14
|
is_arithmetic = frozenset([TOKENS['PLUS'], TOKENS['MINUS']]).__contains__
|
|
14
15
|
|
|
@@ -78,7 +79,7 @@ def visit_BinaryOperatorNode(node: PysBinaryOperatorNode) -> Any:
|
|
|
78
79
|
def visit_EllipsisNode(node: PysEllipsisNode) -> EllipsisType:
|
|
79
80
|
return ...
|
|
80
81
|
|
|
81
|
-
get_visitor = {
|
|
82
|
+
get_visitor: Callable[[type[PysNode]], Callable[[PysNode], Any]] = {
|
|
82
83
|
class_node: globals().get('visit_' + class_node.__name__.removeprefix('Pys'), visit_unknown_node)
|
|
83
84
|
for class_node in PysNode.__subclasses__()
|
|
84
85
|
}.__getitem__
|
|
@@ -4,7 +4,7 @@ from pyscript.core.mapping import SYMBOLS_TOKEN_MAP
|
|
|
4
4
|
from pyscript.core.nodes import *
|
|
5
5
|
from pyscript.core.utils.string import indent as sindent
|
|
6
6
|
|
|
7
|
-
from typing import Literal
|
|
7
|
+
from typing import Callable, Literal
|
|
8
8
|
|
|
9
9
|
def indent(string: str) -> str:
|
|
10
10
|
return sindent(string, 4)
|
|
@@ -539,7 +539,7 @@ def visit_ContinueNode(node: PysContinueNode) -> Literal['continue']:
|
|
|
539
539
|
def visit_BreakNode(node: PysBreakNode) -> Literal['break']:
|
|
540
540
|
return 'break'
|
|
541
541
|
|
|
542
|
-
get_visitor = {
|
|
542
|
+
get_visitor: Callable[[type[PysNode]], Callable[[PysNode], str]] = {
|
|
543
543
|
class_node: globals()['visit_' + class_node.__name__.removeprefix('Pys')]
|
|
544
544
|
for class_node in PysNode.__subclasses__()
|
|
545
545
|
}.__getitem__
|
|
@@ -7,22 +7,20 @@ if (shell.ADVANCE_LINE_SHELL_SUPPORT) {
|
|
|
7
7
|
MAXIMUM_HISTORY_LINE = shell.MAXIMUM_HISTORY_LINE
|
|
8
8
|
|
|
9
9
|
func load() => list(shell.history.load_history_strings())
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (shell.USE_FILE_HISTORY) {
|
|
10
|
+
func append(string) shell.history.append_string(string)
|
|
11
|
+
if (shell.USE_FILE_HISTORY)
|
|
14
12
|
func clear() {
|
|
15
13
|
shell.history._loaded_strings.clear()
|
|
16
14
|
explorer.clear(HISTORY_PATH)
|
|
17
15
|
}
|
|
18
|
-
|
|
16
|
+
else
|
|
19
17
|
func clear() {
|
|
20
18
|
shell.history._loaded_strings.clear()
|
|
21
19
|
shell.history._storage.clear()
|
|
22
20
|
}
|
|
23
|
-
|
|
21
|
+
}
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
else {
|
|
26
24
|
HISTORY_PATH = '<none>'
|
|
27
25
|
MAXIMUM_HISTORY_LINE = 1000
|
|
28
26
|
|
|
@@ -9,7 +9,7 @@ with open('./README.md', 'r', encoding='utf-8') as file:
|
|
|
9
9
|
|
|
10
10
|
setup(
|
|
11
11
|
name='pyscript-programming-language',
|
|
12
|
-
version='1.12.
|
|
12
|
+
version='1.12.8',
|
|
13
13
|
description='PyScript Programming Language',
|
|
14
14
|
long_description=long_description,
|
|
15
15
|
long_description_content_type='text/markdown',
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
## [1.12.7] - 18/03/2026
|
|
4
|
-
|
|
5
|
-
### Added
|
|
6
|
-
- Updated history features in the advanced shell (_REPL_) with `pygments`.
|
|
7
|
-
- New node for the constant keyword `__debug__`.
|
|
8
|
-
- Wrap around pointer and garbage collection mechanism in the `brainfuck` module.
|
|
9
|
-
|
|
10
|
-
### Fixed
|
|
11
|
-
- **Fixed some bugs**.
|
|
12
|
-
- _etc._
|
|
File without changes
|
|
File without changes
|
{pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/__init__.py
RENAMED
|
File without changes
|
{pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/__init__.pyi
RENAMED
|
File without changes
|
{pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/__main__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/bases.py
RENAMED
|
File without changes
|
|
File without changes
|
{pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/cache.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/lexer.py
RENAMED
|
File without changes
|
|
File without changes
|
{pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/nodes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/core/token.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/ansi.pys
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/dis.pys
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/site.pys
RENAMED
|
File without changes
|
|
File without changes
|
{pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/lib/token.pys
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/other/credits
RENAMED
|
File without changes
|
{pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/other/license
RENAMED
|
File without changes
|
|
File without changes
|
{pyscript_programming_language-1.12.7 → pyscript_programming_language-1.12.8}/pyscript/this.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|