Skip to content

Debug free threading build #60562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pandas/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

from pandas.compat._constants import (
IS64,
IS_FREE_THREADING,
ISMUSL,
PY311,
PY312,
PY313,
PYPY,
WASM,
)
Expand Down Expand Up @@ -153,8 +155,10 @@ def is_ci_environment() -> bool:
"HAS_PYARROW",
"IS64",
"ISMUSL",
"IS_FREE_THREADING",
"PY311",
"PY312",
"PY313",
"PYPY",
"WASM",
"is_numpy_dev",
Expand Down
4 changes: 4 additions & 0 deletions pandas/compat/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@

PY311 = sys.version_info >= (3, 11)
PY312 = sys.version_info >= (3, 12)
PY313 = sys.version_info >= (3, 13)
PYPY = platform.python_implementation() == "PyPy"
WASM = (sys.platform == "emscripten") or (platform.machine() in ["wasm32", "wasm64"])
IS_FREE_THREADING = False if not PY313 else not sys._is_gil_enabled() # type: ignore[attr-defined]
ISMUSL = "musl" in (sysconfig.get_config_var("HOST_GNU_TYPE") or "")
REF_COUNT = 2 if PY311 else 3

__all__ = [
"IS64",
"ISMUSL",
"IS_FREE_THREADING",
"PY311",
"PY312",
"PY313",
"PYPY",
"WASM",
]
1 change: 1 addition & 0 deletions pandas/compat/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
np_version_gte1p24p3 = _nlv >= Version("1.24.3")
np_version_gte1p25 = _nlv >= Version("1.25")
np_version_gt2 = _nlv >= Version("2.0.0")
np_version_gt2p2 = _nlv >= Version("2.2.0")
is_numpy_dev = _nlv.dev is not None
_min_numpy_ver = "1.23.5"

Expand Down
6 changes: 6 additions & 0 deletions pandas/tests/arrays/string_/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

from pandas._config import using_string_dtype

from pandas.compat import IS_FREE_THREADING
from pandas.compat.numpy import np_version_gt2p2
from pandas.compat.pyarrow import pa_version_under12p0

from pandas.core.dtypes.common import is_dtype_equal
Expand Down Expand Up @@ -140,6 +142,10 @@ def test_setitem_with_array_with_missing(dtype):
tm.assert_numpy_array_equal(value, value_orig)


@pytest.mark.skipif(
IS_FREE_THREADING and np_version_gt2p2,
reason="Segfaults in TimedeltaArray._format_native_types",
)
def test_astype_roundtrip(dtype):
ser = pd.Series(pd.date_range("2000", periods=12))
ser[0] = None
Expand Down
11 changes: 11 additions & 0 deletions pandas/tests/copy_view/test_replace.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import numpy as np
import pytest

from pandas.compat import IS_FREE_THREADING
from pandas.compat.numpy import np_version_gt2p2

from pandas import (
Categorical,
DataFrame,
Expand Down Expand Up @@ -45,6 +48,10 @@ def test_replace(replace_kwargs):
tm.assert_frame_equal(df, df_orig)


@pytest.mark.skipif(
IS_FREE_THREADING and np_version_gt2p2,
reason="Segfaults in array_algos.replace.replace_regex",
)
def test_replace_regex_inplace_refs():
df = DataFrame({"a": ["aaa", "bbb"]})
df_orig = df.copy()
Expand All @@ -56,6 +63,10 @@ def test_replace_regex_inplace_refs():
tm.assert_frame_equal(view, df_orig)


@pytest.mark.skipif(
IS_FREE_THREADING and np_version_gt2p2,
reason="Segfaults in array_algos.replace.replace_regex",
)
def test_replace_regex_inplace():
df = DataFrame({"a": ["aaa", "bbb"]})
arr = get_array(df, "a")
Expand Down
10 changes: 10 additions & 0 deletions pandas/tests/series/methods/test_astype.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import pytest

from pandas._libs.tslibs import iNaT
from pandas.compat import IS_FREE_THREADING
from pandas.compat.numpy import np_version_gt2p2
import pandas.util._test_decorators as td

from pandas import (
Expand Down Expand Up @@ -299,6 +301,10 @@ def test_astype_str_cast_dt64(self):
expected = Series(["2010-01-04 00:00:00-05:00"], dtype="str")
tm.assert_series_equal(res, expected)

@pytest.mark.skipif(
IS_FREE_THREADING and np_version_gt2p2,
reason="Segfaults in TimedeltaArray._format_native_types",
)
def test_astype_str_cast_td64(self):
# see GH#9757

Expand Down Expand Up @@ -493,6 +499,10 @@ def test_astype_retain_attrs(self, any_numpy_dtype):


class TestAstypeString:
@pytest.mark.skipif(
IS_FREE_THREADING and np_version_gt2p2,
reason="Segfaults in TimedeltaArray._format_native_types",
)
@pytest.mark.parametrize(
"data, dtype",
[
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/series/methods/test_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import numpy as np
import pytest

from pandas.compat import IS_FREE_THREADING
from pandas.compat.numpy import np_version_gt2p2

import pandas as pd
import pandas._testing as tm
from pandas.core.arrays import IntervalArray
Expand Down Expand Up @@ -510,6 +513,10 @@ def test_replace_extension_other(self, frame_or_series):
# should not have changed dtype
tm.assert_equal(obj, result)

@pytest.mark.skipif(
IS_FREE_THREADING and np_version_gt2p2,
reason="Segfaults in array_algos.replace.compare_or_regex_search",
)
def test_replace_with_compiled_regex(self):
# https://github.com/pandas-dev/pandas/issues/35680
s = pd.Series(["a", "b", "c"])
Expand Down
3 changes: 2 additions & 1 deletion scripts/validate_unwanted_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def _get_literal_string_prefix_len(token_string: str) -> int:
return 0


PRIVATE_FUNCTIONS_ALLOWED = {"sys._getframe"} # no known alternative
# no known alternative
PRIVATE_FUNCTIONS_ALLOWED = {"sys._getframe", "sys._is_gil_enabled"}


def private_function_across_module(file_obj: IO[str]) -> Iterable[tuple[int, str]]:
Expand Down
Loading