Skip to content
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

Py_DecodeLocale() incorrect signature #1766

Closed
indygreg opened this issue Aug 8, 2021 · 1 comment · Fixed by #1768
Closed

Py_DecodeLocale() incorrect signature #1766

indygreg opened this issue Aug 8, 2021 · 1 comment · Fixed by #1768

Comments

@indygreg
Copy link
Contributor

indygreg commented Aug 8, 2021

Currently Py_DecodeLocale() is defined as the following:

pub fn Py_DecodeLocale(arg1: *const c_char, arg2: Py_ssize_t) -> *mut wchar_t;

But in CPython Include/fileutils.h, it is defined as the following:

PyAPI_FUNC(wchar_t *) Py_DecodeLocale(
    const char *arg,
    size_t *size);

I believe the Rust signature should be:

pub fn Py_DecodeLocale(arg1: *const c_char, arg2: *mut Py_ssize_t) -> *mut wchar_t;

Given this is an API change, I'm unsure how you want to handle this. Hence why I filed an issue instead of going straight to a PR.

@davidhewitt
Copy link
Member

Yep looks like our ffi definition is wrong; the C declaration you quote has been the same since Python 3.6 (and maybe earlier, didn't check).

Given our declaration is wrong I class this as a bug fix that's fine to be merged whenever. It seems unlikely anyone is using this correctly at the moment.

indygreg added a commit to indygreg/pyo3 that referenced this issue Aug 8, 2021
indygreg added a commit to indygreg/pyo3 that referenced this issue Aug 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants