Skip to content

BUG: str.replace("", "") sometimes hangs up the console #64941

@rcap107

Description

@rcap107

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
>>> c = pd.Series(["1234,56"])
>>> c.str.replace("", "")

Issue Description

I have found a very weird bug while replacing strings with str.replace. The minimal example above in some cases will hang up the console and make it completely unresponsive. It even catches kill signals so I have to terminate the console from elsewhere.

The problem is that I can't seem to be able to reproduce it consistently: it seems to run properly in some cases, and then it will randomly hang up everything. I have confirmed the same bug with other people, and it's also hanging up the CI in one of my repos (https://github.com/skrub-data/skrub/actions/runs/23753708049/job/69302405774?pr=1772), so it's not only my machine that is acting up.

I tried both pandas 3.0.0 and pandas 3.0.1, and had the same issue with both versions.

Expected Behavior

The correct substitution:

>>> import pandas as pd
>>> c = pd.Series(["1234,56"])
>>> c.str.replace("", "")
0    1234,56
dtype: str

Installed Versions

Details

INSTALLED VERSIONS

commit : e04b26f
python : 3.14.0
python-bits : 64
OS : Darwin
OS-release : 24.6.0
Version : Darwin Kernel Version 24.6.0: Mon Jan 19 22:01:41 PST 2026; root:xnu-11417.140.69.708.3~1/RELEASE_ARM64_T8132
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 3.0.1
numpy : 2.4.4
dateutil : 2.9.0.post0
pip : None
Cython : None
sphinx : None
IPython : 9.12.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
bottleneck : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : None
lxml.etree : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
psycopg2 : None
pymysql : None
pyarrow : None
pyiceberg : None
pyreadstat : None
pytest : None
python-calamine : None
pytz : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Arrowpyarrow functionalityBugStringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions