Skip to content

Condition comparing incompatible types in "numpy.distutils.system_info.libpaths" #17489

Closed

Description

Hello,

While analyzing numpy on SonarCloud I saw what looks like an error in numpy/distutils/system_info.py:

Screenshot 2020-10-07 at 14 58 09

You can see the issue in SonarCloud here.

The condition of this if statement will always be False because it compares a tuple and a string with the operator ==. The documentation of platform.architecture() explicitly says:

Returns a tuple (bits, linkage) which contain information about the bit architecture and the linkage format used for the executable. Both values are returned as strings.

I guess the developer intended to write instead:

if platform.architecture()[0] == '32bit':

In case you have any question, suggestion or if you see a False Positive on SonarCloud you can reach out on SonarSource community forum.

A few notes in case you want to use SonarCloud:

  • I am currently testing the python analyzer so the numpy project I created on SonarCloud will only show python issues, but SonarCloud can also analyze C/C++ code and other languages.
  • SonarCloud can easily import pylint and flake8 issues in case you want to use a rule SonarCloud does not already provide. Note however that pylint/flake8 rules and SonarCloud rules are implemented differently. You might see new issues with SonarCloud, or less issues in some cases (we try to avoid False Positives as much as possible).
  • SonarCloud is free for open-source projects.

Activity

  1. eric-wieser commented on Oct 7, 2020

    @eric-wieser
    Member

    I'm curious - are you writing these issues manually, or is this automated?

  2. nicolas-harraudeau-sonarsource commented on Oct 7, 2020

    @nicolas-harraudeau-sonarsource
    Author

    @eric-wieser The detection is automatic on SonarCloud. I wrote the Github issues manually. At SonarSource we validate our static code analyzers by testing them on popular open source projects, such as numpy, to make sure that we find valuable issues and raise no False Positives. This is how I saw these bugs.

    I will report one more issue and stop there for now as I have to to take a look at other open source projects. If you want to see all the bugs we detected you can look at this list here.

    As mentioned above, if you see any False Positives or if you have a question or feedback don't hesitate to share it on the community forum.

  3. eric-wieser commented on Oct 19, 2020

    @eric-wieser
    Member

    This was introduced in ea083bd by @xoviat, which interestingly seems to have no PR associated with it. So at any rate, this was never a regression - it was just a feature that didn't work for 32-bit platforms, likely because few windows users have one.

  4. charris commented on Oct 19, 2020

    @charris
    Member

    xoviat was banned by left GitHub and his PRs disappeared. I don't recall if that also included merged PRs.

    Edit: changed misleading text

  5. eric-wieser commented on Oct 19, 2020

    @eric-wieser
    Member

    Email archive to the rescue - it was #9854

  6. xoviat commented on Oct 20, 2020

    @xoviat
    Contributor

    I wasn't banned from GitHub, I deleted my account because these projects were consuming all of my time. I've been back for some time now, but have been working on other projects for now. I may come back to this, but have no immediate plans. I apologize if my account deletion affected PRs.

  7. eric-wieser commented on Oct 21, 2020

    @eric-wieser
    Member

    No need to apologise for a UI bug in github @xoviat - glad to here you were able to reallocate your time in a way that worked better for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions