Fix correct warning with c engine when skipping lines
State: closed

Fixed bug where c engine would not print warnings for lines
it skipped in case the skipped line had an inline comment.
Also, its accounting of number of fields in such lines would
be off by one.

 - [x] closes #16472 
 - [x] tests added
 - [x] tests passed
 - [x] passes ``git diff upstream/master --name-only -- '*.py' | flake8 --diff``
 - [x] whatsnew entry


Labels:
name: Bug
name: IO CSV
description: read_csv, to_csv

Comments:
does this have an issue number?
@TomAugspurger I have added the whatsnew bug entry and replaced `sys.stderr` patching with `tm.capture_stderr`, and also moved the test to `CParserTests` since it is only applicable to the `c` engine.
The CI tests seem to fail on some pyarrow/feather code.

@jreback Added an issue for this: https://github.com/pandas-dev/pandas/issues/16472

can you rebase on master, CI has been fixed
@gfyoung if you can have a look
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16455?src=pr&el=h1) Report
> Merging [#16455](https://codecov.io/gh/pandas-dev/pandas/pull/16455?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/6cbd5589fd005f987381bacbaa79e96950cd5dcb?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/16455/graphs/tree.svg?height=150&src=pr&token=eZ4WkYLtcO&width=650)](https://codecov.io/gh/pandas-dev/pandas/pull/16455?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master   #16455   +/-   ##
=======================================
  Coverage   90.42%   90.42%           
=======================================
  Files         161      161           
  Lines       51029    51029           
=======================================
  Hits        46144    46144           
  Misses       4885     4885
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.26% <ø> (ø)` | :arrow_up: |
| #single | `40.17% <ø> (ø)` | :arrow_up: |


------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16455?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16455?src=pr&el=footer). Last update [6cbd558...6fd269d](https://codecov.io/gh/pandas-dev/pandas/pull/16455?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16455?src=pr&el=h1) Report
> Merging [#16455](https://codecov.io/gh/pandas-dev/pandas/pull/16455?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/6cbd5589fd005f987381bacbaa79e96950cd5dcb?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/16455/graphs/tree.svg?width=650&height=150&src=pr&token=eZ4WkYLtcO)](https://codecov.io/gh/pandas-dev/pandas/pull/16455?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master   #16455   +/-   ##
=======================================
  Coverage   90.42%   90.42%           
=======================================
  Files         161      161           
  Lines       51029    51029           
=======================================
  Hits        46144    46144           
  Misses       4885     4885
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.26% <ø> (ø)` | :arrow_up: |
| #single | `40.17% <ø> (ø)` | :arrow_up: |


------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16455?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16455?src=pr&el=footer). Last update [6cbd558...6fd269d](https://codecov.io/gh/pandas-dev/pandas/pull/16455?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

LGTM!
Thanks @pankajp!