Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes while adding type annotaions #600

Merged
merged 2 commits into from
Feb 25, 2025
Merged

Minor fixes while adding type annotaions #600

merged 2 commits into from
Feb 25, 2025

Conversation

pmhahn
Copy link
Contributor

@pmhahn pmhahn commented Feb 24, 2025

While working on #514 I – more correctly: mypy – found two minor issues:

  • remove duplicate definition of ENUM_SUNW_SYMINFO_BOUNDTO
  • move several @staticmethod out of class as they are used as functions.

- 5db2966 introduced it first as `ENUM_SYMINFO_BOUNDTO`
- 594dc72 renamed it to `ENUM_SUNW_SYMINFO_BOUNDTO`
- 7b24670 added it a 2nd time

Signed-off-by: Philipp Hahn <[email protected]>
A method expects `self` as the first argument; they are all functions.

Normally you would mark them as `@staticmethod`, but they are all
de-referenced already during class definition, at which point they are
actually still functions: they only become methods after the `class`
scope is finished.

```console
$ test/all_tests.py
E........EE...................E.....E.....E.....................................................................
======================================================================
ERROR: test_reloc (test_arm_call_reloc.TestARMRElocation)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "…/pyelftools/test/test_arm_call_reloc.py", line 41, in test_reloc
    self.assertEqual(do_relocation(rel_elf),
  File "…/pyelftools/test/test_arm_call_reloc.py", line 28, in do_relocation
    rh.apply_section_relocations(stream, rel)
  File "…/pyelftools/elftools/elf/relocation.py", line 238, in apply_section_relocations
    self._do_apply_relocation(stream, reloc, symtab)
  File "…/pyelftools/elftools/elf/relocation.py", line 319, in _do_apply_relocation
    relocated_value = recipe.calc_func(
TypeError: 'staticmethod' object is not callable
```

For clarity move those functions before class `RelocationHandler`.

Signed-off-by: Philipp Hahn <[email protected]>
@eliben eliben merged commit d34b527 into eliben:main Feb 25, 2025
4 checks passed
@pmhahn pmhahn deleted the fixes branch February 26, 2025 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants