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

Astroid 2.0.1 regression: Not detecting that Exception self.args is iterable #2333

Closed
kayhayen opened this issue Jul 23, 2018 · 3 comments
Closed
Labels

Comments

@kayhayen
Copy link

Steps to reproduce

nuitka/Errors.py:37 E1133 not-an-iterable NuitkaNodeError.str
Non-iterable value self.args is used in an iterating context

This is self.args from Exception, as can be seen in the code here:

class NuitkaErrorBase(Exception):
    pass


class NuitkaNodeError(NuitkaErrorBase):

    # Try to output more information about nodes passed.
    def __str__(self):
        from nuitka.codegen.Indentation import indented

        parts = [""]

        for arg in self.args:
            if hasattr(arg, "asXmlText"):
                parts.append(indented("\n%s\n" % arg.asXmlText()))
            else:
                parts.append(arg)

        parts.append("")
        parts.append("The above information should be included in a
bug report.")

I am assuming that the other code in apart from iteration of "self.args" in str is not relevant, but I did not try.

Current behavior

Warning is given:
nuitka/Errors.py:37 E1133 not-an-iterable NuitkaNodeError.str
Non-iterable value self.args is used in an iterating context

Expected behavior

The 2.0.0 version of Astroid doesn't give such warnings, the update to 2.0.1 does.

pylint --version output

python3.6 -m pylint --version
main.py 2.0.0
astroid 2.0.1
Python 3.6.3 (default, Mar 27 2018, 00:29:24)
[GCC 6.3.0 20170516]

Note: Didn't happen with 2.0.0.dev4

@ghost
Copy link

ghost commented Sep 7, 2018

Reproducible with Eclipse PyDev + PyLint.

C:\>python -m pylint --version
__main__.py 2.1.1
astroid 2.0.4
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]

Minimal example:

class MyException(Exception):
    def foobar(self):
        for arg in self.args:
            print(arg)

@mthuurne
Copy link
Contributor

Although the commit that should fix this issue exists on the Astroid 2.3.x branches, the issue still occurs for me with Astroid 2.3.2:

$ pylint --version
pylint 2.4.3
astroid 2.3.2
Python 3.7.2 (default, Feb 26 2019, 13:02:33) 
[GCC 7.3.1 20180323 [gcc-7-branch revision 258812]]

@PCManticore PCManticore reopened this Oct 30, 2019
@PCManticore
Copy link
Contributor

Thanks for checking @mthuurne I can reproduce it as well.

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

3 participants