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

Fix PY2 regression in connect() error handling. #150

Merged
merged 4 commits into from Nov 13, 2019

Commits on Nov 11, 2019

  1. Fix PY2 regression in connect() error handling.

    This autoformatting PR actually changed the behavior of the error handling:
    https://github.com/httplib2/httplib2/pull/105/files#diff-c6669c781a2dee1b2d2671cab4e21c66L985
    
    "raise socket.err, msg" is not the same as "raise socket.error(msg)" in the case where msg is an exception. For instance consider:
    msg = socket.timeout("foo")
    raise socket.error, msg  # => socket.timeout: foo
    raise socket.error(msg)  # => socket.error: foo
    
    This has the effect of potentially changing the type of the error raised by connect(). Interestingly the PY3 copy of the code doesn't have this problem (probably cause it doesn't have msg at all; not sure if it's actually needed but I figured might as well keep it for PY2 in case it is).
    
    The change I propose here will restore the original behavior prior to the autoformat change, and will ensure that both the PY2 and PY3 copies of the code raise the same error type in the event of e.g. a socket.timeout.
    cglouch committed Nov 11, 2019
    Copy the full SHA
    0d0a707 View commit details
    Browse the repository at this point in the history
  2. Simplify raise statement.

    cglouch committed Nov 11, 2019
    Copy the full SHA
    ec2e60f View commit details
    Browse the repository at this point in the history

Commits on Nov 12, 2019

  1. Also fix error type in HTTPSConnectionWithTimeout.

    Moved msg inline for clarity as well.
    cglouch committed Nov 12, 2019
    Copy the full SHA
    963f4cc View commit details
    Browse the repository at this point in the history

Commits on Nov 13, 2019

  1. test

    temoto committed Nov 13, 2019
    Copy the full SHA
    446daf0 View commit details
    Browse the repository at this point in the history