Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ffi: add PyConfig::warn_default_encoding to 3.10+
This field was added in 3.10 but we missed it. This was causing
offsets of subsequent fields to be wrong. This could lead to
unexpected behavior or even crashes.
  • Loading branch information
indygreg committed May 14, 2022
1 parent 87bd10c commit 03cb561
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -28,7 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fixed incorrectly disabled FFI definition `PyThreadState_DeleteCurrent`. [#2357](https://github.com/PyO3/pyo3/pull/2357)
- Correct FFI definition `PyEval_EvalCodeEx` to take `*const *mut PyObject` array arguments instead of `*mut *mut PyObject` (this was changed in CPython 3.6). [#2368](https://github.com/PyO3/pyo3/pull/2368)

- Added missing `warn_default_encoding` field to `PyConfig` on 3.10+. The previously missing field could result in incorrect behavior or crashes. [#2370](https://github.com/PyO3/pyo3/pull/2370)
- Fixed order of `pathconfig_warnings` and `program_name` fields of `PyConfig` on 3.10+. Previously, the order of the fields was swapped and this could lead to incorrect behavior or crashes. [#2370](https://github.com/PyO3/pyo3/pull/2370)

## [0.16.4] - 2022-04-14

Expand Down
4 changes: 3 additions & 1 deletion pyo3-ffi/src/cpython/initconfig.rs
Expand Up @@ -110,6 +110,8 @@ pub struct PyConfig {
pub warnoptions: PyWideStringList,
pub site_import: c_int,
pub bytes_warning: c_int,
#[cfg(Py_3_10)]
pub warn_default_encoding: c_int,
pub inspect: c_int,
pub interactive: c_int,
pub optimization_level: c_int,
Expand All @@ -127,9 +129,9 @@ pub struct PyConfig {
pub legacy_windows_stdio: c_int,

pub check_hash_pycs_mode: *mut wchar_t,
pub pathconfig_warnings: c_int,
#[cfg(Py_3_10)]
pub program_name: *mut wchar_t,
pub pathconfig_warnings: c_int,
pub pythonpath_env: *mut wchar_t,
pub home: *mut wchar_t,
#[cfg(Py_3_10)]
Expand Down

0 comments on commit 03cb561

Please sign in to comment.