Skip to content

Backport #2915 - Use setattr to rewire Cs.disasm to avoid type checking errors#2918

Merged
Rot127 merged 1 commit into
capstone-engine:v5from
Rot127:setattr
May 14, 2026
Merged

Backport #2915 - Use setattr to rewire Cs.disasm to avoid type checking errors#2918
Rot127 merged 1 commit into
capstone-engine:v5from
Rot127:setattr

Conversation

@Rot127
Copy link
Copy Markdown
Collaborator

@Rot127 Rot127 commented May 12, 2026

Your checklist for this pull request

  • I've documented or updated the documentation of every API function and struct this PR changes.
  • I've added tests that prove my fix is effective or that my feature works (if possible)

Detailed description

...

Test plan

...

Closing issues

...

…capstone-engine#2915)

```
error[invalid-argument-type]: Argument to function `Cs.disasm` is incorrect
  --> test.py:15:36
   |
15 |         insn = list(self.cs.disasm(code, address, 1))[0]
   |                                    ^^^^ Expected `Cs`, found `bytes`
   |
info: Function defined here
    --> .venv/lib/python3.14/site-packages/capstone/__init__.py:1466:9
     |
1466 |     def disasm(self, code, offset, count=0):
     |         ^^^^^^ ---- Parameter declared here
     |
info: Union variant `def disasm(self, code, offset, count=0) -> Unknown` is incompatible with this call site
info: Attempted to call union type `(bound method Cs.disasm(code, offset, count=0) -> Unknown) | (def disasm(self, code, offset, count=0) -> Unknown)`
```
@github-actions github-actions Bot added the Python Bindings label May 12, 2026
@Rot127 Rot127 changed the title Backport #2915 Backport #2915 - Use setattr to rewire Cs.disasm to avoid type checking errors May 12, 2026
@Rot127 Rot127 merged commit 36fe16b into capstone-engine:v5 May 14, 2026
17 checks passed
@Rot127 Rot127 deleted the setattr branch May 14, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Python Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants