Skip to content

Reading from stdin might not work. #283

@matyalatte

Description

@matyalatte

cpplint.py says it can read code from stdin when using - as a file path.
https://github.com/cpplint/cpplint/blob/develop/cpplint.py#L6652

So, I tried echo "int a = int(1.0);" | python cpplint.py - on Ubuntu 20.04 with Python3.8.

What I expected was like this.

Done processing -
-:1:  Using deprecated casting style.  Use static_cast<int>(...) instead  [readability/casting] [4]
Total errors found: 1

But I got an error.

Traceback (most recent call last):
  File "cpplint.py", line 6970, in <module>
    main()
  File "cpplint.py", line 6955, in main
    ProcessFile(filename, _cpplint_state.verbose_level)
  File "cpplint.py", line 6660, in ProcessFile
    lines = codecs.StreamReaderWriter(sys.stdin,
  File "/usr/lib/python3.8/codecs.py", line 701, in read
    return self.reader.read(size)
  File "/usr/lib/python3.8/codecs.py", line 500, in read
    data = self.bytebuffer + newdata
TypeError: can't concat str to bytes

I tried both the latest commit and v1.6.1 but got the same result.

Am I missing something? or is it a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions