8000 Fix call to message from TypeError not working with Python 3.6 (#2616) by offgrid-konrad · Pull Request #2617 · spotify/luigi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix call to message from TypeError not working with Python 3.6 (#2616) #2617

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

Merged
merged 2 commits into from
Jan 9, 2019

Conversation

offgrid-konrad
Copy link
Contributor

Description

The issue is that the file luigi/contrib/s3.py uses a call to TypeError member e.message which is only available in Python 2 as opposed to e.args which is available in both Python 2 and Python 3.

Here is the code snippet in luigi/contrib/s3.py from Luigi release 2.8.0 causing the issue (in fact, it seems it's the same code for all releases >= 2.7.6):

        # At this stage, if no credentials provided, boto3 would handle their resolution for us
        # For finding out about the order in which it tries to find these credentials
        # please see here details
        # http://boto3.readthedocs.io/en/latest/guide/configuration.html#configuring-credentials

        if not (aws_access_key_id and aws_secret_access_key):
            logger.debug('no credentials provided, delegating credentials resolution to boto3')

        try:
            self._s3 = boto3.resource('s3',
                                      aws_access_key_id=aws_access_key_id,
                                      aws_secret_access_key=aws_secret_access_key,
                                      aws_session_token=aws_session_token,
                                      **options)
        except TypeError as e:
            logger.error(e.message)
            if 'got an unexpected keyword argument' in e.message:
                raise DeprecatedBotoClientException(
                    "Now using boto3. Check that you're passing the correct arguments")
            raise

To fix this issue, I propose to use e.args[0] instead of e.message like so:

except TypeError as e:
    logger.error(e.args[0])
    if 'got an unexpected keyword argument' in e.args[0]:
        raise DeprecatedBotoClientException(
            "Now using boto3. Check that you're passing the correct arguments")
    raise

Motivation and Context

The change resolves the issue, described in the Description. A link to the original issue:
#2616

Have you tested this? If so, how?

I ran my jobs with this code and it works for me.

@offgrid-konrad
Copy link
Contributor Author

Thanks! I've created the PR. Trying to also create the test.

@Tarrasch Tarrasch merged commit f9095d3 into spotify:master Jan 9, 2019
@Tarrasch
Copy link
Contributor
Tarrasch commented Jan 9, 2019

Thanks!

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.

3 participants
0