Skip to content

Commit 6e1cf43

Browse files
authored
"Backport PR #47387 on branch 1.4.x (TST,WARN: read_csv raises warning at wrong stacklevel, but _assert_raised_with_correct_stacklevel doesn't fail )" (#47513)
1 parent b79c794 commit 6e1cf43

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

doc/source/whatsnew/v1.4.4.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Fixed regressions
2323

2424
Bug fixes
2525
~~~~~~~~~
26-
-
26+
- The :class:`errors.FutureWarning` raised when passing arguments (other than ``filepath_or_buffer``) as positional in :func:`read_csv` is now raised at the correct stacklevel (:issue:`47385`)
2727
-
2828

2929
.. ---------------------------------------------------------------------------

pandas/io/parsers/readers.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,7 @@ def _read(
581581
return parser.read(nrows)
582582

583583

584-
@deprecate_nonkeyword_arguments(
585-
version=None, allowed_args=["filepath_or_buffer"], stacklevel=3
586-
)
584+
@deprecate_nonkeyword_arguments(version=None, allowed_args=["filepath_or_buffer"])
587585
@Appender(
588586
_doc_read_csv_and_table.format(
589587
func_name="read_csv",

pandas/tests/io/parser/common/test_common_basic.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -806,8 +806,7 @@ def test_read_csv_posargs_deprecation(all_parsers):
806806
"In a future version of pandas all arguments of read_csv "
807807
"except for the argument 'filepath_or_buffer' will be keyword-only"
808808
)
809-
with tm.assert_produces_warning(FutureWarning, match=msg):
810-
parser.read_csv(f, " ")
809+
parser.read_csv_check_warnings(FutureWarning, msg, f, " ")
811810

812811

813812
@pytest.mark.parametrize("delimiter", [",", "\t"])

0 commit comments

Comments
 (0)