Skip to content

Pylint not suppressing the stdout of C loaded extensions #3518

@willpxxr

Description

@willpxxr

Steps to reproduce

  1. Pylint configured to load a module which contains a C extension ie. Pygame, and report in JSON
[MASTER]
extension-pkg-whitelist=pygame
...
[REPORTS]
output-format=json
  1. Run Pylint on a file which contains a call to the method containing a C extension.
import pygame
if __name__ == "__main__":
        pygame.init()
pylint main.py > output.json
  1. Cat the output and the result should look as follows:
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
[
    {
        "type": "convention",
        "module": "settings",
        "obj": "",
        "line": 1,
        "column": 0,
        "path": "src/games/space_invaders/settings.py",
        "symbol": "missing-module-docstring",
        "message": "Missing module docstring",
        "message-id": "C0114"
    },
...

Current behavior

Currently Pylint is not suppressing messages written to the stdout of C extensions which get loaded. This results in a report generation which does not follow the json formatting, as it contains anything which may be printed to the stdout by a C extension during analysis.

Expected behavior

Pylint shouldn't print the stdout messages of C extensions being ran during analysis.
ie the report.json should look as follows:

[
    {
        "type": "convention",
        "module": "settings",
        "obj": "",
        "line": 1,
        "column": 0,
        "path": "src/games/space_invaders/settings.py",
        "symbol": "missing-module-docstring",
        "message": "Missing module docstring",
        "message-id": "C0114"
    },
...

pylint --version output

circleci@b0feadac759a:~$ pylint --version
pylint 2.4.4
astroid 2.3.3
Python 3.6.10 (default, Apr 21 2020, 14:40:51)
[GCC 8.3.0]

Metadata

Metadata

Labels

Bug 🪲Needs astroid updateNeeds an astroid update (probably a release too) before being mergable

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions