Skip to content

Commit 85c6bda

Browse files
authored
Merge pull request #305 from chdb-io/py313
2 parents 1212d86 + ee1b962 commit 85c6bda

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
lines changed

.github/workflows/build_linux_arm64_wheels-gh.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
os: [ ubuntu-24.04 ]
31-
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
31+
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]
3232
# python-version: [ "3.7" ]
3333
env:
3434
RUNNER_OS: ${{ matrix.os }}

.github/workflows/build_linux_x86_wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
os: [ ubuntu-22.04 ]
31-
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
31+
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]
3232
# python-version: [ "3.7" ]
3333
env:
3434
RUNNER_OS: ${{ matrix.os }}

.github/workflows/build_macos_x86_wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
os: [ macos-13 ]
25-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12" ]
25+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
2626
env:
2727
RUNNER_OS: ${{ matrix.os }}
2828
PYTHON_VERSION: ${{ matrix.python-version }}

chdb/build_mac_arm64.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ if [ "${dest}" != "darwin-x86_64" ]; then
5151
fi
5252

5353

54-
for PY_VER in 3.9.13 3.10.11 3.11.3 3.12.0; do
54+
for PY_VER in 3.9.13 3.10.11 3.11.3 3.12.9 3.13.2; do
5555
if [ ! -f ${PROJ_DIR}/python_pkg/python-${PY_VER}-macos11.pkg ]; then
5656
wget https://www.python.org/ftp/python/${PY_VER}/python-${PY_VER}-macos11.pkg -O ${PROJ_DIR}/python_pkg/python-${PY_VER}-macos11.pkg
5757
fi

src/TableFunctions/TableFunctionPython.cpp

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,39 @@ py::object findQueryableObj(const std::string & var_name)
4040

4141
while (!current_frame.is_none())
4242
{
43-
auto local_dict = py::reinterpret_borrow<py::dict>(current_frame.attr("f_locals"));
44-
auto global_dict = py::reinterpret_borrow<py::dict>(current_frame.attr("f_globals"));
43+
// Get f_locals and f_globals
44+
py::object locals_obj = current_frame.attr("f_locals");
45+
py::object globals_obj = current_frame.attr("f_globals");
4546

46-
for (const auto & dict : {local_dict, global_dict})
47+
// For each namespace (locals and globals)
48+
for (const auto & namespace_obj : {locals_obj, globals_obj})
4749
{
48-
if (dict.contains(var_name))
50+
// Use Python's __contains__ method to check if the key exists
51+
// This works with both regular dicts and FrameLocalsProxy (Python 3.13+)
52+
if (py::bool_(namespace_obj.attr("__contains__")(var_name)))
4953
{
50-
py::object obj = dict[var_name.data()];
51-
if (isInheritsFromPyReader(obj) || isPandasDf(obj) || isPyarrowTable(obj) || hasGetItem(obj))
52-
return obj;
54+
py::object obj;
55+
try
56+
{
57+
// Get the object using Python's indexing syntax
58+
obj = namespace_obj[py::cast(var_name)];
59+
if (isInheritsFromPyReader(obj) || isPandasDf(obj) || isPyarrowTable(obj) || hasGetItem(obj))
60+
{
61+
return obj;
62+
}
63+
}
64+
catch (const py::error_already_set &)
65+
{
66+
continue; // If getting the value fails, continue to the next namespace
67+
}
5368
}
5469
}
5570

71+
// Move to the parent frame
5672
current_frame = current_frame.attr("f_back");
5773
}
5874

59-
// not found
75+
// Object not found
6076
return py::none();
6177
}
6278

0 commit comments

Comments
 (0)