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

JIRAError does not correctly display full error information #85

Closed
asqui opened this issue Jun 10, 2015 · 1 comment · Fixed by #86
Closed

JIRAError does not correctly display full error information #85

asqui opened this issue Jun 10, 2015 · 1 comment · Fixed by #86

Comments

@asqui
Copy link
Contributor

asqui commented Jun 10, 2015

There seems to be a bug in JIRAError.__str__

    if self.response and hasattr(self.response, 'text'):
        t += "\n\tresponse text = " % self.response.headers

https://github.com/pycontribs/jira/blob/master/jira/utils.py#L161

  1. This checks for the text attribute but then uses the headers attribute (cut-and-paste error from the lines above?)
  2. The response object is "Truthy" based upon the HTTP response, so in the case of a HTTP error it is actually "False" so the conditional check fails.
  3. Which is just as well, because once you fix this you'll see that the format string is invalid and causes an exception because it is missing a %s at the end

:-)

I'll submit a pull request to fix this up shortly.

@asqui
Copy link
Contributor Author

asqui commented Jun 10, 2015

Citation from PEP-8, just to ram the point home:

beware of writing if x when you really mean if x is not None -- e.g. when testing whether a variable or argument that defaults to None was set to some other value. The other value might have a type (such as a container) that could be false in a boolean context!

https://www.python.org/dev/peps/pep-0008/

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.

1 participant