Skip to content

Commit 31cc9fa

Browse files
committed
Upgrade pyo3 to version 0.26
PyObject and ::with_gil have been deprecated, so both of these had to be replaced.
1 parent 64a1bd1 commit 31cc9fa

43 files changed

Lines changed: 507 additions & 515 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ crate-type = ["cdylib"]
1515
autosar-data = {version = "0.20"}
1616
autosar-data-specification = {version = "0.20"}
1717
autosar-data-abstraction = {version = "0.6"}
18-
pyo3 = "0.25"
18+
pyo3 = "0.26"

src/abstraction/arpackage.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use crate::abstraction::{
99
ApplicationArrayDataType, ApplicationArraySize, ApplicationPrimitiveCategory,
1010
ApplicationPrimitiveDataType, ApplicationRecordDataType, BaseTypeEncoding, CompuMethod,
1111
ConstantSpecification, DataConstr, DataTypeMappingSet, ImplementationDataType, SwBaseType,
12-
Unit, pyany_to_implmentation_settings, pyobject_to_compu_method_content,
13-
pyobject_to_value_specification,
12+
Unit, pyany_to_compu_method_content, pyany_to_implmentation_settings,
13+
pyany_to_value_specification,
1414
},
1515
ecu_configuration::{
1616
EcucDefinitionCollection, EcucDestinationUriDefSet, EcucModuleConfigurationValues,
@@ -185,7 +185,7 @@ impl ArPackage {
185185
/// create a new `CompuMethod` in the package
186186
#[pyo3(text_signature = "(self, name: str, content: CompuMethodContent)")]
187187
fn create_compu_method(&self, name: &str, content: &Bound<'_, PyAny>) -> PyResult<CompuMethod> {
188-
let content = pyobject_to_compu_method_content(content)?;
188+
let content = pyany_to_compu_method_content(content)?;
189189
match self.0.create_compu_method(name, content) {
190190
Ok(value) => Ok(CompuMethod(value)),
191191
Err(e) => Err(AutosarAbstractionError::new_err(e.to_string())),
@@ -199,7 +199,7 @@ impl ArPackage {
199199
name: &str,
200200
value: &Bound<'_, PyAny>,
201201
) -> PyResult<ConstantSpecification> {
202-
let value = pyobject_to_value_specification(value)?;
202+
let value = pyany_to_value_specification(value)?;
203203
match self.0.create_constant_specification(name, value) {
204204
Ok(value) => Ok(ConstantSpecification(value)),
205205
Err(e) => Err(AutosarAbstractionError::new_err(e.to_string())),

src/abstraction/communication/data_transformation.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl DataTransformationSet {
8383
name: &str,
8484
config: &Bound<'_, PyAny>, // some variant of TransformationTechnologyConfig
8585
) -> PyResult<TransformationTechnology> {
86-
let config = transformation_technology_config_from_pyobject(config)?;
86+
let config = transformation_technology_config_from_pyany(config)?;
8787
match self.0.create_transformation_technology(name, &config) {
8888
Ok(value) => Ok(TransformationTechnology(value)),
8989
Err(e) => Err(AutosarAbstractionError::new_err(e.to_string())),
@@ -230,15 +230,15 @@ impl TransformationTechnology {
230230
#[pyo3(signature = (config, /))]
231231
#[pyo3(text_signature = "(self, config: TransformationTechnologyConfig, /)")]
232232
fn set_config(&self, config: &Bound<'_, PyAny>) -> PyResult<()> {
233-
let config = transformation_technology_config_from_pyobject(config)?;
233+
let config = transformation_technology_config_from_pyany(config)?;
234234
self.0.set_config(&config).map_err(abstraction_err_to_pyerr)
235235
}
236236

237237
/// Get the configuration of the `TransformationTechnology`
238-
fn config(&self, py: Python) -> Option<PyObject> {
238+
fn config(&self, py: Python) -> Option<Py<PyAny>> {
239239
self.0
240240
.config()
241-
.and_then(|config| transformation_technology_config_to_pyobject(py, &config).ok())
241+
.and_then(|config| transformation_technology_config_to_pyany(py, &config).ok())
242242
}
243243
}
244244

@@ -248,8 +248,8 @@ iterator_wrapper!(TransformationTechnologyIterator, TransformationTechnology);
248248

249249
//##################################################################
250250

251-
// when we receive a generic PyObject, we need to determine the actual type of the config and wrap it appropriately
252-
fn transformation_technology_config_from_pyobject(
251+
// when we receive a generic Py<PyAny>, we need to determine the actual type of the config and wrap it appropriately
252+
fn transformation_technology_config_from_pyany(
253253
config: &Bound<'_, PyAny>,
254254
) -> PyResult<autosar_data_abstraction::communication::TransformationTechnologyConfig> {
255255
if let Ok(config) = config.extract::<GenericTransformationTechnologyConfig>() {
@@ -283,11 +283,11 @@ fn transformation_technology_config_from_pyobject(
283283
}
284284
}
285285

286-
// instead of representing TransformationTechnologyConfig with a matching enum in python, we can simply return generic PyObjects
287-
fn transformation_technology_config_to_pyobject(
286+
// instead of representing TransformationTechnologyConfig with a matching enum in python, we can simply return generic Py<PyAny>s
287+
fn transformation_technology_config_to_pyany(
288288
py: Python,
289289
config: &autosar_data_abstraction::communication::TransformationTechnologyConfig,
290-
) -> PyResult<PyObject> {
290+
) -> PyResult<Py<PyAny>> {
291291
match config {
292292
autosar_data_abstraction::communication::TransformationTechnologyConfig::Generic(
293293
config,

src/abstraction/communication/frame/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl PduToFrameMapping {
5555

5656
/// Reference to the PDU that is mapped into the frame. The PDU reference is mandatory.
5757
#[getter]
58-
fn pdu(&self) -> Option<PyObject> {
58+
fn pdu(&self) -> Option<Py<PyAny>> {
5959
self.0.pdu().and_then(|pdu| pdu_to_pyany(&pdu).ok())
6060
}
6161

src/abstraction/communication/network_management/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ impl NmConfig {
119119
fn nm_clusters(&self) -> NmClusterIterator {
120120
NmClusterIterator::new(self.0.nm_clusters().filter_map(|cluster| match cluster {
121121
autosar_data_abstraction::communication::NmCluster::CanNm(cluster) => {
122-
Python::with_gil(|py| CanNmCluster(cluster).into_py_any(py).ok())
122+
Python::attach(|py| CanNmCluster(cluster).into_py_any(py).ok())
123123
}
124124
autosar_data_abstraction::communication::NmCluster::FlexrayNm(cluster) => {
125-
Python::with_gil(|py| FlexrayNmCluster(cluster).into_py_any(py).ok())
125+
Python::attach(|py| FlexrayNmCluster(cluster).into_py_any(py).ok())
126126
}
127127
autosar_data_abstraction::communication::NmCluster::UdpNm(cluster) => {
128-
Python::with_gil(|py| UdpNmCluster(cluster).into_py_any(py).ok())
128+
Python::attach(|py| UdpNmCluster(cluster).into_py_any(py).ok())
129129
}
130130
}))
131131
}
@@ -177,13 +177,13 @@ impl NmConfig {
177177
fn nm_cluster_couplings(&self) -> NmClusterCouplingIterator {
178178
NmClusterCouplingIterator::new(self.0.nm_cluster_couplings().filter_map(|coupling| match coupling {
179179
autosar_data_abstraction::communication::NmClusterCoupling::CanNmClusterCoupling(coupling) => {
180-
Python::with_gil(|py| CanNmClusterCoupling(coupling).into_py_any(py).ok())
180+
Python::attach(|py| CanNmClusterCoupling(coupling).into_py_any(py).ok())
181181
}
182182
autosar_data_abstraction::communication::NmClusterCoupling::FlexrayNmClusterCoupling(coupling) => {
183-
Python::with_gil(|py| FlexrayNmClusterCoupling(coupling).into_py_any(py).ok())
183+
Python::attach(|py| FlexrayNmClusterCoupling(coupling).into_py_any(py).ok())
184184
}
185185
autosar_data_abstraction::communication::NmClusterCoupling::UdpNmClusterCoupling(coupling) => {
186-
Python::with_gil(|py| UdpNmClusterCoupling(coupling).into_py_any(py).ok())
186+
Python::attach(|py| UdpNmClusterCoupling(coupling).into_py_any(py).ok())
187187
}
188188
}))
189189
}
@@ -208,12 +208,12 @@ impl NmConfig {
208208

209209
iterator_wrapper!(
210210
NmClusterIterator,
211-
PyObject,
211+
Py<PyAny>,
212212
"Union[CanNmCluster, FlexrayNmCluster, UdpNmCluster]"
213213
);
214214
iterator_wrapper!(
215215
NmClusterCouplingIterator,
216-
PyObject,
216+
Py<PyAny>,
217217
"Union[CanNmClusterCoupling, FlexrayNmClusterCoupling, UdpNmClusterCoupling]"
218218
);
219219
iterator_wrapper!(NmEcuIterator, NmEcu);

0 commit comments

Comments
 (0)