Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix sortenvironmentkey
  • Loading branch information
zooba committed Jan 11, 2024
commit 15a3a52fc30ac01989b31e6108801aea41ecb400
13 changes: 9 additions & 4 deletions Modules/_winapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@

#include "Python.h"
#include "pycore_moduleobject.h" // _PyModule_GetState()
#include "pycore_runtime.h" // _Py_ID
#include "structmember.h" // PyMemberDef


#define WINDOWS_LEAN_AND_MEAN
#include "windows.h"
#include <crtdbg.h>
#include "winreparse.h"

#include "pycore_runtime.h" // _Py_ID

#if defined(MS_WIN32) && !defined(MS_WIN64)
#define HANDLE_TO_PYNUM(handle) \
PyLong_FromUnsignedLong((unsigned long) handle)
Expand Down Expand Up @@ -785,8 +785,13 @@ gethandle(PyObject* obj, const char* name)
static PyObject *
sortenvironmentkey(PyObject *module, PyObject *item)
{
return _winapi_LCMapStringEx_impl(NULL, LOCALE_NAME_INVARIANT,
LCMAP_UPPERCASE, item);
PyObject *result = NULL;
PyObject *locale = PyUnicode_FromWideChar(LOCALE_NAME_INVARIANT, -1);
if (locale) {
result = _winapi_LCMapStringEx_impl(NULL, locale, LCMAP_UPPERCASE, item);
Py_DECREF(locale);
}
return result;
}

static PyMethodDef sortenvironmentkey_def = {
Expand Down