xasm 1.2.0__tar.gz → 1.2.1__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 (67) hide show
  1. {xasm-1.2.0 → xasm-1.2.1}/.editorconfig +1 -1
  2. {xasm-1.2.0 → xasm-1.2.1}/.gitignore +3 -0
  3. xasm-1.2.1/.pre-commit-config.yaml +22 -0
  4. {xasm-1.2.0 → xasm-1.2.1}/ChangeLog +260 -7
  5. {xasm-1.2.0 → xasm-1.2.1}/HOW-TO-USE.rst +70 -39
  6. {xasm-1.2.0 → xasm-1.2.1}/Makefile +3 -2
  7. xasm-1.2.1/NEWS.md +44 -0
  8. {xasm-1.2.0/xasm.egg-info → xasm-1.2.1}/PKG-INFO +60 -41
  9. xasm-1.2.0/PKG-INFO → xasm-1.2.1/README.rst +39 -51
  10. xasm-1.2.1/admin-tools/setup-master.sh +16 -0
  11. xasm-1.2.1/pyproject.toml +63 -0
  12. {xasm-1.2.0 → xasm-1.2.1}/pytest/test_write_pyc.py +24 -10
  13. xasm-1.2.1/setup.py +7 -0
  14. {xasm-1.2.0 → xasm-1.2.1}/test/.gitignore +1 -0
  15. {xasm-1.2.0 → xasm-1.2.1}/test/columnize.py +170 -110
  16. {xasm-1.2.0 → xasm-1.2.1}/test/fn.py +3 -1
  17. {xasm-1.2.0 → xasm-1.2.1}/test/gcd.py +9 -6
  18. {xasm-1.2.0 → xasm-1.2.1}/test/multi-fns.py +5 -5
  19. {xasm-1.2.0 → xasm-1.2.1}/test/run-test.py +22 -15
  20. xasm-1.2.1/test/tasm-3.10-bad.pyasm +55 -0
  21. xasm-1.2.1/test/tasm-3.10.pyasm +55 -0
  22. {xasm-1.2.0 → xasm-1.2.1}/test/test_all.py +6 -2
  23. xasm-1.2.1/xasm/.gitignore +2 -0
  24. {xasm-1.2.0 → xasm-1.2.1}/xasm/assemble.py +307 -114
  25. {xasm-1.2.0 → xasm-1.2.1}/xasm/pyc_convert.py +36 -32
  26. {xasm-1.2.0 → xasm-1.2.1}/xasm/version.py +1 -1
  27. {xasm-1.2.0 → xasm-1.2.1}/xasm/write_pyc.py +10 -6
  28. {xasm-1.2.0 → xasm-1.2.1}/xasm/xasm_cli.py +21 -9
  29. xasm-1.2.0/README.rst → xasm-1.2.1/xasm.egg-info/PKG-INFO +70 -22
  30. {xasm-1.2.0 → xasm-1.2.1}/xasm.egg-info/SOURCES.txt +5 -3
  31. xasm-1.2.1/xasm.egg-info/entry_points.txt +2 -0
  32. xasm-1.2.1/xasm.egg-info/requires.txt +8 -0
  33. xasm-1.2.0/.pre-commit-config.yaml +0 -13
  34. xasm-1.2.0/NEWS.md +0 -26
  35. xasm-1.2.0/__pkginfo__.py +0 -69
  36. xasm-1.2.0/admin-tools/setup-master.sh +0 -22
  37. xasm-1.2.0/setup.py +0 -44
  38. xasm-1.2.0/xasm/.gitignore +0 -1
  39. xasm-1.2.0/xasm.egg-info/entry_points.txt +0 -5
  40. xasm-1.2.0/xasm.egg-info/zip-safe +0 -1
  41. {xasm-1.2.0 → xasm-1.2.1}/.github/FUNDING.yml +0 -0
  42. {xasm-1.2.0 → xasm-1.2.1}/LICENSE.gpl2 +0 -0
  43. {xasm-1.2.0 → xasm-1.2.1}/MANIFEST.in +0 -0
  44. {xasm-1.2.0 → xasm-1.2.1}/admin-tools/check-versions.sh +0 -0
  45. {xasm-1.2.0 → xasm-1.2.1}/admin-tools/make-dist.sh +0 -0
  46. {xasm-1.2.0 → xasm-1.2.1}/pytest/.gitignore +0 -0
  47. {xasm-1.2.0 → xasm-1.2.1}/pytest/testdata/test_pyc.pyc +0 -0
  48. {xasm-1.2.0 → xasm-1.2.1}/requirements-dev.txt +0 -0
  49. {xasm-1.2.0 → xasm-1.2.1}/setup.cfg +0 -0
  50. {xasm-1.2.0 → xasm-1.2.1}/test/Makefile +0 -0
  51. {xasm-1.2.0 → xasm-1.2.1}/test/comp.py +0 -0
  52. {xasm-1.2.0 → xasm-1.2.1}/test/fn-2.6.pyasm +0 -0
  53. {xasm-1.2.0 → xasm-1.2.1}/test/multi-assign-2.7.pyasm +0 -0
  54. {xasm-1.2.0 → xasm-1.2.1}/test/multi-assign.py +0 -0
  55. {xasm-1.2.0 → xasm-1.2.1}/test/multi-assign2-2.7.pyasm +0 -0
  56. {xasm-1.2.0 → xasm-1.2.1}/test/multi-fns-2.7.pyasm +0 -0
  57. {xasm-1.2.0 → xasm-1.2.1}/test/multi-line.py +0 -0
  58. {xasm-1.2.0 → xasm-1.2.1}/test/run-pyc.py +0 -0
  59. {xasm-1.2.0 → xasm-1.2.1}/test/tasm-2.5.pyasm +0 -0
  60. {xasm-1.2.0 → xasm-1.2.1}/test/tasm-2.6.pyasm +0 -0
  61. {xasm-1.2.0 → xasm-1.2.1}/test/tasm-2.7.pyasm +0 -0
  62. {xasm-1.2.0 → xasm-1.2.1}/test/tasm-3.5.pyasm +0 -0
  63. {xasm-1.2.0 → xasm-1.2.1}/test/tasm.py +0 -0
  64. {xasm-1.2.0 → xasm-1.2.1}/test/tasm3-3.4.pyasm +0 -0
  65. {xasm-1.2.0 → xasm-1.2.1}/xasm/__init__.py +0 -0
  66. {xasm-1.2.0 → xasm-1.2.1}/xasm.egg-info/dependency_links.txt +0 -0
  67. {xasm-1.2.0 → xasm-1.2.1}/xasm.egg-info/top_level.txt +0 -0
@@ -1,4 +1,4 @@
1
- # THis is an EditorConfig file
1
+ # This is an EditorConfig file
2
2
  # https://EditorConfig.org
3
3
 
4
4
  root = true
@@ -2,8 +2,11 @@
2
2
  *~
3
3
  /.cache
4
4
  /.eggs
5
+ /.idea
6
+ /.mypy_cache
5
7
  /.pytest_cache
6
8
  /.python-version
9
+ /ChangeLog-spell-corrected
7
10
  /README.html
8
11
  /build
9
12
  /dist
@@ -0,0 +1,22 @@
1
+ default_language_version:
2
+ python: python
3
+ repos:
4
+ - repo: https://github.com/pre-commit/pre-commit-hooks
5
+ rev: v4.5.0
6
+ hooks:
7
+ - id: check-merge-conflict
8
+ - id: debug-statements
9
+ stages: [pre-commit]
10
+ - id: end-of-file-fixer
11
+ stages: [pre-commit]
12
+ # - repo: https://github.com/pycqa/isort
13
+ # rev: 5.13.2
14
+ # hooks:
15
+ # - id: isort
16
+ # stages: [pre-commit]
17
+ - repo: https://github.com/psf/black
18
+ rev: 23.12.1
19
+ hooks:
20
+ - id: black
21
+ language_version: python3
22
+ stages: [pre-commit]
@@ -1,8 +1,262 @@
1
+ 2025-10-13 rocky <rb@dusytfeet.com>
2
+
3
+ * xasm/version.py: Get ready for release 1.2.1
4
+
5
+ 2025-10-13 rocky <rb@dusytfeet.com>
6
+
7
+ * README.rst, admin-tools/install-all-3.6-3.10.sh,
8
+ admin-tools/install-all-newest.sh,
9
+ admin-tools/make-dist-3.6-3.10.sh: Better package testing
10
+
11
+ 2025-10-13 rocky <rb@dusytfeet.com>
12
+
13
+ * admin-tools/install-all-3.8-3.10.sh,
14
+ admin-tools/install-all-newest.sh,
15
+ admin-tools/make-dist-3.8-3.10.sh,
16
+ admin-tools/pyenv-3.6-3.10-versions: Packaging, yet again
17
+
18
+ 2025-10-13 rocky <rb@dusytfeet.com>
19
+
20
+ * Makefile, admin-tools/merge-for-3.6.sh: Ever changing "standards"
21
+
22
+ 2025-10-13 rocky <rb@dusytfeet.com>
23
+
24
+ * admin-tools/check-newest-versions.sh: Correct admin scripts
25
+
26
+ 2025-10-13 rocky <rb@dusytfeet.com>
27
+
28
+ * README.rst, admin-tools/make-dist-newest.sh, pyproject.toml,
29
+ setup.py: Packaging
30
+
31
+ 2025-10-13 rocky <rb@dusytfeet.com>
32
+
33
+ * admin-tools/check-3.6-3.10-versions.sh,
34
+ admin-tools/check-newest-versions.sh,
35
+ admin-tools/checkout_common.sh,
36
+ admin-tools/install-all-3.8-3.10.sh,
37
+ admin-tools/install-all-newest.sh,
38
+ admin-tools/make-dist-3.8-3.10.sh, admin-tools/make-dist-newest.sh,
39
+ admin-tools/merge-for-3.6.sh, admin-tools/pyenv-3.6-3.10-versions,
40
+ admin-tools/pyenv-newest-versions, admin-tools/setup-master.sh,
41
+ admin-tools/setup-python-3.6.sh, admin-tools/test-versions.sh: Admin
42
+ crap
43
+
44
+ 2025-10-13 rocky <rb@dusytfeet.com>
45
+
46
+ * .github/workflows/{osx.yml => macos.yml},
47
+ .github/workflows/ubuntu.yml, .pre-commit-config.yaml,
48
+ requirements.txt, xasm/assemble.py: Misc fixes
49
+
50
+ 2025-06-21 rocky <rb@dusytfeet.com>
51
+
52
+ * xasm/assemble.py: Correct bug respecing create_code API Fixes #24
53
+
54
+ 2025-02-18 rocky <rb@dusytfeet.com>
55
+
56
+ * requirements.txt: Make dependabot happy
57
+
58
+ 2024-12-24 rocky <rb@dusytfeet.com>
59
+
60
+ * .pre-commit-config.yaml, requirements.txt: Make dependabot happy
61
+
62
+ 2024-09-10 rocky <rb@dusytfeet.com>
63
+
64
+ * requirements.txt: Silenced dependabot
65
+
66
+ 2024-07-03 rocky <rb@dusytfeet.com>
67
+
68
+ * .github/ISSUE_TEMPLATE/bug-report.md,
69
+ .github/ISSUE_TEMPLATE/config.yml,
70
+ .github/ISSUE_TEMPLATE/feature-request.md, HOW-TO-USE.rst,
71
+ README.rst: Correct spelling typos
72
+
73
+ 2024-07-02 rocky <rb@dusytfeet.com>
74
+
75
+ * HOW-TO-USE.rst, README.rst: Update README.rst
76
+
77
+ 2024-07-02 rocky <rb@dusytfeet.com>
78
+
79
+ * HOW-TO-USE.rst, xasm/assemble.py, xasm/pyc_convert.py: More
80
+ explicit comments and ... add ## comments, and document better module and method information
81
+
82
+ 2024-06-23 rocky <rb@dusytfeet.com>
83
+
84
+ * xasm/assemble.py, xasm/pyc_convert.py: bug fixes... * decode_linotab() -> decode_lineno_tab_old to make it clear that
85
+ this routine works for version before 3.10 * last instruction can be RERAISE or RASE_VARARGS in addition to RETURN_VALUE * Avoid using asm.code.to_native() for now, since there are bugs
86
+
87
+ 2024-06-23 R. Bernstein <rocky@users.noreply.github.com>
88
+
89
+ * HOW-TO-USE.rst: Update HOW-TO-USE.rst Spell check and update information
90
+
91
+ 2024-06-23 R. Bernstein <rocky@users.noreply.github.com>
92
+
93
+ * HOW-TO-USE.rst: Update HOW-TO-USE.rst
94
+
95
+ 2024-06-23 R. Bernstein <rocky@users.noreply.github.com>
96
+
97
+ * HOW-TO-USE.rst: Update HOW-TO-USE.rst
98
+
99
+ 2024-06-23 R. Bernstein <rocky@users.noreply.github.com>
100
+
101
+ * HOW-TO-USE.rst: Update HOW-TO-USE.rst
102
+
103
+ 2024-06-15 rocky <rb@dusytfeet.com>
104
+
105
+ * xasm/assemble.py: Misc tweaks and bug fixes... * Handle numeric labels better * Adjust field name co_linetable for 3.10+ * Warn if duplicate line number seen and < 3.10
106
+
107
+ 2024-06-04 rocky <rb@dusytfeet.com>
108
+
109
+ * .github/workflows/osx.yml, .github/workflows/ubuntu.yml,
110
+ .github/workflows/windows.yml: CI - need latest xdis for testing
111
+
112
+ 2024-06-04 rocky <rb@dusytfeet.com>
113
+
114
+ * pytest/test_assemble.py, xasm/assemble.py: Go over EXTENDED_ARG
115
+ creation in bytecode
116
+
117
+ 2024-06-03 rocky <rb@dusytfeet.com>
118
+
119
+ * xasm/assemble.py: remove unused import
120
+
121
+ 2024-06-03 rocky <rb@dusytfeet.com>
122
+
123
+ * xasm/assemble.py, xasm/xasm_cli.py: Compute EXTENDED_ARG better;
124
+ fix a typo
125
+
126
+ 2024-06-03 rocky <rb@dusytfeet.com>
127
+
128
+ * xasm/assemble.py: Improve offset label handling and .. ignore EXTENDED_ARG
129
+
130
+ 2024-06-03 rocky <rb@dusytfeet.com>
131
+
132
+ * xasm/assemble.py: Fix two misfeatures... 1. If Python bytecode is not set, complain and exit 2. Detect and handle line numbers on instructions
133
+
134
+ 2024-05-26 rocky <rb@dusytfeet.com>
135
+
136
+ * xasm/assemble.py: Check that operand values are in range
137
+
138
+ 2024-05-26 rocky <rb@dusytfeet.com>
139
+
140
+ * xasm/write_pyc.py, xasm/xasm_cli.py: Track and report errors in
141
+ return code better
142
+
143
+ 2024-05-26 rocky <rb@dusytfeet.com>
144
+
145
+ * .editorconfig: Typo
146
+
147
+ 2024-05-26 rocky <rb@dusytfeet.com>
148
+
149
+ * xasm/assemble.py: Tweak missing return value error
150
+
151
+ 2024-05-26 rocky <rb@dusytfeet.com>
152
+
153
+ * pytest/test_write_pyc.py: Skip a pytest on windows CI
154
+
155
+ 2024-05-26 rocky <rb@dusytfeet.com>
156
+
157
+ * .github/workflows/windows.yml, __pkginfo__.py, requirements.txt,
158
+ setup.py: Another attempt to get CI actions working
159
+
160
+ 2024-05-26 rocky <rb@dusytfeet.com>
161
+
162
+ * .github/workflows/osx.yml, .github/workflows/ubuntu.yml,
163
+ .github/workflows/windows.yml: Try Workflows actions
164
+
165
+ 2024-05-26 rocky <rb@dusytfeet.com>
166
+
167
+ * test/TODO.md: Add a TODO
168
+
169
+ 2024-05-26 rocky <rb@dusytfeet.com>
170
+
171
+ * test/tasm-3.10-bad.pyasm, test/tasm-3.10.pyasm, xasm/assemble.py:
172
+ Add a check for last instruction being a "return"
173
+
174
+ 2024-05-22 rocky <rb@dusytfeet.com>
175
+
176
+ * xasm/assemble.py: Offset in 3.10+ need to be divided by two
177
+
178
+ 2024-05-20 rocky <rb@dusytfeet.com>
179
+
180
+ * xasm/xasm_cli.py: Tweak asm file path
181
+
182
+ 2024-02-20 rocky <rb@dusytfeet.com>
183
+
184
+ * requirements.txt: Keep dependabot happy
185
+
186
+ 2024-01-10 rocky <rb@dusytfeet.com>
187
+
188
+ * requirements.txt: Bump cryptography to silence Depedabot
189
+
190
+ 2024-01-10 rocky <rb@dusytfeet.com>
191
+
192
+ * .pre-commit-config.yaml, xasm/assemble.py, xasm/pyc_convert.py,
193
+ xasm/xasm_cli.py: convert % to f-strings
194
+
195
+ 2024-01-09 rocky <rb@dusytfeet.com>
196
+
197
+ * pytest/test_write_pyc.py, requirements.txt: Update requirements as
198
+ recommended by dependabot Also comment out a test where xdis marshal is broken.
199
+
200
+ 2023-12-17 R. Bernstein <rocky@users.noreply.github.com>
201
+
202
+ * : Merge pull request #21 from rocky/lint Some lint found
203
+
204
+ 2023-10-23 rocky <rb@dustyfeet.com>
205
+
206
+ * .gitignore, __pkginfo__.py, requirements.txt, xasm/.gitignore,
207
+ xasm/assemble.py, xasm/pyc_convert.py, xasm/xasm_cli.py: Misc lint
208
+
209
+ 2023-09-18 rocky <rb@dusytfeet.com>
210
+
211
+ * xasm/assemble.py: version -> version_tuple fixes
212
+
213
+ 2023-09-18 rocky <rb@dusytfeet.com>
214
+
215
+ * .gitignore, admin-tools/pyenv-newest-versions,
216
+ admin-tools/setup-master.sh, test/.gitignore: Bump testing versions
217
+
218
+ 2022-12-02 rocky <rb@dustyfeet.com>
219
+
220
+ * xasm/assemble.py: Pycharm lint
221
+
222
+ 2022-12-02 rocky <rb@dusytfeet.com>
223
+
224
+ * xasm/assemble.py: Add a more detailed assert message... about the header.
225
+
226
+ 2022-12-02 rocky <rb@dusytfeet.com>
227
+
228
+ * xasm/version.py: Bump version to development version
229
+
230
+ 2022-10-17 rocky <rb@dusytfeet.com>
231
+
232
+ * xasm/assemble.py, xasm/write_pyc.py: Remove debug statement. Fixes #17 Also, add msg when we can't dump a code object
233
+
234
+ 2022-08-22 rocky <rb@dusytfeet.com>
235
+
236
+ * xasm/assemble.py, xasm/write_pyc.py: Fix a couple of small bugs
237
+
238
+ 2022-06-16 rocky <rb@dusytfeet.com>
239
+
240
+ * xasm/assemble.py: Detect native code objects in constants
241
+
242
+ 2022-04-02 R. Bernstein <rocky@users.noreply.github.com>
243
+
244
+ * : Merge pull request #15 from
245
+ Svenskithesource/Svenskithesource-patch-2 Fix empty append call
246
+
247
+ 2022-03-05 R. Bernstein <rocky@users.noreply.github.com>
248
+
249
+ * : Merge pull request #13 from Svenskithesource/patch-1 Typo
250
+
251
+ 2021-12-04 rocky <rb@dusytfeet.com>
252
+
253
+ * xasm/assemble.py: wrong variable python_version -> version Fixes #11
254
+
1
255
  2021-11-07 rocky <rb@dusytfeet.com>
2
256
 
3
257
  * ChangeLog, NEWS.md, admin-tools/check-versions.sh,
4
- admin-tools/pyenv-versions, xasm/version.py: Get ready for release
5
- 1.2.0
258
+ admin-tools/make-dist.sh, admin-tools/pyenv-versions, setup.cfg,
259
+ xasm/version.py: Get ready for release 1.2.0
6
260
 
7
261
  2021-11-07 rocky <rocky@dusytfeet.com>
8
262
 
@@ -10,7 +264,7 @@
10
264
 
11
265
  2021-11-07 rocky <rocky@dusytfeet.com>
12
266
 
13
- * admin-tools/pyenv-versions, admin-tools/setup-master.sh:
267
+ * admin-tools/pyenv-versions, admin-tools/setup-master.sh:
14
268
  Administrivia
15
269
 
16
270
  2021-11-05 rocky <rocky@dusytfeet.com>
@@ -62,7 +316,7 @@
62
316
 
63
317
  * ChangeLog, NEWS.md, __pkginfo__.py,
64
318
  admin-tools/how-to-make-a-release.md, admin-tools/pyenv-versions,
65
- setup.py, xasm/__init__.py, xasm/pyc_convert.py, xasm/version.py:
319
+ setup.py, xasm/__init__.py, xasm/pyc_convert.py, xasm/version.py:
66
320
  Get ready for release 1.1.1
67
321
 
68
322
  2020-07-02 rocky <rocky@gnu.org>
@@ -129,7 +383,7 @@
129
383
  * Makefile, __pkginfo__.py, admin-tools/how-to-make-a-release.md,
130
384
  admin-tools/pyenv-versions, pytest/.gitignore,
131
385
  pytest/test_write_pyc.py, test/test_all.py, xasm/.gitignore,
132
- xasm/assemble.py, xasm/misc.py, xasm/write_pyc.py, xasm/xasm_cli.py:
386
+ xasm/assemble.py, xasm/misc.py, xasm/write_pyc.py, xasm/xasm_cli.py:
133
387
  Revise for new xdis. Add Better write_pyc() fn
134
388
 
135
389
  2019-11-06 rocky <rb@dustyfeet.com>
@@ -463,7 +717,7 @@
463
717
  2017-07-04 rocky <rb@dustyfeet.com>
464
718
 
465
719
  * test/gcd-2.7.pyasm, xasm/assemble.py: More proper label handling All non-int labels are absolute Labels as an operand don't and shouldn't have the trailing ':'.
466
- pydisasm doen't add that Start moving toward xdis enhanced ability to work with Python code
720
+ pydisasm doesn't add that. Start moving toward xdis's enhanced ability to work with Python code
467
721
  more interchangeably between Python 2 and 3.
468
722
 
469
723
  2017-07-03 rocky <rb@dustyfeet.com>
@@ -547,4 +801,3 @@
547
801
  2017-06-26 rocky <rb@dustyfeet.com>
548
802
 
549
803
  * Assembler first step
550
-
@@ -1,5 +1,5 @@
1
1
  Introduction
2
- *************
2
+ ============
3
3
 
4
4
  Welcome back to the wonderful times world of SEGV's (from the Python interpreter)!
5
5
 
@@ -11,7 +11,7 @@ skeletal. Then use ``pydisasm --xasm`` to convert to the Python source
11
11
  code assembler format. From this then modify the results and run
12
12
  ``pyc-xasm``.
13
13
 
14
- In normal python disassembly code (and in the bytecode file), the main
14
+ In normal Python disassembly code (and in the bytecode file), the main
15
15
  function appears first; it contains constants which contain code to
16
16
  other functions and so on. In Python disassembly these are linearized
17
17
  so that from top down you have a topological sort of the dependencies.
@@ -30,22 +30,39 @@ instructions. Another reason why using ``pydisasm --xasm`` is
30
30
  preferable right now.
31
31
 
32
32
  Format of assembly file
33
- -----------------------
33
+ =======================
34
34
 
35
- Again, easiest to consult the ``pydiasm --xasm`` output ``.pyasm``-file that is
36
- produced. Even easier, just to look in the test directory_ for files that end
35
+ Again, easiest to consult the ``pydisasm --xasm`` output ``.pyasm``-file that is
36
+ produced. Even easier, just to look in the test directory_ for files that end
37
37
  with ``.pyasm``.
38
38
 
39
- In general, lines that start with "#" in column one are comments or code or function
40
- objects other than bytecode instructions.
39
+ Lines that start with '##" are comments.
40
+
41
+ Examples::
42
+
43
+ ## This line is a comment
44
+ ## Method Name: GameSheet
41
45
 
42
- Necessary fields that are in Python code object and function objects
43
- are here. These include stuff like the Python "magic" number which
44
- determines which Python bytecode opcodes to use and which Python
45
- interpreter can be used to run the resulting program.
46
+ Lines that start with ``#``" in column one are used to indicate a code
47
+ or function object that is not a bytecode instructions. However this
48
+ is only true if the rest of the line matches one of the code of
49
+ function objects mentioned below. If instead the the rest of a line
50
+ does not match a function or code object, it line too will be
51
+ treated tacitly as a comment.
46
52
 
47
53
  Module-level info
48
- -----------------
54
+ ------------------
55
+
56
+
57
+ The only necessary mdoule-level inforamation that is needed is the
58
+ Python "magic" number which determines which Python bytecode opcodes
59
+ to use and which Python interpreter can be used to run the resulting
60
+ program.
61
+
62
+ Optional information includes:
63
+
64
+ * Timestamp of code
65
+ * Source code size module 2**32 or a SIP hash
49
66
 
50
67
  Here is an example of the module-level information:
51
68
 
@@ -53,16 +70,27 @@ Here is an example of the module-level information:
53
70
 
54
71
  # Python bytecode 2.2 (60717)
55
72
  # Timestamp in code: 1499156389 (2017-07-04 04:19:49)
73
+ # Source code size mod 2**32: 577 bytes
56
74
 
57
- The bytecode is necessary. However the timestamp is not. In Python 3
58
- there is also a size modulo 2**32 that is recorded.
75
+ Again, the bytecode number is necessary. However the timestamp is not. In Python 3
76
+ there is also a size modulo 2**32 that is recorded, and in later Python this can be a
77
+ SIP hash.
59
78
 
60
79
  ::
61
80
 
62
- # Source code size mod 2**32: 577 bytes
63
81
 
64
82
  Method-level info
65
- .................
83
+ ------------------
84
+
85
+ Method-level information starts with ``#`` in column one. Here is some
86
+ method-level information:
87
+
88
+ * The method name of the code object (``Method Name``)
89
+ * Number of local variables used in module or function (``Number of locals``)
90
+ * A filename where the file (``Filename``)
91
+ * Maximum Stack Size needed to run code (``Stack Size``)
92
+ * Code flags which indicate properties of the code (``Flags``)
93
+ * Fine number for the first line of the code (``First Line``)
66
94
 
67
95
  Here is an example:
68
96
 
@@ -72,9 +100,10 @@ Here is an example:
72
100
  # Filename: exec
73
101
  # Argument count: 2
74
102
  # Kw-only arguments: 0
75
- # Number of locals: 2 # Stack size: 3
103
+ # Number of locals: 2
104
+ # Stack size: 3
76
105
  # Flags: 0x00000043 (NOFREE | NEWLOCALS | OPTIMIZED)
77
- # First Line: 11
106
+ # First Line: 11
78
107
  # Constants:
79
108
  # 0: ' GCD. We assume positive numbers'
80
109
  # 1: 0
@@ -95,7 +124,7 @@ Here is an example:
95
124
 
96
125
  Some of these can be omitted and default values will be used. For the
97
126
  lists like Constants, Names, and so on, those can be omitted too. But
98
- if they are, the instruction section can't refer to those values by list index value. (List index value is however used in the actual bytecode.)b
127
+ if they are, the instruction section can't refer to those values by list index value. (List index value is however used in the actual bytecode.)
99
128
 
100
129
  Although we haven't gotten to the exact format of instructions, what
101
130
  the last sentence means is that
@@ -104,14 +133,14 @@ the last sentence means is that
104
133
 
105
134
  LOAD_CONST 3
106
135
 
107
- would be invalid if the size of the constant array is less than 4, or `constant[3]` wasn't defined by adding it to the `Constants` section. However when you put a value in parenthesis, that indicate a value rather than an index into a list.
136
+ would be invalid if the size of the constant array is less than 4, or `constant[3]` wasn't defined by adding it to the `Constants` section. However when you put a value in parenthesis, that indicate a value rather than an index into a list.
108
137
  So you could instead write:
109
138
 
110
139
  ::
111
140
 
112
141
  LOAD_CONST (1)
113
142
 
114
- which in this case does the same thing since `1 = constant[3]`. If the value 1 does not appear anywhere in the constants list, the assember would append the value 1 to the end of the list of the constants list. When writing the final bytecode file an appropriate constant index will be inserted into that instruction.
143
+ which in this case does the same thing since `1 = constant[3]`. If the value 1 does not appear anywhere in the constants list, the assembler would append the value 1 to the end of the list of the constants list. When writing the final bytecode file an appropriate constant index will be inserted into that instruction.
115
144
 
116
145
  Line Numbers and Labels
117
146
  -----------------------
@@ -126,14 +155,14 @@ example
126
155
  LOAD_CONST ('this is line 66')
127
156
 
128
157
  The ``LOAD_CONST`` instruction will be noted as being on line 66. Note
129
- that Python requires that line numbers don't decrease as the a
158
+ that Python before version 3.10 requires that line numbers don't decrease as the a
130
159
  method increases in bytecode offset. Also note that there can be white
131
160
  space before the line number; the number doesn't have to be in
132
161
  column 1.
133
162
 
134
163
  Labels are like line numbers in that they have a colon suffix on the
135
164
  line and must be the first thing on a line. However The first
136
- character of a label _can't_ be a number: that's how we distinguish
165
+ character of a label *cannot* be a number: that's how we distinguish
137
166
  between line numbers and labels. Here is a label:
138
167
 
139
168
  ::
@@ -151,7 +180,7 @@ Instructions
151
180
  -------------
152
181
 
153
182
  The module level bytecode line determines what Python opcodes are
154
- exceptable and how operands are interpreted.
183
+ acceptable and how operands are interpreted.
155
184
 
156
185
  Instructions come after the other module or function information that starts with `#` and
157
186
  is shown above.
@@ -161,8 +190,19 @@ module field which would start with a #. And it is not a line number
161
190
  or label listed in the last section. We've seen examples of
162
191
  instructions above.
163
192
 
164
- Instructions start with an opcode and will have an operand depending
165
- on whether the opcode requires one or not. However as we've seen above
193
+ Operation name
194
+ ...............
195
+
196
+ Instructions start with an opcode name like ``LOAD_CONST``. The specific opcode names used depends on the Python version you are using.
197
+ So make sure to consult the "opcodes" section of the "dis" module documentation for the version of Python listed at the top of the metadata section.
198
+
199
+
200
+ Operand
201
+ ........
202
+
203
+
204
+ An instruction may also have an operand depending
205
+ on whether the opcode requires one or not. However as we've seen above,
166
206
  the operands can take a couple of forms. The operand can be a number
167
207
  which represents a bytecode offset, or an index into one of the method
168
208
  lists like the Constants, or Names list. I don't recommend though that
@@ -175,13 +215,15 @@ parenthesis. For example:
175
215
  ::
176
216
 
177
217
  LOAD_CONST (3) # loads number 3
178
- LOAD_CONST 3 # load Constants[3]
218
+ LOAD_CONST 3 # load Constants[3]
179
219
  JUMP_ABSOLUTE 10 # Jumps to offset 10
180
220
  JUMP_ABSOLUTE L10 # Jumps to label L10
181
221
  LOAD_CONSTANT (('load_entry_point',)) # Same as: tuple('load_entry_point')
182
222
 
183
223
  Instructions can also have additional stuff after the operand and that is ignored.
184
224
 
225
+ Internally operand values are integers or indexes in some table. When an index value is more than 255 (the largest value that fits in a single byte), an ``EXTENDED_OPERAND`` instruction is added automatically.
226
+
185
227
  Cool Stuff
186
228
  ----------
187
229
 
@@ -196,20 +238,9 @@ doesn't have to be the same as the Python interpreter that runs
196
238
  TODO
197
239
  -----
198
240
 
199
- Possibly we should figure out when to put in ``EXTENDED_ARGS``
200
- instructions. And for now, even though you put in ``EXTENDED_ARGS``,
201
- the operand that follows may have the value folded into it. For
202
- example in Python 3.6 where an operand can be at most 255, of you
203
- wanted to jump relative 259 bytes you'd write:
204
-
205
- ::
206
-
207
- EXTENDED_ARG 1 # Needed because below offset is greater than 255 away
208
- JUMP_FORWARD 259 # Should really be 3 (= 259 - 256)
209
-
210
241
  We should have a better API to generate instructions from inside
211
242
  Python. This is pretty straightforward to do.
212
243
 
213
- I've not put much in the way of error checking and error reporting.
244
+ There is some error checking of consistency of the input file, but more error checking is desirable.
214
245
 
215
246
  .. _directory: https://github.com/rocky/python-xasm/tree/master/test
@@ -11,8 +11,8 @@ check: test
11
11
 
12
12
  #: Run tests
13
13
  test:
14
- py.test pytest
15
- py.test test/test_all.py
14
+ pytest pytest
15
+ pytest test/test_all.py
16
16
 
17
17
  clean:
18
18
  cd test && make clean
@@ -27,3 +27,4 @@ rmChangeLog:
27
27
  #: Create a ChangeLog from git via git log and git2cl
28
28
  ChangeLog: rmChangeLog
29
29
  git log --pretty --numstat --summary | $(GIT2CL) >$@
30
+ patch ChangeLog < ChangeLog-spell-corrected.diff
xasm-1.2.1/NEWS.md ADDED
@@ -0,0 +1,44 @@
1
+ 1.2.1 2025-10-13
2
+ ----------------
3
+
4
+ * Repackage for Python 3.11 and poetry. I can't describe what thrill it gives me to have to do this every few years.
5
+ * Correct bug respecting `create_code` API Fixes #24
6
+ * More explicit comments. Add some `##` comments. Document module and method information better.
7
+ * `decode_linotab()` is now `decode_lineno_tab_old` to make it clear that this routine works for version before 3.10.
8
+ * Avoid using `asm.code.to_native()` for now, since there are bugs.
9
+ * Handle numeric labels better.
10
+ * Adjust field name `co_linetable` for bytecode after 3.10.
11
+ * Warn if duplicate line numbers seen and the assembler is before bytecode for 3.10
12
+ * Improve `EXTENDED_ARG` handling and creation.
13
+ * If Python bytecode is not set, complain and exit.
14
+ * Detect and handle line numbers on instructions
15
+ * Add a check for last instruction being either a `RETURN_VALUE`, or `RERAISE`, or `RAISE_VARARGS`
16
+ * Offsets in bytecode for 3.10 need to be divided by two
17
+ * Lint code a little
18
+
19
+ 1.2.0 2021-11-07
20
+ ----------------
21
+
22
+ * Adjust to use xdis 6.0.3 or later
23
+ * start adding `.READ` directive
24
+
25
+ 1.1.1 2020-10-27
26
+ ----------------
27
+
28
+ - Fix bugs in cross-assembly bytecode writing
29
+ - Detect PyPy.
30
+ - Add SIP hash field. Fixes #4
31
+
32
+ 1.1.0 2020-04-24
33
+ ----------------
34
+
35
+ - Fix bugs in writing 3.7 and 3.8 pyc
36
+ - Require newer xdis to get fixes to 3.8 pyc marshaling
37
+
38
+
39
+ 1.0.0 2019-10-19
40
+ ----------------
41
+
42
+ - Go over docs.
43
+ - Require newer xdis to get early bytecodes bytecodes: 1.0, 1.1, 1.2, and 1.6.
44
+ - More sensitive to network ordering