Skip to content

BUG: read_csv with list causes segfault #46407

Closed
@camillescott

Description

@camillescott

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

test = ['test.csv']
pd.read_csv(test)

Issue Description

Running this code results in an immediate segfault. Specifying engine = 'python' does not, so presumably bad data is passed to the C engine. If test is a dict, set, or numpy.ndarray, a ValueError is raised as expected.

We discovered this error in a Snakemake rule, where the user passed input, which by default a list, directly to read_csv in a run block. Given Snakemake's popularity, this seems like something that could pop up fairly often.

Expected Behavior

It should raise a ValueError.

Installed Versions

My environment seems to break with this.

File ~/miniconda/envs/dissertation/lib/python3.8/site-packages/setuptools/init.py:8, in
5 import os
6 import re
----> 8 import _distutils_hack.override # noqa: F401
10 import distutils.core
11 from distutils.errors import DistutilsOptionError

File ~/miniconda/envs/dissertation/lib/python3.8/site-packages/_distutils_hack/override.py:1, in
----> 1 import('_distutils_hack').do_override()

File ~/miniconda/envs/dissertation/lib/python3.8/site-packages/_distutils_hack/init.py:71, in do_override()
69 if enabled():
70 warn_distutils_present()
---> 71 ensure_local_distutils()

File ~/miniconda/envs/dissertation/lib/python3.8/site-packages/_distutils_hack/init.py:59, in ensure_local_distutils()
57 # check that submodules load as expected
58 core = importlib.import_module('distutils.core')
---> 59 assert '_distutils' in core.file, core.file

AssertionError: /home/camille/miniconda/envs/dissertation/lib/python3.8/distutils/core.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions