Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Check for action arg before use (fix Python 3 error)#79

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

cdbennett
Copy link

Check that the parsedaction attribute exists before using it.
Previously, whenever the command-line tool was invoked on Python 3.4
without a bare-word argument, which is expected to be the action, the
program aborts with an AttributeError in cli.py on the line assigning
arg.action toaction:

AttributeError: 'Namespace' object has no attribute 'action'

Check that the parsed `action` attribute exists before using it.Previously, whenever the command-line tool was invoked on Python 3.4without a bare-word argument, which is expected to be the action, theprogram aborts with an AttributeError in cli.py on the line assigning`arg.action` to `action`:    AttributeError: 'Namespace' object has no attribute 'action'
@gpocentek
Copy link
Contributor

Could you give an example of a command that would generate this error? Thanks.

@cdbennett
Copy link
Author

This issue occurs whenever there is no positional ("bareword") argument given to the program. For instance, with no arguments at allgitlab will hit it:

$ gitlabTraceback (most recent call last):  File "C:\Python34\Scripts\gitlab-script.py", line 9, in <module>    load_entry_point('python-gitlab==0.9.1', 'console_scripts', 'gitlab')()  File "C:\Python34\lib\site-packages\python_gitlab-0.9.1-py3.4.egg\gitlab\cli.py", line 275, in mainAttributeError: 'Namespace' object has no attribute 'action'

It will also occur if you provide option arguments, but still don't provide a positional argument (one that is not an option flag) as ingitlab -v:

$ gitlab -vTraceback (most recent call last):  File "C:\Python34\Scripts\gitlab-script.py", line 9, in <module>    load_entry_point('python-gitlab==0.9.1', 'console_scripts', 'gitlab')()  File "C:\Python34\lib\site-packages\python_gitlab-0.9.1-py3.4.egg\gitlab\cli.py", line 275, in mainAttributeError: 'Namespace' object has no attribute 'action'

This test was performed with the#78 (fix_python3_sort_types) fix applied -- otherwise Python 3 will fail earlier in the program before this point is reached.

@gpocentek
Copy link
Contributor

I just push commit7c38ef6 which should fix for this bug. It uses the argparse features instead of providing a custom test. Could you test it to make sure it behaves as you would expect? Thanks.

@cdbennett
Copy link
Author

Verified fixed with commit7c38ef6. Thanks.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@cdbennett@gpocentek

[8]ページ先頭

©2009-2025 Movatter.jp