pyscript-programming-language 1.12.9__tar.gz → 1.12.11__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.
Files changed (94) hide show
  1. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/PKG-INFO +5 -5
  2. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/README.md +3 -4
  3. pyscript_programming_language-1.12.11/changelog.md +13 -0
  4. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyproject.toml +2 -1
  5. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/__main__.py +92 -84
  6. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/__init__.py +2 -2
  7. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/analyzer.py +24 -16
  8. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/cache.py +13 -22
  9. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/checks.py +18 -12
  10. pyscript_programming_language-1.12.11/pyscript/core/constants.py +43 -0
  11. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/editor/bases.py +2 -2
  12. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/editor/gui.py +5 -3
  13. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/exceptions.py +13 -7
  14. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/handlers.py +1 -1
  15. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/highlight.py +16 -14
  16. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/interpreter.py +135 -96
  17. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/lexer.py +9 -5
  18. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/mapping.py +11 -11
  19. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/nodes.py +42 -40
  20. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/parser.py +18 -17
  21. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/position.py +7 -7
  22. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/pysbuiltins.py +30 -35
  23. pyscript_programming_language-1.12.9/pyscript/core/objects.py → pyscript_programming_language-1.12.11/pyscript/core/pystypes.py +38 -1
  24. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/results.py +3 -6
  25. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/runner.py +18 -12
  26. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/shell.py +49 -44
  27. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/symtab.py +5 -5
  28. pyscript_programming_language-1.12.9/pyscript/core/constants.py → pyscript_programming_language-1.12.11/pyscript/core/token.py +40 -54
  29. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/utils/__init__.py +0 -2
  30. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/utils/debug.py +1 -0
  31. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/utils/decorators.py +14 -12
  32. pyscript_programming_language-1.12.11/pyscript/core/utils/module.py +42 -0
  33. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/utils/path.py +2 -5
  34. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/version.py +2 -2
  35. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/ast/ast_literal_eval.py +10 -16
  36. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/ast/ast_unparse.py +1 -1
  37. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/fpstimer/py_fpstimer.py +0 -5
  38. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/history.pys +0 -1
  39. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/inspect.pys +4 -4
  40. pyscript_programming_language-1.12.11/pyscript/lib/jsdict.pys +5 -0
  41. pyscript_programming_language-1.12.11/pyscript/lib/opcode.pys +1 -0
  42. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/parser.pys +5 -5
  43. pyscript_programming_language-1.12.11/pyscript/lib/site.pys +131 -0
  44. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/tokenize/__init__.pys +2 -1
  45. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/tokenize/tok_untokenize.py +1 -2
  46. pyscript_programming_language-1.12.11/pyscript/other/PyScript.ico +0 -0
  47. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript_programming_language.egg-info/PKG-INFO +5 -5
  48. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript_programming_language.egg-info/SOURCES.txt +2 -2
  49. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/setup.py +3 -2
  50. pyscript_programming_language-1.12.9/changelog.md +0 -11
  51. pyscript_programming_language-1.12.9/pyscript/core/token.py +0 -25
  52. pyscript_programming_language-1.12.9/pyscript/core/utils/jsdict.py +0 -32
  53. pyscript_programming_language-1.12.9/pyscript/core/utils/module.py +0 -27
  54. pyscript_programming_language-1.12.9/pyscript/lib/jsdict.pys +0 -5
  55. pyscript_programming_language-1.12.9/pyscript/lib/site.pys +0 -55
  56. pyscript_programming_language-1.12.9/pyscript/other/PyScript.ico +0 -0
  57. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/MANIFEST.in +0 -0
  58. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/__init__.py +0 -0
  59. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/__init__.pyi +0 -0
  60. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/bases.py +0 -0
  61. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/buffer.py +0 -0
  62. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/context.py +0 -0
  63. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/editor/__init__.py +0 -0
  64. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/editor/terminal.py +0 -0
  65. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/utils/ansi.py +0 -0
  66. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/utils/generic.py +0 -0
  67. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/utils/similarity.py +0 -0
  68. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/core/utils/string.py +0 -0
  69. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/__hello__.pys +0 -0
  70. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/ansi.pys +0 -0
  71. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/ast/__init__.pys +0 -0
  72. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/ast/ast_dump.py +0 -0
  73. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/ast/ast_walk.py +0 -0
  74. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/brainfuck.pys +0 -0
  75. /pyscript_programming_language-1.12.9/pyscript/lib/opcode.pys → /pyscript_programming_language-1.12.11/pyscript/lib/code.pys +0 -0
  76. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/dis.pys +0 -0
  77. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/explorer.pys +0 -0
  78. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/fpstimer/__init__.pys +0 -0
  79. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/getch/__init__.pys +0 -0
  80. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/getch/py_getch.py +0 -0
  81. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/keyword.pys +0 -0
  82. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/pdisplay.pys +0 -0
  83. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/symtable.pys +0 -0
  84. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/lib/token.pys +0 -0
  85. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/other/.nomedia +0 -0
  86. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/other/copyright +0 -0
  87. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/other/credits +0 -0
  88. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/other/license +0 -0
  89. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/site-packages/this.pys +0 -0
  90. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript/this.py +0 -0
  91. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript_programming_language.egg-info/dependency_links.txt +0 -0
  92. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript_programming_language.egg-info/requires.txt +0 -0
  93. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/pyscript_programming_language.egg-info/top_level.txt +0 -0
  94. {pyscript_programming_language-1.12.9 → pyscript_programming_language-1.12.11}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyscript-programming-language
3
- Version: 1.12.9
3
+ Version: 1.12.11
4
4
  Summary: PyScript Programming Language
5
5
  Home-page: https://azzammuhyala.github.io/pyscript
6
6
  Author: azzammuhyala
@@ -9,6 +9,7 @@ License-Expression: MIT
9
9
  Project-URL: Homepage, https://azzammuhyala.github.io/pyscript
10
10
  Project-URL: Source, https://github.com/azzammuhyala/pyscript
11
11
  Project-URL: Bug Tracker, https://github.com/azzammuhyala/pyscript/issues
12
+ Project-URL: Change Log, https://github.com/azzammuhyala/pyscript/blob/main/changelog.md
12
13
  Keywords: pyscript,pyslang,pys,programming,language,programming language
13
14
  Classifier: Programming Language :: Python
14
15
  Classifier: Programming Language :: Python :: 3
@@ -32,8 +33,8 @@ Dynamic: requires-python
32
33
  <img src="https://github.com/azzammuhyala/pyscript/blob/main/PyScript.png?raw=true" alt="PyScript Logo" width="200">
33
34
  </div>
34
35
 
35
- PyScript is a simple programming language built on top of Python. It combines some syntax from Python and JavaScript,
36
- so if you're already familiar with Python, JavaScript or both, it should be quite easy to learn.
36
+ PyScript is a programming language built on top of Python. It combines some syntax from Python and JavaScript, so if
37
+ you're already familiar with Python, JavaScript or both, it should be quite easy to learn.
37
38
 
38
39
  ## Introduction 📖
39
40
  PyScript may not be the language we'll be discussing, but the name PyScript already exists, a flexible and platform for
@@ -55,8 +56,7 @@ First, you'll need to download Python. Make sure you're using the latest version
55
56
  correctly. Visit the official [Python website](https://python.org) to download it.
56
57
 
57
58
  Next, after downloading and configuring the Python application, you can download the PyScript from
58
- [PyScript releases](https://github.com/azzammuhyala/pyscript/releases) or from Python Pip with this command
59
- (_Recommended_):
59
+ [PyScript releases](https://github.com/azzammuhyala/pyscript/releases) or from PIP with this command (_Recommended_):
60
60
  ```sh
61
61
  pip install -U pyscript-programming-language
62
62
  ```
@@ -4,8 +4,8 @@
4
4
  <img src="https://github.com/azzammuhyala/pyscript/blob/main/PyScript.png?raw=true" alt="PyScript Logo" width="200">
5
5
  </div>
6
6
 
7
- PyScript is a simple programming language built on top of Python. It combines some syntax from Python and JavaScript,
8
- so if you're already familiar with Python, JavaScript or both, it should be quite easy to learn.
7
+ PyScript is a programming language built on top of Python. It combines some syntax from Python and JavaScript, so if
8
+ you're already familiar with Python, JavaScript or both, it should be quite easy to learn.
9
9
 
10
10
  ## Introduction 📖
11
11
  PyScript may not be the language we'll be discussing, but the name PyScript already exists, a flexible and platform for
@@ -27,8 +27,7 @@ First, you'll need to download Python. Make sure you're using the latest version
27
27
  correctly. Visit the official [Python website](https://python.org) to download it.
28
28
 
29
29
  Next, after downloading and configuring the Python application, you can download the PyScript from
30
- [PyScript releases](https://github.com/azzammuhyala/pyscript/releases) or from Python Pip with this command
31
- (_Recommended_):
30
+ [PyScript releases](https://github.com/azzammuhyala/pyscript/releases) or from PIP with this command (_Recommended_):
32
31
  ```sh
33
32
  pip install -U pyscript-programming-language
34
33
  ```
@@ -0,0 +1,13 @@
1
+ # Change Log
2
+
3
+ ## [1.12.11] - 11/04/2026
4
+
5
+ ### Added
6
+ - New `-m` / `--module` argument.
7
+ - _etc._
8
+
9
+ ### Fixed
10
+ - Fixed some bugs.
11
+ - Improved and added modules in `sys`.
12
+ - Improved runtime interpreter.
13
+ - _etc._
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pyscript-programming-language"
7
- version = "1.12.9"
7
+ version = "1.12.11"
8
8
  description = "PyScript Programming Language"
9
9
  readme = { file = "README.md", content-type = "text/markdown" }
10
10
  requires-python = ">=3.10"
@@ -36,6 +36,7 @@ classifiers = [
36
36
  Homepage = "https://azzammuhyala.github.io/pyscript"
37
37
  Source = "https://github.com/azzammuhyala/pyscript"
38
38
  "Bug Tracker" = "https://github.com/azzammuhyala/pyscript/issues"
39
+ "Change Log" = "https://github.com/azzammuhyala/pyscript/blob/main/changelog.md"
39
40
 
40
41
  [project.optional-dependencies]
41
42
  other = [
@@ -12,8 +12,8 @@ from .core.highlight import (
12
12
  from .core.runner import _normalize_namespace, pys_runner, pys_shell
13
13
  from .core.utils.debug import USE_NOTEBOOK
14
14
  from .core.utils.generic import is_environ
15
- from .core.utils.module import remove_python_path
16
- from .core.utils.path import getcwd, normpath, get_name_from_path
15
+ from .core.utils.module import find_module_path, remove_python_path
16
+ from .core.utils.path import getcwd, base, normpath
17
17
  from .core.version import __version__
18
18
 
19
19
  if PYGMENTS:
@@ -23,7 +23,7 @@ if PYGMENTS:
23
23
  Terminal256Formatter
24
24
  )
25
25
 
26
- FORMAT_PYGMENTS_MAP = {
26
+ FORMATER_PYGMENTS_MAP = {
27
27
  'pm-bbcode': BBCodeFormatter,
28
28
  'pm-html': HtmlFormatter,
29
29
  'pm-latex': LatexFormatter,
@@ -36,7 +36,7 @@ from argparse import OPTIONAL, REMAINDER, ArgumentParser
36
36
 
37
37
  import sys
38
38
 
39
- FORMAT_HIGHLIGHT_MAP = {
39
+ FORMATER_HIGHLIGHT_MAP = {
40
40
  'html': HLFMT_HTML,
41
41
  'ansi': HLFMT_ANSI,
42
42
  'bbcode': HLFMT_BBCODE
@@ -52,7 +52,7 @@ for supported, name, class_editor in [
52
52
  EDITOR_MAP[name] = class_editor
53
53
 
54
54
  parser = ArgumentParser(
55
- prog=f'{get_name_from_path(sys.executable)} -m pyscript',
55
+ prog=f'{base(sys.executable)} -m pyscript',
56
56
  description=f'PyScript Launcher for Python Version {".".join(map(str, sys.version_info))}'
57
57
  )
58
58
 
@@ -66,13 +66,14 @@ parser.add_argument(
66
66
  '-c', '--command',
67
67
  type=str,
68
68
  default=None,
69
- help="Execute program from a string argument",
69
+ metavar='STRING',
70
+ help="execute program from a string argument",
70
71
  )
71
72
 
72
73
  parser.add_argument(
73
74
  '-d', '-O', '--debug',
74
75
  action='store_true',
75
- help="Set a debug flag, this will ignore assert statement. Check the flag is active with the __debug__ keyword"
76
+ help="set a debug flag, this will ignore assert statement. Check the flag is active with the __debug__ keyword"
76
77
  )
77
78
 
78
79
  if EDITOR_MAP:
@@ -80,57 +81,66 @@ if EDITOR_MAP:
80
81
  '-e', '--editor',
81
82
  choices=tuple(EDITOR_MAP.keys()),
82
83
  default=None,
83
- help="Open the editor panel from a 'file'",
84
+ help="open the editor panel from a 'file'",
84
85
  )
85
86
 
86
87
  parser.add_argument(
87
88
  '-i', '--inspect',
88
89
  action='store_true',
89
- help="Inspect interactively after running a code",
90
+ help="inspect interactively after running a code",
90
91
  )
91
92
 
92
93
  parser.add_argument(
93
94
  '-k', '--classic-line-shell',
94
95
  action='store_true',
95
- help="Use a classic command line shell"
96
+ help="use a classic command line shell"
96
97
  )
97
98
 
98
99
  parser.add_argument(
99
100
  '-l', '--highlight',
100
- choices=tuple(FORMAT_HIGHLIGHT_MAP.keys()) + tuple(FORMAT_PYGMENTS_MAP.keys() if PYGMENTS else ()),
101
+ choices=tuple(FORMATER_HIGHLIGHT_MAP.keys()) + tuple(FORMATER_PYGMENTS_MAP.keys() if PYGMENTS else ()),
101
102
  default=None,
102
- help="Generate highlight code from a 'file'"
103
+ help="generate highlight code from a 'file'"
104
+ )
105
+
106
+ parser.add_argument(
107
+ '-m', '--module',
108
+ type=str,
109
+ default=None,
110
+ metavar='NAME',
111
+ help="run library module as a script"
103
112
  )
104
113
 
105
114
  parser.add_argument(
106
115
  '-n', '--no-color',
107
116
  action='store_true',
108
- help="Suppress colored output"
117
+ help="suppress colored output"
109
118
  )
110
119
 
111
120
  parser.add_argument(
112
121
  '-p', '--no-color-prompt',
113
122
  action='store_true',
114
- help="Suppress colored prompt output"
123
+ help="suppress colored prompt output"
115
124
  )
116
125
 
117
126
  parser.add_argument(
118
127
  '-r', '--py-recursion',
119
128
  type=int,
120
129
  default=None,
121
- help="Set a Python recursion limit"
130
+ metavar='UINTEGER',
131
+ help="set a Python recursion limit"
122
132
  )
123
133
 
124
134
  parser.add_argument(
125
135
  '-t', '--terminal',
126
136
  action='store_true',
127
- help="Configure terminal encoding to UTF-8 and enable ANSI escape code processing on Windows"
137
+ help="configure terminal encoding to UTF-8 and enable ANSI escape code processing on Windows"
128
138
  )
129
139
 
130
140
  parser.add_argument(
131
141
  '-q',
132
142
  action='store_true',
133
- help="Don't print version and copyright messages on interactive startup"
143
+ help="don't print version and copyright messages on interactive startup"
134
144
  )
135
145
 
136
146
  parser.add_argument(
@@ -142,7 +152,7 @@ parser.add_argument(
142
152
  parser.add_argument(
143
153
  '-P',
144
154
  action='store_true',
145
- help="Don't prepend a potentially unsafe path to sys.path (python sys.path)"
155
+ help="don't prepend a potentially unsafe path to sys.path (python sys.path)"
146
156
  )
147
157
 
148
158
  parser.add_argument(
@@ -150,13 +160,13 @@ parser.add_argument(
150
160
  type=str,
151
161
  nargs=OPTIONAL,
152
162
  default=None,
153
- help="File path to be executed"
163
+ help="file path to be executed"
154
164
  )
155
165
 
156
166
  parser.add_argument(
157
167
  'arg',
158
168
  nargs=REMAINDER,
159
- help="Remaining arguments stored in pys_sys.argv (pyscript sys.argv)"
169
+ help="remaining arguments stored in pys_sys.argv (pyscript sys.argv)"
160
170
  )
161
171
 
162
172
  def argument_error(argument, message):
@@ -169,11 +179,16 @@ file_idx = sum(1 for arg in argv if arg.startswith('-'))
169
179
  end_idx = argv.index('--', 0, file_idx) if '--' in argv[:file_idx] else -1
170
180
  end_com = file_idx if end_idx == -1 else end_idx
171
181
  arg_com = argv[:end_com]
182
+
172
183
  com_idx = argv.index('-c', 0, end_com) if '-c' in arg_com else \
173
184
  (argv.index('--command', 0, end_com) if '--command' in arg_com else -1)
185
+ mod_idx = argv.index('-m', 0, end_com) if '-m' in arg_com else \
186
+ (argv.index('--module', 0, end_com) if '--module' in arg_com else -1)
187
+
188
+ ofs_idx = max(com_idx, mod_idx)
174
189
 
175
- args = parser.parse_args(argv if com_idx == -1 else argv[:com_idx + 2])
176
- arg = args.arg if com_idx == -1 else argv[com_idx + 2:]
190
+ args = parser.parse_args(argv if ofs_idx == -1 else argv[:ofs_idx + 2])
191
+ arg = args.arg if ofs_idx == -1 else argv[ofs_idx + 2:]
177
192
 
178
193
  if args.terminal:
179
194
 
@@ -238,8 +253,8 @@ try:
238
253
  del (
239
254
  ENV_PYSCRIPT_NO_COLOR_PROMPT, ENV_PYSCRIPT_CLASSIC_LINE_SHELL, DEFAULT, DEBUG, CLASSIC_LINE_SHELL,
240
255
  NO_COLOR_PROMPT, NOTEBOOK, GUI_SUPPORT, TERMINAL_SUPPORT, PYGMENTS, HLFMT_ANSI, HLFMT_HTML, HLFMT_BBCODE,
241
- USE_NOTEBOOK, OPTIONAL, REMAINDER, file_idx, end_idx, end_com, arg_com, com_idx, arg, pys_sys, __version__,
242
- is_environ, remove_python_path, getcwd, get_name_from_path, PysGUIEditor, PysTerminalEditor, ArgumentParser
256
+ USE_NOTEBOOK, OPTIONAL, REMAINDER, file_idx, end_idx, end_com, arg_com, com_idx, mod_idx, ofs_idx, arg, pys_sys,
257
+ __version__, is_environ, remove_python_path, getcwd, base, PysGUIEditor, PysTerminalEditor, ArgumentParser
243
258
  )
244
259
 
245
260
  del (
@@ -248,30 +263,56 @@ try:
248
263
  except:
249
264
  pass
250
265
 
251
- if args.file is not None:
252
- argv[0] = args.file
253
- path = normpath(args.file)
254
-
266
+ def load_file(path):
267
+ file = PysFileBuffer('', path)
255
268
  try:
256
269
  with open(path, 'r', encoding='utf-8') as file:
257
270
  file = PysFileBuffer(file, path)
258
271
  except FileNotFoundError:
259
- if EDITOR_MAP and args.editor:
260
- file = PysFileBuffer('', path)
261
- else:
262
- parser.error(f"can't open file {path!r}: No such file or directory")
272
+ if not (EDITOR_MAP and args.editor):
273
+ argument_error('file', f"can't open file \"{path}\": No such file or directory")
263
274
  except PermissionError:
264
- parser.error(f"can't open file {path!r}: Permission denied")
275
+ argument_error('file', f"can't open file \"{path}\": Permission denied")
265
276
  except IsADirectoryError:
266
- parser.error(f"can't open file {path!r}: Path is not a file")
277
+ argument_error('file', f"can't open file \"{path}\": Path is not a file")
267
278
  except NotADirectoryError:
268
- parser.error(f"can't open file {path!r}: Attempting to access directory from file")
279
+ argument_error('file', f"can't open file \"{path}\": Attempting to access directory from file")
269
280
  except (OSError, IOError):
270
- parser.error(f"can't open file {path!r}: Attempting to access a system directory or file")
281
+ argument_error('file', f"can't open file \"{path}\": Attempting to access a system directory or file")
271
282
  except UnicodeDecodeError:
272
- parser.error(f"can't read file {path!r}: Bad file")
283
+ argument_error('file', f"can't read file \"{path}\": Bad file")
273
284
  except BaseException as e:
274
- parser.error(f"file {path!r}: Unexpected error: {e}")
285
+ argument_error('file', f"file \"{path}\": Unexpected error: {e}")
286
+ return file
287
+
288
+ def execute(file):
289
+ result = pys_runner(
290
+ file=file,
291
+ mode='exec',
292
+ symbol_table=_normalize_namespace(undefined, file),
293
+ flags=flags
294
+ )
295
+
296
+ code, _ = result.end_process()
297
+
298
+ if args.inspect:
299
+ if sys.stdout.closed or sys.stderr.closed:
300
+ return 1
301
+ elif sys.stdin.closed:
302
+ print("Can't run interactive shell: sys.stdin closed", file=sys.stderr)
303
+ return 1
304
+ else:
305
+ return pys_shell(
306
+ globals=result.context.symbol_table,
307
+ flags=result.context.flags | DONT_SHOW_BANNER_ON_SHELL,
308
+ parser_flags=result.parser_flags
309
+ )
310
+
311
+ return code
312
+
313
+ if args.file is not None:
314
+ argv[0] = args.file
315
+ file = load_file(normpath(args.file))
275
316
 
276
317
  if EDITOR_MAP and args.editor:
277
318
  try:
@@ -281,11 +322,11 @@ if args.file is not None:
281
322
 
282
323
  elif args.highlight:
283
324
  try:
284
- if args.highlight in FORMAT_HIGHLIGHT_MAP:
325
+ if args.highlight in FORMATER_HIGHLIGHT_MAP:
285
326
  print(
286
327
  pys_highlight(
287
328
  source=file,
288
- formatter=FORMAT_HIGHLIGHT_MAP[args.highlight]
329
+ formatter=FORMATER_HIGHLIGHT_MAP[args.highlight]
289
330
  )
290
331
  )
291
332
  else:
@@ -293,60 +334,27 @@ if args.file is not None:
293
334
  highlight(
294
335
  code=file.text,
295
336
  lexer=PygmentsPyScriptLexer(),
296
- formatter=FORMAT_PYGMENTS_MAP[args.highlight](style=PygmentsPyScriptStyle, full=True)
337
+ formatter=FORMATER_PYGMENTS_MAP[args.highlight](style=PygmentsPyScriptStyle, full=True)
297
338
  )
298
339
  )
299
340
  except BaseException as e:
300
341
  argument_error('-l/--highlight', e)
301
342
 
302
343
  else:
303
- result = pys_runner(
304
- file=file,
305
- mode='exec',
306
- symbol_table=_normalize_namespace(undefined, file),
307
- flags=flags
308
- )
344
+ code = execute(file)
309
345
 
310
- code, _ = result.end_process()
346
+ elif args.module is not None:
347
+ _, module_path = find_module_path(None, args.module, '__main__')
348
+ if module_path is None:
349
+ argument_error('-m/--module', f"can't find module \"{args.module}\"")
311
350
 
312
- if args.inspect:
313
- if sys.stdout.closed or sys.stderr.closed:
314
- code = 1
315
- elif sys.stdin.closed:
316
- print("Can't run interactive shell: sys.stdin closed", file=sys.stderr)
317
- code = 1
318
- else:
319
- code = pys_shell(
320
- globals=result.context.symbol_table,
321
- flags=result.context.flags | DONT_SHOW_BANNER_ON_SHELL,
322
- parser_flags=result.parser_flags
323
- )
351
+ file = load_file(module_path)
352
+ argv[0] = file.name
353
+ code = execute(file)
324
354
 
325
355
  elif args.command is not None:
326
356
  argv[0] = '-c'
327
-
328
- file = PysFileBuffer(args.command, '<arg-command>')
329
- result = pys_runner(
330
- file=file,
331
- mode='exec',
332
- symbol_table=_normalize_namespace(undefined, file),
333
- flags=flags
334
- )
335
-
336
- code, _ = result.end_process()
337
-
338
- if args.inspect:
339
- if sys.stdout.closed or sys.stderr.closed:
340
- code = 1
341
- elif sys.stdin.closed:
342
- print("Can't run interactive shell: sys.stdin closed", file=sys.stderr)
343
- code = 1
344
- else:
345
- code = pys_shell(
346
- globals=result.context.symbol_table,
347
- flags=result.context.flags | DONT_SHOW_BANNER_ON_SHELL,
348
- parser_flags=result.parser_flags
349
- )
357
+ code = execute(PysFileBuffer(args.command, '<arg-command>'))
350
358
 
351
359
  else:
352
360
  code = pys_shell(
@@ -354,5 +362,5 @@ else:
354
362
  flags=flags
355
363
  )
356
364
 
357
- # goodbye :>
365
+ # goodbye ;)
358
366
  sys.exit(code)
@@ -18,10 +18,10 @@ from . import (
18
18
  lexer,
19
19
  mapping,
20
20
  nodes,
21
- objects,
22
21
  parser,
23
22
  position,
24
23
  pysbuiltins,
24
+ pystypes,
25
25
  results,
26
26
  runner,
27
27
  shell,
@@ -47,10 +47,10 @@ __all__ = (
47
47
  'lexer',
48
48
  'mapping',
49
49
  'nodes',
50
- 'objects',
51
50
  'parser',
52
51
  'position',
53
52
  'pysbuiltins',
53
+ 'pystypes',
54
54
  'results',
55
55
  'runner',
56
56
  'shell',
@@ -1,17 +1,18 @@
1
1
  from .bases import Pys
2
- from .checks import is_list
3
- from .constants import TOKENS, DEFAULT
2
+ from .checks import is_sequence
3
+ from .constants import DEFAULT
4
4
  from .context import PysContext
5
5
  from .exceptions import PysTraceback
6
6
  from .nodes import *
7
7
  from .position import PysPosition
8
- from .utils.decorators import typechecked
8
+ from .token import TOKENS
9
+ from .utils.decorators import typecheck
9
10
 
10
11
  from typing import Optional
11
12
 
12
13
  class PysAnalyzer(Pys):
13
14
 
14
- @typechecked
15
+ @typecheck
15
16
  def __init__(
16
17
  self,
17
18
  node: PysNode,
@@ -25,7 +26,7 @@ class PysAnalyzer(Pys):
25
26
  self.context_parent = context_parent
26
27
  self.context_parent_entry_position = context_parent_entry_position
27
28
 
28
- @typechecked
29
+ @typecheck
29
30
  def analyze(self) -> PysTraceback | None:
30
31
  self.in_loop = 0
31
32
  self.in_function = 0
@@ -92,7 +93,7 @@ class PysAnalyzer(Pys):
92
93
  if self.error:
93
94
  return
94
95
 
95
- self.visit_slice_SubscriptNode(node.slice)
96
+ self.visit_slice_from_SubscriptNode(node.slice)
96
97
 
97
98
  def visit_CallNode(self, node: PysCallNode) -> None:
98
99
  self.visit(node.target)
@@ -159,7 +160,7 @@ class PysAnalyzer(Pys):
159
160
 
160
161
  def visit_IncrementalNode(self, node: PysIncrementalNode) -> None:
161
162
  operator = 'increase' if node.operand.type == TOKENS['DOUBLE_PLUS'] else 'decrease'
162
- self.visit_declaration_AssignmentNode(node.target, f"cannot {operator} literal", operator)
163
+ self.visit_declaration_from_AssignmentNode(node.target, f"cannot {operator} literal", operator)
163
164
 
164
165
  def visit_StatementsNode(self, node: PysStatementsNode) -> None:
165
166
  for element in node.body:
@@ -168,7 +169,7 @@ class PysAnalyzer(Pys):
168
169
  return
169
170
 
170
171
  def visit_AssignmentNode(self, node: PysAssignmentNode) -> None:
171
- self.visit_declaration_AssignmentNode(
172
+ self.visit_declaration_from_AssignmentNode(
172
173
  node.target,
173
174
  "cannot assign to expression here. Maybe you meant '==' instead of '='?"
174
175
  )
@@ -261,7 +262,7 @@ class PysAnalyzer(Pys):
261
262
  if len(node.header) == 2:
262
263
  declaration, iteration = node.header
263
264
 
264
- self.visit_declaration_AssignmentNode(declaration, "cannot assign to expression")
265
+ self.visit_declaration_from_AssignmentNode(declaration, "cannot assign to expression")
265
266
  if self.error:
266
267
  return
267
268
 
@@ -459,7 +460,7 @@ class PysAnalyzer(Pys):
459
460
  if self.error:
460
461
  return
461
462
 
462
- self.visit_slice_SubscriptNode(target.slice)
463
+ self.visit_slice_from_SubscriptNode(target.slice)
463
464
  if self.error:
464
465
  return
465
466
 
@@ -467,6 +468,10 @@ class PysAnalyzer(Pys):
467
468
  self.throw(f"cannot delete {target.name.value}", target.position)
468
469
  return
469
470
 
471
+ elif type is PysDebugNode:
472
+ self.throw("cannot delete to __debug__", node.position)
473
+ return
474
+
470
475
  elif type is not PysIdentifierNode:
471
476
  self.throw("cannot delete literal", target.position)
472
477
  return
@@ -479,7 +484,7 @@ class PysAnalyzer(Pys):
479
484
  if self.in_loop == 0 and self.in_switch == 0:
480
485
  self.throw("break outside of loop or switch case", node.position)
481
486
 
482
- def visit_slice_SubscriptNode(self, node: PysNode | slice | tuple[PysNode | slice, ...]) -> None:
487
+ def visit_slice_from_SubscriptNode(self, node: PysNode | slice | tuple[PysNode | slice, ...]) -> None:
483
488
  type = node.__class__
484
489
 
485
490
  if type is slice:
@@ -500,14 +505,14 @@ class PysAnalyzer(Pys):
500
505
 
501
506
  elif type is tuple:
502
507
  for element in node:
503
- self.visit_slice_SubscriptNode(element)
508
+ self.visit_slice_from_SubscriptNode(element)
504
509
  if self.error:
505
510
  return
506
511
 
507
512
  else:
508
513
  self.visit(node)
509
514
 
510
- def visit_declaration_AssignmentNode(
515
+ def visit_declaration_from_AssignmentNode(
511
516
  self,
512
517
  node: PysIdentifierNode | PysAttributeNode | PysSubscriptNode | PysSetNode | PysListNode | PysTupleNode,
513
518
  message: str,
@@ -524,16 +529,19 @@ class PysAnalyzer(Pys):
524
529
  if self.error:
525
530
  return
526
531
 
527
- self.visit_slice_SubscriptNode(node.slice)
532
+ self.visit_slice_from_SubscriptNode(node.slice)
528
533
 
529
- elif is_list(type):
534
+ elif is_sequence(type):
530
535
  for element in node.elements:
531
- self.visit_declaration_AssignmentNode(element, message, operator_name)
536
+ self.visit_declaration_from_AssignmentNode(element, message, operator_name)
532
537
  if self.error:
533
538
  return
534
539
 
535
540
  elif type is PysKeywordNode:
536
541
  self.throw(f"cannot {operator_name} to {node.name.value}", node.position)
537
542
 
543
+ elif type is PysDebugNode:
544
+ self.throw(f"cannot {operator_name} to __debug__", node.position)
545
+
538
546
  elif type is not PysIdentifierNode:
539
547
  self.throw(message, node.position)
@@ -17,40 +17,31 @@ pys_sys = ModuleType(
17
17
 
18
18
  pys_sys.__running_shell__ = False
19
19
  pys_sys.__running_breakpoint__ = False
20
+ pys_sys.path = [SITE_PACKAGES_PATH, LIBRARIES_PATH]
21
+ pys_sys.loading_modules = set()
22
+ pys_sys.modules = {}
23
+ pys_sys.singletons = {}
20
24
  pys_sys.argv = ['']
21
25
  pys_sys.flags = DEFAULT
22
26
  pys_sys.displayhook = print_display
23
27
  pys_sys.excepthook = print_traceback
24
28
  pys_sys.clearhook = clear_shell
25
- pys_sys.exec_prefix = pys_sys.prefix = pys_sys.pyscript_path = PYSCRIPT_PATH
29
+ pys_sys.pyscript_path = PYSCRIPT_PATH
26
30
  pys_sys.core_path = CORE_PATH
27
31
  pys_sys.libraries_path = LIBRARIES_PATH
28
32
  pys_sys.site_packages_path = SITE_PACKAGES_PATH
29
33
  pys_sys.executable = f'"{sys.executable}" -m pyscript'
30
34
  pys_sys.ps1 = '>>> '
31
35
  pys_sys.ps2 = '... '
32
- pys_sys.float_info = sys.float_info
33
- pys_sys.int_info = sys.int_info
34
- pys_sys.hash_info = sys.hash_info
35
- pys_sys.stderr = sys.stderr
36
- pys_sys.stdout = sys.stdout
37
- pys_sys.stdin = sys.stdin
38
- pys_sys.platform = sys.platform
39
- pys_sys.exit = sys.exit
40
- pys_sys.getrecursionlimit = sys.getrecursionlimit
41
- pys_sys.getrefcount = sys.getrefcount
42
- pys_sys.getsizeof = sys.getsizeof
43
- pys_sys.setrecursionlimit = sys.setrecursionlimit
44
-
45
- # added in python>=3.10.7
46
- if hasattr(sys, 'get_int_max_str_digits') and hasattr(sys, 'set_int_max_str_digits'):
47
- pys_sys.get_int_max_str_digits = sys.get_int_max_str_digits
48
- pys_sys.set_int_max_str_digits = sys.set_int_max_str_digits
49
36
 
50
- pys_sys.path = [SITE_PACKAGES_PATH, LIBRARIES_PATH]
51
- pys_sys.loading_modules = set()
52
- pys_sys.modules = {}
53
- pys_sys.singletons = {}
37
+ for name in (
38
+ 'exit', 'float_info', 'float_repr_style', 'get_int_max_str_digits', 'getdefaultencoding',
39
+ 'getfilesystemencodeerrors', 'getfilesystemencoding', 'getrecursionlimit', 'getrefcount', 'getsizeof',
40
+ 'gettotalrefcount', 'hash_info', 'hexversion', 'int_info', 'intern', 'maxsize', 'maxunicode', 'platform',
41
+ 'set_int_max_str_digits', 'setrecursionlimit', 'stderr', 'stdin', 'stdout', 'thread_info'
42
+ ):
43
+ if hasattr(sys, name):
44
+ setattr(pys_sys, name, getattr(sys, name))
54
45
 
55
46
  @singleton
56
47
  @inheritable