Skip to content

AttributeError: 'staticmethod' object has no attribute '__name__' #1

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

Closed
veehaitch opened this issue Jan 26, 2022 · 3 comments · Fixed by #3
Closed

AttributeError: 'staticmethod' object has no attribute '__name__' #1

veehaitch opened this issue Jan 26, 2022 · 3 comments · Fixed by #3

Comments

@veehaitch
Copy link

Thanks for the project!

Using the latest version 0.0.2 from PyPI, I see the following error:

# python -m openssh_key id_ed25519 --passphrase hunter12
Traceback (most recent call last):
  File "/nix/store/k5lw9imni647dl2n10xvq9w4yb840a8l-python3-3.9.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/nix/store/k5lw9imni647dl2n10xvq9w4yb840a8l-python3-3.9.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/nix/store/0zgs6a1i93f3y7bqalvw1l6n63r7g91y-python3-3.9.9-env/lib/python3.9/site-packages/openssh_key/__main__.py", line 23, in <module>
    if file_contents.startswith(PrivateKeyList.OPENSSH_PRIVATE_KEY_HEADER):
  File "/nix/store/0zgs6a1i93f3y7bqalvw1l6n63r7g91y-python3-3.9.9-env/lib/python3.9/site-packages/openssh_key/utils.py", line 51, in __get__
    getattr(cls, self._getter.__name__)()
AttributeError: 'staticmethod' object has no attribute '__name__'

Version 0.0.1 works and all tests pass.

I'm using Nix with the following derivation, if that's of any help: NixOS/nixpkgs@master...veehaitch:py3-openssh_key_parser

@scottcwang
Copy link
Owner

Thank you for the bug report, and for using the package!

This issue is because I was working in python 3.10, which adds the __name__ attribute to @staticmethod and @classmethod. I didn't realise this was new to python 3.10. Sorry about that.

I will fix the readonly_static_property so it takes a str name, not the staticmethod object itself. Would you need this fix soon?

@veehaitch
Copy link
Author

Ah, okay, thanks for the quick response!

I'm happy to use Python 3.10, that's not an issue. I'd just suggest to adapt setup.py if you don't plan to support prior versions in the near future:

python_requires='>=3.8',

Feel free to close this issue.

FloLie added a commit to FloLie/openssh_key_parser that referenced this issue Jan 27, 2022
Only python3.10 is compatiple with current use of @staticmethod as discussed in scottcwang#1. Too avoid auto update issues, with python <3.10
@FloLie FloLie mentioned this issue Jan 27, 2022
@scottcwang scottcwang linked a pull request Jan 27, 2022 that will close this issue
@scottcwang
Copy link
Owner

Good point! It is a little bit trickier than I thought to support the prior versions. In the future, I might overhaul this descriptor to be less clunky.

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 a pull request may close this issue.

2 participants