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

filename ordering / exception mutation breaks exception-message-attribute #2893

Closed
asottile opened this issue May 1, 2019 · 1 comment
Closed
Labels

Comments

@asottile
Copy link
Contributor

asottile commented May 1, 2019

Steps to reproduce

I have the following minimal setup:

# a.py

def f():
    e = Exception()
    e.message = 'bang!'
    raise e
# b.py

def g():
    try:
        raise TypeError('ohai')
    except Exception as e:
        print(e.message)

Current behavior

Currently, errors are reported based on the ordering of the invocation:

$ pylint --py3k a.py b.py

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
$ pylint --py3k b.py a.py
************* Module b
b.py:7:14: W1645: Exception.message removed in Python 3 (exception-message-attribute)

------------------------------------------------------------------
Your code has been rated at 8.89/10 (previous run: 8.89/10, +0.00)

Expected behavior

I expect both to produce the error from b.py, and maybe even an error in a.py for assigning to Exception.message

pylint --version output

$ pylint --version
pylint 2.3.1
astroid 2.2.5
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0]
@PCManticore
Copy link
Contributor

Thanks for the report! This looks like #689 but we should definitely emit the same error for both files, regardless from where the attribute came.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants