Skip to content

Commit 5de2859

Browse files
dbrattliclaude
andauthored
[Python] Update PyO3 from 0.27.2 to 0.28.2 (#4348)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e9bae17 commit 5de2859

6 files changed

Lines changed: 28 additions & 47 deletions

File tree

src/fable-library-py/Cargo.lock

Lines changed: 10 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/fable-library-py/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ name = "_core"
1212
crate-type = ["cdylib"]
1313

1414
[dependencies]
15-
pyo3 = { version = "0.27.2", features = ["extension-module", "chrono"] }
15+
pyo3 = { version = "0.28.2", features = ["extension-module", "chrono"] }
1616
byteorder = "1.5.0"
1717
chrono = "0.4.42"
1818
regex = "1.12.1"

src/fable-library-py/src/array.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use pyo3::{
1616
};
1717
use std::sync::{Arc, Mutex};
1818

19-
#[pyclass(module = "fable", subclass)]
19+
#[pyclass(module = "fable", subclass, from_py_object)]
2020
#[derive(Clone, Debug)]
2121

2222
pub struct FSharpArray {
@@ -480,7 +480,11 @@ impl FSharpArray {
480480
pub fn __iter__(slf: PyRef<'_, Self>, py: Python<'_>) -> PyResult<Py<PyAny>> {
481481
let len = slf.storage.len();
482482
// SAFETY: slf.as_ptr() is valid and from_borrowed_ptr increments refcount
483-
let array: Py<FSharpArray> = unsafe { Py::from_borrowed_ptr(py, slf.as_ptr()) };
483+
let array: Py<FSharpArray> = unsafe {
484+
Bound::from_borrowed_ptr(py, slf.as_ptr())
485+
.cast_into_unchecked::<FSharpArray>()
486+
}
487+
.unbind();
484488
let iter = FSharpArrayIter {
485489
array,
486490
index: 0,
@@ -496,7 +500,11 @@ impl FSharpArray {
496500
pub fn GetEnumerator(slf: PyRef<'_, Self>, py: Python<'_>, _unit: Option<&Bound<'_, PyAny>>) -> PyResult<Py<PyAny>> {
497501
let len = slf.storage.len();
498502
// SAFETY: slf.as_ptr() is valid and from_borrowed_ptr increments refcount
499-
let array: Py<FSharpArray> = unsafe { Py::from_borrowed_ptr(py, slf.as_ptr()) };
503+
let array: Py<FSharpArray> = unsafe {
504+
Bound::from_borrowed_ptr(py, slf.as_ptr())
505+
.cast_into_unchecked::<FSharpArray>()
506+
}
507+
.unbind();
500508
let enumerator = FSharpArrayEnumerator {
501509
array,
502510
index: -1, // Before first element
@@ -4377,7 +4385,7 @@ pub fn of_seq(
43774385
}
43784386

43794387
// Constructor class for array allocation
4380-
#[pyclass(module = "fable")]
4388+
#[pyclass(module = "fable", from_py_object)]
43814389
#[derive(Clone)]
43824390
struct FSharpCons {
43834391
#[pyo3(get, set)]

src/fable-library-py/src/floats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::ops::Deref;
1010
// Macro to generate float wrapper types (Float32, Float64)
1111
macro_rules! float_variant {
1212
($name:ident, $type:ty) => {
13-
#[pyclass(module = "fable", frozen)]
13+
#[pyclass(module = "fable", frozen, from_py_object)]
1414
#[derive(Clone, Copy)] // Floats are typically Copy
1515
pub struct $name(pub $type);
1616

src/fable-library-py/src/ints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ macro_rules! integer_variant {
204204
/// - Full Python special method support
205205
/// - Type-safe operations with automatic conversions
206206
/// - Direct access to the underlying value via Deref
207-
#[pyclass(module = "fable", frozen)]
207+
#[pyclass(module = "fable", frozen, from_py_object)]
208208
#[derive(Clone)]
209209
pub struct $name(pub $type); // Make the inner field public
210210

src/fable-library-py/src/strings.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ mod printf {
107107
/// def fail(msg): raise Exception(msg)
108108
/// printf("Error: %s").cont(fail)("something went wrong") # raises Exception
109109
/// ```
110-
#[pyclass(module = "fable")]
110+
#[pyclass(module = "fable", from_py_object)]
111111
pub struct IPrintfFormat {
112112
/// The original format string with placeholders
113113
input: String,
@@ -633,7 +633,7 @@ mod printf {
633633
}
634634

635635
/// Console printer wrapper that maintains F# currying semantics
636-
#[pyclass]
636+
#[pyclass(from_py_object)]
637637
#[derive(Clone)]
638638
pub struct ConsolePrinter {
639639
format: IPrintfFormat,
@@ -1676,7 +1676,7 @@ mod formatting {
16761676
}
16771677

16781678
/// String comparison enumeration
1679-
#[pyclass(module = "fable")]
1679+
#[pyclass(module = "fable", from_py_object)]
16801680
#[derive(Clone, Copy)]
16811681
pub struct StringComparison {
16821682
pub value: i32,

0 commit comments

Comments
 (0)