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

Add check for empty socket.error args #1580

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gustafsson
Copy link

When doing a

gsutil cp myfile gs://mybucket/name

With a https_proxy that was limiting the number of concurrent sockets. I got a

socket.timeout: timed out

During handling of the above exception, another exception occurred:
...
socks.GeneralProxyError: Socket error: timed out

During handling of the above exception, another exception occurred:
...
~/Applications/google-cloud-sdk/platform/gsutil/gslib/gcs_json_media.py", line 587, in _conn_request
    err = getattr(e, 'args')[0]

It seems socket.error can have empty args. This PR adds a check.

gsutil_IndexError_tuple_index_out_of_range.txt

Copy link
Collaborator

@dilipped dilipped left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late response here and thanks for the PR. Can you please add tests for the change? The test can go in the file tests/test_gcs_json_media.py.

@@ -583,7 +583,7 @@ def _conn_request(self, conn, request_uri, method, body, headers): # pylint: di
raise
except socket.error as e:
err = 0
if hasattr(e, 'args'):
if hasattr(e, 'args') and getattr(e, 'args'):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can replace the entire line with if getattr(e, 'args', None)

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