diff --git a/PC/WinMain.c b/PC/WinMain.c deleted file mode 100644 index e439bed9ed113794118d34b80d8ad5068ed16aa8..0000000000000000000000000000000000000000 --- a/PC/WinMain.c +++ /dev/null @@ -1,16 +0,0 @@ -/* Minimal main program -- everything is loaded from the library. */ - -#include "Python.h" - -#define WIN32_LEAN_AND_MEAN -#include - -int WINAPI wWinMain( - HINSTANCE hInstance, /* handle to current instance */ - HINSTANCE hPrevInstance, /* handle to previous instance */ - LPWSTR lpCmdLine, /* pointer to command line */ - int nCmdShow /* show state of window */ -) -{ - return Py_Main(__argc, __wargv); -} diff --git a/PC/_msi.c b/PC/_msi.c deleted file mode 100644 index 01516e85ccff30b4839ca111b48bb417dbd5e057..0000000000000000000000000000000000000000 --- a/PC/_msi.c +++ /dev/null @@ -1,1323 +0,0 @@ -/* Helper library for MSI creation with Python. - * Copyright (C) 2005 Martin v. Löwis - * Licensed to PSF under a contributor agreement. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/*[clinic input] -module _msi -class _msi.Record "msiobj *" "&record_Type" -class _msi.SummaryInformation "msiobj *" "&summary_Type" -class _msi.View "msiobj *" "&msiview_Type" -class _msi.Database "msiobj *" "&msidb_Type" -[clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=89a3605762cf4bdc]*/ - -static PyObject *MSIError; - -/*[clinic input] -_msi.UuidCreate - -Return the string representation of a new unique identifier. -[clinic start generated code]*/ - -static PyObject * -_msi_UuidCreate_impl(PyObject *module) -/*[clinic end generated code: output=534ecf36f10af98e input=168024ab4b3e832b]*/ -{ - UUID result; - wchar_t *cresult; - PyObject *oresult; - - /* May return ok, local only, and no address. - For local only, the documentation says we still get a uuid. - For RPC_S_UUID_NO_ADDRESS, it's not clear whether we can - use the result. */ - if (UuidCreate(&result) == RPC_S_UUID_NO_ADDRESS) { - PyErr_SetString(PyExc_NotImplementedError, "processing 'no address' result"); - return NULL; - } - - if (UuidToStringW(&result, &cresult) == RPC_S_OUT_OF_MEMORY) { - PyErr_SetString(PyExc_MemoryError, "out of memory in uuidgen"); - return NULL; - } - - oresult = PyUnicode_FromWideChar(cresult, wcslen(cresult)); - RpcStringFreeW(&cresult); - return oresult; - -} - -/* Helper for converting file names from UTF-8 to wchat_t*. */ -static wchar_t * -utf8_to_wchar(const char *s, int *err) -{ - PyObject *obj = PyUnicode_FromString(s); - if (obj == NULL) { - if (PyErr_ExceptionMatches(PyExc_MemoryError)) { - *err = ENOMEM; - } - else { - *err = EINVAL; - } - PyErr_Clear(); - return NULL; - } - wchar_t *ws = PyUnicode_AsWideCharString(obj, NULL); - if (ws == NULL) { - *err = ENOMEM; - PyErr_Clear(); - } - Py_DECREF(obj); - return ws; -} - -/* FCI callback functions */ - -static FNFCIALLOC(cb_alloc) -{ - return PyMem_RawMalloc(cb); -} - -static FNFCIFREE(cb_free) -{ - PyMem_RawFree(memory); -} - -static FNFCIOPEN(cb_open) -{ - wchar_t *ws = utf8_to_wchar(pszFile, err); - if (ws == NULL) { - return -1; - } - int result = _wopen(ws, oflag | O_NOINHERIT, pmode); - PyMem_Free(ws); - if (result == -1) - *err = errno; - return result; -} - -static FNFCIREAD(cb_read) -{ - UINT result = (UINT)_read((int)hf, memory, cb); - if (result != cb) - *err = errno; - return result; -} - -static FNFCIWRITE(cb_write) -{ - UINT result = (UINT)_write((int)hf, memory, cb); - if (result != cb) - *err = errno; - return result; -} - -static FNFCICLOSE(cb_close) -{ - int result = _close((int)hf); - if (result != 0) - *err = errno; - return result; -} - -static FNFCISEEK(cb_seek) -{ - long result = (long)_lseek((int)hf, dist, seektype); - if (result == -1) - *err = errno; - return result; -} - -static FNFCIDELETE(cb_delete) -{ - wchar_t *ws = utf8_to_wchar(pszFile, err); - if (ws == NULL) { - return -1; - } - int result = _wremove(ws); - PyMem_Free(ws); - if (result != 0) - *err = errno; - return result; -} - -static FNFCIFILEPLACED(cb_fileplaced) -{ - return 0; -} - -static FNFCIGETTEMPFILE(cb_gettempfile) -{ - char *name = _tempnam("", "tmp"); - if ((name != NULL) && ((int)strlen(name) < cbTempName)) { - strcpy(pszTempName, name); - free(name); - return TRUE; - } - - if (name) free(name); - return FALSE; -} - -static FNFCISTATUS(cb_status) -{ - if (pv) { - _Py_IDENTIFIER(status); - - PyObject *result = _PyObject_CallMethodId(pv, &PyId_status, "iii", typeStatus, cb1, cb2); - if (result == NULL) - return -1; - Py_DECREF(result); - } - return 0; -} - -static FNFCIGETNEXTCABINET(cb_getnextcabinet) -{ - if (pv) { - _Py_IDENTIFIER(getnextcabinet); - - PyObject *result = _PyObject_CallMethodId(pv, &PyId_getnextcabinet, "i", pccab->iCab); - if (result == NULL) - return -1; - if (!PyBytes_Check(result)) { - PyErr_Format(PyExc_TypeError, - "Incorrect return type %s from getnextcabinet", - Py_TYPE(result)->tp_name); - Py_DECREF(result); - return FALSE; - } - strncpy(pccab->szCab, PyBytes_AsString(result), sizeof(pccab->szCab)); - return TRUE; - } - return FALSE; -} - -static FNFCIGETOPENINFO(cb_getopeninfo) -{ - BY_HANDLE_FILE_INFORMATION bhfi; - FILETIME filetime; - HANDLE handle; - - wchar_t *ws = utf8_to_wchar(pszName, err); - if (ws == NULL) { - return -1; - } - - /* Need Win32 handle to get time stamps */ - handle = CreateFileW(ws, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (handle == INVALID_HANDLE_VALUE) { - PyMem_Free(ws); - return -1; - } - - if (GetFileInformationByHandle(handle, &bhfi) == FALSE) { - CloseHandle(handle); - PyMem_Free(ws); - return -1; - } - - FileTimeToLocalFileTime(&bhfi.ftLastWriteTime, &filetime); - FileTimeToDosDateTime(&filetime, pdate, ptime); - - *pattribs = (int)(bhfi.dwFileAttributes & - (_A_RDONLY | _A_SYSTEM | _A_HIDDEN | _A_ARCH)); - - CloseHandle(handle); - - int result = _wopen(ws, _O_RDONLY | _O_BINARY | O_NOINHERIT); - PyMem_Free(ws); - return result; -} - -/*[clinic input] -_msi.FCICreate - cabname: str - the name of the CAB file - files: object - a list of tuples, each containing the name of the file on disk, - and the name of the file inside the CAB file - / - -Create a new CAB file. -[clinic start generated code]*/ - -static PyObject * -_msi_FCICreate_impl(PyObject *module, const char *cabname, PyObject *files) -/*[clinic end generated code: output=55dc05728361b799 input=1d2d75fdc8b44b71]*/ -{ - const char *p; - CCAB ccab; - HFCI hfci; - ERF erf; - Py_ssize_t i; - - if (!PyList_Check(files)) { - PyErr_SetString(PyExc_TypeError, "FCICreate expects a list"); - return NULL; - } - - ccab.cb = INT_MAX; /* no need to split CAB into multiple media */ - ccab.cbFolderThresh = 1000000; /* flush directory after this many bytes */ - ccab.cbReserveCFData = 0; - ccab.cbReserveCFFolder = 0; - ccab.cbReserveCFHeader = 0; - - ccab.iCab = 1; - ccab.iDisk = 1; - - ccab.setID = 0; - ccab.szDisk[0] = '\0'; - - for (i = 0, p = cabname; *p; p++) - if (*p == '\\' || *p == '/') - i = p - cabname + 1; - - if (i >= sizeof(ccab.szCabPath) || - strlen(cabname+i) >= sizeof(ccab.szCab)) { - PyErr_SetString(PyExc_ValueError, "path name too long"); - return 0; - } - - if (i > 0) { - memcpy(ccab.szCabPath, cabname, i); - ccab.szCabPath[i] = '\0'; - strcpy(ccab.szCab, cabname+i); - } else { - strcpy(ccab.szCabPath, ".\\"); - strcpy(ccab.szCab, cabname); - } - - hfci = FCICreate(&erf, cb_fileplaced, cb_alloc, cb_free, - cb_open, cb_read, cb_write, cb_close, cb_seek, cb_delete, - cb_gettempfile, &ccab, NULL); - - if (hfci == NULL) { - PyErr_Format(PyExc_ValueError, "FCI error %d", erf.erfOper); - return NULL; - } - - for (i=0; i < PyList_GET_SIZE(files); i++) { - PyObject *item = PyList_GET_ITEM(files, i); - char *filename, *cabname; - - if (!PyArg_ParseTuple(item, "ss", &filename, &cabname)) { - PyErr_SetString(PyExc_TypeError, "FCICreate expects a list of tuples containing two strings"); - FCIDestroy(hfci); - return NULL; - } - - if (!FCIAddFile(hfci, filename, cabname, FALSE, - cb_getnextcabinet, cb_status, cb_getopeninfo, - tcompTYPE_MSZIP)) - goto err; - } - - if (!FCIFlushCabinet(hfci, FALSE, cb_getnextcabinet, cb_status)) - goto err; - - if (!FCIDestroy(hfci)) - goto err; - - Py_RETURN_NONE; -err: - if(erf.fError) - PyErr_Format(PyExc_ValueError, "FCI error %d", erf.erfOper); /* XXX better error type */ - else - PyErr_SetString(PyExc_ValueError, "FCI general error"); - - FCIDestroy(hfci); - return NULL; -} - -typedef struct msiobj{ - PyObject_HEAD - MSIHANDLE h; -}msiobj; - -static void -msiobj_dealloc(msiobj* msidb) -{ - MsiCloseHandle(msidb->h); - msidb->h = 0; - PyObject_Free(msidb); -} - -static PyObject* -msierror(int status) -{ - int code; - char buf[2000]; - char *res = buf; - DWORD size = sizeof(buf); - MSIHANDLE err = MsiGetLastErrorRecord(); - - if (err == 0) { - switch(status) { - case ERROR_ACCESS_DENIED: - PyErr_SetString(MSIError, "access denied"); - return NULL; - case ERROR_FUNCTION_FAILED: - PyErr_SetString(MSIError, "function failed"); - return NULL; - case ERROR_INVALID_DATA: - PyErr_SetString(MSIError, "invalid data"); - return NULL; - case ERROR_INVALID_HANDLE: - PyErr_SetString(MSIError, "invalid handle"); - return NULL; - case ERROR_INVALID_STATE: - PyErr_SetString(MSIError, "invalid state"); - return NULL; - case ERROR_INVALID_PARAMETER: - PyErr_SetString(MSIError, "invalid parameter"); - return NULL; - case ERROR_OPEN_FAILED: - PyErr_SetString(MSIError, "open failed"); - return NULL; - case ERROR_CREATE_FAILED: - PyErr_SetString(MSIError, "create failed"); - return NULL; - default: - PyErr_Format(MSIError, "unknown error %x", status); - return NULL; - } - } - - code = MsiRecordGetInteger(err, 1); /* XXX code */ - if (MsiFormatRecord(0, err, res, &size) == ERROR_MORE_DATA) { - res = malloc(size+1); - if (res == NULL) { - MsiCloseHandle(err); - return PyErr_NoMemory(); - } - MsiFormatRecord(0, err, res, &size); - res[size]='\0'; - } - MsiCloseHandle(err); - PyErr_SetString(MSIError, res); - if (res != buf) - free(res); - return NULL; -} - -#include "clinic/_msi.c.h" - -/*[clinic input] -_msi.Database.Close - -Close the database object. -[clinic start generated code]*/ - -static PyObject * -_msi_Database_Close_impl(msiobj *self) -/*[clinic end generated code: output=ddf2d7712ea804f1 input=104330ce4a486187]*/ -{ - int status; - if ((status = MsiCloseHandle(self->h)) != ERROR_SUCCESS) { - return msierror(status); - } - self->h = 0; - Py_RETURN_NONE; -} - -/*************************** Record objects **********************/ - -/*[clinic input] -_msi.Record.GetFieldCount - -Return the number of fields of the record. -[clinic start generated code]*/ - -static PyObject * -_msi_Record_GetFieldCount_impl(msiobj *self) -/*[clinic end generated code: output=112795079c904398 input=5fb9d4071b28897b]*/ -{ - return PyLong_FromLong(MsiRecordGetFieldCount(self->h)); -} - -/*[clinic input] -_msi.Record.GetInteger - field: unsigned_int(bitwise=True) - / - -Return the value of field as an integer where possible. -[clinic start generated code]*/ - -static PyObject * -_msi_Record_GetInteger_impl(msiobj *self, unsigned int field) -/*[clinic end generated code: output=7174ebb6e8ed1c79 input=d19209947e2bfe61]*/ -{ - int status; - - status = MsiRecordGetInteger(self->h, field); - if (status == MSI_NULL_INTEGER){ - PyErr_SetString(MSIError, "could not convert record field to integer"); - return NULL; - } - return PyLong_FromLong((long) status); -} - -/*[clinic input] -_msi.Record.GetString - field: unsigned_int(bitwise=True) - / - -Return the value of field as a string where possible. -[clinic start generated code]*/ - -static PyObject * -_msi_Record_GetString_impl(msiobj *self, unsigned int field) -/*[clinic end generated code: output=f670d1b484cfa47c input=ffa11f21450b77d8]*/ -{ - unsigned int status; - WCHAR buf[2000]; - WCHAR *res = buf; - DWORD size = sizeof(buf); - PyObject* string; - - status = MsiRecordGetStringW(self->h, field, res, &size); - if (status == ERROR_MORE_DATA) { - res = (WCHAR*) malloc((size + 1)*sizeof(WCHAR)); - if (res == NULL) - return PyErr_NoMemory(); - status = MsiRecordGetStringW(self->h, field, res, &size); - } - if (status != ERROR_SUCCESS) - return msierror((int) status); - string = PyUnicode_FromWideChar(res, size); - if (buf != res) - free(res); - return string; -} - -/*[clinic input] -_msi.Record.ClearData - -Set all fields of the record to 0. -[clinic start generated code]*/ - -static PyObject * -_msi_Record_ClearData_impl(msiobj *self) -/*[clinic end generated code: output=1891467214b977f4 input=2a911c95aaded102]*/ -{ - int status = MsiRecordClearData(self->h); - if (status != ERROR_SUCCESS) - return msierror(status); - - Py_RETURN_NONE; -} - -/*[clinic input] -_msi.Record.SetString - field: int - value: Py_UNICODE - / - -Set field to a string value. -[clinic start generated code]*/ - -static PyObject * -_msi_Record_SetString_impl(msiobj *self, int field, const Py_UNICODE *value) -/*[clinic end generated code: output=2e37505b0f11f985 input=fb8ec70a2a6148e0]*/ -{ - int status; - - if ((status = MsiRecordSetStringW(self->h, field, value)) != ERROR_SUCCESS) - return msierror(status); - - Py_RETURN_NONE; -} - -/*[clinic input] -_msi.Record.SetStream - field: int - value: Py_UNICODE - / - -Set field to the contents of the file named value. -[clinic start generated code]*/ - -static PyObject * -_msi_Record_SetStream_impl(msiobj *self, int field, const Py_UNICODE *value) -/*[clinic end generated code: output=442facac16913b48 input=a07aa19b865e8292]*/ -{ - int status; - - if ((status = MsiRecordSetStreamW(self->h, field, value)) != ERROR_SUCCESS) - return msierror(status); - - Py_RETURN_NONE; -} - -/*[clinic input] -_msi.Record.SetInteger - field: int - value: int - / - -Set field to an integer value. -[clinic start generated code]*/ - -static PyObject * -_msi_Record_SetInteger_impl(msiobj *self, int field, int value) -/*[clinic end generated code: output=669e8647775d0ce7 input=c571aa775e7e451b]*/ -{ - int status; - - if ((status = MsiRecordSetInteger(self->h, field, value)) != ERROR_SUCCESS) - return msierror(status); - - Py_RETURN_NONE; -} - - - -static PyMethodDef record_methods[] = { - _MSI_RECORD_GETFIELDCOUNT_METHODDEF - _MSI_RECORD_GETINTEGER_METHODDEF - _MSI_RECORD_GETSTRING_METHODDEF - _MSI_RECORD_SETSTRING_METHODDEF - _MSI_RECORD_SETSTREAM_METHODDEF - _MSI_RECORD_SETINTEGER_METHODDEF - _MSI_RECORD_CLEARDATA_METHODDEF - { NULL, NULL } -}; - -static PyTypeObject record_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "_msi.Record", /*tp_name*/ - sizeof(msiobj), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)msiobj_dealloc, /*tp_dealloc*/ - 0, /*tp_vectorcall_offset*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_as_async*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - PyObject_GenericGetAttr,/*tp_getattro*/ - PyObject_GenericSetAttr,/*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - record_methods, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - 0, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ -}; - -static PyObject* -record_new(MSIHANDLE h) -{ - msiobj *result = PyObject_New(struct msiobj, &record_Type); - - if (!result) { - MsiCloseHandle(h); - return NULL; - } - - result->h = h; - return (PyObject*)result; -} - -/*************************** SummaryInformation objects **************/ - -/*[clinic input] -_msi.SummaryInformation.GetProperty - field: int - the name of the property, one of the PID_* constants - / - -Return a property of the summary. -[clinic start generated code]*/ - -static PyObject * -_msi_SummaryInformation_GetProperty_impl(msiobj *self, int field) -/*[clinic end generated code: output=f8946a33ee14f6ef input=f8dfe2c890d6cb8b]*/ -{ - int status; - PyObject *result; - UINT type; - INT ival; - FILETIME fval; - char sbuf[1000]; - char *sval = sbuf; - DWORD ssize = sizeof(sbuf); - - status = MsiSummaryInfoGetProperty(self->h, field, &type, &ival, - &fval, sval, &ssize); - if (status == ERROR_MORE_DATA) { - ssize++; - sval = malloc(ssize); - if (sval == NULL) { - return PyErr_NoMemory(); - } - status = MsiSummaryInfoGetProperty(self->h, field, &type, &ival, - &fval, sval, &ssize); - } - if (status != ERROR_SUCCESS) { - return msierror(status); - } - - switch(type) { - case VT_I2: - case VT_I4: - result = PyLong_FromLong(ival); - break; - case VT_FILETIME: - PyErr_SetString(PyExc_NotImplementedError, "FILETIME result"); - result = NULL; - break; - case VT_LPSTR: - result = PyBytes_FromStringAndSize(sval, ssize); - break; - case VT_EMPTY: - Py_INCREF(Py_None); - result = Py_None; - break; - default: - PyErr_Format(PyExc_NotImplementedError, "result of type %d", type); - result = NULL; - break; - } - if (sval != sbuf) - free(sval); - return result; -} - -/*[clinic input] -_msi.SummaryInformation.GetPropertyCount - -Return the number of summary properties. -[clinic start generated code]*/ - -static PyObject * -_msi_SummaryInformation_GetPropertyCount_impl(msiobj *self) -/*[clinic end generated code: output=68e94b2aeee92b3d input=2e71e985586d82dc]*/ -{ - int status; - UINT result; - - status = MsiSummaryInfoGetPropertyCount(self->h, &result); - if (status != ERROR_SUCCESS) - return msierror(status); - - return PyLong_FromLong(result); -} - -/*[clinic input] -_msi.SummaryInformation.SetProperty - field: int - the name of the property, one of the PID_* constants - value as data: object - the new value of the property (integer or string) - / - -Set a property. -[clinic start generated code]*/ - -static PyObject * -_msi_SummaryInformation_SetProperty_impl(msiobj *self, int field, - PyObject *data) -/*[clinic end generated code: output=3d4692c8984bb675 input=f2a7811b905abbed]*/ -{ - int status; - - if (PyUnicode_Check(data)) { -#if USE_UNICODE_WCHAR_CACHE - const WCHAR *value = _PyUnicode_AsUnicode(data); -#else /* USE_UNICODE_WCHAR_CACHE */ - WCHAR *value = PyUnicode_AsWideCharString(data, NULL); -#endif /* USE_UNICODE_WCHAR_CACHE */ - if (value == NULL) { - return NULL; - } - status = MsiSummaryInfoSetPropertyW(self->h, field, VT_LPSTR, - 0, NULL, value); -#if !USE_UNICODE_WCHAR_CACHE - PyMem_Free(value); -#endif /* USE_UNICODE_WCHAR_CACHE */ - } else if (PyLong_CheckExact(data)) { - long value = PyLong_AsLong(data); - if (value == -1 && PyErr_Occurred()) { - return NULL; - } - status = MsiSummaryInfoSetProperty(self->h, field, VT_I4, - value, NULL, NULL); - } else { - PyErr_SetString(PyExc_TypeError, "unsupported type"); - return NULL; - } - - if (status != ERROR_SUCCESS) - return msierror(status); - - Py_RETURN_NONE; -} - - -/*[clinic input] -_msi.SummaryInformation.Persist - -Write the modified properties to the summary information stream. -[clinic start generated code]*/ - -static PyObject * -_msi_SummaryInformation_Persist_impl(msiobj *self) -/*[clinic end generated code: output=c564bd17f5e122c9 input=e3dda9d530095ef7]*/ -{ - int status; - - status = MsiSummaryInfoPersist(self->h); - if (status != ERROR_SUCCESS) - return msierror(status); - Py_RETURN_NONE; -} - -static PyMethodDef summary_methods[] = { - _MSI_SUMMARYINFORMATION_GETPROPERTY_METHODDEF - _MSI_SUMMARYINFORMATION_GETPROPERTYCOUNT_METHODDEF - _MSI_SUMMARYINFORMATION_SETPROPERTY_METHODDEF - _MSI_SUMMARYINFORMATION_PERSIST_METHODDEF - { NULL, NULL } -}; - -static PyTypeObject summary_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "_msi.SummaryInformation", /*tp_name*/ - sizeof(msiobj), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)msiobj_dealloc, /*tp_dealloc*/ - 0, /*tp_vectorcall_offset*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_as_async*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - PyObject_GenericGetAttr,/*tp_getattro*/ - PyObject_GenericSetAttr,/*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - summary_methods, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - 0, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ -}; - -/*************************** View objects **************/ - -/*[clinic input] -_msi.View.Execute - params as oparams: object - a record describing actual values of the parameter tokens - in the query or None - / - -Execute the SQL query of the view. -[clinic start generated code]*/ - -static PyObject * -_msi_View_Execute(msiobj *self, PyObject *oparams) -/*[clinic end generated code: output=f0f65fd2900bcb4e input=cb163a15d453348e]*/ -{ - int status; - MSIHANDLE params = 0; - - if (oparams != Py_None) { - if (!Py_IS_TYPE(oparams, &record_Type)) { - PyErr_SetString(PyExc_TypeError, "Execute argument must be a record"); - return NULL; - } - params = ((msiobj*)oparams)->h; - } - - status = MsiViewExecute(self->h, params); - if (status != ERROR_SUCCESS) - return msierror(status); - - Py_RETURN_NONE; -} - -/*[clinic input] -_msi.View.Fetch - -Return a result record of the query. -[clinic start generated code]*/ - -static PyObject * -_msi_View_Fetch_impl(msiobj *self) -/*[clinic end generated code: output=ba154a3794537d4e input=7f3e3d06c449001c]*/ -{ - int status; - MSIHANDLE result; - - status = MsiViewFetch(self->h, &result); - if (status == ERROR_NO_MORE_ITEMS) { - Py_RETURN_NONE; - } else if (status != ERROR_SUCCESS) { - return msierror(status); - } - - return record_new(result); -} - -/*[clinic input] -_msi.View.GetColumnInfo - kind: int - MSICOLINFO_NAMES or MSICOLINFO_TYPES - / - -Return a record describing the columns of the view. -[clinic start generated code]*/ - -static PyObject * -_msi_View_GetColumnInfo_impl(msiobj *self, int kind) -/*[clinic end generated code: output=e7c1697db9403660 input=afedb892bf564a3b]*/ -{ - int status; - MSIHANDLE result; - - if ((status = MsiViewGetColumnInfo(self->h, kind, &result)) != ERROR_SUCCESS) - return msierror(status); - - return record_new(result); -} - -/*[clinic input] -_msi.View.Modify - kind: int - one of the MSIMODIFY_* constants - data: object - a record describing the new data - / - -Modify the view. -[clinic start generated code]*/ - -static PyObject * -_msi_View_Modify_impl(msiobj *self, int kind, PyObject *data) -/*[clinic end generated code: output=69aaf3ce8ddac0ba input=2828de22de0d47b4]*/ -{ - int status; - - if (!Py_IS_TYPE(data, &record_Type)) { - PyErr_SetString(PyExc_TypeError, "Modify expects a record object"); - return NULL; - } - - if ((status = MsiViewModify(self->h, kind, ((msiobj*)data)->h)) != ERROR_SUCCESS) - return msierror(status); - - Py_RETURN_NONE; -} - -/*[clinic input] -_msi.View.Close - -Close the view. -[clinic start generated code]*/ - -static PyObject * -_msi_View_Close_impl(msiobj *self) -/*[clinic end generated code: output=488f7b8645ca104a input=de6927d1308c401c]*/ -{ - int status; - - if ((status = MsiViewClose(self->h)) != ERROR_SUCCESS) - return msierror(status); - - Py_RETURN_NONE; -} - -static PyMethodDef view_methods[] = { - _MSI_VIEW_EXECUTE_METHODDEF - _MSI_VIEW_GETCOLUMNINFO_METHODDEF - _MSI_VIEW_FETCH_METHODDEF - _MSI_VIEW_MODIFY_METHODDEF - _MSI_VIEW_CLOSE_METHODDEF - { NULL, NULL } -}; - -static PyTypeObject msiview_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "_msi.View", /*tp_name*/ - sizeof(msiobj), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)msiobj_dealloc, /*tp_dealloc*/ - 0, /*tp_vectorcall_offset*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_as_async*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - PyObject_GenericGetAttr,/*tp_getattro*/ - PyObject_GenericSetAttr,/*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - view_methods, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - 0, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ -}; - -/*************************** Database objects **************/ - -/*[clinic input] -_msi.Database.OpenView - sql: Py_UNICODE - the SQL statement to execute - / - -Return a view object. -[clinic start generated code]*/ - -static PyObject * -_msi_Database_OpenView_impl(msiobj *self, const Py_UNICODE *sql) -/*[clinic end generated code: output=e712e6a11229abfd input=50f1771f37e500df]*/ -{ - int status; - MSIHANDLE hView; - msiobj *result; - - if ((status = MsiDatabaseOpenViewW(self->h, sql, &hView)) != ERROR_SUCCESS) - return msierror(status); - - result = PyObject_New(struct msiobj, &msiview_Type); - if (!result) { - MsiCloseHandle(hView); - return NULL; - } - - result->h = hView; - return (PyObject*)result; -} - -/*[clinic input] -_msi.Database.Commit - -Commit the changes pending in the current transaction. -[clinic start generated code]*/ - -static PyObject * -_msi_Database_Commit_impl(msiobj *self) -/*[clinic end generated code: output=f33021feb8b0cdd8 input=375bb120d402266d]*/ -{ - int status; - - if ((status = MsiDatabaseCommit(self->h)) != ERROR_SUCCESS) - return msierror(status); - - Py_RETURN_NONE; -} - -/*[clinic input] -_msi.Database.GetSummaryInformation - count: int - the maximum number of updated values - / - -Return a new summary information object. -[clinic start generated code]*/ - -static PyObject * -_msi_Database_GetSummaryInformation_impl(msiobj *self, int count) -/*[clinic end generated code: output=781e51a4ea4da847 input=18a899ead6521735]*/ -{ - int status; - MSIHANDLE result; - msiobj *oresult; - - status = MsiGetSummaryInformation(self->h, NULL, count, &result); - if (status != ERROR_SUCCESS) - return msierror(status); - - oresult = PyObject_New(struct msiobj, &summary_Type); - if (!oresult) { - MsiCloseHandle(result); - return NULL; - } - - oresult->h = result; - return (PyObject*)oresult; -} - -static PyMethodDef db_methods[] = { - _MSI_DATABASE_OPENVIEW_METHODDEF - _MSI_DATABASE_COMMIT_METHODDEF - _MSI_DATABASE_GETSUMMARYINFORMATION_METHODDEF - _MSI_DATABASE_CLOSE_METHODDEF - { NULL, NULL } -}; - -static PyTypeObject msidb_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "_msi.Database", /*tp_name*/ - sizeof(msiobj), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)msiobj_dealloc, /*tp_dealloc*/ - 0, /*tp_vectorcall_offset*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_as_async*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - PyObject_GenericGetAttr,/*tp_getattro*/ - PyObject_GenericSetAttr,/*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - db_methods, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - 0, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ -}; - -#define Py_NOT_PERSIST(x, flag) \ - (x != (SIZE_T)(flag) && \ - x != ((SIZE_T)(flag) | MSIDBOPEN_PATCHFILE)) - -#define Py_INVALID_PERSIST(x) \ - (Py_NOT_PERSIST(x, MSIDBOPEN_READONLY) && \ - Py_NOT_PERSIST(x, MSIDBOPEN_TRANSACT) && \ - Py_NOT_PERSIST(x, MSIDBOPEN_DIRECT) && \ - Py_NOT_PERSIST(x, MSIDBOPEN_CREATE) && \ - Py_NOT_PERSIST(x, MSIDBOPEN_CREATEDIRECT)) - -/*[clinic input] -_msi.OpenDatabase - path: Py_UNICODE - the file name of the MSI file - persist: int - the persistence mode - / - -Return a new database object. -[clinic start generated code]*/ - -static PyObject * -_msi_OpenDatabase_impl(PyObject *module, const Py_UNICODE *path, int persist) -/*[clinic end generated code: output=d34b7202b745de05 input=1300f3b97659559b]*/ -{ - int status; - MSIHANDLE h; - msiobj *result; - - /* We need to validate that persist is a valid MSIDBOPEN_* value. Otherwise, - MsiOpenDatabase may treat the value as a pointer, leading to unexpected - behavior. */ - if (Py_INVALID_PERSIST(persist)) - return msierror(ERROR_INVALID_PARAMETER); - status = MsiOpenDatabaseW(path, (LPCWSTR)(SIZE_T)persist, &h); - if (status != ERROR_SUCCESS) - return msierror(status); - - result = PyObject_New(struct msiobj, &msidb_Type); - if (!result) { - MsiCloseHandle(h); - return NULL; - } - result->h = h; - return (PyObject*)result; -} - -/*[clinic input] -_msi.CreateRecord - count: int - the number of fields of the record - / - -Return a new record object. -[clinic start generated code]*/ - -static PyObject * -_msi_CreateRecord_impl(PyObject *module, int count) -/*[clinic end generated code: output=0ba0a00beea3e99e input=53f17d5b5d9b077d]*/ -{ - MSIHANDLE h; - - h = MsiCreateRecord(count); - if (h == 0) - return msierror(0); - - return record_new(h); -} - - -static PyMethodDef msi_methods[] = { - _MSI_UUIDCREATE_METHODDEF - _MSI_FCICREATE_METHODDEF - _MSI_OPENDATABASE_METHODDEF - _MSI_CREATERECORD_METHODDEF - {NULL, NULL} /* sentinel */ -}; - -static char msi_doc[] = "Documentation"; - - -static struct PyModuleDef _msimodule = { - PyModuleDef_HEAD_INIT, - "_msi", - msi_doc, - -1, - msi_methods, - NULL, - NULL, - NULL, - NULL -}; - -PyMODINIT_FUNC -PyInit__msi(void) -{ - PyObject *m; - - m = PyModule_Create(&_msimodule); - if (m == NULL) - return NULL; - - PyModule_AddIntConstant(m, "MSIDBOPEN_CREATEDIRECT", (long)(SIZE_T)MSIDBOPEN_CREATEDIRECT); - PyModule_AddIntConstant(m, "MSIDBOPEN_CREATE", (long)(SIZE_T)MSIDBOPEN_CREATE); - PyModule_AddIntConstant(m, "MSIDBOPEN_DIRECT", (long)(SIZE_T)MSIDBOPEN_DIRECT); - PyModule_AddIntConstant(m, "MSIDBOPEN_READONLY", (long)(SIZE_T)MSIDBOPEN_READONLY); - PyModule_AddIntConstant(m, "MSIDBOPEN_TRANSACT", (long)(SIZE_T)MSIDBOPEN_TRANSACT); - PyModule_AddIntConstant(m, "MSIDBOPEN_PATCHFILE", (long)(SIZE_T)MSIDBOPEN_PATCHFILE); - - PyModule_AddIntMacro(m, MSICOLINFO_NAMES); - PyModule_AddIntMacro(m, MSICOLINFO_TYPES); - - PyModule_AddIntMacro(m, MSIMODIFY_SEEK); - PyModule_AddIntMacro(m, MSIMODIFY_REFRESH); - PyModule_AddIntMacro(m, MSIMODIFY_INSERT); - PyModule_AddIntMacro(m, MSIMODIFY_UPDATE); - PyModule_AddIntMacro(m, MSIMODIFY_ASSIGN); - PyModule_AddIntMacro(m, MSIMODIFY_REPLACE); - PyModule_AddIntMacro(m, MSIMODIFY_MERGE); - PyModule_AddIntMacro(m, MSIMODIFY_DELETE); - PyModule_AddIntMacro(m, MSIMODIFY_INSERT_TEMPORARY); - PyModule_AddIntMacro(m, MSIMODIFY_VALIDATE); - PyModule_AddIntMacro(m, MSIMODIFY_VALIDATE_NEW); - PyModule_AddIntMacro(m, MSIMODIFY_VALIDATE_FIELD); - PyModule_AddIntMacro(m, MSIMODIFY_VALIDATE_DELETE); - - PyModule_AddIntMacro(m, PID_CODEPAGE); - PyModule_AddIntMacro(m, PID_TITLE); - PyModule_AddIntMacro(m, PID_SUBJECT); - PyModule_AddIntMacro(m, PID_AUTHOR); - PyModule_AddIntMacro(m, PID_KEYWORDS); - PyModule_AddIntMacro(m, PID_COMMENTS); - PyModule_AddIntMacro(m, PID_TEMPLATE); - PyModule_AddIntMacro(m, PID_LASTAUTHOR); - PyModule_AddIntMacro(m, PID_REVNUMBER); - PyModule_AddIntMacro(m, PID_LASTPRINTED); - PyModule_AddIntMacro(m, PID_CREATE_DTM); - PyModule_AddIntMacro(m, PID_LASTSAVE_DTM); - PyModule_AddIntMacro(m, PID_PAGECOUNT); - PyModule_AddIntMacro(m, PID_WORDCOUNT); - PyModule_AddIntMacro(m, PID_CHARCOUNT); - PyModule_AddIntMacro(m, PID_APPNAME); - PyModule_AddIntMacro(m, PID_SECURITY); - - MSIError = PyErr_NewException ("_msi.MSIError", NULL, NULL); - if (!MSIError) - return NULL; - PyModule_AddObject(m, "MSIError", MSIError); - return m; -} diff --git a/PC/_testconsole.c b/PC/_testconsole.c deleted file mode 100644 index db84f73c7744f39fcd5cdc19172d6f1234d5ca1c..0000000000000000000000000000000000000000 --- a/PC/_testconsole.c +++ /dev/null @@ -1,133 +0,0 @@ - -/* Testing module for multi-phase initialization of extension modules (PEP 489) - */ - -#include "Python.h" - -#ifdef MS_WINDOWS - -#include "..\modules\_io\_iomodule.h" - -#define WIN32_LEAN_AND_MEAN -#include -#include - - /* The full definition is in iomodule. We reproduce - enough here to get the fd, which is all we want. */ -typedef struct { - PyObject_HEAD - int fd; -} winconsoleio; - - -static int execfunc(PyObject *m) -{ - return 0; -} - -PyModuleDef_Slot testconsole_slots[] = { - {Py_mod_exec, execfunc}, - {0, NULL}, -}; - -/*[clinic input] -module _testconsole - -_testconsole.write_input - file: object - s: PyBytesObject - -Writes UTF-16-LE encoded bytes to the console as if typed by a user. -[clinic start generated code]*/ - -static PyObject * -_testconsole_write_input_impl(PyObject *module, PyObject *file, - PyBytesObject *s) -/*[clinic end generated code: output=48f9563db34aedb3 input=4c774f2d05770bc6]*/ -{ - INPUT_RECORD *rec = NULL; - - if (!PyWindowsConsoleIO_Check(file)) { - PyErr_SetString(PyExc_TypeError, "expected raw console object"); - return NULL; - } - - const wchar_t *p = (const wchar_t *)PyBytes_AS_STRING(s); - DWORD size = (DWORD)PyBytes_GET_SIZE(s) / sizeof(wchar_t); - - rec = (INPUT_RECORD*)PyMem_Calloc(size, sizeof(INPUT_RECORD)); - if (!rec) - goto error; - - INPUT_RECORD *prec = rec; - for (DWORD i = 0; i < size; ++i, ++p, ++prec) { - prec->EventType = KEY_EVENT; - prec->Event.KeyEvent.bKeyDown = TRUE; - prec->Event.KeyEvent.wRepeatCount = 1; - prec->Event.KeyEvent.uChar.UnicodeChar = *p; - } - - HANDLE hInput = _Py_get_osfhandle(((winconsoleio*)file)->fd); - if (hInput == INVALID_HANDLE_VALUE) - goto error; - - DWORD total = 0; - while (total < size) { - DWORD wrote; - if (!WriteConsoleInputW(hInput, &rec[total], (size - total), &wrote)) { - PyErr_SetFromWindowsErr(0); - goto error; - } - total += wrote; - } - - PyMem_Free((void*)rec); - - Py_RETURN_NONE; -error: - if (rec) - PyMem_Free((void*)rec); - return NULL; -} - -/*[clinic input] -_testconsole.read_output - file: object - -Reads a str from the console as written to stdout. -[clinic start generated code]*/ - -static PyObject * -_testconsole_read_output_impl(PyObject *module, PyObject *file) -/*[clinic end generated code: output=876310d81a73e6d2 input=b3521f64b1b558e3]*/ -{ - Py_RETURN_NONE; -} - -#include "clinic\_testconsole.c.h" - -PyMethodDef testconsole_methods[] = { - _TESTCONSOLE_WRITE_INPUT_METHODDEF - _TESTCONSOLE_READ_OUTPUT_METHODDEF - {NULL, NULL} -}; - -static PyModuleDef testconsole_def = { - PyModuleDef_HEAD_INIT, /* m_base */ - "_testconsole", /* m_name */ - PyDoc_STR("Test module for the Windows console"), /* m_doc */ - 0, /* m_size */ - testconsole_methods, /* m_methods */ - testconsole_slots, /* m_slots */ - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL, /* m_free */ -}; - -PyMODINIT_FUNC -PyInit__testconsole(PyObject *spec) -{ - return PyModuleDef_Init(&testconsole_def); -} - -#endif /* MS_WINDOWS */ diff --git a/PC/classicAppCompat.can.xml b/PC/classicAppCompat.can.xml deleted file mode 100644 index df361f8e3e2cd3248ffb9e82ff442483abaf9400..0000000000000000000000000000000000000000 --- a/PC/classicAppCompat.can.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/PC/classicAppCompat.cat b/PC/classicAppCompat.cat deleted file mode 100644 index 3d213596accffa255e1443126228f7ab1bb2899c..0000000000000000000000000000000000000000 Binary files a/PC/classicAppCompat.cat and /dev/null differ diff --git a/PC/classicAppCompat.sccd b/PC/classicAppCompat.sccd deleted file mode 100644 index d7a70cdd0533c3dd385ea081612765e05a136229..0000000000000000000000000000000000000000 --- a/PC/classicAppCompat.sccd +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MIIucgYJKoZIhvcNAQcCoIIuYzCCLl8CAQExDzANBglghkgBZQMEAgEFADCCARAGCSsGAQQBgjcKAaCCAQEwgf4wDAYKKwYBBAGCNwwBAQQQ293slyDTMUOmVyeQqmcNSBcNMjIwMjA0MDkwNjU2WjAOBgorBgEEAYI3DAEDBQAwgbwwKgQUdgFpbn9QXi/ly4CZFKA2Eimoq6YxEjAQBgorBgEEAYI3DAIDMQKCADCBjQQg3YHMbvV3unL0mx/RJ8ihTJd1C/SYSnMHbN0yMrWijuQxaTAQBgorBgEEAYI3DAIDMQKCADBVBgorBgEEAYI3AgEEMUcwRTAQBgorBgEEAYI3AgEZogKAADAxMA0GCWCGSAFlAwQCAQUABCDdgcxu9Xe6cvSbH9EnyKFMl3UL9JhKcwds3TIytaKO5KCCE8owggYEMIID7KADAgECAhMzAA/d9uEraWrDsxZGAAAAD932MA0GCSqGSIb3DQEBCwUAMIGLMQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMQwwCgYDVQQLEwNBT0MxJzAlBgNVBAMTHk1pY3Jvc29mdCBNYXJrZXRwbGFjZSBDQSBHIDAyMjAeFw0yMjAyMDQwODU5MzZaFw0yMjAyMDcwODU5MzZaMC8xLTArBgNVBAMTJDQ2ZTIwYzY2LTUxNTEtNDNhOS05MWQ4LTMwNDY0ZGZhMDg4ZjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALaMR5Ajlp2POidTxT0N47z5sukiE9fqMuI1QimTXIfB2/gPdMsNUbVCD57ha8J1DUJQpO5nuunbk3SONwfDTdWKx9u7zWubpEmgG7hZ8LTKFlF+xhS6lS/FBSSHyXpdScWPg62BMnDysqHMH/AjLw26HNPRWK8A0vx9jsalFwLg15u4MPuKN3Bpawr/OL0B+7eh/dGO3PutAqJ4aZs2lUCIyODg0q3Tzhgi7SIvFacFWJ8Qj6+D3AfasOv8oanfpNLLPhPlxXGEK9sMKHOOb8mTU9V/ibERqEKTHkJ24Vu+BwrXq5eVedtwmHT2WWR7teaIvrUT9AiPmMhx4hIF/0MCAwEAAaOCAbowggG2MBgGA1UdJQEB/wQOMAwGCisGAQQBgjdMHAEwHQYDVR0OBBYEFB4NpkpeSLk/j691tPw97rB4XKDJMA0GA1UdEQQGMASCAlVTMB8GA1UdIwQYMBaAFPeC7EkBPjJR1eFAcP4hAMeQ72IPMF8GA1UdHwRYMFYwVKBSoFCGTmh0dHA6Ly93d3cubWljcm9zb2Z0LmNvbS9wa2lvcHMvY3JsL01pY3Jvc29mdCUyME1hcmtldHBsYWNlJTIwQ0ElMjBHJTIwMDIyLmNybDBsBggrBgEFBQcBAQRgMF4wXAYIKwYBBQUHMAKGUGh0dHA6Ly93d3cubWljcm9zb2Z0LmNvbS9wa2lvcHMvY2VydHMvTWljcm9zb2Z0JTIwTWFya2V0cGxhY2UlMjBDQSUyMEclMjAwMjIuY3J0MAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgXgMDwGCSsGAQQBgjcVBwQvMC0GJSsGAQQBgjcVCIOS9kTqrxCDkY0wgqzgLIKinDE0g+6NOIaE7wACAWQCARcwIAYJKwYBBAGCNxUKAQH/BBAwDjAMBgorBgEEAYI3TBwBMA0GCSqGSIb3DQEBCwUAA4ICAQBAiJuIJeMS+PMrxG+kwPWT7yy7A6P8trchwtXyYep/WXu7xT2tH2ys3wuP4DYG5CY4nKekjTKraQhZGuYj4r4KrUviShe8ZWMIcK4MRduXAU81UOd/fsCq5djQ6NDN4Bzq1TxjwZKiEMEWmXaunj6XAlDSX3SgyyMb/ywmur8VVKO+xFVkOxAqCjNo1VaCv3zEvr3Y6dUwO9gYQui1bAQVQzdxRYUPEJlsFBmbNL1AnZ39r4/9K/6orxavU4qwkj4cXnhtMYKDjTIIbTBrfD4glP6mnmkcZpN0ItfEAVgU9rGpXg84hQLeP83nBs2Y8DrF3bBF9867dJCl90c5rK1DMcelmH3oUAwqZ3U+jIIj3HGyfefAQ6HPL0yiY9OYLXQZUxcZF13m92l5s7dy2C21cIh0W0iTcWPIhNn9cia4Hr7FabTC0RoQkO1bg0PKvPMnoe0AqEVmPKImNDncg538AjPy2qeUxn7+0kcuZWEdKVAPwWfzh5qvSAmYKk4XNBfN2E40GQ0ruRdvMVMFeYBLXKm4SJR6zoiBa5v7qzt1uQqZf6GD4BNFZivBp0P2B9lTubEAU6SmUsazRnEVmekIO+x7gDuXbMS8tv6mb1pbGCtIV/wRcIYNcDkHKTHMbW5xR/OmGTM3mPRxoMQtaWtxIeagZkU2nl+pElA/0h7pIjCCBtcwggS/oAMCAQICCmESRKIAAAAAAAIwDQYJKoZIhvcNAQELBQAwgYgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xMjAwBgNVBAMTKU1pY3Jvc29mdCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAyMDExMB4XDTExMDMyODIxMDkzOVoXDTMxMDMyODIxMTkzOVowfTELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEnMCUGA1UEAxMeTWljcm9zb2Z0IE1hcmtldFBsYWNlIFBDQSAyMDExMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAubUaSwGYVsE3MAnPfvmozUhAB3qxBABgJRW1vDp4+tVinXxD32f7k1K89JQ6zDOgS/iDgULC+yFK1K/1Qjac/0M7P6c8v5LSjnWGlERLa/qY32j46S7SLQcit3g2jgoTTO03eUG+9yHZUTGV/FJdRYB8uXhrznJBa+Y+yGwiQKF+m6XFeBH/KORoKFx+dmMoy9EWJ/m/o9IiUj2kzm9C691+vZ/I2w0Bj93W9SPPkV2PCNHlzgfIAoeajWpHmi38Wi3xZHonkzAVBHxPsCBppOoNsWvmAfUM7eBthkSPvFruekyDCPNEYhfGqgqtqLkoBebXLZCOVybF7wTQaLvse60//3P003icRcCoQYgY4NAqrF7j80o5U7DkeXxcB0xvengsaKgiAaV1DKkRbpe98wCqr1AASvm5rAJUYMU+mXmOieV2EelY2jGrenWe9FQpNXYV1NoWBh0WKoFxttoWYAnF705bIWtSZsz08ZfK6WLX4GXNLcPBlgCzfTm1sdKYASWdBbH2haaNhPapFhQQBJHKwnVW2iXErImhuPi45W3MVTZ5D9ASshZx69cLYY6xAdIa+89Kf/uRrsGOVZfahDuDw+NI183iAyzC8z/QRt2P32LYxP0xrCdqVh+DJo2i4NoE8Uk1usCdbVRuBMBQl/AwpOTq7IMvHGElf65CqzUCAwEAAaOCAUswggFHMBAGCSsGAQQBgjcVAQQDAgEAMB0GA1UdDgQWBBQPU8s/FmEl/mCJHdO5fOiQrbOU0TAZBgkrBgEEAYI3FAIEDB4KAFMAdQBiAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBRyLToCMZBDuRQFTuHqp8cx0SOJNDBaBgNVHR8EUzBRME+gTaBLhklodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpL2NybC9wcm9kdWN0cy9NaWNSb29DZXJBdXQyMDExXzIwMTFfMDNfMjIuY3JsMF4GCCsGAQUFBwEBBFIwUDBOBggrBgEFBQcwAoZCaHR0cDovL3d3dy5taWNyb3NvZnQuY29tL3BraS9jZXJ0cy9NaWNSb29DZXJBdXQyMDExXzIwMTFfMDNfMjIuY3J0MA0GCSqGSIb3DQEBCwUAA4ICAQCjuZmM8ZVNDgp9wHsL4RY8KJ8nLinvxFTphNGCrxaLknkYG5pmMhVlX+UB/tSiW8W13W60nggz9u5xwMx7v/1t/Tgm6g2brVyOKI5A7u6/2SIJwkJKFw953K0YIKVT28w9zl8dSJnmRnyR0G86ncWbF6CLQ6A6lBQ9o2mTGVqDr4m35WKAnc6YxUUM1y74mbzFFZr63VHsCcOp3pXWnUqAY1rb6Q6NX1b3clncKqLFm0EjKHcQ56grTbwuuB7pMdh/IFCJR01MQzQbDtpEisbOeZUi43YVAAHKqI1EO9bRwg3frCjwAbml9MmI4utMW94gWFgvrMxIX+n42RBDIjf3Ot3jkT6gt3XeTTmO9bptgblZimhERdkFRUFpVtkocJeLoGuuzP93uH/Yp032wzRH+XmMgujfZv+vnfllJqxdowoQLx55FxLLeTeYfwi/xMSjZO2gNven3U/3KeSCd1kUOFS3AOrwZ0UNOXJeW5JQC6Vfd1BavFZ6FAta1fMLu3WFvNB+FqeHUaU3ya7rmtxJnzk29DeSqXgGNmVSywBS4NajI5jJIKAA6UhNJlsg8CHYwUOKf5ej8OoQCkbadUxXygAfxCfW2YBbujtI+PoyejRFxWUjYFWO5LeTI62UMyqfOEiqugoYjNxmQZla2s4YHVuqIC34R85FQlg9pKQBsDCCBuMwggTLoAMCAQICEzMAAABLZz0Eed1JFCkAAAAAAEswDQYJKoZIhvcNAQELBQAwfTELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEnMCUGA1UEAxMeTWljcm9zb2Z0IE1hcmtldFBsYWNlIFBDQSAyMDExMB4XDTE5MDQxODIwNDUwNFoXDTI0MDQxODIwNDUwNFowgYsxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xDDAKBgNVBAsTA0FPQzEnMCUGA1UEAxMeTWljcm9zb2Z0IE1hcmtldHBsYWNlIENBIEcgMDIyMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAzGfV5tDxZ3oPG8aq2OwrBLSRFC61lYvWtkqOdKswlBHVncuoOIzekLIFNsMwluoK0plNZ5w/JPmwkGTGIrt9ftbWQz0k7XRfacXvQQfhCaBgjkybvvDx7CTL0UDEUiXfEEkylUcQKOdm9LApPDP4oO/V8RS4ugkqkjsuVaOyfYv0TytjVVQon72W+wR/AyrBAXgfwzzEb85403GTJRzQMlTw1YqdgS/o9SCsvH9dRZTGlWCatIl+a00eTG5zgeu0xCtqwgERhw9UT6mlPqmp6RqJ8XMgKylh9Ss+jI53EmraAFlelph16kuqF6n3vNnRBfhQ+gmNdtKi9s3jI8Di7ip8hYGPHGGhtcw0AYUg5r/VQhIfXxO45zO7SFvjujX0ji0b3WKB/xD9Sg1KO1fiTpj82ifyPqHvL+iwn5dV98C4ru0dQ0hfK7tA4K5qkW+2gym0fBjGYWq81/smrj6LbPdNqCotgTMU4dCMBhmSJOD9fSiPUybrbHJrHGR5YNs5VJbHH5u1ia8UrgsSrGTb1bh38Tb10matJpBI7NwDWTkV7kMvgNRQsGO/1+dg47PLW3X7TbiZniTPC+oAqOh1CiF+ODnem4Nw1iRw854LN3yqibLHgTi093mCBtPGWZxg2sTcHUX4fo/UHNbSh8bERJznnennm4gEJXAYtpnEFSUCAwEAAaOCAUswggFHMA4GA1UdDwEB/wQEAwIBhjAQBgkrBgEEAYI3FQEEAwIBADAdBgNVHQ4EFgQU94LsSQE+MlHV4UBw/iEAx5DvYg8wGQYJKwYBBAGCNxQCBAweCgBTAHUAYgBDAEEwEgYDVR0TAQH/BAgwBgEB/wIBADAfBgNVHSMEGDAWgBQPU8s/FmEl/mCJHdO5fOiQrbOU0TBXBgNVHR8EUDBOMEygSqBIhkZodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpL2NybC9wcm9kdWN0cy9NaWNNYXJQQ0EyMDExXzIwMTEtMDMtMjguY3JsMFsGCCsGAQUFBwEBBE8wTTBLBggrBgEFBQcwAoY/aHR0cDovL3d3dy5taWNyb3NvZnQuY29tL3BraS9jZXJ0cy9NaWNNYXJQQ0EyMDExXzIwMTEtMDMtMjguY3J0MA0GCSqGSIb3DQEBCwUAA4ICAQAbTWps31OnBv77EVpCaU68drubToSKtpw9fYt4MvAhorXGRrRRfS6qou5o45QZAKjwzbOrr33dWxF4P3gCGqZxCotW32p6hlXGP7BnYlVw6242nlX0PahgpyWVWBmi0ElKH8N6HYhJqAW74tUNCzY7ALNMwk/JVEMKpWq+5XqutAEmtP0SdoSZPRwPtdiRjMLS8yyjP4HVAiKJ+m0wV3bLBtCG20BttEGkly7fYa2/E0ps41PLeX3T2yKRgmnGjhD16NUcMDdRpBh7MCXktwpISDEanB8QySJNdErU+NaKukgOW68+Oyk7lGiiZcG3boCGNec9JkM7dQdpA4tneQg0FI/o0mkDZR5aVItbAjRfMgAXpm6Hfu9DqOP+/R0K9v+CwyhwEjF3+SeL8YBAijXHD5YaiWzwZzBDtNQpuOXc91NmF7ifdHVy9IE1EhuIIQsMio3l0Uo87vGdwQ50po8o1F72zi1vfvKfDmszVezk6fF7cy7fZYh8I0ceVbZ4XY4xJ76TdYMItUAoPkvVdDq5B/d4oI7/xHfomRsEw08fuLxCRE8/BcvzSlDpnxu4wL6IULqVwHE+fbQ82Lr5ZDLxa1dYUw8zBGgCnx/ObVPj1RO1CaVi13wCxm8yaHeflKJWw7ZHOLeOGQyMRT+f9cFFk+5fzCA9GcwiSlEyYj4ilzGCGWUwghlhAgEBMIGjMIGLMQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMQwwCgYDVQQLEwNBT0MxJzAlBgNVBAMTHk1pY3Jvc29mdCBNYXJrZXRwbGFjZSBDQSBHIDAyMgITMwAP3fbhK2lqw7MWRgAAAA/d9jANBglghkgBZQMEAgEFAKCBjzAYBgkqhkiG9w0BCQMxCwYJKwYBBAGCNwoBMC8GCSqGSIb3DQEJBDEiBCBDgOMhvMousTIzk/P1eC2qGiSJLdSm3brGanFMLa41+DBCBgorBgEEAYI3AgEMMTQwMqAUgBIATQBpAGMAcgBvAHMAbwBmAHShGoAYaHR0cDovL3d3dy5taWNyb3NvZnQuY29tMA0GCSqGSIb3DQEBAQUABIIBAJ8LEwzLh2rDfLOOOodKT10yXoCzHPaQLv9sMwei+650mqV0iHaw9bUolBZAdBnF7JBRjY+yb9AIF7M/Av9pHRKvuLHWDntlo49RrfvNucHaJqPjCMm81h/GAuimPSBMpRtTCW+HHDWrw+HoGbRWQ+N/Vpt//pzj9gAzOzs8W9gU0RMz3ub4Hfgunm/CGACjFu5Hi2sjJbgigNlyRnxjI4+h3J7dGVOfR8hlhRB9YjXDB700F0bzaKqxC9LH7kZbAjiHPgLLCWz7OQ/rTo7wV5/e6v9GCKpamydPy/0MObq4TDi0fn75aVHTJJrzlwt1BJKyVPdAsOhiFUH3Mq4WheKhghcAMIIW/AYKKwYBBAGCNwMDATGCFuwwghboBgkqhkiG9w0BBwKgghbZMIIW1QIBAzEPMA0GCWCGSAFlAwQCAQUAMIIBUQYLKoZIhvcNAQkQAQSgggFABIIBPDCCATgCAQEGCisGAQQBhFkKAwEwMTANBglghkgBZQMEAgEFAAQgr34HNu5gF3j5DAITqq38vc6sNxs6ZqLz9i9zU2oQDtoCBmH66bcTCRgTMjAyMjAyMDQwOTA5NDkuNTkxWjAEgAIB9KCB0KSBzTCByjELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjElMCMGA1UECxMcTWljcm9zb2Z0IEFtZXJpY2EgT3BlcmF0aW9uczEmMCQGA1UECxMdVGhhbGVzIFRTUyBFU046REQ4Qy1FMzM3LTJGQUUxJTAjBgNVBAMTHE1pY3Jvc29mdCBUaW1lLVN0YW1wIFNlcnZpY2WgghFXMIIHDDCCBPSgAwIBAgITMwAAAZwPpk1h0p5LKAABAAABnDANBgkqhkiG9w0BAQsFADB8MQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSYwJAYDVQQDEx1NaWNyb3NvZnQgVGltZS1TdGFtcCBQQ0EgMjAxMDAeFw0yMTEyMDIxOTA1MTlaFw0yMzAyMjgxOTA1MTlaMIHKMQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSUwIwYDVQQLExxNaWNyb3NvZnQgQW1lcmljYSBPcGVyYXRpb25zMSYwJAYDVQQLEx1UaGFsZXMgVFNTIEVTTjpERDhDLUUzMzctMkZBRTElMCMGA1UEAxMcTWljcm9zb2Z0IFRpbWUtU3RhbXAgU2VydmljZTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANtSKgwZXUkWP6zrXazTaYq7bco9Q2zvU6MN4ka3GRMX2tJZOK4DxeBiQACL/n7YV/sKTslwpD0f9cPU4rCDX9sfcTWo7XPxdHLQ+WkaGbKKWATsqw69bw8hkJ/bjcp2V2A6vGsvwcqJCh07BK3JPmUtZikyy5PZ8fyTyiKGN7hOWlaIU9oIoucUNoAHQJzLq8h20eNgHUh7eI5k+Kyq4v6810LHuA6EHyKJOZN2xTw5JSkLy0FN5Mhg/OaFrFBl3iag2Tqp4InKLt+Jbh/Jd0etnei2aDHFrmlfPmlRSv5wSNX5zAhgEyRpjmQcz1zp0QaSAefRkMm923/ngU51IbrVbAeHj569SHC9doHgsIxkh0K3lpw582+0ONXcIfIU6nkBT+qADAZ+0dT1uu/gRTBy614QAofjo258TbSX9aOU1SHuAC+3bMoyM7jNdHEJROH+msFDBcmJRl4VKsReI5+S69KUGeLIBhhmnmQ6drF8Ip0ZiO+vhAsD3e9AnqnY7Hcge850I9oKvwuwpVwWnKnwwSGElMz7UvCocmoUMXk7Vn2aNti+bdH28+GQb5EMsqhOmvuZOCRpOWN33G+b3g5unwEP0eTiY+LnWa2AuK43z/pplURJVle29K42QPkOcglB6sjLmNpEpb9basJ72eA0Mlp1LtH3oYZGXsggTfuXAgMBAAGjggE2MIIBMjAdBgNVHQ4EFgQUu2kJZ1Ndjl2112SynL6jGMID+rIwHwYDVR0jBBgwFoAUn6cVXQBeYl2D9OXSZacbUzUZ6XIwXwYDVR0fBFgwVjBUoFKgUIZOaHR0cDovL3d3dy5taWNyb3NvZnQuY29tL3BraW9wcy9jcmwvTWljcm9zb2Z0JTIwVGltZS1TdGFtcCUyMFBDQSUyMDIwMTAoMSkuY3JsMGwGCCsGAQUFBwEBBGAwXjBcBggrBgEFBQcwAoZQaHR0cDovL3d3dy5taWNyb3NvZnQuY29tL3BraW9wcy9jZXJ0cy9NaWNyb3NvZnQlMjBUaW1lLVN0YW1wJTIwUENBJTIwMjAxMCgxKS5jcnQwDAYDVR0TAQH/BAIwADATBgNVHSUEDDAKBggrBgEFBQcDCDANBgkqhkiG9w0BAQsFAAOCAgEApwAqpiMYRzNNYyz3PSbtijbeyCpUXcvIrqA4zPtMIcAk34W9u9mRDndWS+tlR3WwTpr1OgaV1wmc6YFzqK6EGWm903UEsFE7xBJMPXjfdVOPhcJB3vfvA0PX56oobcF2OvNsOSwTB8bi/ns+Cs39Puzs+QSNQZd8iAVBCSvxNCL78dln2RGU1xyB4AKqV9vi4Y/Gfmx2FA+jF0y+YLeob0M40nlSxL0q075t7L6iFRMNr0u8ROhzhDPLl+4ePYfUmyYJoobvydel9anAEsHFlhKl+aXb2ic3yNwbsoPycZJL/vo8OVvYYxCy+/5FrQmAvoW0ZEaBiYcKkzrNWt/hX9r5KgdwL61x0ZiTZopTko6W/58UTefTbhX7Pni0MApH3Pvyt6N0IFap+/LlwFRD1zn7e6ccPTwESnuo/auCmgPznq80OATA7vufsRZPvqeX8jKtsraSNscvNQymEWlcqdXV9hYkjb4T/Qse9cUYaoXg68wFHFuslWfTdPYPLl1vqzlPMnNJpC8KtdioDgcq+y1BaSqSm8EdNfwzT37+/JFtVc3Gs915fDqgPZDgOSzKQIV+fw3aPYt2LET3AbmKKW/r13Oy8cg3+D0D362GQBAJVv0NRI5NowgaCw6oNgWOFPrN72WSEcca/8QQiTGP2XpLiGpRDJZ6sWRpRYNdydkwggdxMIIFWaADAgECAhMzAAAAFcXna54Cm0mZAAAAAAAVMA0GCSqGSIb3DQEBCwUAMIGIMQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTIwMAYDVQQDEylNaWNyb3NvZnQgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgMjAxMDAeFw0yMTA5MzAxODIyMjVaFw0zMDA5MzAxODMyMjVaMHwxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xJjAkBgNVBAMTHU1pY3Jvc29mdCBUaW1lLVN0YW1wIFBDQSAyMDEwMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA5OGmTOe0ciELeaLL1yR5vQ7VgtP97pwHB9KpbE51yMo1V/YBf2xK4OK9uT4XYDP/XE/HZveVU3Fa4n5KWv64NmeFRiMMtY0Tz3cywBAY6GB9alKDRLemjkZrBxTzxXb1hlDcwUTIcVxRMTegCjhuje3XD9gmU3w5YQJ6xKr9cmmvHaus9ja+NSZk2pg7uhp7M62AW36MEBydUv626GIl3GoPz130/o5Tz9bshVZN7928jaTjkY+yOSxRnOlwaQ3KNi1wjjHINSi947SHJMPgyY9+tVSP3PoFVZhtaDuaRr3tpK56KTesy+uDRedGbsoy1cCGMFxPLOJiss254o2I5JasAUq7vnGpF1tnYN74kpEeHT39IM9zfUGaRnXNxF803RKJ1v2lIH1+/NmeRd+2ci/bfV+AutuqfjbsNkz2K26oElHovwUDo9Fzpk03dJQcNIIP8BDyt0cY7afomXw/TNuvXsLz1dhzPUNOwTM5TI4CvEJoLhDqhFFG4tG9ahhaYQFzymeiXtcodgLiMxhy16cg8ML6EgrXY28MyTZki1ugpoMhXV8wdJGUlNi5UPkLiWHzNgY1GIRH29wb0f2y1BzFa/ZcUlFdEtsluq9QBXpsxREdcu+N+VLEhReTwDwV2xo3xwgVGD94q0W29R6HXtqPnhZyacaue7e3PmriLq0CAwEAAaOCAd0wggHZMBIGCSsGAQQBgjcVAQQFAgMBAAEwIwYJKwYBBAGCNxUCBBYEFCqnUv5kxJq+gpE8RjUpzxD/LwTuMB0GA1UdDgQWBBSfpxVdAF5iXYP05dJlpxtTNRnpcjBcBgNVHSAEVTBTMFEGDCsGAQQBgjdMg30BATBBMD8GCCsGAQUFBwIBFjNodHRwOi8vd3d3Lm1pY3Jvc29mdC5jb20vcGtpb3BzL0RvY3MvUmVwb3NpdG9yeS5odG0wEwYDVR0lBAwwCgYIKwYBBQUHAwgwGQYJKwYBBAGCNxQCBAweCgBTAHUAYgBDAEEwCwYDVR0PBAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAU1fZWy4/oolxiaNE9lJBb186aGMQwVgYDVR0fBE8wTTBLoEmgR4ZFaHR0cDovL2NybC5taWNyb3NvZnQuY29tL3BraS9jcmwvcHJvZHVjdHMvTWljUm9vQ2VyQXV0XzIwMTAtMDYtMjMuY3JsMFoGCCsGAQUFBwEBBE4wTDBKBggrBgEFBQcwAoY+aHR0cDovL3d3dy5taWNyb3NvZnQuY29tL3BraS9jZXJ0cy9NaWNSb29DZXJBdXRfMjAxMC0wNi0yMy5jcnQwDQYJKoZIhvcNAQELBQADggIBAJ1VffwqreEsH2cBMSRb4Z5yS/ypb+pcFLY+TkdkeLEGk5c9MTO1OdfCcTY/2mRsfNB1OW27DzHkwo/7bNGhlBgi7ulmZzpTTd2YurYeeNg2LpypglYAA7AFvonoaeC6Ce5732pvvinLbtg/SHUB2RjebYIM9W0jVOR4U3UkV7ndn/OOPcbzaN9l9qRWqveVtihVJ9AkvUCgvxm2EhIRXT0n4ECWOKz3+SmJw7wXsFSFQrP8DJ6LGYnn8AtqgcKBGUIZUnWKNsIdw2FzLixre24/LAl4FOmRsqlb30mjdAy87JGA0j3mSj5mO0+7hvoyGtmW9I/2kQH2zsZ0/fZMcm8Qq3UwxTSwethQ/gpY3UA8x1RtnWN0SCyxTkctwRQEcb9k+SS+c23Kjgm9swFXSVRk2XPXfx5bRAGOWhmRaw2fpCjcZxkoJLo4S5pu+yFUa2pFEUep8beuyOiJXk+d0tBMdrVXVAmxaQFEfnyhYWxz/gq77EFmPWn9y8FBSX5+k77L+DvktxW/tM4+pTFRhLy/AsGConsXHRWJjXD+57XQKBqJC4822rpM+Zv/Cuk0+CQ1ZyvgDbjmjJnW4SLq8CdCPSWU5nR0W2rRnj7tfqAxM328y+l7vzhwRNGQ8cirOoo6CGJ/2XBjU02N7oJtpQUQwXEGahC0HVUzWLOhcGbyoYICzjCCAjcCAQEwgfihgdCkgc0wgcoxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xJTAjBgNVBAsTHE1pY3Jvc29mdCBBbWVyaWNhIE9wZXJhdGlvbnMxJjAkBgNVBAsTHVRoYWxlcyBUU1MgRVNOOkREOEMtRTMzNy0yRkFFMSUwIwYDVQQDExxNaWNyb3NvZnQgVGltZS1TdGFtcCBTZXJ2aWNloiMKAQEwBwYFKw4DAhoDFQDN2Wnq3fCz9ucStub1zQz7129TQKCBgzCBgKR+MHwxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xJjAkBgNVBAMTHU1pY3Jvc29mdCBUaW1lLVN0YW1wIFBDQSAyMDEwMA0GCSqGSIb3DQEBBQUAAgUA5adiZjAiGA8yMDIyMDIwNDE2MjkyNloYDzIwMjIwMjA1MTYyOTI2WjB3MD0GCisGAQQBhFkKBAExLzAtMAoCBQDlp2JmAgEAMAoCAQACAh92AgH/MAcCAQACAhFfMAoCBQDlqLPmAgEAMDYGCisGAQQBhFkKBAIxKDAmMAwGCisGAQQBhFkKAwKgCjAIAgEAAgMHoSChCjAIAgEAAgMBhqAwDQYJKoZIhvcNAQEFBQADgYEAbKzHReDTwgAKGSkgO/zxCAV/RcxwGpZK4M2bWgwqHVIi+/xiAKdQOSKeMz3UwRO4LI4EN4BjeK+ATpruzOtVGkyA8yzwdJFPv99j4O/Hc5kJSvovfECah62tBB3siNIFaAYNK+BF76k3j4+y9q9lF5yjQ8ZylVYbOfOjlJ2uevsxggQNMIIECQIBATCBkzB8MQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSYwJAYDVQQDEx1NaWNyb3NvZnQgVGltZS1TdGFtcCBQQ0EgMjAxMAITMwAAAZwPpk1h0p5LKAABAAABnDANBglghkgBZQMEAgEFAKCCAUowGgYJKoZIhvcNAQkDMQ0GCyqGSIb3DQEJEAEEMC8GCSqGSIb3DQEJBDEiBCD10XWSucJFd8jLe5PaC9h9/GHXK7ZZ0kb4BGFNqgWk9DCB+gYLKoZIhvcNAQkQAi8xgeowgecwgeQwgb0EIDcPRYUgjSzKOhF39d4QgbRZQgrPO7Lo/qE5GtvSeqa8MIGYMIGApH4wfDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEmMCQGA1UEAxMdTWljcm9zb2Z0IFRpbWUtU3RhbXAgUENBIDIwMTACEzMAAAGcD6ZNYdKeSygAAQAAAZwwIgQgPTEmgx6rn5xpH+xmlpYkcn0dL16GyYRqyG8uRajrfTYwDQYJKoZIhvcNAQELBQAEggIAxmSLisdd5cs+7liXX7vsF8zX3Y1rbtyPZ0M466WBaVULlfeuu9RMzOhWha7bkfYmKs5hXOQNBJrIHxnHbWeDu/V7EVF80IQ7/6qWiVPNcLtMnS8+uyw3Tby2gEhshO/HHOJRqllrgtUGuPl8FoAAPbPKV7X7jrg1kqOWoqpwyiSzt5cN/qijwfTcTIaPeON5wMd8wRT2l5F9e/JDBSq0WuzYb2r0kifv9wq21orm4sQkbg5GgDa/oCr3PQVCNSvPb2G7HANcqJXHeRKyoCeVhX5UaFrCQbdxGFytOc5GzptQKNn18yGg4VYrFpigUcglLbuREqqlPabwZh/QfgKdp4b4uVA6On5HIV5e9XdJ9TXhvDArEQ+Kgyao5xlgb4MkvPO9Thh9UIbw9r3JhQ+uKnCvXyiE2SpTLq1OXTjt/RrLZb+qsZW4nrDRBlBswa4G5OVW/svvI8N2/+YYrSdaCWt4unWSnSxeVUWZkugBmWdeoEJpfs5Qy8NwC+g1TyXcMjolOFTfBB6JYpHCbk6Euh2gKxq5weBb7puxVN4cvawYY2zorp6ZXtAmQGflZTl02nWld+nvDoF/zi6IUmP7PTKvbEVs8T+QkCiIM7cpLMs4NFK29f33lu1iZeGwJAxCYsV/P7geuRfA++bpDutTXjLKMqUTgf00sqJ/5HGuwLE= diff --git a/PC/clinic/_msi.c.h b/PC/clinic/_msi.c.h deleted file mode 100644 index 85c4d226ee408cad4a63dadfde17365431539df0..0000000000000000000000000000000000000000 --- a/PC/clinic/_msi.c.h +++ /dev/null @@ -1,716 +0,0 @@ -/*[clinic input] -preserve -[clinic start generated code]*/ - -PyDoc_STRVAR(_msi_UuidCreate__doc__, -"UuidCreate($module, /)\n" -"--\n" -"\n" -"Return the string representation of a new unique identifier."); - -#define _MSI_UUIDCREATE_METHODDEF \ - {"UuidCreate", (PyCFunction)_msi_UuidCreate, METH_NOARGS, _msi_UuidCreate__doc__}, - -static PyObject * -_msi_UuidCreate_impl(PyObject *module); - -static PyObject * -_msi_UuidCreate(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _msi_UuidCreate_impl(module); -} - -PyDoc_STRVAR(_msi_FCICreate__doc__, -"FCICreate($module, cabname, files, /)\n" -"--\n" -"\n" -"Create a new CAB file.\n" -"\n" -" cabname\n" -" the name of the CAB file\n" -" files\n" -" a list of tuples, each containing the name of the file on disk,\n" -" and the name of the file inside the CAB file"); - -#define _MSI_FCICREATE_METHODDEF \ - {"FCICreate", (PyCFunction)(void(*)(void))_msi_FCICreate, METH_FASTCALL, _msi_FCICreate__doc__}, - -static PyObject * -_msi_FCICreate_impl(PyObject *module, const char *cabname, PyObject *files); - -static PyObject * -_msi_FCICreate(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - const char *cabname; - PyObject *files; - - if (!_PyArg_CheckPositional("FCICreate", nargs, 2, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("FCICreate", "argument 1", "str", args[0]); - goto exit; - } - Py_ssize_t cabname_length; - cabname = PyUnicode_AsUTF8AndSize(args[0], &cabname_length); - if (cabname == NULL) { - goto exit; - } - if (strlen(cabname) != (size_t)cabname_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } - files = args[1]; - return_value = _msi_FCICreate_impl(module, cabname, files); - -exit: - return return_value; -} - -PyDoc_STRVAR(_msi_Database_Close__doc__, -"Close($self, /)\n" -"--\n" -"\n" -"Close the database object."); - -#define _MSI_DATABASE_CLOSE_METHODDEF \ - {"Close", (PyCFunction)_msi_Database_Close, METH_NOARGS, _msi_Database_Close__doc__}, - -static PyObject * -_msi_Database_Close_impl(msiobj *self); - -static PyObject * -_msi_Database_Close(msiobj *self, PyObject *Py_UNUSED(ignored)) -{ - return _msi_Database_Close_impl(self); -} - -PyDoc_STRVAR(_msi_Record_GetFieldCount__doc__, -"GetFieldCount($self, /)\n" -"--\n" -"\n" -"Return the number of fields of the record."); - -#define _MSI_RECORD_GETFIELDCOUNT_METHODDEF \ - {"GetFieldCount", (PyCFunction)_msi_Record_GetFieldCount, METH_NOARGS, _msi_Record_GetFieldCount__doc__}, - -static PyObject * -_msi_Record_GetFieldCount_impl(msiobj *self); - -static PyObject * -_msi_Record_GetFieldCount(msiobj *self, PyObject *Py_UNUSED(ignored)) -{ - return _msi_Record_GetFieldCount_impl(self); -} - -PyDoc_STRVAR(_msi_Record_GetInteger__doc__, -"GetInteger($self, field, /)\n" -"--\n" -"\n" -"Return the value of field as an integer where possible."); - -#define _MSI_RECORD_GETINTEGER_METHODDEF \ - {"GetInteger", (PyCFunction)_msi_Record_GetInteger, METH_O, _msi_Record_GetInteger__doc__}, - -static PyObject * -_msi_Record_GetInteger_impl(msiobj *self, unsigned int field); - -static PyObject * -_msi_Record_GetInteger(msiobj *self, PyObject *arg) -{ - PyObject *return_value = NULL; - unsigned int field; - - field = (unsigned int)PyLong_AsUnsignedLongMask(arg); - if (field == (unsigned int)-1 && PyErr_Occurred()) { - goto exit; - } - return_value = _msi_Record_GetInteger_impl(self, field); - -exit: - return return_value; -} - -PyDoc_STRVAR(_msi_Record_GetString__doc__, -"GetString($self, field, /)\n" -"--\n" -"\n" -"Return the value of field as a string where possible."); - -#define _MSI_RECORD_GETSTRING_METHODDEF \ - {"GetString", (PyCFunction)_msi_Record_GetString, METH_O, _msi_Record_GetString__doc__}, - -static PyObject * -_msi_Record_GetString_impl(msiobj *self, unsigned int field); - -static PyObject * -_msi_Record_GetString(msiobj *self, PyObject *arg) -{ - PyObject *return_value = NULL; - unsigned int field; - - field = (unsigned int)PyLong_AsUnsignedLongMask(arg); - if (field == (unsigned int)-1 && PyErr_Occurred()) { - goto exit; - } - return_value = _msi_Record_GetString_impl(self, field); - -exit: - return return_value; -} - -PyDoc_STRVAR(_msi_Record_ClearData__doc__, -"ClearData($self, /)\n" -"--\n" -"\n" -"Set all fields of the record to 0."); - -#define _MSI_RECORD_CLEARDATA_METHODDEF \ - {"ClearData", (PyCFunction)_msi_Record_ClearData, METH_NOARGS, _msi_Record_ClearData__doc__}, - -static PyObject * -_msi_Record_ClearData_impl(msiobj *self); - -static PyObject * -_msi_Record_ClearData(msiobj *self, PyObject *Py_UNUSED(ignored)) -{ - return _msi_Record_ClearData_impl(self); -} - -PyDoc_STRVAR(_msi_Record_SetString__doc__, -"SetString($self, field, value, /)\n" -"--\n" -"\n" -"Set field to a string value."); - -#define _MSI_RECORD_SETSTRING_METHODDEF \ - {"SetString", (PyCFunction)(void(*)(void))_msi_Record_SetString, METH_FASTCALL, _msi_Record_SetString__doc__}, - -static PyObject * -_msi_Record_SetString_impl(msiobj *self, int field, const Py_UNICODE *value); - -static PyObject * -_msi_Record_SetString(msiobj *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int field; - const Py_UNICODE *value; - - if (!_PyArg_CheckPositional("SetString", nargs, 2, 2)) { - goto exit; - } - field = _PyLong_AsInt(args[0]); - if (field == -1 && PyErr_Occurred()) { - goto exit; - } - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("SetString", "argument 2", "str", args[1]); - goto exit; - } - #if USE_UNICODE_WCHAR_CACHE - value = _PyUnicode_AsUnicode(args[1]); - #else /* USE_UNICODE_WCHAR_CACHE */ - value = PyUnicode_AsWideCharString(args[1], NULL); - #endif /* USE_UNICODE_WCHAR_CACHE */ - if (value == NULL) { - goto exit; - } - return_value = _msi_Record_SetString_impl(self, field, value); - -exit: - /* Cleanup for value */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)value); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(_msi_Record_SetStream__doc__, -"SetStream($self, field, value, /)\n" -"--\n" -"\n" -"Set field to the contents of the file named value."); - -#define _MSI_RECORD_SETSTREAM_METHODDEF \ - {"SetStream", (PyCFunction)(void(*)(void))_msi_Record_SetStream, METH_FASTCALL, _msi_Record_SetStream__doc__}, - -static PyObject * -_msi_Record_SetStream_impl(msiobj *self, int field, const Py_UNICODE *value); - -static PyObject * -_msi_Record_SetStream(msiobj *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int field; - const Py_UNICODE *value; - - if (!_PyArg_CheckPositional("SetStream", nargs, 2, 2)) { - goto exit; - } - field = _PyLong_AsInt(args[0]); - if (field == -1 && PyErr_Occurred()) { - goto exit; - } - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("SetStream", "argument 2", "str", args[1]); - goto exit; - } - #if USE_UNICODE_WCHAR_CACHE - value = _PyUnicode_AsUnicode(args[1]); - #else /* USE_UNICODE_WCHAR_CACHE */ - value = PyUnicode_AsWideCharString(args[1], NULL); - #endif /* USE_UNICODE_WCHAR_CACHE */ - if (value == NULL) { - goto exit; - } - return_value = _msi_Record_SetStream_impl(self, field, value); - -exit: - /* Cleanup for value */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)value); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(_msi_Record_SetInteger__doc__, -"SetInteger($self, field, value, /)\n" -"--\n" -"\n" -"Set field to an integer value."); - -#define _MSI_RECORD_SETINTEGER_METHODDEF \ - {"SetInteger", (PyCFunction)(void(*)(void))_msi_Record_SetInteger, METH_FASTCALL, _msi_Record_SetInteger__doc__}, - -static PyObject * -_msi_Record_SetInteger_impl(msiobj *self, int field, int value); - -static PyObject * -_msi_Record_SetInteger(msiobj *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int field; - int value; - - if (!_PyArg_CheckPositional("SetInteger", nargs, 2, 2)) { - goto exit; - } - field = _PyLong_AsInt(args[0]); - if (field == -1 && PyErr_Occurred()) { - goto exit; - } - value = _PyLong_AsInt(args[1]); - if (value == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _msi_Record_SetInteger_impl(self, field, value); - -exit: - return return_value; -} - -PyDoc_STRVAR(_msi_SummaryInformation_GetProperty__doc__, -"GetProperty($self, field, /)\n" -"--\n" -"\n" -"Return a property of the summary.\n" -"\n" -" field\n" -" the name of the property, one of the PID_* constants"); - -#define _MSI_SUMMARYINFORMATION_GETPROPERTY_METHODDEF \ - {"GetProperty", (PyCFunction)_msi_SummaryInformation_GetProperty, METH_O, _msi_SummaryInformation_GetProperty__doc__}, - -static PyObject * -_msi_SummaryInformation_GetProperty_impl(msiobj *self, int field); - -static PyObject * -_msi_SummaryInformation_GetProperty(msiobj *self, PyObject *arg) -{ - PyObject *return_value = NULL; - int field; - - field = _PyLong_AsInt(arg); - if (field == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _msi_SummaryInformation_GetProperty_impl(self, field); - -exit: - return return_value; -} - -PyDoc_STRVAR(_msi_SummaryInformation_GetPropertyCount__doc__, -"GetPropertyCount($self, /)\n" -"--\n" -"\n" -"Return the number of summary properties."); - -#define _MSI_SUMMARYINFORMATION_GETPROPERTYCOUNT_METHODDEF \ - {"GetPropertyCount", (PyCFunction)_msi_SummaryInformation_GetPropertyCount, METH_NOARGS, _msi_SummaryInformation_GetPropertyCount__doc__}, - -static PyObject * -_msi_SummaryInformation_GetPropertyCount_impl(msiobj *self); - -static PyObject * -_msi_SummaryInformation_GetPropertyCount(msiobj *self, PyObject *Py_UNUSED(ignored)) -{ - return _msi_SummaryInformation_GetPropertyCount_impl(self); -} - -PyDoc_STRVAR(_msi_SummaryInformation_SetProperty__doc__, -"SetProperty($self, field, value, /)\n" -"--\n" -"\n" -"Set a property.\n" -"\n" -" field\n" -" the name of the property, one of the PID_* constants\n" -" value\n" -" the new value of the property (integer or string)"); - -#define _MSI_SUMMARYINFORMATION_SETPROPERTY_METHODDEF \ - {"SetProperty", (PyCFunction)(void(*)(void))_msi_SummaryInformation_SetProperty, METH_FASTCALL, _msi_SummaryInformation_SetProperty__doc__}, - -static PyObject * -_msi_SummaryInformation_SetProperty_impl(msiobj *self, int field, - PyObject *data); - -static PyObject * -_msi_SummaryInformation_SetProperty(msiobj *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int field; - PyObject *data; - - if (!_PyArg_CheckPositional("SetProperty", nargs, 2, 2)) { - goto exit; - } - field = _PyLong_AsInt(args[0]); - if (field == -1 && PyErr_Occurred()) { - goto exit; - } - data = args[1]; - return_value = _msi_SummaryInformation_SetProperty_impl(self, field, data); - -exit: - return return_value; -} - -PyDoc_STRVAR(_msi_SummaryInformation_Persist__doc__, -"Persist($self, /)\n" -"--\n" -"\n" -"Write the modified properties to the summary information stream."); - -#define _MSI_SUMMARYINFORMATION_PERSIST_METHODDEF \ - {"Persist", (PyCFunction)_msi_SummaryInformation_Persist, METH_NOARGS, _msi_SummaryInformation_Persist__doc__}, - -static PyObject * -_msi_SummaryInformation_Persist_impl(msiobj *self); - -static PyObject * -_msi_SummaryInformation_Persist(msiobj *self, PyObject *Py_UNUSED(ignored)) -{ - return _msi_SummaryInformation_Persist_impl(self); -} - -PyDoc_STRVAR(_msi_View_Execute__doc__, -"Execute($self, params, /)\n" -"--\n" -"\n" -"Execute the SQL query of the view.\n" -"\n" -" params\n" -" a record describing actual values of the parameter tokens\n" -" in the query or None"); - -#define _MSI_VIEW_EXECUTE_METHODDEF \ - {"Execute", (PyCFunction)_msi_View_Execute, METH_O, _msi_View_Execute__doc__}, - -PyDoc_STRVAR(_msi_View_Fetch__doc__, -"Fetch($self, /)\n" -"--\n" -"\n" -"Return a result record of the query."); - -#define _MSI_VIEW_FETCH_METHODDEF \ - {"Fetch", (PyCFunction)_msi_View_Fetch, METH_NOARGS, _msi_View_Fetch__doc__}, - -static PyObject * -_msi_View_Fetch_impl(msiobj *self); - -static PyObject * -_msi_View_Fetch(msiobj *self, PyObject *Py_UNUSED(ignored)) -{ - return _msi_View_Fetch_impl(self); -} - -PyDoc_STRVAR(_msi_View_GetColumnInfo__doc__, -"GetColumnInfo($self, kind, /)\n" -"--\n" -"\n" -"Return a record describing the columns of the view.\n" -"\n" -" kind\n" -" MSICOLINFO_NAMES or MSICOLINFO_TYPES"); - -#define _MSI_VIEW_GETCOLUMNINFO_METHODDEF \ - {"GetColumnInfo", (PyCFunction)_msi_View_GetColumnInfo, METH_O, _msi_View_GetColumnInfo__doc__}, - -static PyObject * -_msi_View_GetColumnInfo_impl(msiobj *self, int kind); - -static PyObject * -_msi_View_GetColumnInfo(msiobj *self, PyObject *arg) -{ - PyObject *return_value = NULL; - int kind; - - kind = _PyLong_AsInt(arg); - if (kind == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _msi_View_GetColumnInfo_impl(self, kind); - -exit: - return return_value; -} - -PyDoc_STRVAR(_msi_View_Modify__doc__, -"Modify($self, kind, data, /)\n" -"--\n" -"\n" -"Modify the view.\n" -"\n" -" kind\n" -" one of the MSIMODIFY_* constants\n" -" data\n" -" a record describing the new data"); - -#define _MSI_VIEW_MODIFY_METHODDEF \ - {"Modify", (PyCFunction)(void(*)(void))_msi_View_Modify, METH_FASTCALL, _msi_View_Modify__doc__}, - -static PyObject * -_msi_View_Modify_impl(msiobj *self, int kind, PyObject *data); - -static PyObject * -_msi_View_Modify(msiobj *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int kind; - PyObject *data; - - if (!_PyArg_CheckPositional("Modify", nargs, 2, 2)) { - goto exit; - } - kind = _PyLong_AsInt(args[0]); - if (kind == -1 && PyErr_Occurred()) { - goto exit; - } - data = args[1]; - return_value = _msi_View_Modify_impl(self, kind, data); - -exit: - return return_value; -} - -PyDoc_STRVAR(_msi_View_Close__doc__, -"Close($self, /)\n" -"--\n" -"\n" -"Close the view."); - -#define _MSI_VIEW_CLOSE_METHODDEF \ - {"Close", (PyCFunction)_msi_View_Close, METH_NOARGS, _msi_View_Close__doc__}, - -static PyObject * -_msi_View_Close_impl(msiobj *self); - -static PyObject * -_msi_View_Close(msiobj *self, PyObject *Py_UNUSED(ignored)) -{ - return _msi_View_Close_impl(self); -} - -PyDoc_STRVAR(_msi_Database_OpenView__doc__, -"OpenView($self, sql, /)\n" -"--\n" -"\n" -"Return a view object.\n" -"\n" -" sql\n" -" the SQL statement to execute"); - -#define _MSI_DATABASE_OPENVIEW_METHODDEF \ - {"OpenView", (PyCFunction)_msi_Database_OpenView, METH_O, _msi_Database_OpenView__doc__}, - -static PyObject * -_msi_Database_OpenView_impl(msiobj *self, const Py_UNICODE *sql); - -static PyObject * -_msi_Database_OpenView(msiobj *self, PyObject *arg) -{ - PyObject *return_value = NULL; - const Py_UNICODE *sql; - - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("OpenView", "argument", "str", arg); - goto exit; - } - #if USE_UNICODE_WCHAR_CACHE - sql = _PyUnicode_AsUnicode(arg); - #else /* USE_UNICODE_WCHAR_CACHE */ - sql = PyUnicode_AsWideCharString(arg, NULL); - #endif /* USE_UNICODE_WCHAR_CACHE */ - if (sql == NULL) { - goto exit; - } - return_value = _msi_Database_OpenView_impl(self, sql); - -exit: - /* Cleanup for sql */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)sql); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(_msi_Database_Commit__doc__, -"Commit($self, /)\n" -"--\n" -"\n" -"Commit the changes pending in the current transaction."); - -#define _MSI_DATABASE_COMMIT_METHODDEF \ - {"Commit", (PyCFunction)_msi_Database_Commit, METH_NOARGS, _msi_Database_Commit__doc__}, - -static PyObject * -_msi_Database_Commit_impl(msiobj *self); - -static PyObject * -_msi_Database_Commit(msiobj *self, PyObject *Py_UNUSED(ignored)) -{ - return _msi_Database_Commit_impl(self); -} - -PyDoc_STRVAR(_msi_Database_GetSummaryInformation__doc__, -"GetSummaryInformation($self, count, /)\n" -"--\n" -"\n" -"Return a new summary information object.\n" -"\n" -" count\n" -" the maximum number of updated values"); - -#define _MSI_DATABASE_GETSUMMARYINFORMATION_METHODDEF \ - {"GetSummaryInformation", (PyCFunction)_msi_Database_GetSummaryInformation, METH_O, _msi_Database_GetSummaryInformation__doc__}, - -static PyObject * -_msi_Database_GetSummaryInformation_impl(msiobj *self, int count); - -static PyObject * -_msi_Database_GetSummaryInformation(msiobj *self, PyObject *arg) -{ - PyObject *return_value = NULL; - int count; - - count = _PyLong_AsInt(arg); - if (count == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _msi_Database_GetSummaryInformation_impl(self, count); - -exit: - return return_value; -} - -PyDoc_STRVAR(_msi_OpenDatabase__doc__, -"OpenDatabase($module, path, persist, /)\n" -"--\n" -"\n" -"Return a new database object.\n" -"\n" -" path\n" -" the file name of the MSI file\n" -" persist\n" -" the persistence mode"); - -#define _MSI_OPENDATABASE_METHODDEF \ - {"OpenDatabase", (PyCFunction)(void(*)(void))_msi_OpenDatabase, METH_FASTCALL, _msi_OpenDatabase__doc__}, - -static PyObject * -_msi_OpenDatabase_impl(PyObject *module, const Py_UNICODE *path, int persist); - -static PyObject * -_msi_OpenDatabase(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - const Py_UNICODE *path; - int persist; - - if (!_PyArg_CheckPositional("OpenDatabase", nargs, 2, 2)) { - goto exit; - } - if (!PyUnicode_Check(args[0])) { - _PyArg_BadArgument("OpenDatabase", "argument 1", "str", args[0]); - goto exit; - } - #if USE_UNICODE_WCHAR_CACHE - path = _PyUnicode_AsUnicode(args[0]); - #else /* USE_UNICODE_WCHAR_CACHE */ - path = PyUnicode_AsWideCharString(args[0], NULL); - #endif /* USE_UNICODE_WCHAR_CACHE */ - if (path == NULL) { - goto exit; - } - persist = _PyLong_AsInt(args[1]); - if (persist == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _msi_OpenDatabase_impl(module, path, persist); - -exit: - /* Cleanup for path */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)path); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(_msi_CreateRecord__doc__, -"CreateRecord($module, count, /)\n" -"--\n" -"\n" -"Return a new record object.\n" -"\n" -" count\n" -" the number of fields of the record"); - -#define _MSI_CREATERECORD_METHODDEF \ - {"CreateRecord", (PyCFunction)_msi_CreateRecord, METH_O, _msi_CreateRecord__doc__}, - -static PyObject * -_msi_CreateRecord_impl(PyObject *module, int count); - -static PyObject * -_msi_CreateRecord(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int count; - - count = _PyLong_AsInt(arg); - if (count == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _msi_CreateRecord_impl(module, count); - -exit: - return return_value; -} -/*[clinic end generated code: output=49debf733ee5cab2 input=a9049054013a1b77]*/ diff --git a/PC/clinic/_testconsole.c.h b/PC/clinic/_testconsole.c.h deleted file mode 100644 index cf5e4ee09063aaa9149261f5a2fc7d41a8e2f684..0000000000000000000000000000000000000000 --- a/PC/clinic/_testconsole.c.h +++ /dev/null @@ -1,91 +0,0 @@ -/*[clinic input] -preserve -[clinic start generated code]*/ - -#if defined(MS_WINDOWS) - -PyDoc_STRVAR(_testconsole_write_input__doc__, -"write_input($module, /, file, s)\n" -"--\n" -"\n" -"Writes UTF-16-LE encoded bytes to the console as if typed by a user."); - -#define _TESTCONSOLE_WRITE_INPUT_METHODDEF \ - {"write_input", (PyCFunction)(void(*)(void))_testconsole_write_input, METH_FASTCALL|METH_KEYWORDS, _testconsole_write_input__doc__}, - -static PyObject * -_testconsole_write_input_impl(PyObject *module, PyObject *file, - PyBytesObject *s); - -static PyObject * -_testconsole_write_input(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"file", "s", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "write_input", 0}; - PyObject *argsbuf[2]; - PyObject *file; - PyBytesObject *s; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { - goto exit; - } - file = args[0]; - if (!PyBytes_Check(args[1])) { - _PyArg_BadArgument("write_input", "argument 's'", "bytes", args[1]); - goto exit; - } - s = (PyBytesObject *)args[1]; - return_value = _testconsole_write_input_impl(module, file, s); - -exit: - return return_value; -} - -#endif /* defined(MS_WINDOWS) */ - -#if defined(MS_WINDOWS) - -PyDoc_STRVAR(_testconsole_read_output__doc__, -"read_output($module, /, file)\n" -"--\n" -"\n" -"Reads a str from the console as written to stdout."); - -#define _TESTCONSOLE_READ_OUTPUT_METHODDEF \ - {"read_output", (PyCFunction)(void(*)(void))_testconsole_read_output, METH_FASTCALL|METH_KEYWORDS, _testconsole_read_output__doc__}, - -static PyObject * -_testconsole_read_output_impl(PyObject *module, PyObject *file); - -static PyObject * -_testconsole_read_output(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"file", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "read_output", 0}; - PyObject *argsbuf[1]; - PyObject *file; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); - if (!args) { - goto exit; - } - file = args[0]; - return_value = _testconsole_read_output_impl(module, file); - -exit: - return return_value; -} - -#endif /* defined(MS_WINDOWS) */ - -#ifndef _TESTCONSOLE_WRITE_INPUT_METHODDEF - #define _TESTCONSOLE_WRITE_INPUT_METHODDEF -#endif /* !defined(_TESTCONSOLE_WRITE_INPUT_METHODDEF) */ - -#ifndef _TESTCONSOLE_READ_OUTPUT_METHODDEF - #define _TESTCONSOLE_READ_OUTPUT_METHODDEF -#endif /* !defined(_TESTCONSOLE_READ_OUTPUT_METHODDEF) */ -/*[clinic end generated code: output=dd8b093a91b62753 input=a9049054013a1b77]*/ diff --git a/PC/clinic/msvcrtmodule.c.h b/PC/clinic/msvcrtmodule.c.h deleted file mode 100644 index 1ac82cb965b6439da9ab1c5f219a006cefe15565..0000000000000000000000000000000000000000 --- a/PC/clinic/msvcrtmodule.c.h +++ /dev/null @@ -1,650 +0,0 @@ -/*[clinic input] -preserve -[clinic start generated code]*/ - -PyDoc_STRVAR(msvcrt_heapmin__doc__, -"heapmin($module, /)\n" -"--\n" -"\n" -"Minimize the malloc() heap.\n" -"\n" -"Force the malloc() heap to clean itself up and return unused blocks\n" -"to the operating system. On failure, this raises OSError."); - -#define MSVCRT_HEAPMIN_METHODDEF \ - {"heapmin", (PyCFunction)msvcrt_heapmin, METH_NOARGS, msvcrt_heapmin__doc__}, - -static PyObject * -msvcrt_heapmin_impl(PyObject *module); - -static PyObject * -msvcrt_heapmin(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return msvcrt_heapmin_impl(module); -} - -PyDoc_STRVAR(msvcrt_locking__doc__, -"locking($module, fd, mode, nbytes, /)\n" -"--\n" -"\n" -"Lock part of a file based on file descriptor fd from the C runtime.\n" -"\n" -"Raises OSError on failure. The locked region of the file extends from\n" -"the current file position for nbytes bytes, and may continue beyond\n" -"the end of the file. mode must be one of the LK_* constants listed\n" -"below. Multiple regions in a file may be locked at the same time, but\n" -"may not overlap. Adjacent regions are not merged; they must be unlocked\n" -"individually."); - -#define MSVCRT_LOCKING_METHODDEF \ - {"locking", (PyCFunction)(void(*)(void))msvcrt_locking, METH_FASTCALL, msvcrt_locking__doc__}, - -static PyObject * -msvcrt_locking_impl(PyObject *module, int fd, int mode, long nbytes); - -static PyObject * -msvcrt_locking(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int fd; - int mode; - long nbytes; - - if (!_PyArg_CheckPositional("locking", nargs, 3, 3)) { - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - mode = _PyLong_AsInt(args[1]); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } - nbytes = PyLong_AsLong(args[2]); - if (nbytes == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = msvcrt_locking_impl(module, fd, mode, nbytes); - -exit: - return return_value; -} - -PyDoc_STRVAR(msvcrt_setmode__doc__, -"setmode($module, fd, mode, /)\n" -"--\n" -"\n" -"Set the line-end translation mode for the file descriptor fd.\n" -"\n" -"To set it to text mode, flags should be os.O_TEXT; for binary, it\n" -"should be os.O_BINARY.\n" -"\n" -"Return value is the previous mode."); - -#define MSVCRT_SETMODE_METHODDEF \ - {"setmode", (PyCFunction)(void(*)(void))msvcrt_setmode, METH_FASTCALL, msvcrt_setmode__doc__}, - -static long -msvcrt_setmode_impl(PyObject *module, int fd, int flags); - -static PyObject * -msvcrt_setmode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int fd; - int flags; - long _return_value; - - if (!_PyArg_CheckPositional("setmode", nargs, 2, 2)) { - goto exit; - } - fd = _PyLong_AsInt(args[0]); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - flags = _PyLong_AsInt(args[1]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; - } - _return_value = msvcrt_setmode_impl(module, fd, flags); - if ((_return_value == -1) && PyErr_Occurred()) { - goto exit; - } - return_value = PyLong_FromLong(_return_value); - -exit: - return return_value; -} - -PyDoc_STRVAR(msvcrt_open_osfhandle__doc__, -"open_osfhandle($module, handle, flags, /)\n" -"--\n" -"\n" -"Create a C runtime file descriptor from the file handle handle.\n" -"\n" -"The flags parameter should be a bitwise OR of os.O_APPEND, os.O_RDONLY,\n" -"and os.O_TEXT. The returned file descriptor may be used as a parameter\n" -"to os.fdopen() to create a file object."); - -#define MSVCRT_OPEN_OSFHANDLE_METHODDEF \ - {"open_osfhandle", (PyCFunction)(void(*)(void))msvcrt_open_osfhandle, METH_FASTCALL, msvcrt_open_osfhandle__doc__}, - -static long -msvcrt_open_osfhandle_impl(PyObject *module, void *handle, int flags); - -static PyObject * -msvcrt_open_osfhandle(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - void *handle; - int flags; - long _return_value; - - if (!_PyArg_ParseStack(args, nargs, ""_Py_PARSE_UINTPTR"i:open_osfhandle", - &handle, &flags)) { - goto exit; - } - _return_value = msvcrt_open_osfhandle_impl(module, handle, flags); - if ((_return_value == -1) && PyErr_Occurred()) { - goto exit; - } - return_value = PyLong_FromLong(_return_value); - -exit: - return return_value; -} - -PyDoc_STRVAR(msvcrt_get_osfhandle__doc__, -"get_osfhandle($module, fd, /)\n" -"--\n" -"\n" -"Return the file handle for the file descriptor fd.\n" -"\n" -"Raises OSError if fd is not recognized."); - -#define MSVCRT_GET_OSFHANDLE_METHODDEF \ - {"get_osfhandle", (PyCFunction)msvcrt_get_osfhandle, METH_O, msvcrt_get_osfhandle__doc__}, - -static void * -msvcrt_get_osfhandle_impl(PyObject *module, int fd); - -static PyObject * -msvcrt_get_osfhandle(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int fd; - void *_return_value; - - fd = _PyLong_AsInt(arg); - if (fd == -1 && PyErr_Occurred()) { - goto exit; - } - _return_value = msvcrt_get_osfhandle_impl(module, fd); - if ((_return_value == NULL || _return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { - goto exit; - } - return_value = PyLong_FromVoidPtr(_return_value); - -exit: - return return_value; -} - -PyDoc_STRVAR(msvcrt_kbhit__doc__, -"kbhit($module, /)\n" -"--\n" -"\n" -"Return true if a keypress is waiting to be read."); - -#define MSVCRT_KBHIT_METHODDEF \ - {"kbhit", (PyCFunction)msvcrt_kbhit, METH_NOARGS, msvcrt_kbhit__doc__}, - -static long -msvcrt_kbhit_impl(PyObject *module); - -static PyObject * -msvcrt_kbhit(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - PyObject *return_value = NULL; - long _return_value; - - _return_value = msvcrt_kbhit_impl(module); - if ((_return_value == -1) && PyErr_Occurred()) { - goto exit; - } - return_value = PyLong_FromLong(_return_value); - -exit: - return return_value; -} - -PyDoc_STRVAR(msvcrt_getch__doc__, -"getch($module, /)\n" -"--\n" -"\n" -"Read a keypress and return the resulting character as a byte string.\n" -"\n" -"Nothing is echoed to the console. This call will block if a keypress is\n" -"not already available, but will not wait for Enter to be pressed. If the\n" -"pressed key was a special function key, this will return \'\\000\' or\n" -"\'\\xe0\'; the next call will return the keycode. The Control-C keypress\n" -"cannot be read with this function."); - -#define MSVCRT_GETCH_METHODDEF \ - {"getch", (PyCFunction)msvcrt_getch, METH_NOARGS, msvcrt_getch__doc__}, - -static int -msvcrt_getch_impl(PyObject *module); - -static PyObject * -msvcrt_getch(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - PyObject *return_value = NULL; - char s[1]; - - s[0] = msvcrt_getch_impl(module); - return_value = PyBytes_FromStringAndSize(s, 1); - - return return_value; -} - -PyDoc_STRVAR(msvcrt_getwch__doc__, -"getwch($module, /)\n" -"--\n" -"\n" -"Wide char variant of getch(), returning a Unicode value."); - -#define MSVCRT_GETWCH_METHODDEF \ - {"getwch", (PyCFunction)msvcrt_getwch, METH_NOARGS, msvcrt_getwch__doc__}, - -static wchar_t -msvcrt_getwch_impl(PyObject *module); - -static PyObject * -msvcrt_getwch(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - PyObject *return_value = NULL; - wchar_t _return_value; - - _return_value = msvcrt_getwch_impl(module); - return_value = PyUnicode_FromOrdinal(_return_value); - - return return_value; -} - -PyDoc_STRVAR(msvcrt_getche__doc__, -"getche($module, /)\n" -"--\n" -"\n" -"Similar to getch(), but the keypress will be echoed if possible."); - -#define MSVCRT_GETCHE_METHODDEF \ - {"getche", (PyCFunction)msvcrt_getche, METH_NOARGS, msvcrt_getche__doc__}, - -static int -msvcrt_getche_impl(PyObject *module); - -static PyObject * -msvcrt_getche(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - PyObject *return_value = NULL; - char s[1]; - - s[0] = msvcrt_getche_impl(module); - return_value = PyBytes_FromStringAndSize(s, 1); - - return return_value; -} - -PyDoc_STRVAR(msvcrt_getwche__doc__, -"getwche($module, /)\n" -"--\n" -"\n" -"Wide char variant of getche(), returning a Unicode value."); - -#define MSVCRT_GETWCHE_METHODDEF \ - {"getwche", (PyCFunction)msvcrt_getwche, METH_NOARGS, msvcrt_getwche__doc__}, - -static wchar_t -msvcrt_getwche_impl(PyObject *module); - -static PyObject * -msvcrt_getwche(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - PyObject *return_value = NULL; - wchar_t _return_value; - - _return_value = msvcrt_getwche_impl(module); - return_value = PyUnicode_FromOrdinal(_return_value); - - return return_value; -} - -PyDoc_STRVAR(msvcrt_putch__doc__, -"putch($module, char, /)\n" -"--\n" -"\n" -"Print the byte string char to the console without buffering."); - -#define MSVCRT_PUTCH_METHODDEF \ - {"putch", (PyCFunction)msvcrt_putch, METH_O, msvcrt_putch__doc__}, - -static PyObject * -msvcrt_putch_impl(PyObject *module, char char_value); - -static PyObject * -msvcrt_putch(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - char char_value; - - if (PyBytes_Check(arg) && PyBytes_GET_SIZE(arg) == 1) { - char_value = PyBytes_AS_STRING(arg)[0]; - } - else if (PyByteArray_Check(arg) && PyByteArray_GET_SIZE(arg) == 1) { - char_value = PyByteArray_AS_STRING(arg)[0]; - } - else { - _PyArg_BadArgument("putch", "argument", "a byte string of length 1", arg); - goto exit; - } - return_value = msvcrt_putch_impl(module, char_value); - -exit: - return return_value; -} - -PyDoc_STRVAR(msvcrt_putwch__doc__, -"putwch($module, unicode_char, /)\n" -"--\n" -"\n" -"Wide char variant of putch(), accepting a Unicode value."); - -#define MSVCRT_PUTWCH_METHODDEF \ - {"putwch", (PyCFunction)msvcrt_putwch, METH_O, msvcrt_putwch__doc__}, - -static PyObject * -msvcrt_putwch_impl(PyObject *module, int unicode_char); - -static PyObject * -msvcrt_putwch(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int unicode_char; - - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("putwch", "argument", "a unicode character", arg); - goto exit; - } - if (PyUnicode_READY(arg)) { - goto exit; - } - if (PyUnicode_GET_LENGTH(arg) != 1) { - _PyArg_BadArgument("putwch", "argument", "a unicode character", arg); - goto exit; - } - unicode_char = PyUnicode_READ_CHAR(arg, 0); - return_value = msvcrt_putwch_impl(module, unicode_char); - -exit: - return return_value; -} - -PyDoc_STRVAR(msvcrt_ungetch__doc__, -"ungetch($module, char, /)\n" -"--\n" -"\n" -"Opposite of getch.\n" -"\n" -"Cause the byte string char to be \"pushed back\" into the\n" -"console buffer; it will be the next character read by\n" -"getch() or getche()."); - -#define MSVCRT_UNGETCH_METHODDEF \ - {"ungetch", (PyCFunction)msvcrt_ungetch, METH_O, msvcrt_ungetch__doc__}, - -static PyObject * -msvcrt_ungetch_impl(PyObject *module, char char_value); - -static PyObject * -msvcrt_ungetch(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - char char_value; - - if (PyBytes_Check(arg) && PyBytes_GET_SIZE(arg) == 1) { - char_value = PyBytes_AS_STRING(arg)[0]; - } - else if (PyByteArray_Check(arg) && PyByteArray_GET_SIZE(arg) == 1) { - char_value = PyByteArray_AS_STRING(arg)[0]; - } - else { - _PyArg_BadArgument("ungetch", "argument", "a byte string of length 1", arg); - goto exit; - } - return_value = msvcrt_ungetch_impl(module, char_value); - -exit: - return return_value; -} - -PyDoc_STRVAR(msvcrt_ungetwch__doc__, -"ungetwch($module, unicode_char, /)\n" -"--\n" -"\n" -"Wide char variant of ungetch(), accepting a Unicode value."); - -#define MSVCRT_UNGETWCH_METHODDEF \ - {"ungetwch", (PyCFunction)msvcrt_ungetwch, METH_O, msvcrt_ungetwch__doc__}, - -static PyObject * -msvcrt_ungetwch_impl(PyObject *module, int unicode_char); - -static PyObject * -msvcrt_ungetwch(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int unicode_char; - - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("ungetwch", "argument", "a unicode character", arg); - goto exit; - } - if (PyUnicode_READY(arg)) { - goto exit; - } - if (PyUnicode_GET_LENGTH(arg) != 1) { - _PyArg_BadArgument("ungetwch", "argument", "a unicode character", arg); - goto exit; - } - unicode_char = PyUnicode_READ_CHAR(arg, 0); - return_value = msvcrt_ungetwch_impl(module, unicode_char); - -exit: - return return_value; -} - -#if defined(_DEBUG) - -PyDoc_STRVAR(msvcrt_CrtSetReportFile__doc__, -"CrtSetReportFile($module, type, file, /)\n" -"--\n" -"\n" -"Wrapper around _CrtSetReportFile.\n" -"\n" -"Only available on Debug builds."); - -#define MSVCRT_CRTSETREPORTFILE_METHODDEF \ - {"CrtSetReportFile", (PyCFunction)(void(*)(void))msvcrt_CrtSetReportFile, METH_FASTCALL, msvcrt_CrtSetReportFile__doc__}, - -static void * -msvcrt_CrtSetReportFile_impl(PyObject *module, int type, void *file); - -static PyObject * -msvcrt_CrtSetReportFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int type; - void *file; - void *_return_value; - - if (!_PyArg_ParseStack(args, nargs, "i"_Py_PARSE_UINTPTR":CrtSetReportFile", - &type, &file)) { - goto exit; - } - _return_value = msvcrt_CrtSetReportFile_impl(module, type, file); - if ((_return_value == NULL || _return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) { - goto exit; - } - return_value = PyLong_FromVoidPtr(_return_value); - -exit: - return return_value; -} - -#endif /* defined(_DEBUG) */ - -#if defined(_DEBUG) - -PyDoc_STRVAR(msvcrt_CrtSetReportMode__doc__, -"CrtSetReportMode($module, type, mode, /)\n" -"--\n" -"\n" -"Wrapper around _CrtSetReportMode.\n" -"\n" -"Only available on Debug builds."); - -#define MSVCRT_CRTSETREPORTMODE_METHODDEF \ - {"CrtSetReportMode", (PyCFunction)(void(*)(void))msvcrt_CrtSetReportMode, METH_FASTCALL, msvcrt_CrtSetReportMode__doc__}, - -static long -msvcrt_CrtSetReportMode_impl(PyObject *module, int type, int mode); - -static PyObject * -msvcrt_CrtSetReportMode(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int type; - int mode; - long _return_value; - - if (!_PyArg_CheckPositional("CrtSetReportMode", nargs, 2, 2)) { - goto exit; - } - type = _PyLong_AsInt(args[0]); - if (type == -1 && PyErr_Occurred()) { - goto exit; - } - mode = _PyLong_AsInt(args[1]); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } - _return_value = msvcrt_CrtSetReportMode_impl(module, type, mode); - if ((_return_value == -1) && PyErr_Occurred()) { - goto exit; - } - return_value = PyLong_FromLong(_return_value); - -exit: - return return_value; -} - -#endif /* defined(_DEBUG) */ - -#if defined(_DEBUG) - -PyDoc_STRVAR(msvcrt_set_error_mode__doc__, -"set_error_mode($module, mode, /)\n" -"--\n" -"\n" -"Wrapper around _set_error_mode.\n" -"\n" -"Only available on Debug builds."); - -#define MSVCRT_SET_ERROR_MODE_METHODDEF \ - {"set_error_mode", (PyCFunction)msvcrt_set_error_mode, METH_O, msvcrt_set_error_mode__doc__}, - -static long -msvcrt_set_error_mode_impl(PyObject *module, int mode); - -static PyObject * -msvcrt_set_error_mode(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - int mode; - long _return_value; - - mode = _PyLong_AsInt(arg); - if (mode == -1 && PyErr_Occurred()) { - goto exit; - } - _return_value = msvcrt_set_error_mode_impl(module, mode); - if ((_return_value == -1) && PyErr_Occurred()) { - goto exit; - } - return_value = PyLong_FromLong(_return_value); - -exit: - return return_value; -} - -#endif /* defined(_DEBUG) */ - -PyDoc_STRVAR(msvcrt_GetErrorMode__doc__, -"GetErrorMode($module, /)\n" -"--\n" -"\n" -"Wrapper around GetErrorMode."); - -#define MSVCRT_GETERRORMODE_METHODDEF \ - {"GetErrorMode", (PyCFunction)msvcrt_GetErrorMode, METH_NOARGS, msvcrt_GetErrorMode__doc__}, - -static PyObject * -msvcrt_GetErrorMode_impl(PyObject *module); - -static PyObject * -msvcrt_GetErrorMode(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return msvcrt_GetErrorMode_impl(module); -} - -PyDoc_STRVAR(msvcrt_SetErrorMode__doc__, -"SetErrorMode($module, mode, /)\n" -"--\n" -"\n" -"Wrapper around SetErrorMode."); - -#define MSVCRT_SETERRORMODE_METHODDEF \ - {"SetErrorMode", (PyCFunction)msvcrt_SetErrorMode, METH_O, msvcrt_SetErrorMode__doc__}, - -static PyObject * -msvcrt_SetErrorMode_impl(PyObject *module, unsigned int mode); - -static PyObject * -msvcrt_SetErrorMode(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - unsigned int mode; - - mode = (unsigned int)PyLong_AsUnsignedLongMask(arg); - if (mode == (unsigned int)-1 && PyErr_Occurred()) { - goto exit; - } - return_value = msvcrt_SetErrorMode_impl(module, mode); - -exit: - return return_value; -} - -#ifndef MSVCRT_CRTSETREPORTFILE_METHODDEF - #define MSVCRT_CRTSETREPORTFILE_METHODDEF -#endif /* !defined(MSVCRT_CRTSETREPORTFILE_METHODDEF) */ - -#ifndef MSVCRT_CRTSETREPORTMODE_METHODDEF - #define MSVCRT_CRTSETREPORTMODE_METHODDEF -#endif /* !defined(MSVCRT_CRTSETREPORTMODE_METHODDEF) */ - -#ifndef MSVCRT_SET_ERROR_MODE_METHODDEF - #define MSVCRT_SET_ERROR_MODE_METHODDEF -#endif /* !defined(MSVCRT_SET_ERROR_MODE_METHODDEF) */ -/*[clinic end generated code: output=20dfbc768edce7c0 input=a9049054013a1b77]*/ diff --git a/PC/clinic/winreg.c.h b/PC/clinic/winreg.c.h deleted file mode 100644 index 3051bcccf0db024cf0268d33b8ea8bdf9291501b..0000000000000000000000000000000000000000 --- a/PC/clinic/winreg.c.h +++ /dev/null @@ -1,1352 +0,0 @@ -/*[clinic input] -preserve -[clinic start generated code]*/ - -PyDoc_STRVAR(winreg_HKEYType_Close__doc__, -"Close($self, /)\n" -"--\n" -"\n" -"Closes the underlying Windows handle.\n" -"\n" -"If the handle is already closed, no error is raised."); - -#define WINREG_HKEYTYPE_CLOSE_METHODDEF \ - {"Close", (PyCFunction)winreg_HKEYType_Close, METH_NOARGS, winreg_HKEYType_Close__doc__}, - -static PyObject * -winreg_HKEYType_Close_impl(PyHKEYObject *self); - -static PyObject * -winreg_HKEYType_Close(PyHKEYObject *self, PyObject *Py_UNUSED(ignored)) -{ - return winreg_HKEYType_Close_impl(self); -} - -PyDoc_STRVAR(winreg_HKEYType_Detach__doc__, -"Detach($self, /)\n" -"--\n" -"\n" -"Detaches the Windows handle from the handle object.\n" -"\n" -"The result is the value of the handle before it is detached. If the\n" -"handle is already detached, this will return zero.\n" -"\n" -"After calling this function, the handle is effectively invalidated,\n" -"but the handle is not closed. You would call this function when you\n" -"need the underlying win32 handle to exist beyond the lifetime of the\n" -"handle object."); - -#define WINREG_HKEYTYPE_DETACH_METHODDEF \ - {"Detach", (PyCFunction)winreg_HKEYType_Detach, METH_NOARGS, winreg_HKEYType_Detach__doc__}, - -static PyObject * -winreg_HKEYType_Detach_impl(PyHKEYObject *self); - -static PyObject * -winreg_HKEYType_Detach(PyHKEYObject *self, PyObject *Py_UNUSED(ignored)) -{ - return winreg_HKEYType_Detach_impl(self); -} - -PyDoc_STRVAR(winreg_HKEYType___enter____doc__, -"__enter__($self, /)\n" -"--\n" -"\n"); - -#define WINREG_HKEYTYPE___ENTER___METHODDEF \ - {"__enter__", (PyCFunction)winreg_HKEYType___enter__, METH_NOARGS, winreg_HKEYType___enter____doc__}, - -static PyHKEYObject * -winreg_HKEYType___enter___impl(PyHKEYObject *self); - -static PyObject * -winreg_HKEYType___enter__(PyHKEYObject *self, PyObject *Py_UNUSED(ignored)) -{ - PyObject *return_value = NULL; - PyHKEYObject *_return_value; - - _return_value = winreg_HKEYType___enter___impl(self); - return_value = (PyObject *)_return_value; - - return return_value; -} - -PyDoc_STRVAR(winreg_HKEYType___exit____doc__, -"__exit__($self, /, exc_type, exc_value, traceback)\n" -"--\n" -"\n"); - -#define WINREG_HKEYTYPE___EXIT___METHODDEF \ - {"__exit__", (PyCFunction)(void(*)(void))winreg_HKEYType___exit__, METH_FASTCALL|METH_KEYWORDS, winreg_HKEYType___exit____doc__}, - -static PyObject * -winreg_HKEYType___exit___impl(PyHKEYObject *self, PyObject *exc_type, - PyObject *exc_value, PyObject *traceback); - -static PyObject * -winreg_HKEYType___exit__(PyHKEYObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"exc_type", "exc_value", "traceback", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "__exit__", 0}; - PyObject *argsbuf[3]; - PyObject *exc_type; - PyObject *exc_value; - PyObject *traceback; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); - if (!args) { - goto exit; - } - exc_type = args[0]; - exc_value = args[1]; - traceback = args[2]; - return_value = winreg_HKEYType___exit___impl(self, exc_type, exc_value, traceback); - -exit: - return return_value; -} - -PyDoc_STRVAR(winreg_CloseKey__doc__, -"CloseKey($module, hkey, /)\n" -"--\n" -"\n" -"Closes a previously opened registry key.\n" -"\n" -" hkey\n" -" A previously opened key.\n" -"\n" -"Note that if the key is not closed using this method, it will be\n" -"closed when the hkey object is destroyed by Python."); - -#define WINREG_CLOSEKEY_METHODDEF \ - {"CloseKey", (PyCFunction)winreg_CloseKey, METH_O, winreg_CloseKey__doc__}, - -PyDoc_STRVAR(winreg_ConnectRegistry__doc__, -"ConnectRegistry($module, computer_name, key, /)\n" -"--\n" -"\n" -"Establishes a connection to the registry on another computer.\n" -"\n" -" computer_name\n" -" The name of the remote computer, of the form r\"\\\\computername\". If\n" -" None, the local computer is used.\n" -" key\n" -" The predefined key to connect to.\n" -"\n" -"The return value is the handle of the opened key.\n" -"If the function fails, an OSError exception is raised."); - -#define WINREG_CONNECTREGISTRY_METHODDEF \ - {"ConnectRegistry", (PyCFunction)(void(*)(void))winreg_ConnectRegistry, METH_FASTCALL, winreg_ConnectRegistry__doc__}, - -static HKEY -winreg_ConnectRegistry_impl(PyObject *module, - const Py_UNICODE *computer_name, HKEY key); - -static PyObject * -winreg_ConnectRegistry(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - const Py_UNICODE *computer_name; - HKEY key; - HKEY _return_value; - - if (!_PyArg_CheckPositional("ConnectRegistry", nargs, 2, 2)) { - goto exit; - } - if (args[0] == Py_None) { - computer_name = NULL; - } - else if (PyUnicode_Check(args[0])) { - #if USE_UNICODE_WCHAR_CACHE - computer_name = _PyUnicode_AsUnicode(args[0]); - #else /* USE_UNICODE_WCHAR_CACHE */ - computer_name = PyUnicode_AsWideCharString(args[0], NULL); - #endif /* USE_UNICODE_WCHAR_CACHE */ - if (computer_name == NULL) { - goto exit; - } - } - else { - _PyArg_BadArgument("ConnectRegistry", "argument 1", "str or None", args[0]); - goto exit; - } - if (!clinic_HKEY_converter(args[1], &key)) { - goto exit; - } - _return_value = winreg_ConnectRegistry_impl(module, computer_name, key); - if (_return_value == NULL) { - goto exit; - } - return_value = PyHKEY_FromHKEY(_return_value); - -exit: - /* Cleanup for computer_name */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)computer_name); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(winreg_CreateKey__doc__, -"CreateKey($module, key, sub_key, /)\n" -"--\n" -"\n" -"Creates or opens the specified key.\n" -"\n" -" key\n" -" An already open key, or one of the predefined HKEY_* constants.\n" -" sub_key\n" -" The name of the key this method opens or creates.\n" -"\n" -"If key is one of the predefined keys, sub_key may be None. In that case,\n" -"the handle returned is the same key handle passed in to the function.\n" -"\n" -"If the key already exists, this function opens the existing key.\n" -"\n" -"The return value is the handle of the opened key.\n" -"If the function fails, an OSError exception is raised."); - -#define WINREG_CREATEKEY_METHODDEF \ - {"CreateKey", (PyCFunction)(void(*)(void))winreg_CreateKey, METH_FASTCALL, winreg_CreateKey__doc__}, - -static HKEY -winreg_CreateKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key); - -static PyObject * -winreg_CreateKey(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - HKEY key; - const Py_UNICODE *sub_key; - HKEY _return_value; - - if (!_PyArg_CheckPositional("CreateKey", nargs, 2, 2)) { - goto exit; - } - if (!clinic_HKEY_converter(args[0], &key)) { - goto exit; - } - if (args[1] == Py_None) { - sub_key = NULL; - } - else if (PyUnicode_Check(args[1])) { - #if USE_UNICODE_WCHAR_CACHE - sub_key = _PyUnicode_AsUnicode(args[1]); - #else /* USE_UNICODE_WCHAR_CACHE */ - sub_key = PyUnicode_AsWideCharString(args[1], NULL); - #endif /* USE_UNICODE_WCHAR_CACHE */ - if (sub_key == NULL) { - goto exit; - } - } - else { - _PyArg_BadArgument("CreateKey", "argument 2", "str or None", args[1]); - goto exit; - } - _return_value = winreg_CreateKey_impl(module, key, sub_key); - if (_return_value == NULL) { - goto exit; - } - return_value = PyHKEY_FromHKEY(_return_value); - -exit: - /* Cleanup for sub_key */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)sub_key); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(winreg_CreateKeyEx__doc__, -"CreateKeyEx($module, /, key, sub_key, reserved=0,\n" -" access=winreg.KEY_WRITE)\n" -"--\n" -"\n" -"Creates or opens the specified key.\n" -"\n" -" key\n" -" An already open key, or one of the predefined HKEY_* constants.\n" -" sub_key\n" -" The name of the key this method opens or creates.\n" -" reserved\n" -" A reserved integer, and must be zero. Default is zero.\n" -" access\n" -" An integer that specifies an access mask that describes the\n" -" desired security access for the key. Default is KEY_WRITE.\n" -"\n" -"If key is one of the predefined keys, sub_key may be None. In that case,\n" -"the handle returned is the same key handle passed in to the function.\n" -"\n" -"If the key already exists, this function opens the existing key\n" -"\n" -"The return value is the handle of the opened key.\n" -"If the function fails, an OSError exception is raised."); - -#define WINREG_CREATEKEYEX_METHODDEF \ - {"CreateKeyEx", (PyCFunction)(void(*)(void))winreg_CreateKeyEx, METH_FASTCALL|METH_KEYWORDS, winreg_CreateKeyEx__doc__}, - -static HKEY -winreg_CreateKeyEx_impl(PyObject *module, HKEY key, - const Py_UNICODE *sub_key, int reserved, - REGSAM access); - -static PyObject * -winreg_CreateKeyEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL}; - static _PyArg_Parser _parser = {"O&O&|ii:CreateKeyEx", _keywords, 0}; - HKEY key; - const Py_UNICODE *sub_key; - int reserved = 0; - REGSAM access = KEY_WRITE; - HKEY _return_value; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - clinic_HKEY_converter, &key, _PyUnicode_WideCharString_Opt_Converter, &sub_key, &reserved, &access)) { - goto exit; - } - _return_value = winreg_CreateKeyEx_impl(module, key, sub_key, reserved, access); - if (_return_value == NULL) { - goto exit; - } - return_value = PyHKEY_FromHKEY(_return_value); - -exit: - /* Cleanup for sub_key */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)sub_key); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(winreg_DeleteKey__doc__, -"DeleteKey($module, key, sub_key, /)\n" -"--\n" -"\n" -"Deletes the specified key.\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -" sub_key\n" -" A string that must be the name of a subkey of the key identified by\n" -" the key parameter. This value must not be None, and the key may not\n" -" have subkeys.\n" -"\n" -"This method can not delete keys with subkeys.\n" -"\n" -"If the function succeeds, the entire key, including all of its values,\n" -"is removed. If the function fails, an OSError exception is raised."); - -#define WINREG_DELETEKEY_METHODDEF \ - {"DeleteKey", (PyCFunction)(void(*)(void))winreg_DeleteKey, METH_FASTCALL, winreg_DeleteKey__doc__}, - -static PyObject * -winreg_DeleteKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key); - -static PyObject * -winreg_DeleteKey(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - HKEY key; - const Py_UNICODE *sub_key; - - if (!_PyArg_CheckPositional("DeleteKey", nargs, 2, 2)) { - goto exit; - } - if (!clinic_HKEY_converter(args[0], &key)) { - goto exit; - } - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("DeleteKey", "argument 2", "str", args[1]); - goto exit; - } - #if USE_UNICODE_WCHAR_CACHE - sub_key = _PyUnicode_AsUnicode(args[1]); - #else /* USE_UNICODE_WCHAR_CACHE */ - sub_key = PyUnicode_AsWideCharString(args[1], NULL); - #endif /* USE_UNICODE_WCHAR_CACHE */ - if (sub_key == NULL) { - goto exit; - } - return_value = winreg_DeleteKey_impl(module, key, sub_key); - -exit: - /* Cleanup for sub_key */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)sub_key); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(winreg_DeleteKeyEx__doc__, -"DeleteKeyEx($module, /, key, sub_key, access=winreg.KEY_WOW64_64KEY,\n" -" reserved=0)\n" -"--\n" -"\n" -"Deletes the specified key (intended for 64-bit OS).\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -" sub_key\n" -" A string that must be the name of a subkey of the key identified by\n" -" the key parameter. This value must not be None, and the key may not\n" -" have subkeys.\n" -" access\n" -" An integer that specifies an access mask that describes the\n" -" desired security access for the key. Default is KEY_WOW64_64KEY.\n" -" reserved\n" -" A reserved integer, and must be zero. Default is zero.\n" -"\n" -"While this function is intended to be used for 64-bit OS, it is also\n" -" available on 32-bit systems.\n" -"\n" -"This method can not delete keys with subkeys.\n" -"\n" -"If the function succeeds, the entire key, including all of its values,\n" -"is removed. If the function fails, an OSError exception is raised.\n" -"On unsupported Windows versions, NotImplementedError is raised."); - -#define WINREG_DELETEKEYEX_METHODDEF \ - {"DeleteKeyEx", (PyCFunction)(void(*)(void))winreg_DeleteKeyEx, METH_FASTCALL|METH_KEYWORDS, winreg_DeleteKeyEx__doc__}, - -static PyObject * -winreg_DeleteKeyEx_impl(PyObject *module, HKEY key, - const Py_UNICODE *sub_key, REGSAM access, - int reserved); - -static PyObject * -winreg_DeleteKeyEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"key", "sub_key", "access", "reserved", NULL}; - static _PyArg_Parser _parser = {"O&O&|ii:DeleteKeyEx", _keywords, 0}; - HKEY key; - const Py_UNICODE *sub_key; - REGSAM access = KEY_WOW64_64KEY; - int reserved = 0; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - clinic_HKEY_converter, &key, _PyUnicode_WideCharString_Converter, &sub_key, &access, &reserved)) { - goto exit; - } - return_value = winreg_DeleteKeyEx_impl(module, key, sub_key, access, reserved); - -exit: - /* Cleanup for sub_key */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)sub_key); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(winreg_DeleteValue__doc__, -"DeleteValue($module, key, value, /)\n" -"--\n" -"\n" -"Removes a named value from a registry key.\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -" value\n" -" A string that identifies the value to remove."); - -#define WINREG_DELETEVALUE_METHODDEF \ - {"DeleteValue", (PyCFunction)(void(*)(void))winreg_DeleteValue, METH_FASTCALL, winreg_DeleteValue__doc__}, - -static PyObject * -winreg_DeleteValue_impl(PyObject *module, HKEY key, const Py_UNICODE *value); - -static PyObject * -winreg_DeleteValue(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - HKEY key; - const Py_UNICODE *value; - - if (!_PyArg_CheckPositional("DeleteValue", nargs, 2, 2)) { - goto exit; - } - if (!clinic_HKEY_converter(args[0], &key)) { - goto exit; - } - if (args[1] == Py_None) { - value = NULL; - } - else if (PyUnicode_Check(args[1])) { - #if USE_UNICODE_WCHAR_CACHE - value = _PyUnicode_AsUnicode(args[1]); - #else /* USE_UNICODE_WCHAR_CACHE */ - value = PyUnicode_AsWideCharString(args[1], NULL); - #endif /* USE_UNICODE_WCHAR_CACHE */ - if (value == NULL) { - goto exit; - } - } - else { - _PyArg_BadArgument("DeleteValue", "argument 2", "str or None", args[1]); - goto exit; - } - return_value = winreg_DeleteValue_impl(module, key, value); - -exit: - /* Cleanup for value */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)value); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(winreg_EnumKey__doc__, -"EnumKey($module, key, index, /)\n" -"--\n" -"\n" -"Enumerates subkeys of an open registry key.\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -" index\n" -" An integer that identifies the index of the key to retrieve.\n" -"\n" -"The function retrieves the name of one subkey each time it is called.\n" -"It is typically called repeatedly until an OSError exception is\n" -"raised, indicating no more values are available."); - -#define WINREG_ENUMKEY_METHODDEF \ - {"EnumKey", (PyCFunction)(void(*)(void))winreg_EnumKey, METH_FASTCALL, winreg_EnumKey__doc__}, - -static PyObject * -winreg_EnumKey_impl(PyObject *module, HKEY key, int index); - -static PyObject * -winreg_EnumKey(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - HKEY key; - int index; - - if (!_PyArg_CheckPositional("EnumKey", nargs, 2, 2)) { - goto exit; - } - if (!clinic_HKEY_converter(args[0], &key)) { - goto exit; - } - index = _PyLong_AsInt(args[1]); - if (index == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = winreg_EnumKey_impl(module, key, index); - -exit: - return return_value; -} - -PyDoc_STRVAR(winreg_EnumValue__doc__, -"EnumValue($module, key, index, /)\n" -"--\n" -"\n" -"Enumerates values of an open registry key.\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -" index\n" -" An integer that identifies the index of the value to retrieve.\n" -"\n" -"The function retrieves the name of one subkey each time it is called.\n" -"It is typically called repeatedly, until an OSError exception\n" -"is raised, indicating no more values.\n" -"\n" -"The result is a tuple of 3 items:\n" -" value_name\n" -" A string that identifies the value.\n" -" value_data\n" -" An object that holds the value data, and whose type depends\n" -" on the underlying registry type.\n" -" data_type\n" -" An integer that identifies the type of the value data."); - -#define WINREG_ENUMVALUE_METHODDEF \ - {"EnumValue", (PyCFunction)(void(*)(void))winreg_EnumValue, METH_FASTCALL, winreg_EnumValue__doc__}, - -static PyObject * -winreg_EnumValue_impl(PyObject *module, HKEY key, int index); - -static PyObject * -winreg_EnumValue(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - HKEY key; - int index; - - if (!_PyArg_CheckPositional("EnumValue", nargs, 2, 2)) { - goto exit; - } - if (!clinic_HKEY_converter(args[0], &key)) { - goto exit; - } - index = _PyLong_AsInt(args[1]); - if (index == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = winreg_EnumValue_impl(module, key, index); - -exit: - return return_value; -} - -PyDoc_STRVAR(winreg_ExpandEnvironmentStrings__doc__, -"ExpandEnvironmentStrings($module, string, /)\n" -"--\n" -"\n" -"Expand environment vars."); - -#define WINREG_EXPANDENVIRONMENTSTRINGS_METHODDEF \ - {"ExpandEnvironmentStrings", (PyCFunction)winreg_ExpandEnvironmentStrings, METH_O, winreg_ExpandEnvironmentStrings__doc__}, - -static PyObject * -winreg_ExpandEnvironmentStrings_impl(PyObject *module, - const Py_UNICODE *string); - -static PyObject * -winreg_ExpandEnvironmentStrings(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - const Py_UNICODE *string; - - if (!PyUnicode_Check(arg)) { - _PyArg_BadArgument("ExpandEnvironmentStrings", "argument", "str", arg); - goto exit; - } - #if USE_UNICODE_WCHAR_CACHE - string = _PyUnicode_AsUnicode(arg); - #else /* USE_UNICODE_WCHAR_CACHE */ - string = PyUnicode_AsWideCharString(arg, NULL); - #endif /* USE_UNICODE_WCHAR_CACHE */ - if (string == NULL) { - goto exit; - } - return_value = winreg_ExpandEnvironmentStrings_impl(module, string); - -exit: - /* Cleanup for string */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)string); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(winreg_FlushKey__doc__, -"FlushKey($module, key, /)\n" -"--\n" -"\n" -"Writes all the attributes of a key to the registry.\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -"\n" -"It is not necessary to call FlushKey to change a key. Registry changes\n" -"are flushed to disk by the registry using its lazy flusher. Registry\n" -"changes are also flushed to disk at system shutdown. Unlike\n" -"CloseKey(), the FlushKey() method returns only when all the data has\n" -"been written to the registry.\n" -"\n" -"An application should only call FlushKey() if it requires absolute\n" -"certainty that registry changes are on disk. If you don\'t know whether\n" -"a FlushKey() call is required, it probably isn\'t."); - -#define WINREG_FLUSHKEY_METHODDEF \ - {"FlushKey", (PyCFunction)winreg_FlushKey, METH_O, winreg_FlushKey__doc__}, - -static PyObject * -winreg_FlushKey_impl(PyObject *module, HKEY key); - -static PyObject * -winreg_FlushKey(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - HKEY key; - - if (!clinic_HKEY_converter(arg, &key)) { - goto exit; - } - return_value = winreg_FlushKey_impl(module, key); - -exit: - return return_value; -} - -PyDoc_STRVAR(winreg_LoadKey__doc__, -"LoadKey($module, key, sub_key, file_name, /)\n" -"--\n" -"\n" -"Insert data into the registry from a file.\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -" sub_key\n" -" A string that identifies the sub-key to load.\n" -" file_name\n" -" The name of the file to load registry data from. This file must\n" -" have been created with the SaveKey() function. Under the file\n" -" allocation table (FAT) file system, the filename may not have an\n" -" extension.\n" -"\n" -"Creates a subkey under the specified key and stores registration\n" -"information from a specified file into that subkey.\n" -"\n" -"A call to LoadKey() fails if the calling process does not have the\n" -"SE_RESTORE_PRIVILEGE privilege.\n" -"\n" -"If key is a handle returned by ConnectRegistry(), then the path\n" -"specified in fileName is relative to the remote computer.\n" -"\n" -"The MSDN docs imply key must be in the HKEY_USER or HKEY_LOCAL_MACHINE\n" -"tree."); - -#define WINREG_LOADKEY_METHODDEF \ - {"LoadKey", (PyCFunction)(void(*)(void))winreg_LoadKey, METH_FASTCALL, winreg_LoadKey__doc__}, - -static PyObject * -winreg_LoadKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, - const Py_UNICODE *file_name); - -static PyObject * -winreg_LoadKey(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - HKEY key; - const Py_UNICODE *sub_key; - const Py_UNICODE *file_name; - - if (!_PyArg_CheckPositional("LoadKey", nargs, 3, 3)) { - goto exit; - } - if (!clinic_HKEY_converter(args[0], &key)) { - goto exit; - } - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("LoadKey", "argument 2", "str", args[1]); - goto exit; - } - #if USE_UNICODE_WCHAR_CACHE - sub_key = _PyUnicode_AsUnicode(args[1]); - #else /* USE_UNICODE_WCHAR_CACHE */ - sub_key = PyUnicode_AsWideCharString(args[1], NULL); - #endif /* USE_UNICODE_WCHAR_CACHE */ - if (sub_key == NULL) { - goto exit; - } - if (!PyUnicode_Check(args[2])) { - _PyArg_BadArgument("LoadKey", "argument 3", "str", args[2]); - goto exit; - } - #if USE_UNICODE_WCHAR_CACHE - file_name = _PyUnicode_AsUnicode(args[2]); - #else /* USE_UNICODE_WCHAR_CACHE */ - file_name = PyUnicode_AsWideCharString(args[2], NULL); - #endif /* USE_UNICODE_WCHAR_CACHE */ - if (file_name == NULL) { - goto exit; - } - return_value = winreg_LoadKey_impl(module, key, sub_key, file_name); - -exit: - /* Cleanup for sub_key */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)sub_key); - #endif /* USE_UNICODE_WCHAR_CACHE */ - /* Cleanup for file_name */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)file_name); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(winreg_OpenKey__doc__, -"OpenKey($module, /, key, sub_key, reserved=0, access=winreg.KEY_READ)\n" -"--\n" -"\n" -"Opens the specified key.\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -" sub_key\n" -" A string that identifies the sub_key to open.\n" -" reserved\n" -" A reserved integer that must be zero. Default is zero.\n" -" access\n" -" An integer that specifies an access mask that describes the desired\n" -" security access for the key. Default is KEY_READ.\n" -"\n" -"The result is a new handle to the specified key.\n" -"If the function fails, an OSError exception is raised."); - -#define WINREG_OPENKEY_METHODDEF \ - {"OpenKey", (PyCFunction)(void(*)(void))winreg_OpenKey, METH_FASTCALL|METH_KEYWORDS, winreg_OpenKey__doc__}, - -static HKEY -winreg_OpenKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, - int reserved, REGSAM access); - -static PyObject * -winreg_OpenKey(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL}; - static _PyArg_Parser _parser = {"O&O&|ii:OpenKey", _keywords, 0}; - HKEY key; - const Py_UNICODE *sub_key; - int reserved = 0; - REGSAM access = KEY_READ; - HKEY _return_value; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - clinic_HKEY_converter, &key, _PyUnicode_WideCharString_Opt_Converter, &sub_key, &reserved, &access)) { - goto exit; - } - _return_value = winreg_OpenKey_impl(module, key, sub_key, reserved, access); - if (_return_value == NULL) { - goto exit; - } - return_value = PyHKEY_FromHKEY(_return_value); - -exit: - /* Cleanup for sub_key */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)sub_key); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(winreg_OpenKeyEx__doc__, -"OpenKeyEx($module, /, key, sub_key, reserved=0, access=winreg.KEY_READ)\n" -"--\n" -"\n" -"Opens the specified key.\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -" sub_key\n" -" A string that identifies the sub_key to open.\n" -" reserved\n" -" A reserved integer that must be zero. Default is zero.\n" -" access\n" -" An integer that specifies an access mask that describes the desired\n" -" security access for the key. Default is KEY_READ.\n" -"\n" -"The result is a new handle to the specified key.\n" -"If the function fails, an OSError exception is raised."); - -#define WINREG_OPENKEYEX_METHODDEF \ - {"OpenKeyEx", (PyCFunction)(void(*)(void))winreg_OpenKeyEx, METH_FASTCALL|METH_KEYWORDS, winreg_OpenKeyEx__doc__}, - -static HKEY -winreg_OpenKeyEx_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, - int reserved, REGSAM access); - -static PyObject * -winreg_OpenKeyEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL}; - static _PyArg_Parser _parser = {"O&O&|ii:OpenKeyEx", _keywords, 0}; - HKEY key; - const Py_UNICODE *sub_key; - int reserved = 0; - REGSAM access = KEY_READ; - HKEY _return_value; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - clinic_HKEY_converter, &key, _PyUnicode_WideCharString_Opt_Converter, &sub_key, &reserved, &access)) { - goto exit; - } - _return_value = winreg_OpenKeyEx_impl(module, key, sub_key, reserved, access); - if (_return_value == NULL) { - goto exit; - } - return_value = PyHKEY_FromHKEY(_return_value); - -exit: - /* Cleanup for sub_key */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)sub_key); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(winreg_QueryInfoKey__doc__, -"QueryInfoKey($module, key, /)\n" -"--\n" -"\n" -"Returns information about a key.\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -"\n" -"The result is a tuple of 3 items:\n" -"An integer that identifies the number of sub keys this key has.\n" -"An integer that identifies the number of values this key has.\n" -"An integer that identifies when the key was last modified (if available)\n" -"as 100\'s of nanoseconds since Jan 1, 1600."); - -#define WINREG_QUERYINFOKEY_METHODDEF \ - {"QueryInfoKey", (PyCFunction)winreg_QueryInfoKey, METH_O, winreg_QueryInfoKey__doc__}, - -static PyObject * -winreg_QueryInfoKey_impl(PyObject *module, HKEY key); - -static PyObject * -winreg_QueryInfoKey(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - HKEY key; - - if (!clinic_HKEY_converter(arg, &key)) { - goto exit; - } - return_value = winreg_QueryInfoKey_impl(module, key); - -exit: - return return_value; -} - -PyDoc_STRVAR(winreg_QueryValue__doc__, -"QueryValue($module, key, sub_key, /)\n" -"--\n" -"\n" -"Retrieves the unnamed value for a key.\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -" sub_key\n" -" A string that holds the name of the subkey with which the value\n" -" is associated. If this parameter is None or empty, the function\n" -" retrieves the value set by the SetValue() method for the key\n" -" identified by key.\n" -"\n" -"Values in the registry have name, type, and data components. This method\n" -"retrieves the data for a key\'s first value that has a NULL name.\n" -"But since the underlying API call doesn\'t return the type, you\'ll\n" -"probably be happier using QueryValueEx; this function is just here for\n" -"completeness."); - -#define WINREG_QUERYVALUE_METHODDEF \ - {"QueryValue", (PyCFunction)(void(*)(void))winreg_QueryValue, METH_FASTCALL, winreg_QueryValue__doc__}, - -static PyObject * -winreg_QueryValue_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key); - -static PyObject * -winreg_QueryValue(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - HKEY key; - const Py_UNICODE *sub_key; - - if (!_PyArg_CheckPositional("QueryValue", nargs, 2, 2)) { - goto exit; - } - if (!clinic_HKEY_converter(args[0], &key)) { - goto exit; - } - if (args[1] == Py_None) { - sub_key = NULL; - } - else if (PyUnicode_Check(args[1])) { - #if USE_UNICODE_WCHAR_CACHE - sub_key = _PyUnicode_AsUnicode(args[1]); - #else /* USE_UNICODE_WCHAR_CACHE */ - sub_key = PyUnicode_AsWideCharString(args[1], NULL); - #endif /* USE_UNICODE_WCHAR_CACHE */ - if (sub_key == NULL) { - goto exit; - } - } - else { - _PyArg_BadArgument("QueryValue", "argument 2", "str or None", args[1]); - goto exit; - } - return_value = winreg_QueryValue_impl(module, key, sub_key); - -exit: - /* Cleanup for sub_key */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)sub_key); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(winreg_QueryValueEx__doc__, -"QueryValueEx($module, key, name, /)\n" -"--\n" -"\n" -"Retrieves the type and value of a specified sub-key.\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -" name\n" -" A string indicating the value to query.\n" -"\n" -"Behaves mostly like QueryValue(), but also returns the type of the\n" -"specified value name associated with the given open registry key.\n" -"\n" -"The return value is a tuple of the value and the type_id."); - -#define WINREG_QUERYVALUEEX_METHODDEF \ - {"QueryValueEx", (PyCFunction)(void(*)(void))winreg_QueryValueEx, METH_FASTCALL, winreg_QueryValueEx__doc__}, - -static PyObject * -winreg_QueryValueEx_impl(PyObject *module, HKEY key, const Py_UNICODE *name); - -static PyObject * -winreg_QueryValueEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - HKEY key; - const Py_UNICODE *name; - - if (!_PyArg_CheckPositional("QueryValueEx", nargs, 2, 2)) { - goto exit; - } - if (!clinic_HKEY_converter(args[0], &key)) { - goto exit; - } - if (args[1] == Py_None) { - name = NULL; - } - else if (PyUnicode_Check(args[1])) { - #if USE_UNICODE_WCHAR_CACHE - name = _PyUnicode_AsUnicode(args[1]); - #else /* USE_UNICODE_WCHAR_CACHE */ - name = PyUnicode_AsWideCharString(args[1], NULL); - #endif /* USE_UNICODE_WCHAR_CACHE */ - if (name == NULL) { - goto exit; - } - } - else { - _PyArg_BadArgument("QueryValueEx", "argument 2", "str or None", args[1]); - goto exit; - } - return_value = winreg_QueryValueEx_impl(module, key, name); - -exit: - /* Cleanup for name */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)name); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(winreg_SaveKey__doc__, -"SaveKey($module, key, file_name, /)\n" -"--\n" -"\n" -"Saves the specified key, and all its subkeys to the specified file.\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -" file_name\n" -" The name of the file to save registry data to. This file cannot\n" -" already exist. If this filename includes an extension, it cannot be\n" -" used on file allocation table (FAT) file systems by the LoadKey(),\n" -" ReplaceKey() or RestoreKey() methods.\n" -"\n" -"If key represents a key on a remote computer, the path described by\n" -"file_name is relative to the remote computer.\n" -"\n" -"The caller of this method must possess the SeBackupPrivilege\n" -"security privilege. This function passes NULL for security_attributes\n" -"to the API."); - -#define WINREG_SAVEKEY_METHODDEF \ - {"SaveKey", (PyCFunction)(void(*)(void))winreg_SaveKey, METH_FASTCALL, winreg_SaveKey__doc__}, - -static PyObject * -winreg_SaveKey_impl(PyObject *module, HKEY key, const Py_UNICODE *file_name); - -static PyObject * -winreg_SaveKey(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - HKEY key; - const Py_UNICODE *file_name; - - if (!_PyArg_CheckPositional("SaveKey", nargs, 2, 2)) { - goto exit; - } - if (!clinic_HKEY_converter(args[0], &key)) { - goto exit; - } - if (!PyUnicode_Check(args[1])) { - _PyArg_BadArgument("SaveKey", "argument 2", "str", args[1]); - goto exit; - } - #if USE_UNICODE_WCHAR_CACHE - file_name = _PyUnicode_AsUnicode(args[1]); - #else /* USE_UNICODE_WCHAR_CACHE */ - file_name = PyUnicode_AsWideCharString(args[1], NULL); - #endif /* USE_UNICODE_WCHAR_CACHE */ - if (file_name == NULL) { - goto exit; - } - return_value = winreg_SaveKey_impl(module, key, file_name); - -exit: - /* Cleanup for file_name */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)file_name); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(winreg_SetValue__doc__, -"SetValue($module, key, sub_key, type, value, /)\n" -"--\n" -"\n" -"Associates a value with a specified key.\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -" sub_key\n" -" A string that names the subkey with which the value is associated.\n" -" type\n" -" An integer that specifies the type of the data. Currently this must\n" -" be REG_SZ, meaning only strings are supported.\n" -" value\n" -" A string that specifies the new value.\n" -"\n" -"If the key specified by the sub_key parameter does not exist, the\n" -"SetValue function creates it.\n" -"\n" -"Value lengths are limited by available memory. Long values (more than\n" -"2048 bytes) should be stored as files with the filenames stored in\n" -"the configuration registry to help the registry perform efficiently.\n" -"\n" -"The key identified by the key parameter must have been opened with\n" -"KEY_SET_VALUE access."); - -#define WINREG_SETVALUE_METHODDEF \ - {"SetValue", (PyCFunction)(void(*)(void))winreg_SetValue, METH_FASTCALL, winreg_SetValue__doc__}, - -static PyObject * -winreg_SetValue_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, - DWORD type, PyObject *value_obj); - -static PyObject * -winreg_SetValue(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - HKEY key; - const Py_UNICODE *sub_key; - DWORD type; - PyObject *value_obj; - - if (!_PyArg_ParseStack(args, nargs, "O&O&kU:SetValue", - clinic_HKEY_converter, &key, _PyUnicode_WideCharString_Opt_Converter, &sub_key, &type, &value_obj)) { - goto exit; - } - return_value = winreg_SetValue_impl(module, key, sub_key, type, value_obj); - -exit: - /* Cleanup for sub_key */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)sub_key); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(winreg_SetValueEx__doc__, -"SetValueEx($module, key, value_name, reserved, type, value, /)\n" -"--\n" -"\n" -"Stores data in the value field of an open registry key.\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -" value_name\n" -" A string containing the name of the value to set, or None.\n" -" reserved\n" -" Can be anything - zero is always passed to the API.\n" -" type\n" -" An integer that specifies the type of the data, one of:\n" -" REG_BINARY -- Binary data in any form.\n" -" REG_DWORD -- A 32-bit number.\n" -" REG_DWORD_LITTLE_ENDIAN -- A 32-bit number in little-endian format. Equivalent to REG_DWORD\n" -" REG_DWORD_BIG_ENDIAN -- A 32-bit number in big-endian format.\n" -" REG_EXPAND_SZ -- A null-terminated string that contains unexpanded\n" -" references to environment variables (for example,\n" -" %PATH%).\n" -" REG_LINK -- A Unicode symbolic link.\n" -" REG_MULTI_SZ -- A sequence of null-terminated strings, terminated\n" -" by two null characters. Note that Python handles\n" -" this termination automatically.\n" -" REG_NONE -- No defined value type.\n" -" REG_QWORD -- A 64-bit number.\n" -" REG_QWORD_LITTLE_ENDIAN -- A 64-bit number in little-endian format. Equivalent to REG_QWORD.\n" -" REG_RESOURCE_LIST -- A device-driver resource list.\n" -" REG_SZ -- A null-terminated string.\n" -" value\n" -" A string that specifies the new value.\n" -"\n" -"This method can also set additional value and type information for the\n" -"specified key. The key identified by the key parameter must have been\n" -"opened with KEY_SET_VALUE access.\n" -"\n" -"To open the key, use the CreateKeyEx() or OpenKeyEx() methods.\n" -"\n" -"Value lengths are limited by available memory. Long values (more than\n" -"2048 bytes) should be stored as files with the filenames stored in\n" -"the configuration registry to help the registry perform efficiently."); - -#define WINREG_SETVALUEEX_METHODDEF \ - {"SetValueEx", (PyCFunction)(void(*)(void))winreg_SetValueEx, METH_FASTCALL, winreg_SetValueEx__doc__}, - -static PyObject * -winreg_SetValueEx_impl(PyObject *module, HKEY key, - const Py_UNICODE *value_name, PyObject *reserved, - DWORD type, PyObject *value); - -static PyObject * -winreg_SetValueEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - HKEY key; - const Py_UNICODE *value_name; - PyObject *reserved; - DWORD type; - PyObject *value; - - if (!_PyArg_ParseStack(args, nargs, "O&O&OkO:SetValueEx", - clinic_HKEY_converter, &key, _PyUnicode_WideCharString_Opt_Converter, &value_name, &reserved, &type, &value)) { - goto exit; - } - return_value = winreg_SetValueEx_impl(module, key, value_name, reserved, type, value); - -exit: - /* Cleanup for value_name */ - #if !USE_UNICODE_WCHAR_CACHE - PyMem_Free((void *)value_name); - #endif /* USE_UNICODE_WCHAR_CACHE */ - - return return_value; -} - -PyDoc_STRVAR(winreg_DisableReflectionKey__doc__, -"DisableReflectionKey($module, key, /)\n" -"--\n" -"\n" -"Disables registry reflection for 32bit processes running on a 64bit OS.\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -"\n" -"Will generally raise NotImplementedError if executed on a 32bit OS.\n" -"\n" -"If the key is not on the reflection list, the function succeeds but has\n" -"no effect. Disabling reflection for a key does not affect reflection\n" -"of any subkeys."); - -#define WINREG_DISABLEREFLECTIONKEY_METHODDEF \ - {"DisableReflectionKey", (PyCFunction)winreg_DisableReflectionKey, METH_O, winreg_DisableReflectionKey__doc__}, - -static PyObject * -winreg_DisableReflectionKey_impl(PyObject *module, HKEY key); - -static PyObject * -winreg_DisableReflectionKey(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - HKEY key; - - if (!clinic_HKEY_converter(arg, &key)) { - goto exit; - } - return_value = winreg_DisableReflectionKey_impl(module, key); - -exit: - return return_value; -} - -PyDoc_STRVAR(winreg_EnableReflectionKey__doc__, -"EnableReflectionKey($module, key, /)\n" -"--\n" -"\n" -"Restores registry reflection for the specified disabled key.\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -"\n" -"Will generally raise NotImplementedError if executed on a 32bit OS.\n" -"Restoring reflection for a key does not affect reflection of any\n" -"subkeys."); - -#define WINREG_ENABLEREFLECTIONKEY_METHODDEF \ - {"EnableReflectionKey", (PyCFunction)winreg_EnableReflectionKey, METH_O, winreg_EnableReflectionKey__doc__}, - -static PyObject * -winreg_EnableReflectionKey_impl(PyObject *module, HKEY key); - -static PyObject * -winreg_EnableReflectionKey(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - HKEY key; - - if (!clinic_HKEY_converter(arg, &key)) { - goto exit; - } - return_value = winreg_EnableReflectionKey_impl(module, key); - -exit: - return return_value; -} - -PyDoc_STRVAR(winreg_QueryReflectionKey__doc__, -"QueryReflectionKey($module, key, /)\n" -"--\n" -"\n" -"Returns the reflection state for the specified key as a bool.\n" -"\n" -" key\n" -" An already open key, or any one of the predefined HKEY_* constants.\n" -"\n" -"Will generally raise NotImplementedError if executed on a 32bit OS."); - -#define WINREG_QUERYREFLECTIONKEY_METHODDEF \ - {"QueryReflectionKey", (PyCFunction)winreg_QueryReflectionKey, METH_O, winreg_QueryReflectionKey__doc__}, - -static PyObject * -winreg_QueryReflectionKey_impl(PyObject *module, HKEY key); - -static PyObject * -winreg_QueryReflectionKey(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - HKEY key; - - if (!clinic_HKEY_converter(arg, &key)) { - goto exit; - } - return_value = winreg_QueryReflectionKey_impl(module, key); - -exit: - return return_value; -} -/*[clinic end generated code: output=8ce6fb3b6cd46242 input=a9049054013a1b77]*/ diff --git a/PC/clinic/winsound.c.h b/PC/clinic/winsound.c.h deleted file mode 100644 index c5458990baa7f2b8590a429c52268936bdb9461b..0000000000000000000000000000000000000000 --- a/PC/clinic/winsound.c.h +++ /dev/null @@ -1,134 +0,0 @@ -/*[clinic input] -preserve -[clinic start generated code]*/ - -PyDoc_STRVAR(winsound_PlaySound__doc__, -"PlaySound($module, /, sound, flags)\n" -"--\n" -"\n" -"A wrapper around the Windows PlaySound API.\n" -"\n" -" sound\n" -" The sound to play; a filename, data, or None.\n" -" flags\n" -" Flag values, ored together. See module documentation."); - -#define WINSOUND_PLAYSOUND_METHODDEF \ - {"PlaySound", (PyCFunction)(void(*)(void))winsound_PlaySound, METH_FASTCALL|METH_KEYWORDS, winsound_PlaySound__doc__}, - -static PyObject * -winsound_PlaySound_impl(PyObject *module, PyObject *sound, int flags); - -static PyObject * -winsound_PlaySound(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"sound", "flags", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "PlaySound", 0}; - PyObject *argsbuf[2]; - PyObject *sound; - int flags; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { - goto exit; - } - sound = args[0]; - flags = _PyLong_AsInt(args[1]); - if (flags == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = winsound_PlaySound_impl(module, sound, flags); - -exit: - return return_value; -} - -PyDoc_STRVAR(winsound_Beep__doc__, -"Beep($module, /, frequency, duration)\n" -"--\n" -"\n" -"A wrapper around the Windows Beep API.\n" -"\n" -" frequency\n" -" Frequency of the sound in hertz.\n" -" Must be in the range 37 through 32,767.\n" -" duration\n" -" How long the sound should play, in milliseconds."); - -#define WINSOUND_BEEP_METHODDEF \ - {"Beep", (PyCFunction)(void(*)(void))winsound_Beep, METH_FASTCALL|METH_KEYWORDS, winsound_Beep__doc__}, - -static PyObject * -winsound_Beep_impl(PyObject *module, int frequency, int duration); - -static PyObject * -winsound_Beep(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"frequency", "duration", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "Beep", 0}; - PyObject *argsbuf[2]; - int frequency; - int duration; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); - if (!args) { - goto exit; - } - frequency = _PyLong_AsInt(args[0]); - if (frequency == -1 && PyErr_Occurred()) { - goto exit; - } - duration = _PyLong_AsInt(args[1]); - if (duration == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = winsound_Beep_impl(module, frequency, duration); - -exit: - return return_value; -} - -PyDoc_STRVAR(winsound_MessageBeep__doc__, -"MessageBeep($module, /, type=MB_OK)\n" -"--\n" -"\n" -"Call Windows MessageBeep(x).\n" -"\n" -"x defaults to MB_OK."); - -#define WINSOUND_MESSAGEBEEP_METHODDEF \ - {"MessageBeep", (PyCFunction)(void(*)(void))winsound_MessageBeep, METH_FASTCALL|METH_KEYWORDS, winsound_MessageBeep__doc__}, - -static PyObject * -winsound_MessageBeep_impl(PyObject *module, int type); - -static PyObject * -winsound_MessageBeep(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"type", NULL}; - static _PyArg_Parser _parser = {NULL, _keywords, "MessageBeep", 0}; - PyObject *argsbuf[1]; - Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - int type = MB_OK; - - args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); - if (!args) { - goto exit; - } - if (!noptargs) { - goto skip_optional_pos; - } - type = _PyLong_AsInt(args[0]); - if (type == -1 && PyErr_Occurred()) { - goto exit; - } -skip_optional_pos: - return_value = winsound_MessageBeep_impl(module, type); - -exit: - return return_value; -} -/*[clinic end generated code: output=16b3c1a96861cd3a input=a9049054013a1b77]*/ diff --git a/PC/config.c b/PC/config.c deleted file mode 100644 index 87cd76d37bede8a263eefd3fec86825a910cf284..0000000000000000000000000000000000000000 --- a/PC/config.c +++ /dev/null @@ -1,174 +0,0 @@ -/* Module configuration */ - -/* This file contains the table of built-in modules. - See create_builtin() in import.c. */ - -#include "Python.h" - -extern PyObject* PyInit__abc(void); -extern PyObject* PyInit_array(void); -extern PyObject* PyInit_audioop(void); -extern PyObject* PyInit_binascii(void); -extern PyObject* PyInit_cmath(void); -extern PyObject* PyInit_errno(void); -extern PyObject* PyInit_faulthandler(void); -extern PyObject* PyInit__tracemalloc(void); -extern PyObject* PyInit_gc(void); -extern PyObject* PyInit_math(void); -extern PyObject* PyInit__md5(void); -extern PyObject* PyInit_nt(void); -extern PyObject* PyInit__operator(void); -extern PyObject* PyInit__signal(void); -extern PyObject* PyInit__sha1(void); -extern PyObject* PyInit__sha256(void); -extern PyObject* PyInit__sha512(void); -extern PyObject* PyInit__sha3(void); -extern PyObject* PyInit__statistics(void); -extern PyObject* PyInit__blake2(void); -extern PyObject* PyInit_time(void); -extern PyObject* PyInit__thread(void); -#ifdef WIN32 -extern PyObject* PyInit_msvcrt(void); -extern PyObject* PyInit__locale(void); -#endif -extern PyObject* PyInit__codecs(void); -extern PyObject* PyInit__weakref(void); -/* XXX: These two should really be extracted to standalone extensions. */ -extern PyObject* PyInit_xxsubtype(void); -extern PyObject* PyInit__xxsubinterpreters(void); -extern PyObject* PyInit__random(void); -extern PyObject* PyInit_itertools(void); -extern PyObject* PyInit__collections(void); -extern PyObject* PyInit__heapq(void); -extern PyObject* PyInit__bisect(void); -extern PyObject* PyInit__symtable(void); -extern PyObject* PyInit_mmap(void); -extern PyObject* PyInit__csv(void); -extern PyObject* PyInit__sre(void); -extern PyObject* PyInit_winreg(void); -extern PyObject* PyInit__struct(void); -extern PyObject* PyInit__datetime(void); -extern PyObject* PyInit__functools(void); -extern PyObject* PyInit__json(void); -#ifdef _Py_HAVE_ZLIB -extern PyObject* PyInit_zlib(void); -#endif - -extern PyObject* PyInit__multibytecodec(void); -extern PyObject* PyInit__codecs_cn(void); -extern PyObject* PyInit__codecs_hk(void); -extern PyObject* PyInit__codecs_iso2022(void); -extern PyObject* PyInit__codecs_jp(void); -extern PyObject* PyInit__codecs_kr(void); -extern PyObject* PyInit__codecs_tw(void); -extern PyObject* PyInit__winapi(void); -extern PyObject* PyInit__lsprof(void); -extern PyObject* PyInit__ast(void); -extern PyObject* PyInit__io(void); -extern PyObject* PyInit__pickle(void); -extern PyObject* PyInit_atexit(void); -extern PyObject* _PyWarnings_Init(void); -extern PyObject* PyInit__string(void); -extern PyObject* PyInit__stat(void); -extern PyObject* PyInit__opcode(void); - -extern PyObject* PyInit__contextvars(void); - - -/* tools/freeze/makeconfig.py marker for additional "extern" */ -/* -- ADDMODULE MARKER 1 -- */ - -extern PyObject* PyMarshal_Init(void); -extern PyObject* PyInit__imp(void); - -struct _inittab _PyImport_Inittab[] = { - - {"_abc", PyInit__abc}, - {"array", PyInit_array}, - {"_ast", PyInit__ast}, - {"audioop", PyInit_audioop}, - {"binascii", PyInit_binascii}, - {"cmath", PyInit_cmath}, - {"errno", PyInit_errno}, - {"faulthandler", PyInit_faulthandler}, - {"gc", PyInit_gc}, - {"math", PyInit_math}, - {"nt", PyInit_nt}, /* Use the NT os functions, not posix */ - {"_operator", PyInit__operator}, - {"_signal", PyInit__signal}, - {"_md5", PyInit__md5}, - {"_sha1", PyInit__sha1}, - {"_sha256", PyInit__sha256}, - {"_sha512", PyInit__sha512}, - {"_sha3", PyInit__sha3}, - {"_blake2", PyInit__blake2}, - {"time", PyInit_time}, - {"_thread", PyInit__thread}, - {"_statistics", PyInit__statistics}, -#ifdef WIN32 - {"msvcrt", PyInit_msvcrt}, - {"_locale", PyInit__locale}, -#endif - {"_tracemalloc", PyInit__tracemalloc}, - /* XXX Should _winapi go in a WIN32 block? not WIN64? */ - {"_winapi", PyInit__winapi}, - - {"_codecs", PyInit__codecs}, - {"_weakref", PyInit__weakref}, - {"_random", PyInit__random}, - {"_bisect", PyInit__bisect}, - {"_heapq", PyInit__heapq}, - {"_lsprof", PyInit__lsprof}, - {"itertools", PyInit_itertools}, - {"_collections", PyInit__collections}, - {"_symtable", PyInit__symtable}, - {"mmap", PyInit_mmap}, - {"_csv", PyInit__csv}, - {"_sre", PyInit__sre}, - {"winreg", PyInit_winreg}, - {"_struct", PyInit__struct}, - {"_datetime", PyInit__datetime}, - {"_functools", PyInit__functools}, - {"_json", PyInit__json}, - - {"xxsubtype", PyInit_xxsubtype}, - {"_xxsubinterpreters", PyInit__xxsubinterpreters}, -#ifdef _Py_HAVE_ZLIB - {"zlib", PyInit_zlib}, -#endif - - /* CJK codecs */ - {"_multibytecodec", PyInit__multibytecodec}, - {"_codecs_cn", PyInit__codecs_cn}, - {"_codecs_hk", PyInit__codecs_hk}, - {"_codecs_iso2022", PyInit__codecs_iso2022}, - {"_codecs_jp", PyInit__codecs_jp}, - {"_codecs_kr", PyInit__codecs_kr}, - {"_codecs_tw", PyInit__codecs_tw}, - -/* tools/freeze/makeconfig.py marker for additional "_inittab" entries */ -/* -- ADDMODULE MARKER 2 -- */ - - /* This module "lives in" with marshal.c */ - {"marshal", PyMarshal_Init}, - - /* This lives it with import.c */ - {"_imp", PyInit__imp}, - - /* These entries are here for sys.builtin_module_names */ - {"builtins", NULL}, - {"sys", NULL}, - {"_warnings", _PyWarnings_Init}, - {"_string", PyInit__string}, - - {"_io", PyInit__io}, - {"_pickle", PyInit__pickle}, - {"atexit", PyInit_atexit}, - {"_stat", PyInit__stat}, - {"_opcode", PyInit__opcode}, - - {"_contextvars", PyInit__contextvars}, - - /* Sentinel */ - {0, 0} -}; diff --git a/PC/crtlicense.txt b/PC/crtlicense.txt deleted file mode 100644 index f86841f263efe824f4336d162a6662881a7aad10..0000000000000000000000000000000000000000 --- a/PC/crtlicense.txt +++ /dev/null @@ -1,41 +0,0 @@ - - -Additional Conditions for this Windows binary build ---------------------------------------------------- - -This program is linked with and uses Microsoft Distributable Code, -copyrighted by Microsoft Corporation. The Microsoft Distributable Code -is embedded in each .exe, .dll and .pyd file as a result of running -the code through a linker. - -If you further distribute programs that include the Microsoft -Distributable Code, you must comply with the restrictions on -distribution specified by Microsoft. In particular, you must require -distributors and external end users to agree to terms that protect the -Microsoft Distributable Code at least as much as Microsoft's own -requirements for the Distributable Code. See Microsoft's documentation -(included in its developer tools and on its website at microsoft.com) -for specific details. - -Redistribution of the Windows binary build of the Python interpreter -complies with this agreement, provided that you do not: - -- alter any copyright, trademark or patent notice in Microsoft's -Distributable Code; - -- use Microsoft's trademarks in your programs' names or in a way that -suggests your programs come from or are endorsed by Microsoft; - -- distribute Microsoft's Distributable Code to run on a platform other -than Microsoft operating systems, run-time technologies or application -platforms; or - -- include Microsoft Distributable Code in malicious, deceptive or -unlawful programs. - -These restrictions apply only to the Microsoft Distributable Code as -defined above, not to Python itself or any programs running on the -Python interpreter. The redistribution of the Python interpreter and -libraries is governed by the Python Software License included with this -file, or by other licenses as marked. - diff --git a/PC/dl_nt.c b/PC/dl_nt.c deleted file mode 100644 index 7f17ee168727f0e80587cbc8968c1f9507361468..0000000000000000000000000000000000000000 --- a/PC/dl_nt.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - -Entry point for the Windows NT DLL. - -About the only reason for having this, is so initall() can automatically -be called, removing that burden (and possible source of frustration if -forgotten) from the programmer. - -*/ - -#include "Python.h" -#include "windows.h" - -#ifdef Py_ENABLE_SHARED - -// Python Globals -HMODULE PyWin_DLLhModule = NULL; -const char *PyWin_DLLVersionString = MS_DLL_ID; - -BOOL WINAPI DllMain (HANDLE hInst, - ULONG ul_reason_for_call, - LPVOID lpReserved) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - PyWin_DLLhModule = hInst; - break; - - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} - -#endif /* Py_ENABLE_SHARED */ diff --git a/PC/empty.c b/PC/empty.c deleted file mode 100644 index 846b4d0d646217f5ada73dba86c29ccf9ad87b0c..0000000000000000000000000000000000000000 --- a/PC/empty.c +++ /dev/null @@ -1,6 +0,0 @@ -#include -int __stdcall -WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) -{ - return 0; -} \ No newline at end of file diff --git a/PC/errmap.h b/PC/errmap.h deleted file mode 100644 index a7489ab75c65618c5486a9fb0b8c6f87fc88489c..0000000000000000000000000000000000000000 --- a/PC/errmap.h +++ /dev/null @@ -1,140 +0,0 @@ -int -winerror_to_errno(int winerror) -{ - // Unwrap FACILITY_WIN32 HRESULT errors. - if ((winerror & 0xFFFF0000) == 0x80070000) { - winerror &= 0x0000FFFF; - } - - // Winsock error codes (10000-11999) are errno values. - if (winerror >= 10000 && winerror < 12000) { - switch (winerror) { - case WSAEINTR: - case WSAEBADF: - case WSAEACCES: - case WSAEFAULT: - case WSAEINVAL: - case WSAEMFILE: - // Winsock definitions of errno values. See WinSock2.h - return winerror - 10000; - default: - return winerror; - } - } - - switch (winerror) { - case ERROR_FILE_NOT_FOUND: // 2 - case ERROR_PATH_NOT_FOUND: // 3 - case ERROR_INVALID_DRIVE: // 15 - case ERROR_NO_MORE_FILES: // 18 - case ERROR_BAD_NETPATH: // 53 - case ERROR_BAD_NET_NAME: // 67 - case ERROR_BAD_PATHNAME: // 161 - case ERROR_FILENAME_EXCED_RANGE: // 206 - return ENOENT; - - case ERROR_BAD_ENVIRONMENT: // 10 - return E2BIG; - - case ERROR_BAD_FORMAT: // 11 - case ERROR_INVALID_STARTING_CODESEG: // 188 - case ERROR_INVALID_STACKSEG: // 189 - case ERROR_INVALID_MODULETYPE: // 190 - case ERROR_INVALID_EXE_SIGNATURE: // 191 - case ERROR_EXE_MARKED_INVALID: // 192 - case ERROR_BAD_EXE_FORMAT: // 193 - case ERROR_ITERATED_DATA_EXCEEDS_64k: // 194 - case ERROR_INVALID_MINALLOCSIZE: // 195 - case ERROR_DYNLINK_FROM_INVALID_RING: // 196 - case ERROR_IOPL_NOT_ENABLED: // 197 - case ERROR_INVALID_SEGDPL: // 198 - case ERROR_AUTODATASEG_EXCEEDS_64k: // 199 - case ERROR_RING2SEG_MUST_BE_MOVABLE: // 200 - case ERROR_RELOC_CHAIN_XEEDS_SEGLIM: // 201 - case ERROR_INFLOOP_IN_RELOC_CHAIN: // 202 - return ENOEXEC; - - case ERROR_INVALID_HANDLE: // 6 - case ERROR_INVALID_TARGET_HANDLE: // 114 - case ERROR_DIRECT_ACCESS_HANDLE: // 130 - return EBADF; - - case ERROR_WAIT_NO_CHILDREN: // 128 - case ERROR_CHILD_NOT_COMPLETE: // 129 - return ECHILD; - - case ERROR_NO_PROC_SLOTS: // 89 - case ERROR_MAX_THRDS_REACHED: // 164 - case ERROR_NESTING_NOT_ALLOWED: // 215 - return EAGAIN; - - case ERROR_ARENA_TRASHED: // 7 - case ERROR_NOT_ENOUGH_MEMORY: // 8 - case ERROR_INVALID_BLOCK: // 9 - case ERROR_NOT_ENOUGH_QUOTA: // 1816 - return ENOMEM; - - case ERROR_ACCESS_DENIED: // 5 - case ERROR_CURRENT_DIRECTORY: // 16 - case ERROR_WRITE_PROTECT: // 19 - case ERROR_BAD_UNIT: // 20 - case ERROR_NOT_READY: // 21 - case ERROR_BAD_COMMAND: // 22 - case ERROR_CRC: // 23 - case ERROR_BAD_LENGTH: // 24 - case ERROR_SEEK: // 25 - case ERROR_NOT_DOS_DISK: // 26 - case ERROR_SECTOR_NOT_FOUND: // 27 - case ERROR_OUT_OF_PAPER: // 28 - case ERROR_WRITE_FAULT: // 29 - case ERROR_READ_FAULT: // 30 - case ERROR_GEN_FAILURE: // 31 - case ERROR_SHARING_VIOLATION: // 32 - case ERROR_LOCK_VIOLATION: // 33 - case ERROR_WRONG_DISK: // 34 - case ERROR_SHARING_BUFFER_EXCEEDED: // 36 - case ERROR_NETWORK_ACCESS_DENIED: // 65 - case ERROR_CANNOT_MAKE: // 82 - case ERROR_FAIL_I24: // 83 - case ERROR_DRIVE_LOCKED: // 108 - case ERROR_SEEK_ON_DEVICE: // 132 - case ERROR_NOT_LOCKED: // 158 - case ERROR_LOCK_FAILED: // 167 - case 35: // 35 (undefined) - return EACCES; - - case ERROR_FILE_EXISTS: // 80 - case ERROR_ALREADY_EXISTS: // 183 - return EEXIST; - - case ERROR_NOT_SAME_DEVICE: // 17 - return EXDEV; - - case ERROR_DIRECTORY: // 267 (bpo-12802) - return ENOTDIR; - - case ERROR_TOO_MANY_OPEN_FILES: // 4 - return EMFILE; - - case ERROR_DISK_FULL: // 112 - return ENOSPC; - - case ERROR_BROKEN_PIPE: // 109 - case ERROR_NO_DATA: // 232 (bpo-13063) - return EPIPE; - - case ERROR_DIR_NOT_EMPTY: // 145 - return ENOTEMPTY; - - case ERROR_NO_UNICODE_TRANSLATION: // 1113 - return EILSEQ; - - case ERROR_INVALID_FUNCTION: // 1 - case ERROR_INVALID_ACCESS: // 12 - case ERROR_INVALID_DATA: // 13 - case ERROR_INVALID_PARAMETER: // 87 - case ERROR_NEGATIVE_SEEK: // 131 - default: - return EINVAL; - } -} diff --git a/PC/errmap.mak b/PC/errmap.mak deleted file mode 100644 index 646bcd0a2096f88e9f815f2fe8e9fbd99527aaba..0000000000000000000000000000000000000000 --- a/PC/errmap.mak +++ /dev/null @@ -1,5 +0,0 @@ -errmap.h: generrmap.exe - .\generrmap.exe > errmap.h - -genermap.exe: generrmap.c - cl generrmap.c diff --git a/PC/frozen_dllmain.c b/PC/frozen_dllmain.c deleted file mode 100644 index 0156c5008bc93a905665ea2651a2fd8dc224edf9..0000000000000000000000000000000000000000 --- a/PC/frozen_dllmain.c +++ /dev/null @@ -1,134 +0,0 @@ -/* FreezeDLLMain.cpp - -This is a DLLMain suitable for frozen applications/DLLs on -a Windows platform. - -The general problem is that many Python extension modules may define -DLL main functions, but when statically linked together to form -a frozen application, this DLLMain symbol exists multiple times. - -The solution is: -* Each module checks for a frozen build, and if so, defines its DLLMain - function as "__declspec(dllexport) DllMain%module%" - (eg, DllMainpythoncom, or DllMainpywintypes) - -* The frozen .EXE/.DLL links against this module, which provides - the single DllMain. - -* This DllMain attempts to locate and call the DllMain for each - of the extension modules. - -* This code also has hooks to "simulate" DllMain when used from - a frozen .EXE. - -At this stage, there is a static table of "possibly embedded modules". -This should change to something better, but it will work OK for now. - -Note that this scheme does not handle dependencies in the order -of DllMain calls - except it does call pywintypes first :-) - -As an example of how an extension module with a DllMain should be -changed, here is a snippet from the pythoncom extension module. - - // end of example code from pythoncom's DllMain.cpp - #ifndef BUILD_FREEZE - #define DLLMAIN DllMain - #define DLLMAIN_DECL - #else - #define DLLMAIN DllMainpythoncom - #define DLLMAIN_DECL __declspec(dllexport) - #endif - - extern "C" DLLMAIN_DECL - BOOL WINAPI DLLMAIN(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) - // end of example code from pythoncom's DllMain.cpp - -***************************************************************************/ -#include "windows.h" - -static char *possibleModules[] = { - "pywintypes", - "pythoncom", - "win32ui", - NULL, -}; - -BOOL CallModuleDllMain(char *modName, DWORD dwReason); - - -/* - Called by a frozen .EXE only, so that built-in extension - modules are initialized correctly -*/ -void PyWinFreeze_ExeInit(void) -{ - char **modName; - for (modName = possibleModules;*modName;*modName++) { -/* printf("Initialising '%s'\n", *modName); */ - CallModuleDllMain(*modName, DLL_PROCESS_ATTACH); - } -} - -/* - Called by a frozen .EXE only, so that built-in extension - modules are cleaned up -*/ -void PyWinFreeze_ExeTerm(void) -{ - // Must go backwards - char **modName; - for (modName = possibleModules+Py_ARRAY_LENGTH(possibleModules)-2; - modName >= possibleModules; - *modName--) { -/* printf("Terminating '%s'\n", *modName);*/ - CallModuleDllMain(*modName, DLL_PROCESS_DETACH); - } -} - -BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) -{ - BOOL ret = TRUE; - switch (dwReason) { - case DLL_PROCESS_ATTACH: - { - char **modName; - for (modName = possibleModules;*modName;*modName++) { - BOOL ok = CallModuleDllMain(*modName, dwReason); - if (!ok) - ret = FALSE; - } - break; - } - case DLL_PROCESS_DETACH: - { - // Must go backwards - char **modName; - for (modName = possibleModules+Py_ARRAY_LENGTH(possibleModules)-2; - modName >= possibleModules; - *modName--) - CallModuleDllMain(*modName, DLL_PROCESS_DETACH); - break; - } - } - return ret; -} - -BOOL CallModuleDllMain(char *modName, DWORD dwReason) -{ - BOOL (WINAPI * pfndllmain)(HINSTANCE, DWORD, LPVOID); - - char funcName[255]; - HMODULE hmod = GetModuleHandleW(NULL); - strcpy(funcName, "_DllMain"); - strcat(funcName, modName); - strcat(funcName, "@12"); // stdcall convention. - pfndllmain = (BOOL (WINAPI *)(HINSTANCE, DWORD, LPVOID))GetProcAddress(hmod, funcName); - if (pfndllmain==NULL) { - /* No function by that name exported - then that module does - not appear in our frozen program - return OK - */ - return TRUE; - } - return (*pfndllmain)(hmod, dwReason, NULL); -} - diff --git a/PC/getpathp.c b/PC/getpathp.c deleted file mode 100644 index 7c0eeab5dbab4a36ee5957ac764c6dc026a45158..0000000000000000000000000000000000000000 --- a/PC/getpathp.c +++ /dev/null @@ -1,1140 +0,0 @@ - -/* Return the initial module search path. */ -/* Used by DOS, Windows 3.1, Windows 95/98, Windows NT. */ - -/* ---------------------------------------------------------------- - PATH RULES FOR WINDOWS: - This describes how sys.path is formed on Windows. It describes the - functionality, not the implementation (ie, the order in which these - are actually fetched is different). The presence of a python._pth or - pythonXY._pth file alongside the program overrides these rules - see - below. - - * Python always adds an empty entry at the start, which corresponds - to the current directory. - - * If the PYTHONPATH env. var. exists, its entries are added next. - - * We look in the registry for "application paths" - that is, sub-keys - under the main PythonPath registry key. These are added next (the - order of sub-key processing is undefined). - HKEY_CURRENT_USER is searched and added first. - HKEY_LOCAL_MACHINE is searched and added next. - (Note that all known installers only use HKLM, so HKCU is typically - empty) - - * We attempt to locate the "Python Home" - if the PYTHONHOME env var - is set, we believe it. Otherwise, we use the path of our host .EXE's - to try and locate one of our "landmarks" and deduce our home. - - If we DO have a Python Home: The relevant sub-directories (Lib, - DLLs, etc) are based on the Python Home - - If we DO NOT have a Python Home, the core Python Path is - loaded from the registry. (This is the main PythonPath key, - and both HKLM and HKCU are combined to form the path) - - * Iff - we can not locate the Python Home, have not had a PYTHONPATH - specified, and can't locate any Registry entries (ie, we have _nothing_ - we can assume is a good path), a default path with relative entries is - used (eg. .\Lib;.\DLLs, etc) - - - If a '._pth' file exists adjacent to the executable with the same base name - (e.g. python._pth adjacent to python.exe) or adjacent to the shared library - (e.g. python36._pth adjacent to python36.dll), it is used in preference to - the above process. The shared library file takes precedence over the - executable. The path file must contain a list of paths to add to sys.path, - one per line. Each path is relative to the directory containing the file. - Blank lines and comments beginning with '#' are permitted. - - In the presence of this ._pth file, no other paths are added to the search - path, the registry finder is not enabled, site.py is not imported and - isolated mode is enabled. The site package can be enabled by including a - line reading "import site"; no other imports are recognized. Any invalid - entry (other than directories that do not exist) will result in immediate - termination of the program. - - - The end result of all this is: - * When running python.exe, or any other .exe in the main Python directory - (either an installed version, or directly from the PCbuild directory), - the core path is deduced, and the core paths in the registry are - ignored. Other "application paths" in the registry are always read. - - * When Python is hosted in another exe (different directory, embedded via - COM, etc), the Python Home will not be deduced, so the core path from - the registry is used. Other "application paths" in the registry are - always read. - - * If Python can't find its home and there is no registry (eg, frozen - exe, some very strange installation setup) you get a path with - some default, but relative, paths. - - * An embedding application can use Py_SetPath() to override all of - these automatic path computations. - - * An install of Python can fully specify the contents of sys.path using - either a 'EXENAME._pth' or 'DLLNAME._pth' file, optionally including - "import site" to enable the site module. - - ---------------------------------------------------------------- */ - - -#include "Python.h" -#include "pycore_initconfig.h" // PyStatus -#include "pycore_pathconfig.h" // _PyPathConfig -#include "osdefs.h" // SEP, ALTSEP -#include - -#ifndef MS_WINDOWS -#error getpathp.c should only be built on Windows -#endif - -#include -#include - -#ifdef HAVE_SYS_TYPES_H -#include -#endif /* HAVE_SYS_TYPES_H */ - -#ifdef HAVE_SYS_STAT_H -#include -#endif /* HAVE_SYS_STAT_H */ - -#include - -/* Search in some common locations for the associated Python libraries. - * - * Py_GetPath() tries to return a sensible Python module search path. - * - * The approach is an adaptation for Windows of the strategy used in - * ../Modules/getpath.c; it uses the Windows Registry as one of its - * information sources. - * - * Py_SetPath() can be used to override this mechanism. Call Py_SetPath - * with a semicolon separated path prior to calling Py_Initialize. - */ - -#ifndef LANDMARK -# define LANDMARK L"lib\\os.py" -#endif - -#define INIT_ERR_BUFFER_OVERFLOW() _PyStatus_ERR("buffer overflow") - - -typedef struct { - const wchar_t *path_env; /* PATH environment variable */ - const wchar_t *home; /* PYTHONHOME environment variable */ - - /* Registry key "Software\Python\PythonCore\X.Y\PythonPath" - where X.Y is the Python version (major.minor) */ - wchar_t *machine_path; /* from HKEY_LOCAL_MACHINE */ - wchar_t *user_path; /* from HKEY_CURRENT_USER */ - - const wchar_t *pythonpath_env; -} PyCalculatePath; - - -/* determine if "ch" is a separator character */ -static int -is_sep(wchar_t ch) -{ -#ifdef ALTSEP - return ch == SEP || ch == ALTSEP; -#else - return ch == SEP; -#endif -} - - -/* assumes 'dir' null terminated in bounds. Never writes - beyond existing terminator. */ -static void -reduce(wchar_t *dir) -{ - size_t i = wcsnlen_s(dir, MAXPATHLEN+1); - if (i >= MAXPATHLEN+1) { - Py_FatalError("buffer overflow in getpathp.c's reduce()"); - } - - while (i > 0 && !is_sep(dir[i])) - --i; - dir[i] = '\0'; -} - - -static int -change_ext(wchar_t *dest, const wchar_t *src, const wchar_t *ext) -{ - if (src && src != dest) { - size_t src_len = wcsnlen_s(src, MAXPATHLEN+1); - size_t i = src_len; - if (i >= MAXPATHLEN+1) { - Py_FatalError("buffer overflow in getpathp.c's reduce()"); - } - - while (i > 0 && src[i] != '.' && !is_sep(src[i])) - --i; - - if (i == 0) { - dest[0] = '\0'; - return -1; - } - - if (is_sep(src[i])) { - i = src_len; - } - - if (wcsncpy_s(dest, MAXPATHLEN+1, src, i)) { - dest[0] = '\0'; - return -1; - } - } else { - wchar_t *s = wcsrchr(dest, L'.'); - if (s) { - s[0] = '\0'; - } - } - - if (wcscat_s(dest, MAXPATHLEN+1, ext)) { - dest[0] = '\0'; - return -1; - } - - return 0; -} - - -static int -exists(const wchar_t *filename) -{ - return GetFileAttributesW(filename) != 0xFFFFFFFF; -} - - -/* Is module -- check for .pyc too. - Assumes 'filename' MAXPATHLEN+1 bytes long - - may extend 'filename' by one character. */ -static int -ismodule(wchar_t *filename, int update_filename) -{ - size_t n; - - if (exists(filename)) { - return 1; - } - - /* Check for the compiled version of prefix. */ - n = wcsnlen_s(filename, MAXPATHLEN+1); - if (n < MAXPATHLEN) { - int exist = 0; - filename[n] = L'c'; - filename[n + 1] = L'\0'; - exist = exists(filename); - if (!update_filename) { - filename[n] = L'\0'; - } - return exist; - } - return 0; -} - - -/* Add a path component, by appending stuff to buffer. - buffer must have at least MAXPATHLEN + 1 bytes allocated, and contain a - NUL-terminated string with no more than MAXPATHLEN characters (not counting - the trailing NUL). It's a fatal error if it contains a string longer than - that (callers must be careful!). If these requirements are met, it's - guaranteed that buffer will still be a NUL-terminated string with no more - than MAXPATHLEN characters at exit. If stuff is too long, only as much of - stuff as fits will be appended. -*/ - -static void -join(wchar_t *buffer, const wchar_t *stuff) -{ - if (FAILED(PathCchCombineEx(buffer, MAXPATHLEN+1, buffer, stuff, 0))) { - Py_FatalError("buffer overflow in getpathp.c's join()"); - } -} - -/* Call PathCchCanonicalizeEx(path): remove navigation elements such as "." - and ".." to produce a direct, well-formed path. */ -static PyStatus -canonicalize(wchar_t *buffer, const wchar_t *path) -{ - if (buffer == NULL) { - return _PyStatus_NO_MEMORY(); - } - - if (FAILED(PathCchCanonicalizeEx(buffer, MAXPATHLEN + 1, path, 0))) { - return INIT_ERR_BUFFER_OVERFLOW(); - } - return _PyStatus_OK(); -} - - -/* gotlandmark only called by search_for_prefix, which ensures - 'prefix' is null terminated in bounds. join() ensures - 'landmark' can not overflow prefix if too long. */ -static int -gotlandmark(const wchar_t *prefix, const wchar_t *landmark) -{ - wchar_t filename[MAXPATHLEN+1]; - memset(filename, 0, sizeof(filename)); - wcscpy_s(filename, Py_ARRAY_LENGTH(filename), prefix); - join(filename, landmark); - return ismodule(filename, FALSE); -} - - -/* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd. - assumption provided by only caller, calculate_path() */ -static int -search_for_prefix(wchar_t *prefix, const wchar_t *argv0_path, const wchar_t *landmark) -{ - /* Search from argv0_path, until landmark is found */ - wcscpy_s(prefix, MAXPATHLEN + 1, argv0_path); - do { - if (gotlandmark(prefix, landmark)) { - return 1; - } - reduce(prefix); - } while (prefix[0]); - return 0; -} - - -static int -get_dllpath(wchar_t *dllpath) -{ -#ifdef Py_ENABLE_SHARED - extern HANDLE PyWin_DLLhModule; - if (PyWin_DLLhModule && GetModuleFileNameW(PyWin_DLLhModule, dllpath, MAXPATHLEN)) { - return 0; - } -#endif - return -1; -} - - -#ifdef Py_ENABLE_SHARED - -/* a string loaded from the DLL at startup.*/ -extern const char *PyWin_DLLVersionString; - -/* Load a PYTHONPATH value from the registry. - Load from either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER. - - Works in both Unicode and 8bit environments. Only uses the - Ex family of functions so it also works with Windows CE. - - Returns NULL, or a pointer that should be freed. - - XXX - this code is pretty strange, as it used to also - work on Win16, where the buffer sizes were not available - in advance. It could be simplied now Win16/Win32s is dead! -*/ -static wchar_t * -getpythonregpath(HKEY keyBase, int skipcore) -{ - HKEY newKey = 0; - DWORD dataSize = 0; - DWORD numKeys = 0; - LONG rc; - wchar_t *retval = NULL; - WCHAR *dataBuf = NULL; - static const WCHAR keyPrefix[] = L"Software\\Python\\PythonCore\\"; - static const WCHAR keySuffix[] = L"\\PythonPath"; - size_t versionLen, keyBufLen; - DWORD index; - WCHAR *keyBuf = NULL; - WCHAR *keyBufPtr; - WCHAR **ppPaths = NULL; - - /* Tried to use sysget("winver") but here is too early :-( */ - versionLen = strlen(PyWin_DLLVersionString); - /* Space for all the chars, plus one \0 */ - keyBufLen = sizeof(keyPrefix) + - sizeof(WCHAR)*(versionLen-1) + - sizeof(keySuffix); - keyBuf = keyBufPtr = PyMem_RawMalloc(keyBufLen); - if (keyBuf==NULL) { - goto done; - } - - memcpy_s(keyBufPtr, keyBufLen, keyPrefix, sizeof(keyPrefix)-sizeof(WCHAR)); - keyBufPtr += Py_ARRAY_LENGTH(keyPrefix) - 1; - mbstowcs(keyBufPtr, PyWin_DLLVersionString, versionLen); - keyBufPtr += versionLen; - /* NULL comes with this one! */ - memcpy(keyBufPtr, keySuffix, sizeof(keySuffix)); - /* Open the root Python key */ - rc=RegOpenKeyExW(keyBase, - keyBuf, /* subkey */ - 0, /* reserved */ - KEY_READ, - &newKey); - if (rc!=ERROR_SUCCESS) { - goto done; - } - /* Find out how big our core buffer is, and how many subkeys we have */ - rc = RegQueryInfoKeyW(newKey, NULL, NULL, NULL, &numKeys, NULL, NULL, - NULL, NULL, &dataSize, NULL, NULL); - if (rc!=ERROR_SUCCESS) { - goto done; - } - if (skipcore) { - dataSize = 0; /* Only count core ones if we want them! */ - } - /* Allocate a temp array of char buffers, so we only need to loop - reading the registry once - */ - ppPaths = PyMem_RawCalloc(numKeys, sizeof(WCHAR *)); - if (ppPaths==NULL) { - goto done; - } - /* Loop over all subkeys, allocating a temp sub-buffer. */ - for(index=0;index 0) { - *(szCur++) = L';'; - dataSize--; - } - if (ppPaths[index]) { - Py_ssize_t len = wcslen(ppPaths[index]); - wcsncpy(szCur, ppPaths[index], len); - szCur += len; - assert(dataSize > (DWORD)len); - dataSize -= (DWORD)len; - } - } - if (skipcore) { - *szCur = '\0'; - } - else { - /* If we have no values, we don't need a ';' */ - if (numKeys) { - *(szCur++) = L';'; - dataSize--; - } - /* Now append the core path entries - - this will include the NULL - */ - rc = RegQueryValueExW(newKey, NULL, 0, NULL, - (LPBYTE)szCur, &dataSize); - if (rc != ERROR_SUCCESS) { - PyMem_RawFree(dataBuf); - goto done; - } - } - /* And set the result - caller must free */ - retval = dataBuf; - } -done: - /* Loop freeing my temp buffers */ - if (ppPaths) { - for(index=0; indexbase_executable == NULL) { - pathconfig->base_executable = PyMem_RawMalloc( - sizeof(wchar_t) * (MAXPATHLEN + 1)); - if (pathconfig->base_executable == NULL) { - return _PyStatus_NO_MEMORY(); - } - - status = canonicalize(pathconfig->base_executable, - program_full_path); - if (_PyStatus_EXCEPTION(status)) { - return status; - } - } - - wcscpy_s(program_full_path, MAXPATHLEN+1, pyvenv_launcher); - /* bpo-35873: Clear the environment variable to avoid it being - * inherited by child processes. */ - _wputenv_s(L"__PYVENV_LAUNCHER__", L""); - } - - if (pathconfig->program_full_path == NULL) { - pathconfig->program_full_path = PyMem_RawMalloc( - sizeof(wchar_t) * (MAXPATHLEN + 1)); - if (pathconfig->program_full_path == NULL) { - return _PyStatus_NO_MEMORY(); - } - - status = canonicalize(pathconfig->program_full_path, - program_full_path); - if (_PyStatus_EXCEPTION(status)) { - return status; - } - } - return _PyStatus_OK(); -} - - -static PyStatus -read_pth_file(_PyPathConfig *pathconfig, wchar_t *prefix, const wchar_t *path, - int *found) -{ - PyStatus status; - wchar_t *buf = NULL; - wchar_t *wline = NULL; - FILE *sp_file; - - sp_file = _Py_wfopen(path, L"r"); - if (sp_file == NULL) { - return _PyStatus_OK(); - } - - wcscpy_s(prefix, MAXPATHLEN+1, path); - reduce(prefix); - pathconfig->isolated = 1; - pathconfig->site_import = 0; - - size_t bufsiz = MAXPATHLEN; - size_t prefixlen = wcslen(prefix); - - buf = (wchar_t*)PyMem_RawMalloc(bufsiz * sizeof(wchar_t)); - if (buf == NULL) { - status = _PyStatus_NO_MEMORY(); - goto done; - } - buf[0] = '\0'; - - while (!feof(sp_file)) { - char line[MAXPATHLEN + 1]; - char *p = fgets(line, Py_ARRAY_LENGTH(line), sp_file); - if (!p) { - break; - } - if (*p == '\0' || *p == '\r' || *p == '\n' || *p == '#') { - continue; - } - while (*++p) { - if (*p == '\r' || *p == '\n') { - *p = '\0'; - break; - } - } - - if (strcmp(line, "import site") == 0) { - pathconfig->site_import = 1; - continue; - } - else if (strncmp(line, "import ", 7) == 0) { - status = _PyStatus_ERR("only 'import site' is supported " - "in ._pth file"); - goto done; - } - - DWORD wn = MultiByteToWideChar(CP_UTF8, 0, line, -1, NULL, 0); - wchar_t *wline = (wchar_t*)PyMem_RawMalloc((wn + 1) * sizeof(wchar_t)); - if (wline == NULL) { - status = _PyStatus_NO_MEMORY(); - goto done; - } - wn = MultiByteToWideChar(CP_UTF8, 0, line, -1, wline, wn + 1); - wline[wn] = '\0'; - - size_t usedsiz = wcslen(buf); - while (usedsiz + wn + prefixlen + 4 > bufsiz) { - bufsiz += MAXPATHLEN; - wchar_t *tmp = (wchar_t*)PyMem_RawRealloc(buf, (bufsiz + 1) * - sizeof(wchar_t)); - if (tmp == NULL) { - status = _PyStatus_NO_MEMORY(); - goto done; - } - buf = tmp; - } - - if (usedsiz) { - wcscat_s(buf, bufsiz, L";"); - usedsiz += 1; - } - - errno_t result; - _Py_BEGIN_SUPPRESS_IPH - result = wcscat_s(buf, bufsiz, prefix); - _Py_END_SUPPRESS_IPH - - if (result == EINVAL) { - status = _PyStatus_ERR("invalid argument during ._pth processing"); - goto done; - } else if (result == ERANGE) { - status = _PyStatus_ERR("buffer overflow during ._pth processing"); - goto done; - } - - wchar_t *b = &buf[usedsiz]; - join(b, wline); - - PyMem_RawFree(wline); - wline = NULL; - } - - if (pathconfig->module_search_path == NULL) { - pathconfig->module_search_path = _PyMem_RawWcsdup(buf); - if (pathconfig->module_search_path == NULL) { - status = _PyStatus_NO_MEMORY(); - goto done; - } - } - - *found = 1; - status = _PyStatus_OK(); - goto done; - -done: - PyMem_RawFree(buf); - PyMem_RawFree(wline); - fclose(sp_file); - return status; -} - - -static int -get_pth_filename(PyCalculatePath *calculate, wchar_t *filename, - const _PyPathConfig *pathconfig) -{ - if (!get_dllpath(filename) && - !change_ext(filename, filename, L"._pth") && - exists(filename)) - { - return 1; - } - if (pathconfig->program_full_path[0] && - !change_ext(filename, pathconfig->program_full_path, L"._pth") && - exists(filename)) - { - return 1; - } - return 0; -} - - -static PyStatus -calculate_pth_file(PyCalculatePath *calculate, _PyPathConfig *pathconfig, - wchar_t *prefix, int *found) -{ - wchar_t filename[MAXPATHLEN+1]; - - if (!get_pth_filename(calculate, filename, pathconfig)) { - return _PyStatus_OK(); - } - - return read_pth_file(pathconfig, prefix, filename, found); -} - - -/* Search for an environment configuration file, first in the - executable's directory and then in the parent directory. - If found, open it for use when searching for prefixes. -*/ -static PyStatus -calculate_pyvenv_file(PyCalculatePath *calculate, - wchar_t *argv0_path, size_t argv0_path_len) -{ - wchar_t filename[MAXPATHLEN+1]; - const wchar_t *env_cfg = L"pyvenv.cfg"; - - /* Filename: / "pyvenv.cfg" */ - wcscpy_s(filename, MAXPATHLEN+1, argv0_path); - join(filename, env_cfg); - - FILE *env_file = _Py_wfopen(filename, L"r"); - if (env_file == NULL) { - errno = 0; - - /* Filename: / "pyvenv.cfg" */ - reduce(filename); - reduce(filename); - join(filename, env_cfg); - - env_file = _Py_wfopen(filename, L"r"); - if (env_file == NULL) { - errno = 0; - return _PyStatus_OK(); - } - } - - /* Look for a 'home' variable and set argv0_path to it, if found */ - wchar_t *home = NULL; - PyStatus status = _Py_FindEnvConfigValue(env_file, L"home", &home); - if (_PyStatus_EXCEPTION(status)) { - fclose(env_file); - return status; - } - if (home) { - wcscpy_s(argv0_path, argv0_path_len, home); - PyMem_RawFree(home); - } - fclose(env_file); - return _PyStatus_OK(); -} - - -static void -calculate_home_prefix(PyCalculatePath *calculate, - const wchar_t *argv0_path, - const wchar_t *zip_path, - wchar_t *prefix) -{ - if (calculate->home == NULL || *calculate->home == '\0') { - if (zip_path[0] && exists(zip_path)) { - wcscpy_s(prefix, MAXPATHLEN+1, zip_path); - reduce(prefix); - calculate->home = prefix; - } - else if (search_for_prefix(prefix, argv0_path, LANDMARK)) { - calculate->home = prefix; - } - else { - calculate->home = NULL; - } - } - else { - wcscpy_s(prefix, MAXPATHLEN+1, calculate->home); - } -} - - -static PyStatus -calculate_module_search_path(PyCalculatePath *calculate, - _PyPathConfig *pathconfig, - const wchar_t *argv0_path, - wchar_t *prefix, - const wchar_t *zip_path) -{ - int skiphome = calculate->home==NULL ? 0 : 1; -#ifdef Py_ENABLE_SHARED - if (!Py_IgnoreEnvironmentFlag) { - calculate->machine_path = getpythonregpath(HKEY_LOCAL_MACHINE, - skiphome); - calculate->user_path = getpythonregpath(HKEY_CURRENT_USER, skiphome); - } -#endif - /* We only use the default relative PYTHONPATH if we haven't - anything better to use! */ - int skipdefault = (calculate->pythonpath_env != NULL || - calculate->home != NULL || - calculate->machine_path != NULL || - calculate->user_path != NULL); - - /* We need to construct a path from the following parts. - (1) the PYTHONPATH environment variable, if set; - (2) for Win32, the zip archive file path; - (3) for Win32, the machine_path and user_path, if set; - (4) the PYTHONPATH config macro, with the leading "." - of each component replaced with home, if set; - (5) the directory containing the executable (argv0_path). - The length calculation calculates #4 first. - Extra rules: - - If PYTHONHOME is set (in any way) item (3) is ignored. - - If registry values are used, (4) and (5) are ignored. - */ - - /* Calculate size of return buffer */ - size_t bufsz = 0; - if (calculate->home != NULL) { - const wchar_t *p; - bufsz = 1; - for (p = PYTHONPATH; *p; p++) { - if (*p == DELIM) { - bufsz++; /* number of DELIM plus one */ - } - } - bufsz *= wcslen(calculate->home); - } - bufsz += wcslen(PYTHONPATH) + 1; - bufsz += wcslen(argv0_path) + 1; - if (calculate->user_path) { - bufsz += wcslen(calculate->user_path) + 1; - } - if (calculate->machine_path) { - bufsz += wcslen(calculate->machine_path) + 1; - } - bufsz += wcslen(zip_path) + 1; - if (calculate->pythonpath_env != NULL) { - bufsz += wcslen(calculate->pythonpath_env) + 1; - } - - wchar_t *buf, *start_buf; - buf = PyMem_RawMalloc(bufsz * sizeof(wchar_t)); - if (buf == NULL) { - return _PyStatus_NO_MEMORY(); - } - start_buf = buf; - - if (calculate->pythonpath_env) { - if (wcscpy_s(buf, bufsz - (buf - start_buf), - calculate->pythonpath_env)) { - return INIT_ERR_BUFFER_OVERFLOW(); - } - buf = wcschr(buf, L'\0'); - *buf++ = DELIM; - } - if (zip_path[0]) { - if (wcscpy_s(buf, bufsz - (buf - start_buf), zip_path)) { - return INIT_ERR_BUFFER_OVERFLOW(); - } - buf = wcschr(buf, L'\0'); - *buf++ = DELIM; - } - if (calculate->user_path) { - if (wcscpy_s(buf, bufsz - (buf - start_buf), calculate->user_path)) { - return INIT_ERR_BUFFER_OVERFLOW(); - } - buf = wcschr(buf, L'\0'); - *buf++ = DELIM; - } - if (calculate->machine_path) { - if (wcscpy_s(buf, bufsz - (buf - start_buf), calculate->machine_path)) { - return INIT_ERR_BUFFER_OVERFLOW(); - } - buf = wcschr(buf, L'\0'); - *buf++ = DELIM; - } - if (calculate->home == NULL) { - if (!skipdefault) { - if (wcscpy_s(buf, bufsz - (buf - start_buf), PYTHONPATH)) { - return INIT_ERR_BUFFER_OVERFLOW(); - } - buf = wcschr(buf, L'\0'); - *buf++ = DELIM; - } - } else { - const wchar_t *p = PYTHONPATH; - const wchar_t *q; - size_t n; - for (;;) { - q = wcschr(p, DELIM); - if (q == NULL) { - n = wcslen(p); - } - else { - n = q-p; - } - if (p[0] == '.' && is_sep(p[1])) { - if (wcscpy_s(buf, bufsz - (buf - start_buf), calculate->home)) { - return INIT_ERR_BUFFER_OVERFLOW(); - } - buf = wcschr(buf, L'\0'); - p++; - n--; - } - wcsncpy(buf, p, n); - buf += n; - *buf++ = DELIM; - if (q == NULL) { - break; - } - p = q+1; - } - } - if (argv0_path) { - wcscpy(buf, argv0_path); - buf = wcschr(buf, L'\0'); - *buf++ = DELIM; - } - *(buf - 1) = L'\0'; - - /* Now to pull one last hack/trick. If sys.prefix is - empty, then try and find it somewhere on the paths - we calculated. We scan backwards, as our general policy - is that Python core directories are at the *end* of - sys.path. We assume that our "lib" directory is - on the path, and that our 'prefix' directory is - the parent of that. - */ - if (prefix[0] == L'\0') { - wchar_t lookBuf[MAXPATHLEN+1]; - const wchar_t *look = buf - 1; /* 'buf' is at the end of the buffer */ - while (1) { - Py_ssize_t nchars; - const wchar_t *lookEnd = look; - /* 'look' will end up one character before the - start of the path in question - even if this - is one character before the start of the buffer - */ - while (look >= start_buf && *look != DELIM) - look--; - nchars = lookEnd-look; - wcsncpy(lookBuf, look+1, nchars); - lookBuf[nchars] = L'\0'; - /* Up one level to the parent */ - reduce(lookBuf); - if (search_for_prefix(prefix, lookBuf, LANDMARK)) { - break; - } - /* If we are out of paths to search - give up */ - if (look < start_buf) { - break; - } - look--; - } - } - - pathconfig->module_search_path = start_buf; - return _PyStatus_OK(); -} - - -static PyStatus -calculate_path(PyCalculatePath *calculate, _PyPathConfig *pathconfig) -{ - PyStatus status; - - status = get_program_full_path(pathconfig); - if (_PyStatus_EXCEPTION(status)) { - return status; - } - - /* program_full_path guaranteed \0 terminated in MAXPATH+1 bytes. */ - wchar_t argv0_path[MAXPATHLEN+1]; - memset(argv0_path, 0, sizeof(argv0_path)); - - wcscpy_s(argv0_path, MAXPATHLEN+1, pathconfig->program_full_path); - reduce(argv0_path); - - wchar_t prefix[MAXPATHLEN+1]; - memset(prefix, 0, sizeof(prefix)); - - /* Search for a sys.path file */ - int pth_found = 0; - status = calculate_pth_file(calculate, pathconfig, prefix, &pth_found); - if (_PyStatus_EXCEPTION(status)) { - return status; - } - if (pth_found) { - goto done; - } - - status = calculate_pyvenv_file(calculate, - argv0_path, Py_ARRAY_LENGTH(argv0_path)); - if (_PyStatus_EXCEPTION(status)) { - return status; - } - - /* Calculate zip archive path from DLL or exe path */ - wchar_t zip_path[MAXPATHLEN+1]; - memset(zip_path, 0, sizeof(zip_path)); - - if (get_dllpath(zip_path) || change_ext(zip_path, zip_path, L".zip")) - { - if (change_ext(zip_path, pathconfig->program_full_path, L".zip")) { - zip_path[0] = L'\0'; - } - } - - calculate_home_prefix(calculate, argv0_path, zip_path, prefix); - - if (pathconfig->module_search_path == NULL) { - status = calculate_module_search_path(calculate, pathconfig, - argv0_path, prefix, zip_path); - if (_PyStatus_EXCEPTION(status)) { - return status; - } - } - -done: - if (pathconfig->prefix == NULL) { - pathconfig->prefix = _PyMem_RawWcsdup(prefix); - if (pathconfig->prefix == NULL) { - return _PyStatus_NO_MEMORY(); - } - } - if (pathconfig->exec_prefix == NULL) { - pathconfig->exec_prefix = _PyMem_RawWcsdup(prefix); - if (pathconfig->exec_prefix == NULL) { - return _PyStatus_NO_MEMORY(); - } - } - - return _PyStatus_OK(); -} - - -static PyStatus -calculate_init(PyCalculatePath *calculate, _PyPathConfig *pathconfig, - const PyConfig *config) -{ - calculate->home = pathconfig->home; - calculate->path_env = _wgetenv(L"PATH"); - - calculate->pythonpath_env = config->pythonpath_env; - - return _PyStatus_OK(); -} - - -static void -calculate_free(PyCalculatePath *calculate) -{ - PyMem_RawFree(calculate->machine_path); - PyMem_RawFree(calculate->user_path); -} - - -/* Calculate the Python path configuration. - - Inputs: - - - PyConfig.pythonpath_env: PYTHONPATH environment variable - - _PyPathConfig.home: Py_SetPythonHome() or PYTHONHOME environment variable - - PATH environment variable - - __PYVENV_LAUNCHER__ environment variable - - GetModuleFileNameW(NULL): fully qualified path of the executable file of - the current process - - ._pth configuration file - - pyvenv.cfg configuration file - - Registry key "Software\Python\PythonCore\X.Y\PythonPath" - of HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE where X.Y is the Python - version. - - Outputs, 'pathconfig' fields: - - - base_executable - - program_full_path - - module_search_path - - prefix - - exec_prefix - - isolated - - site_import - - If a field is already set (non NULL), it is left unchanged. */ -PyStatus -_PyPathConfig_Calculate(_PyPathConfig *pathconfig, const PyConfig *config) -{ - PyStatus status; - PyCalculatePath calculate; - memset(&calculate, 0, sizeof(calculate)); - - status = calculate_init(&calculate, pathconfig, config); - if (_PyStatus_EXCEPTION(status)) { - goto done; - } - - status = calculate_path(&calculate, pathconfig); - -done: - calculate_free(&calculate); - return status; -} - - -/* Load python3.dll before loading any extension module that might refer - to it. That way, we can be sure that always the python3.dll corresponding - to this python DLL is loaded, not a python3.dll that might be on the path - by chance. - Return whether the DLL was found. -*/ -static int python3_checked = 0; -static HANDLE hPython3; -int -_Py_CheckPython3(void) -{ - wchar_t py3path[MAXPATHLEN+1]; - if (python3_checked) { - return hPython3 != NULL; - } - python3_checked = 1; - - /* If there is a python3.dll next to the python3y.dll, - use that DLL */ - if (!get_dllpath(py3path)) { - reduce(py3path); - join(py3path, PY3_DLLNAME); - hPython3 = LoadLibraryExW(py3path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); - if (hPython3 != NULL) { - return 1; - } - } - - /* If we can locate python3.dll in our application dir, - use that DLL */ - hPython3 = LoadLibraryExW(PY3_DLLNAME, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR); - if (hPython3 != NULL) { - return 1; - } - - /* For back-compat, also search {sys.prefix}\DLLs, though - that has not been a normal install layout for a while */ - wcscpy(py3path, Py_GetPrefix()); - if (py3path[0]) { - join(py3path, L"DLLs\\" PY3_DLLNAME); - hPython3 = LoadLibraryExW(py3path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); - } - return hPython3 != NULL; -} diff --git a/PC/icons/idlex150.png b/PC/icons/idlex150.png deleted file mode 100644 index 806cb0c8aa219be92c78937b5d291ba905cf9978..0000000000000000000000000000000000000000 Binary files a/PC/icons/idlex150.png and /dev/null differ diff --git a/PC/icons/idlex44.png b/PC/icons/idlex44.png deleted file mode 100644 index 3ef66e6c68e6bb77bf84fe310112a96908c23d73..0000000000000000000000000000000000000000 Binary files a/PC/icons/idlex44.png and /dev/null differ diff --git a/PC/icons/launcher.icns b/PC/icons/launcher.icns deleted file mode 100644 index 59a917f20d37ca7d86723f75fbb8e8324ce69710..0000000000000000000000000000000000000000 Binary files a/PC/icons/launcher.icns and /dev/null differ diff --git a/PC/icons/launcher.ico b/PC/icons/launcher.ico deleted file mode 100644 index c4e3c693dcb4a9baa6ba26cdfe1359fc552db2f7..0000000000000000000000000000000000000000 Binary files a/PC/icons/launcher.ico and /dev/null differ diff --git a/PC/icons/launcher.svg b/PC/icons/launcher.svg deleted file mode 100644 index 0590b0d2d0d5d4f0ac3faac11610bbb0e15964d6..0000000000000000000000000000000000000000 --- a/PC/icons/launcher.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/PC/icons/logo.svg b/PC/icons/logo.svg deleted file mode 100644 index 6f521503a3832890e60c70f4374a9fbc9aefa34e..0000000000000000000000000000000000000000 --- a/PC/icons/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/PC/icons/logox128.png b/PC/icons/logox128.png deleted file mode 100644 index a403de5818cfecadf9516f5ca93322371240cd50..0000000000000000000000000000000000000000 Binary files a/PC/icons/logox128.png and /dev/null differ diff --git a/PC/icons/py.icns b/PC/icons/py.icns deleted file mode 100644 index 2dc4e296f81e823ab751172c02ebb97d65852648..0000000000000000000000000000000000000000 Binary files a/PC/icons/py.icns and /dev/null differ diff --git a/PC/icons/py.ico b/PC/icons/py.ico deleted file mode 100644 index 1d8a79bfb310c71c30d2d59a975c8bae82775ee5..0000000000000000000000000000000000000000 Binary files a/PC/icons/py.ico and /dev/null differ diff --git a/PC/icons/py.png b/PC/icons/py.png deleted file mode 100644 index 629022a70bdc4443e761223af8dbb80b36bb2d38..0000000000000000000000000000000000000000 Binary files a/PC/icons/py.png and /dev/null differ diff --git a/PC/icons/py.svg b/PC/icons/py.svg deleted file mode 100644 index 0924e83fbc711e1d07a6e548cc725a4029f8abfa..0000000000000000000000000000000000000000 --- a/PC/icons/py.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/PC/icons/pyc.icns b/PC/icons/pyc.icns deleted file mode 100644 index 50da9a161501d9566c668f5a09720f60630d9914..0000000000000000000000000000000000000000 Binary files a/PC/icons/pyc.icns and /dev/null differ diff --git a/PC/icons/pyc.ico b/PC/icons/pyc.ico deleted file mode 100644 index 74dde81b649eedaee58db05851f4f8c4af246501..0000000000000000000000000000000000000000 Binary files a/PC/icons/pyc.ico and /dev/null differ diff --git a/PC/icons/pyc.svg b/PC/icons/pyc.svg deleted file mode 100644 index 5c3e9e7920bd30c1c3670b8de0910dd06e5890f8..0000000000000000000000000000000000000000 --- a/PC/icons/pyc.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/PC/icons/pyd.icns b/PC/icons/pyd.icns deleted file mode 100644 index 5d3d24ee2567946ae21327efd208c6029958cc87..0000000000000000000000000000000000000000 Binary files a/PC/icons/pyd.icns and /dev/null differ diff --git a/PC/icons/pyd.ico b/PC/icons/pyd.ico deleted file mode 100644 index 9f6cb601afb65ab1821af0d7418fa6dcfd83e16d..0000000000000000000000000000000000000000 Binary files a/PC/icons/pyd.ico and /dev/null differ diff --git a/PC/icons/pyd.svg b/PC/icons/pyd.svg deleted file mode 100644 index 17eff6a30770f7c08e49b8ef504deebd4802905d..0000000000000000000000000000000000000000 --- a/PC/icons/pyd.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/PC/icons/python.icns b/PC/icons/python.icns deleted file mode 100644 index fc53e02f4a91989a80570f8fdfc288b1ade7e378..0000000000000000000000000000000000000000 Binary files a/PC/icons/python.icns and /dev/null differ diff --git a/PC/icons/python.ico b/PC/icons/python.ico deleted file mode 100644 index b8a38ef15994ff855ce1cecd379cab146ea82dda..0000000000000000000000000000000000000000 Binary files a/PC/icons/python.ico and /dev/null differ diff --git a/PC/icons/python.svg b/PC/icons/python.svg deleted file mode 100644 index e23e5a3f636121e466f5fa6f2a74cda7d6ddbb4a..0000000000000000000000000000000000000000 --- a/PC/icons/python.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/PC/icons/pythonw.icns b/PC/icons/pythonw.icns deleted file mode 100644 index 9354cf870a9f6a5e6154fa815fa3137aa0659457..0000000000000000000000000000000000000000 Binary files a/PC/icons/pythonw.icns and /dev/null differ diff --git a/PC/icons/pythonw.ico b/PC/icons/pythonw.ico deleted file mode 100644 index 6195d433475e06186e5d5dc92e005c1926f20fe6..0000000000000000000000000000000000000000 Binary files a/PC/icons/pythonw.ico and /dev/null differ diff --git a/PC/icons/pythonw.svg b/PC/icons/pythonw.svg deleted file mode 100644 index 7cb26074744e3fd1c10cb26a8cc57cdae7571d00..0000000000000000000000000000000000000000 --- a/PC/icons/pythonw.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/PC/icons/pythonwx150.png b/PC/icons/pythonwx150.png deleted file mode 100644 index 589873aeb100b2dac67580fd236552208c520f48..0000000000000000000000000000000000000000 Binary files a/PC/icons/pythonwx150.png and /dev/null differ diff --git a/PC/icons/pythonwx44.png b/PC/icons/pythonwx44.png deleted file mode 100644 index 8cd8dd0286f681e040d2f0d8abb156f80139d91d..0000000000000000000000000000000000000000 Binary files a/PC/icons/pythonwx44.png and /dev/null differ diff --git a/PC/icons/pythonx150.png b/PC/icons/pythonx150.png deleted file mode 100644 index e00aa758edcd4720b7ba43da2a135c546584c369..0000000000000000000000000000000000000000 Binary files a/PC/icons/pythonx150.png and /dev/null differ diff --git a/PC/icons/pythonx44.png b/PC/icons/pythonx44.png deleted file mode 100644 index db0e9b91d40fe558e507d2e0ba62a77c74838b46..0000000000000000000000000000000000000000 Binary files a/PC/icons/pythonx44.png and /dev/null differ diff --git a/PC/icons/pythonx50.png b/PC/icons/pythonx50.png deleted file mode 100644 index 8eb5ffce221faedfaafbf4e1a09f8c290e992e11..0000000000000000000000000000000000000000 Binary files a/PC/icons/pythonx50.png and /dev/null differ diff --git a/PC/icons/setup.icns b/PC/icons/setup.icns deleted file mode 100644 index 6f0e6b01a0da4bcde3128932ef9e2b221eeabfcc..0000000000000000000000000000000000000000 Binary files a/PC/icons/setup.icns and /dev/null differ diff --git a/PC/icons/setup.ico b/PC/icons/setup.ico deleted file mode 100644 index e54364b3af11d3173c8b48d8ee32bce18f85f2ec..0000000000000000000000000000000000000000 Binary files a/PC/icons/setup.ico and /dev/null differ diff --git a/PC/icons/setup.svg b/PC/icons/setup.svg deleted file mode 100644 index 06138568f2cebcde3f45e3d5bea7964f5d64491b..0000000000000000000000000000000000000000 --- a/PC/icons/setup.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/PC/invalid_parameter_handler.c b/PC/invalid_parameter_handler.c deleted file mode 100644 index d634710cbec71439446067f2fd8df8d78998b5d2..0000000000000000000000000000000000000000 --- a/PC/invalid_parameter_handler.c +++ /dev/null @@ -1,22 +0,0 @@ -#ifdef _MSC_VER - -#include - -#if _MSC_VER >= 1900 -/* pyconfig.h uses this function in the _Py_BEGIN/END_SUPPRESS_IPH - * macros. It does not need to be defined when building using MSVC - * earlier than 14.0 (_MSC_VER == 1900). - */ - -static void __cdecl _silent_invalid_parameter_handler( - wchar_t const* expression, - wchar_t const* function, - wchar_t const* file, - unsigned int line, - uintptr_t pReserved) { } - -_invalid_parameter_handler _Py_silent_invalid_parameter_handler = _silent_invalid_parameter_handler; - -#endif - -#endif diff --git a/PC/launcher.c b/PC/launcher.c deleted file mode 100644 index 7c34e0ded7bfa86495dba7b0c2a711cf5d22d813..0000000000000000000000000000000000000000 --- a/PC/launcher.c +++ /dev/null @@ -1,2041 +0,0 @@ -/* - * Copyright (C) 2011-2013 Vinay Sajip. - * Licensed to PSF under a contributor agreement. - * - * Based on the work of: - * - * Mark Hammond (original author of Python version) - * Curt Hagenlocher (job management) - */ - -#include -#include -#include -#include - -#define BUFSIZE 256 -#define MSGSIZE 1024 - -/* Build options. */ -#define SKIP_PREFIX -#define SEARCH_PATH - -/* Error codes */ - -#define RC_NO_STD_HANDLES 100 -#define RC_CREATE_PROCESS 101 -#define RC_BAD_VIRTUAL_PATH 102 -#define RC_NO_PYTHON 103 -#define RC_NO_MEMORY 104 -/* - * SCRIPT_WRAPPER is used to choose one of the variants of an executable built - * from this source file. If not defined, the PEP 397 Python launcher is built; - * if defined, a script launcher of the type used by setuptools is built, which - * looks for a script name related to the executable name and runs that script - * with the appropriate Python interpreter. - * - * SCRIPT_WRAPPER should be undefined in the source, and defined in a VS project - * which builds the setuptools-style launcher. - */ -#if defined(SCRIPT_WRAPPER) -#define RC_NO_SCRIPT 105 -#endif -/* - * VENV_REDIRECT is used to choose the variant that looks for an adjacent or - * one-level-higher pyvenv.cfg, and uses its "home" property to locate and - * launch the original python.exe. - */ -#if defined(VENV_REDIRECT) -#define RC_NO_VENV_CFG 106 -#define RC_BAD_VENV_CFG 107 -#endif - -/* Just for now - static definition */ - -static FILE * log_fp = NULL; - -static wchar_t * -skip_whitespace(wchar_t * p) -{ - while (*p && isspace(*p)) - ++p; - return p; -} - -static void -debug(wchar_t * format, ...) -{ - va_list va; - - if (log_fp != NULL) { - va_start(va, format); - vfwprintf_s(log_fp, format, va); - va_end(va); - } -} - -static void -winerror(int rc, wchar_t * message, int size) -{ - FormatMessageW( - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, rc, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - message, size, NULL); -} - -static void -error(int rc, wchar_t * format, ... ) -{ - va_list va; - wchar_t message[MSGSIZE]; - wchar_t win_message[MSGSIZE]; - int len; - - va_start(va, format); - len = _vsnwprintf_s(message, MSGSIZE, _TRUNCATE, format, va); - va_end(va); - - if (rc == 0) { /* a Windows error */ - winerror(GetLastError(), win_message, MSGSIZE); - if (len >= 0) { - _snwprintf_s(&message[len], MSGSIZE - len, _TRUNCATE, L": %ls", - win_message); - } - } - -#if !defined(_WINDOWS) - fwprintf(stderr, L"%ls\n", message); -#else - MessageBoxW(NULL, message, L"Python Launcher is sorry to say ...", - MB_OK); -#endif - exit(rc); -} - -/* - * This function is here to simplify memory management - * and to treat blank values as if they are absent. - */ -static wchar_t * get_env(wchar_t * key) -{ - /* This is not thread-safe, just like getenv */ - static wchar_t buf[BUFSIZE]; - DWORD result = GetEnvironmentVariableW(key, buf, BUFSIZE); - - if (result >= BUFSIZE) { - /* Large environment variable. Accept some leakage */ - wchar_t *buf2 = (wchar_t*)malloc(sizeof(wchar_t) * (result+1)); - if (buf2 == NULL) { - error(RC_NO_MEMORY, L"Could not allocate environment buffer"); - } - GetEnvironmentVariableW(key, buf2, result); - return buf2; - } - - if (result == 0) - /* Either some error, e.g. ERROR_ENVVAR_NOT_FOUND, - or an empty environment variable. */ - return NULL; - - return buf; -} - -#if defined(_DEBUG) -/* Do not define EXECUTABLEPATH_VALUE in debug builds as it'll - never point to the debug build. */ -#if defined(_WINDOWS) - -#define PYTHON_EXECUTABLE L"pythonw_d.exe" - -#else - -#define PYTHON_EXECUTABLE L"python_d.exe" - -#endif -#else -#if defined(_WINDOWS) - -#define PYTHON_EXECUTABLE L"pythonw.exe" -#define EXECUTABLEPATH_VALUE L"WindowedExecutablePath" - -#else - -#define PYTHON_EXECUTABLE L"python.exe" -#define EXECUTABLEPATH_VALUE L"ExecutablePath" - -#endif -#endif - -#define MAX_VERSION_SIZE 8 - -typedef struct { - wchar_t version[MAX_VERSION_SIZE]; /* m.n */ - int bits; /* 32 or 64 */ - wchar_t executable[MAX_PATH]; - wchar_t exe_display[MAX_PATH]; -} INSTALLED_PYTHON; - -/* - * To avoid messing about with heap allocations, just assume we can allocate - * statically and never have to deal with more versions than this. - */ -#define MAX_INSTALLED_PYTHONS 100 - -static INSTALLED_PYTHON installed_pythons[MAX_INSTALLED_PYTHONS]; - -static size_t num_installed_pythons = 0; - -/* - * To hold SOFTWARE\Python\PythonCore\X.Y...\InstallPath - * The version name can be longer than MAX_VERSION_SIZE, but will be - * truncated to just X.Y for comparisons. - */ -#define IP_BASE_SIZE 80 -#define IP_VERSION_SIZE 8 -#define IP_SIZE (IP_BASE_SIZE + IP_VERSION_SIZE) -#define CORE_PATH L"SOFTWARE\\Python\\PythonCore" -/* - * Installations from the Microsoft Store will set the same registry keys, - * but because of a limitation in Windows they cannot be enumerated normally - * (unless you have no other Python installations... which is probably false - * because that's the most likely way to get this launcher!) - * This key is under HKEY_LOCAL_MACHINE - */ -#define LOOKASIDE_PATH L"SOFTWARE\\Microsoft\\AppModel\\Lookaside\\user\\Software\\Python\\PythonCore" - -static wchar_t * location_checks[] = { - L"\\", - L"\\PCbuild\\win32\\", - L"\\PCbuild\\amd64\\", - /* To support early 32bit versions of Python that stuck the build binaries - * directly in PCbuild... */ - L"\\PCbuild\\", - NULL -}; - -static INSTALLED_PYTHON * -find_existing_python(const wchar_t * path) -{ - INSTALLED_PYTHON * result = NULL; - size_t i; - INSTALLED_PYTHON * ip; - - for (i = 0, ip = installed_pythons; i < num_installed_pythons; i++, ip++) { - if (_wcsicmp(path, ip->executable) == 0) { - result = ip; - break; - } - } - return result; -} - -static INSTALLED_PYTHON * -find_existing_python2(int bits, const wchar_t * version) -{ - INSTALLED_PYTHON * result = NULL; - size_t i; - INSTALLED_PYTHON * ip; - - for (i = 0, ip = installed_pythons; i < num_installed_pythons; i++, ip++) { - if (bits == ip->bits && _wcsicmp(version, ip->version) == 0) { - result = ip; - break; - } - } - return result; -} - -static void -_locate_pythons_for_key(HKEY root, LPCWSTR subkey, REGSAM flags, int bits, - int display_name_only) -{ - HKEY core_root, ip_key; - LSTATUS status = RegOpenKeyExW(root, subkey, 0, flags, &core_root); - wchar_t message[MSGSIZE]; - DWORD i; - size_t n; - BOOL ok, append_name; - DWORD type, data_size, attrs; - INSTALLED_PYTHON * ip, * pip; - wchar_t ip_version[IP_VERSION_SIZE]; - wchar_t ip_path[IP_SIZE]; - wchar_t * check; - wchar_t ** checkp; - wchar_t *key_name = (root == HKEY_LOCAL_MACHINE) ? L"HKLM" : L"HKCU"; - - if (status != ERROR_SUCCESS) - debug(L"locate_pythons_for_key: unable to open PythonCore key in %ls\n", - key_name); - else { - ip = &installed_pythons[num_installed_pythons]; - for (i = 0; num_installed_pythons < MAX_INSTALLED_PYTHONS; i++) { - status = RegEnumKeyW(core_root, i, ip_version, IP_VERSION_SIZE); - if (status != ERROR_SUCCESS) { - if (status != ERROR_NO_MORE_ITEMS) { - /* unexpected error */ - winerror(status, message, MSGSIZE); - debug(L"Can't enumerate registry key for version %ls: %ls\n", - ip_version, message); - } - break; - } - else { - wcsncpy_s(ip->version, MAX_VERSION_SIZE, ip_version, - MAX_VERSION_SIZE-1); - /* Still treating version as "x.y" rather than sys.winver - * When PEP 514 tags are properly used, we shouldn't need - * to strip this off here. - */ - check = wcsrchr(ip->version, L'-'); - if (check && !wcscmp(check, L"-32")) { - *check = L'\0'; - } - _snwprintf_s(ip_path, IP_SIZE, _TRUNCATE, - L"%ls\\%ls\\InstallPath", subkey, ip_version); - status = RegOpenKeyExW(root, ip_path, 0, flags, &ip_key); - if (status != ERROR_SUCCESS) { - winerror(status, message, MSGSIZE); - /* Note: 'message' already has a trailing \n*/ - debug(L"%ls\\%ls: %ls", key_name, ip_path, message); - continue; - } - data_size = sizeof(ip->executable) - 1; - append_name = FALSE; -#ifdef EXECUTABLEPATH_VALUE - status = RegQueryValueExW(ip_key, EXECUTABLEPATH_VALUE, NULL, &type, - (LPBYTE)ip->executable, &data_size); -#else - status = ERROR_FILE_NOT_FOUND; /* actual error doesn't matter */ -#endif - if (status != ERROR_SUCCESS || type != REG_SZ || !data_size) { - append_name = TRUE; - data_size = sizeof(ip->executable) - 1; - status = RegQueryValueExW(ip_key, NULL, NULL, &type, - (LPBYTE)ip->executable, &data_size); - if (status != ERROR_SUCCESS) { - winerror(status, message, MSGSIZE); - debug(L"%ls\\%ls: %ls\n", key_name, ip_path, message); - RegCloseKey(ip_key); - continue; - } - } - RegCloseKey(ip_key); - if (type != REG_SZ) { - continue; - } - - data_size = data_size / sizeof(wchar_t) - 1; /* for NUL */ - if (ip->executable[data_size - 1] == L'\\') - --data_size; /* reg value ended in a backslash */ - /* ip->executable is data_size long */ - for (checkp = location_checks; *checkp; ++checkp) { - check = *checkp; - if (append_name) { - _snwprintf_s(&ip->executable[data_size], - MAX_PATH - data_size, - MAX_PATH - data_size, - L"%ls%ls", check, PYTHON_EXECUTABLE); - } - attrs = GetFileAttributesW(ip->executable); - if (attrs == INVALID_FILE_ATTRIBUTES) { - winerror(GetLastError(), message, MSGSIZE); - debug(L"locate_pythons_for_key: %ls: %ls", - ip->executable, message); - } - else if (attrs & FILE_ATTRIBUTE_DIRECTORY) { - debug(L"locate_pythons_for_key: '%ls' is a directory\n", - ip->executable); - } - else if (find_existing_python(ip->executable)) { - debug(L"locate_pythons_for_key: %ls: already found\n", - ip->executable); - } - else { - /* check the executable type. */ - if (bits) { - ip->bits = bits; - } else { - ok = GetBinaryTypeW(ip->executable, &attrs); - if (!ok) { - debug(L"Failure getting binary type: %ls\n", - ip->executable); - } - else { - if (attrs == SCS_64BIT_BINARY) - ip->bits = 64; - else if (attrs == SCS_32BIT_BINARY) - ip->bits = 32; - else - ip->bits = 0; - } - } - if (ip->bits == 0) { - debug(L"locate_pythons_for_key: %ls: \ -invalid binary type: %X\n", - ip->executable, attrs); - } - else { - if (display_name_only) { - /* display just the executable name. This is - * primarily for the Store installs */ - const wchar_t *name = wcsrchr(ip->executable, L'\\'); - if (name) { - wcscpy_s(ip->exe_display, MAX_PATH, name+1); - } - } - if (wcschr(ip->executable, L' ') != NULL) { - /* has spaces, so quote, and set original as - * the display name */ - if (!ip->exe_display[0]) { - wcscpy_s(ip->exe_display, MAX_PATH, ip->executable); - } - n = wcslen(ip->executable); - memmove(&ip->executable[1], - ip->executable, n * sizeof(wchar_t)); - ip->executable[0] = L'\"'; - ip->executable[n + 1] = L'\"'; - ip->executable[n + 2] = L'\0'; - } - debug(L"locate_pythons_for_key: %ls \ -is a %dbit executable\n", - ip->executable, ip->bits); - if (find_existing_python2(ip->bits, ip->version)) { - debug(L"locate_pythons_for_key: %ls-%i: already \ -found\n", ip->version, ip->bits); - } - else { - ++num_installed_pythons; - pip = ip++; - if (num_installed_pythons >= - MAX_INSTALLED_PYTHONS) - break; - } - } - } - } - } - } - RegCloseKey(core_root); - } -} - -static int -compare_pythons(const void * p1, const void * p2) -{ - INSTALLED_PYTHON * ip1 = (INSTALLED_PYTHON *) p1; - INSTALLED_PYTHON * ip2 = (INSTALLED_PYTHON *) p2; - /* note reverse sorting on version */ - int result = CompareStringW(LOCALE_INVARIANT, SORT_DIGITSASNUMBERS, - ip2->version, -1, ip1->version, -1); - switch (result) { - case 0: - error(0, L"CompareStringW failed"); - return 0; - case CSTR_LESS_THAN: - return -1; - case CSTR_EQUAL: - return ip2->bits - ip1->bits; /* 64 before 32 */ - case CSTR_GREATER_THAN: - return 1; - default: - return 0; // This should never be reached. - } -} - -static void -locate_pythons_for_key(HKEY root, REGSAM flags) -{ - _locate_pythons_for_key(root, CORE_PATH, flags, 0, FALSE); -} - -static void -locate_store_pythons() -{ -#if defined(_M_X64) - /* 64bit process, so look in native registry */ - _locate_pythons_for_key(HKEY_LOCAL_MACHINE, LOOKASIDE_PATH, - KEY_READ, 64, TRUE); -#else - /* 32bit process, so check that we're on 64bit OS */ - BOOL f64 = FALSE; - if (IsWow64Process(GetCurrentProcess(), &f64) && f64) { - _locate_pythons_for_key(HKEY_LOCAL_MACHINE, LOOKASIDE_PATH, - KEY_READ | KEY_WOW64_64KEY, 64, TRUE); - } -#endif -} - -static void -locate_venv_python() -{ - static wchar_t venv_python[MAX_PATH]; - INSTALLED_PYTHON * ip; - wchar_t *virtual_env = get_env(L"VIRTUAL_ENV"); - DWORD attrs; - - /* Check for VIRTUAL_ENV environment variable */ - if (virtual_env == NULL || virtual_env[0] == L'\0') { - return; - } - - /* Check for a python executable in the venv */ - debug(L"Checking for Python executable in virtual env '%ls'\n", virtual_env); - _snwprintf_s(venv_python, MAX_PATH, _TRUNCATE, - L"%ls\\Scripts\\%ls", virtual_env, PYTHON_EXECUTABLE); - attrs = GetFileAttributesW(venv_python); - if (attrs == INVALID_FILE_ATTRIBUTES) { - debug(L"Python executable %ls missing from virtual env\n", venv_python); - return; - } - - ip = &installed_pythons[num_installed_pythons++]; - wcscpy_s(ip->executable, MAX_PATH, venv_python); - ip->bits = 0; - wcscpy_s(ip->version, MAX_VERSION_SIZE, L"venv"); -} - -static void -locate_all_pythons() -{ - /* venv Python is highest priority */ - locate_venv_python(); -#if defined(_M_X64) - /* If we are a 64bit process, first hit the 32bit keys. */ - debug(L"locating Pythons in 32bit registry\n"); - locate_pythons_for_key(HKEY_CURRENT_USER, KEY_READ | KEY_WOW64_32KEY); - locate_pythons_for_key(HKEY_LOCAL_MACHINE, KEY_READ | KEY_WOW64_32KEY); -#else - /* If we are a 32bit process on a 64bit Windows, first hit the 64bit keys.*/ - BOOL f64 = FALSE; - if (IsWow64Process(GetCurrentProcess(), &f64) && f64) { - debug(L"locating Pythons in 64bit registry\n"); - locate_pythons_for_key(HKEY_CURRENT_USER, KEY_READ | KEY_WOW64_64KEY); - locate_pythons_for_key(HKEY_LOCAL_MACHINE, KEY_READ | KEY_WOW64_64KEY); - } -#endif - /* now hit the "native" key for this process bittedness. */ - debug(L"locating Pythons in native registry\n"); - locate_pythons_for_key(HKEY_CURRENT_USER, KEY_READ); - locate_pythons_for_key(HKEY_LOCAL_MACHINE, KEY_READ); - /* Store-installed Python is lowest priority */ - locate_store_pythons(); - qsort(installed_pythons, num_installed_pythons, sizeof(INSTALLED_PYTHON), - compare_pythons); -} - -static INSTALLED_PYTHON * -find_python_by_version(wchar_t const * wanted_ver) -{ - INSTALLED_PYTHON * result = NULL; - INSTALLED_PYTHON * ip = installed_pythons; - size_t i, n; - size_t wlen = wcslen(wanted_ver); - int bits = 0; - - if (wcsstr(wanted_ver, L"-32")) { - bits = 32; - wlen -= wcslen(L"-32"); - } - else if (wcsstr(wanted_ver, L"-64")) { /* Added option to select 64 bit explicitly */ - bits = 64; - wlen -= wcslen(L"-64"); - } - for (i = 0; i < num_installed_pythons; i++, ip++) { - n = wcslen(ip->version); - /* - * If wlen is greater than 1, we're probably trying to find a specific - * version and thus want an exact match: 3.1 != 3.10. Otherwise, we - * just want a prefix match. - */ - if ((wlen > 1) && (n != wlen)) { - continue; - } - if (n > wlen) { - n = wlen; - } - if ((wcsncmp(ip->version, wanted_ver, n) == 0) && - /* bits == 0 => don't care */ - ((bits == 0) || (ip->bits == bits))) { - result = ip; - break; - } - } - return result; -} - - -static wchar_t appdata_ini_path[MAX_PATH]; -static wchar_t launcher_ini_path[MAX_PATH]; - -/* - * Get a value either from the environment or a configuration file. - * The key passed in will either be "python", "python2" or "python3". - */ -static wchar_t * -get_configured_value(wchar_t * key) -{ -/* - * Note: this static value is used to return a configured value - * obtained either from the environment or configuration file. - * This should be OK since there wouldn't be any concurrent calls. - */ - static wchar_t configured_value[MSGSIZE]; - wchar_t * result = NULL; - wchar_t * found_in = L"environment"; - DWORD size; - - /* First, search the environment. */ - _snwprintf_s(configured_value, MSGSIZE, _TRUNCATE, L"py_%ls", key); - result = get_env(configured_value); - if (result == NULL && appdata_ini_path[0]) { - /* Not in environment: check local configuration. */ - size = GetPrivateProfileStringW(L"defaults", key, NULL, - configured_value, MSGSIZE, - appdata_ini_path); - if (size > 0) { - result = configured_value; - found_in = appdata_ini_path; - } - } - if (result == NULL && launcher_ini_path[0]) { - /* Not in environment or local: check global configuration. */ - size = GetPrivateProfileStringW(L"defaults", key, NULL, - configured_value, MSGSIZE, - launcher_ini_path); - if (size > 0) { - result = configured_value; - found_in = launcher_ini_path; - } - } - if (result) { - debug(L"found configured value '%ls=%ls' in %ls\n", - key, result, found_in ? found_in : L"(unknown)"); - } else { - debug(L"found no configured value for '%ls'\n", key); - } - return result; -} - -static INSTALLED_PYTHON * -locate_python(wchar_t * wanted_ver, BOOL from_shebang) -{ - static wchar_t config_key [] = { L"pythonX" }; - static wchar_t * last_char = &config_key[sizeof(config_key) / - sizeof(wchar_t) - 2]; - INSTALLED_PYTHON * result = NULL; - size_t n = wcslen(wanted_ver); - wchar_t * configured_value; - - if (num_installed_pythons == 0) - locate_all_pythons(); - - if (n == 1) { /* just major version specified */ - *last_char = *wanted_ver; - configured_value = get_configured_value(config_key); - if (configured_value != NULL) - wanted_ver = configured_value; - } - if (*wanted_ver) { - result = find_python_by_version(wanted_ver); - debug(L"search for Python version '%ls' found ", wanted_ver); - if (result) { - debug(L"'%ls'\n", result->executable); - } else { - debug(L"no interpreter\n"); - } - } - else { - *last_char = L'\0'; /* look for an overall default */ - result = find_python_by_version(L"venv"); - if (result == NULL) { - configured_value = get_configured_value(config_key); - if (configured_value) - result = find_python_by_version(configured_value); - } - /* Not found a value yet - try by major version. - * If we're looking for an interpreter specified in a shebang line, - * we want to try Python 2 first, then Python 3 (for Unix and backward - * compatibility). If we're being called interactively, assume the user - * wants the latest version available, so try Python 3 first, then - * Python 2. - */ - if (result == NULL) - result = find_python_by_version(from_shebang ? L"2" : L"3"); - if (result == NULL) - result = find_python_by_version(from_shebang ? L"3" : L"2"); - debug(L"search for default Python found "); - if (result) { - debug(L"version %ls at '%ls'\n", - result->version, result->executable); - } else { - debug(L"no interpreter\n"); - } - } - return result; -} - -#if defined(SCRIPT_WRAPPER) -/* - * Check for a script located alongside the executable - */ - -#if defined(_WINDOWS) -#define SCRIPT_SUFFIX L"-script.pyw" -#else -#define SCRIPT_SUFFIX L"-script.py" -#endif - -static wchar_t wrapped_script_path[MAX_PATH]; - -/* Locate the script being wrapped. - * - * This code should store the name of the wrapped script in - * wrapped_script_path, or terminate the program with an error if there is no - * valid wrapped script file. - */ -static void -locate_wrapped_script() -{ - wchar_t * p; - size_t plen; - DWORD attrs; - - plen = GetModuleFileNameW(NULL, wrapped_script_path, MAX_PATH); - p = wcsrchr(wrapped_script_path, L'.'); - if (p == NULL) { - debug(L"GetModuleFileNameW returned value has no extension: %ls\n", - wrapped_script_path); - error(RC_NO_SCRIPT, L"Wrapper name '%ls' is not valid.", wrapped_script_path); - } - - wcsncpy_s(p, MAX_PATH - (p - wrapped_script_path) + 1, SCRIPT_SUFFIX, _TRUNCATE); - attrs = GetFileAttributesW(wrapped_script_path); - if (attrs == INVALID_FILE_ATTRIBUTES) { - debug(L"File '%ls' non-existent\n", wrapped_script_path); - error(RC_NO_SCRIPT, L"Script file '%ls' is not present.", wrapped_script_path); - } - - debug(L"Using wrapped script file '%ls'\n", wrapped_script_path); -} -#endif - -/* - * Process creation code - */ - -static BOOL -safe_duplicate_handle(HANDLE in, HANDLE * pout) -{ - BOOL ok; - HANDLE process = GetCurrentProcess(); - DWORD rc; - - *pout = NULL; - ok = DuplicateHandle(process, in, process, pout, 0, TRUE, - DUPLICATE_SAME_ACCESS); - if (!ok) { - rc = GetLastError(); - if (rc == ERROR_INVALID_HANDLE) { - debug(L"DuplicateHandle returned ERROR_INVALID_HANDLE\n"); - ok = TRUE; - } - else { - debug(L"DuplicateHandle returned %d\n", rc); - } - } - return ok; -} - -static BOOL WINAPI -ctrl_c_handler(DWORD code) -{ - return TRUE; /* We just ignore all control events. */ -} - -static void -run_child(wchar_t * cmdline) -{ - HANDLE job; - JOBOBJECT_EXTENDED_LIMIT_INFORMATION info; - DWORD rc; - BOOL ok; - STARTUPINFOW si; - PROCESS_INFORMATION pi; - -#if defined(_WINDOWS) - /* - When explorer launches a Windows (GUI) application, it displays - the "app starting" (the "pointer + hourglass") cursor for a number - of seconds, or until the app does something UI-ish (eg, creating a - window, or fetching a message). As this launcher doesn't do this - directly, that cursor remains even after the child process does these - things. We avoid that by doing a simple post+get message. - See http://bugs.python.org/issue17290 and - https://bitbucket.org/vinay.sajip/pylauncher/issue/20/busy-cursor-for-a-long-time-when-running - */ - MSG msg; - - PostMessage(0, 0, 0, 0); - GetMessage(&msg, 0, 0, 0); -#endif - - debug(L"run_child: about to run '%ls'\n", cmdline); - job = CreateJobObject(NULL, NULL); - ok = QueryInformationJobObject(job, JobObjectExtendedLimitInformation, - &info, sizeof(info), &rc); - if (!ok || (rc != sizeof(info)) || !job) - error(RC_CREATE_PROCESS, L"Job information querying failed"); - info.BasicLimitInformation.LimitFlags |= JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | - JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK; - ok = SetInformationJobObject(job, JobObjectExtendedLimitInformation, &info, - sizeof(info)); - if (!ok) - error(RC_CREATE_PROCESS, L"Job information setting failed"); - memset(&si, 0, sizeof(si)); - GetStartupInfoW(&si); - ok = safe_duplicate_handle(GetStdHandle(STD_INPUT_HANDLE), &si.hStdInput); - if (!ok) - error(RC_NO_STD_HANDLES, L"stdin duplication failed"); - ok = safe_duplicate_handle(GetStdHandle(STD_OUTPUT_HANDLE), &si.hStdOutput); - if (!ok) - error(RC_NO_STD_HANDLES, L"stdout duplication failed"); - ok = safe_duplicate_handle(GetStdHandle(STD_ERROR_HANDLE), &si.hStdError); - if (!ok) - error(RC_NO_STD_HANDLES, L"stderr duplication failed"); - - ok = SetConsoleCtrlHandler(ctrl_c_handler, TRUE); - if (!ok) - error(RC_CREATE_PROCESS, L"control handler setting failed"); - - si.dwFlags = STARTF_USESTDHANDLES; - ok = CreateProcessW(NULL, cmdline, NULL, NULL, TRUE, - 0, NULL, NULL, &si, &pi); - if (!ok) - error(RC_CREATE_PROCESS, L"Unable to create process using '%ls'", cmdline); - AssignProcessToJobObject(job, pi.hProcess); - CloseHandle(pi.hThread); - WaitForSingleObjectEx(pi.hProcess, INFINITE, FALSE); - ok = GetExitCodeProcess(pi.hProcess, &rc); - if (!ok) - error(RC_CREATE_PROCESS, L"Failed to get exit code of process"); - debug(L"child process exit code: %d\n", rc); - exit(rc); -} - -static void -invoke_child(wchar_t * executable, wchar_t * suffix, wchar_t * cmdline) -{ - wchar_t * child_command; - size_t child_command_size; - BOOL no_suffix = (suffix == NULL) || (*suffix == L'\0'); - BOOL no_cmdline = (*cmdline == L'\0'); - - if (no_suffix && no_cmdline) - run_child(executable); - else { - if (no_suffix) { - /* add 2 for space separator + terminating NUL. */ - child_command_size = wcslen(executable) + wcslen(cmdline) + 2; - } - else { - /* add 3 for 2 space separators + terminating NUL. */ - child_command_size = wcslen(executable) + wcslen(suffix) + - wcslen(cmdline) + 3; - } - child_command = calloc(child_command_size, sizeof(wchar_t)); - if (child_command == NULL) - error(RC_CREATE_PROCESS, L"unable to allocate %zd bytes for child command.", - child_command_size); - if (no_suffix) - _snwprintf_s(child_command, child_command_size, - child_command_size - 1, L"%ls %ls", - executable, cmdline); - else - _snwprintf_s(child_command, child_command_size, - child_command_size - 1, L"%ls %ls %ls", - executable, suffix, cmdline); - run_child(child_command); - free(child_command); - } -} - -typedef struct { - wchar_t *shebang; - BOOL search; -} SHEBANG; - -static SHEBANG builtin_virtual_paths [] = { - { L"/usr/bin/env python", TRUE }, - { L"/usr/bin/python", FALSE }, - { L"/usr/local/bin/python", FALSE }, - { L"python", FALSE }, - { NULL, FALSE }, -}; - -/* For now, a static array of commands. */ - -#define MAX_COMMANDS 100 - -typedef struct { - wchar_t key[MAX_PATH]; - wchar_t value[MSGSIZE]; -} COMMAND; - -static COMMAND commands[MAX_COMMANDS]; -static int num_commands = 0; - -#if defined(SKIP_PREFIX) - -static wchar_t * builtin_prefixes [] = { - /* These must be in an order that the longest matches should be found, - * i.e. if the prefix is "/usr/bin/env ", it should match that entry - * *before* matching "/usr/bin/". - */ - L"/usr/bin/env ", - L"/usr/bin/", - L"/usr/local/bin/", - NULL -}; - -static wchar_t * skip_prefix(wchar_t * name) -{ - wchar_t ** pp = builtin_prefixes; - wchar_t * result = name; - wchar_t * p; - size_t n; - - for (; p = *pp; pp++) { - n = wcslen(p); - if (_wcsnicmp(p, name, n) == 0) { - result += n; /* skip the prefix */ - if (p[n - 1] == L' ') /* No empty strings in table, so n > 1 */ - result = skip_whitespace(result); - break; - } - } - return result; -} - -#endif - -#if defined(SEARCH_PATH) - -static COMMAND path_command; - -static COMMAND * find_on_path(wchar_t * name) -{ - wchar_t * pathext; - size_t varsize; - wchar_t * context = NULL; - wchar_t * extension; - COMMAND * result = NULL; - DWORD len; - errno_t rc; - - wcscpy_s(path_command.key, MAX_PATH, name); - if (wcschr(name, L'.') != NULL) { - /* assume it has an extension. */ - len = SearchPathW(NULL, name, NULL, MSGSIZE, path_command.value, NULL); - if (len) { - result = &path_command; - } - } - else { - /* No extension - search using registered extensions. */ - rc = _wdupenv_s(&pathext, &varsize, L"PATHEXT"); - if (rc == 0) { - extension = wcstok_s(pathext, L";", &context); - while (extension) { - len = SearchPathW(NULL, name, extension, MSGSIZE, path_command.value, NULL); - if (len) { - result = &path_command; - break; - } - extension = wcstok_s(NULL, L";", &context); - } - free(pathext); - } - } - return result; -} - -#endif - -static COMMAND * find_command(wchar_t * name) -{ - COMMAND * result = NULL; - COMMAND * cp = commands; - int i; - - for (i = 0; i < num_commands; i++, cp++) { - if (_wcsicmp(cp->key, name) == 0) { - result = cp; - break; - } - } -#if defined(SEARCH_PATH) - if (result == NULL) - result = find_on_path(name); -#endif - return result; -} - -static void -update_command(COMMAND * cp, wchar_t * name, wchar_t * cmdline) -{ - wcsncpy_s(cp->key, MAX_PATH, name, _TRUNCATE); - wcsncpy_s(cp->value, MSGSIZE, cmdline, _TRUNCATE); -} - -static void -add_command(wchar_t * name, wchar_t * cmdline) -{ - if (num_commands >= MAX_COMMANDS) { - debug(L"can't add %ls = '%ls': no room\n", name, cmdline); - } - else { - COMMAND * cp = &commands[num_commands++]; - - update_command(cp, name, cmdline); - } -} - -static void -read_config_file(wchar_t * config_path) -{ - wchar_t keynames[MSGSIZE]; - wchar_t value[MSGSIZE]; - DWORD read; - wchar_t * key; - COMMAND * cp; - wchar_t * cmdp; - - read = GetPrivateProfileStringW(L"commands", NULL, NULL, keynames, MSGSIZE, - config_path); - if (read == MSGSIZE - 1) { - debug(L"read_commands: %ls: not enough space for names\n", config_path); - } - key = keynames; - while (*key) { - read = GetPrivateProfileStringW(L"commands", key, NULL, value, MSGSIZE, - config_path); - if (read == MSGSIZE - 1) { - debug(L"read_commands: %ls: not enough space for %ls\n", - config_path, key); - } - cmdp = skip_whitespace(value); - if (*cmdp) { - cp = find_command(key); - if (cp == NULL) - add_command(key, value); - else - update_command(cp, key, value); - } - key += wcslen(key) + 1; - } -} - -static void read_commands() -{ - if (launcher_ini_path[0]) - read_config_file(launcher_ini_path); - if (appdata_ini_path[0]) - read_config_file(appdata_ini_path); -} - -static BOOL -parse_shebang(wchar_t * shebang_line, int nchars, wchar_t ** command, - wchar_t ** suffix, BOOL *search) -{ - BOOL rc = FALSE; - SHEBANG * vpp; - size_t plen; - wchar_t * p; - wchar_t zapped; - wchar_t * endp = shebang_line + nchars - 1; - COMMAND * cp; - wchar_t * skipped; - - *command = NULL; /* failure return */ - *suffix = NULL; - *search = FALSE; - - if ((*shebang_line++ == L'#') && (*shebang_line++ == L'!')) { - shebang_line = skip_whitespace(shebang_line); - if (*shebang_line) { - *command = shebang_line; - for (vpp = builtin_virtual_paths; vpp->shebang; ++vpp) { - plen = wcslen(vpp->shebang); - if (wcsncmp(shebang_line, vpp->shebang, plen) == 0) { - rc = TRUE; - *search = vpp->search; - /* We can do this because all builtin commands contain - * "python". - */ - *command = wcsstr(shebang_line, L"python"); - break; - } - } - if (vpp->shebang == NULL) { - /* - * Not found in builtins - look in customized commands. - * - * We can't permanently modify the shebang line in case - * it's not a customized command, but we can temporarily - * stick a NUL after the command while searching for it, - * then put back the char we zapped. - */ -#if defined(SKIP_PREFIX) - skipped = skip_prefix(shebang_line); -#else - skipped = shebang_line; -#endif - p = wcspbrk(skipped, L" \t\r\n"); - if (p != NULL) { - zapped = *p; - *p = L'\0'; - } - cp = find_command(skipped); - if (p != NULL) - *p = zapped; - if (cp != NULL) { - *command = cp->value; - if (p != NULL) - *suffix = skip_whitespace(p); - } - } - /* remove trailing whitespace */ - while ((endp > shebang_line) && isspace(*endp)) - --endp; - if (endp > shebang_line) - endp[1] = L'\0'; - } - } - return rc; -} - -/* #define CP_UTF8 65001 defined in winnls.h */ -#define CP_UTF16LE 1200 -#define CP_UTF16BE 1201 -#define CP_UTF32LE 12000 -#define CP_UTF32BE 12001 - -typedef struct { - int length; - char sequence[4]; - UINT code_page; -} BOM; - -/* - * Strictly, we don't need to handle UTF-16 and UTF-32, since Python itself - * doesn't. Never mind, one day it might - there's no harm leaving it in. - */ -static BOM BOMs[] = { - { 3, { 0xEF, 0xBB, 0xBF }, CP_UTF8 }, /* UTF-8 - keep first */ - /* Test UTF-32LE before UTF-16LE since UTF-16LE BOM is a prefix - * of UTF-32LE BOM. */ - { 4, { 0xFF, 0xFE, 0x00, 0x00 }, CP_UTF32LE }, /* UTF-32LE */ - { 4, { 0x00, 0x00, 0xFE, 0xFF }, CP_UTF32BE }, /* UTF-32BE */ - { 2, { 0xFF, 0xFE }, CP_UTF16LE }, /* UTF-16LE */ - { 2, { 0xFE, 0xFF }, CP_UTF16BE }, /* UTF-16BE */ - { 0 } /* sentinel */ -}; - -static BOM * -find_BOM(char * buffer) -{ -/* - * Look for a BOM in the input and return a pointer to the - * corresponding structure, or NULL if not found. - */ - BOM * result = NULL; - BOM *bom; - - for (bom = BOMs; bom->length; bom++) { - if (strncmp(bom->sequence, buffer, bom->length) == 0) { - result = bom; - break; - } - } - return result; -} - -static char * -find_terminator(char * buffer, int len, BOM *bom) -{ - char * result = NULL; - char * end = buffer + len; - char * p; - char c; - int cp; - - for (p = buffer; p < end; p++) { - c = *p; - if (c == '\r') { - result = p; - break; - } - if (c == '\n') { - result = p; - break; - } - } - if (result != NULL) { - cp = bom->code_page; - - /* adjustments to include all bytes of the char */ - /* no adjustment needed for UTF-8 or big endian */ - if (cp == CP_UTF16LE) - ++result; - else if (cp == CP_UTF32LE) - result += 3; - ++result; /* point just past terminator */ - } - return result; -} - -static BOOL -validate_version(wchar_t * p) -{ - /* - Version information should start with the major version, - Optionally followed by a period and a minor version, - Optionally followed by a minus and one of 32 or 64. - Valid examples: - 2 - 3 - 2.7 - 3.6 - 2.7-32 - The intent is to add to the valid patterns: - 3.10 - 3-32 - 3.6-64 - 3-64 - */ - BOOL result = (p != NULL); /* Default to False if null pointer. */ - - result = result && iswdigit(*p); /* Result = False if first string element is not a digit. */ - - while (result && iswdigit(*p)) /* Require a major version */ - ++p; /* Skip all leading digit(s) */ - if (result && (*p == L'.')) /* Allow . for major minor separator.*/ - { - result = iswdigit(*++p); /* Must be at least one digit */ - while (result && iswdigit(*++p)) ; /* Skip any more Digits */ - } - if (result && (*p == L'-')) { /* Allow - for Bits Separator */ - switch(*++p){ - case L'3': /* 3 is OK */ - result = (*++p == L'2') && !*++p; /* only if followed by 2 and ended.*/ - break; - case L'6': /* 6 is OK */ - result = (*++p == L'4') && !*++p; /* only if followed by 4 and ended.*/ - break; - default: - result = FALSE; - break; - } - } - result = result && !*p; /* Must have reached EOS */ - return result; - -} - -typedef struct { - unsigned short min; - unsigned short max; - wchar_t version[MAX_VERSION_SIZE]; -} PYC_MAGIC; - -static PYC_MAGIC magic_values[] = { - { 50823, 50823, L"2.0" }, - { 60202, 60202, L"2.1" }, - { 60717, 60717, L"2.2" }, - { 62011, 62021, L"2.3" }, - { 62041, 62061, L"2.4" }, - { 62071, 62131, L"2.5" }, - { 62151, 62161, L"2.6" }, - { 62171, 62211, L"2.7" }, - { 3000, 3131, L"3.0" }, - { 3141, 3151, L"3.1" }, - { 3160, 3180, L"3.2" }, - { 3190, 3230, L"3.3" }, - { 3250, 3310, L"3.4" }, - { 3320, 3351, L"3.5" }, - { 3360, 3379, L"3.6" }, - { 3390, 3399, L"3.7" }, - { 3400, 3419, L"3.8" }, - { 3420, 3429, L"3.9" }, - { 3430, 3439, L"3.10" }, - { 0 } -}; - -static INSTALLED_PYTHON * -find_by_magic(unsigned short magic) -{ - INSTALLED_PYTHON * result = NULL; - PYC_MAGIC * mp; - - for (mp = magic_values; mp->min; mp++) { - if ((magic >= mp->min) && (magic <= mp->max)) { - result = locate_python(mp->version, FALSE); - if (result != NULL) - break; - } - } - return result; -} - -static void -maybe_handle_shebang(wchar_t ** argv, wchar_t * cmdline) -{ -/* - * Look for a shebang line in the first argument. If found - * and we spawn a child process, this never returns. If it - * does return then we process the args "normally". - * - * argv[0] might be a filename with a shebang. - */ - FILE * fp; - errno_t rc = _wfopen_s(&fp, *argv, L"rb"); - char buffer[BUFSIZE]; - wchar_t shebang_line[BUFSIZE + 1]; - size_t read; - char *p; - char * start; - char * shebang_alias = (char *) shebang_line; - BOM* bom; - int i, j, nchars = 0; - int header_len; - BOOL is_virt; - BOOL search; - wchar_t * command; - wchar_t * suffix; - COMMAND *cmd = NULL; - INSTALLED_PYTHON * ip; - - if (rc == 0) { - read = fread(buffer, sizeof(char), BUFSIZE, fp); - debug(L"maybe_handle_shebang: read %zd bytes\n", read); - fclose(fp); - - if ((read >= 4) && (buffer[3] == '\n') && (buffer[2] == '\r')) { - ip = find_by_magic((((unsigned char)buffer[1]) << 8 | - (unsigned char)buffer[0]) & 0xFFFF); - if (ip != NULL) { - debug(L"script file is compiled against Python %ls\n", - ip->version); - invoke_child(ip->executable, NULL, cmdline); - } - } - /* Look for BOM */ - bom = find_BOM(buffer); - if (bom == NULL) { - start = buffer; - debug(L"maybe_handle_shebang: BOM not found, using UTF-8\n"); - bom = BOMs; /* points to UTF-8 entry - the default */ - } - else { - debug(L"maybe_handle_shebang: BOM found, code page %u\n", - bom->code_page); - start = &buffer[bom->length]; - } - p = find_terminator(start, BUFSIZE, bom); - /* - * If no CR or LF was found in the heading, - * we assume it's not a shebang file. - */ - if (p == NULL) { - debug(L"maybe_handle_shebang: No line terminator found\n"); - } - else { - /* - * Found line terminator - parse the shebang. - * - * Strictly, we don't need to handle UTF-16 anf UTF-32, - * since Python itself doesn't. - * Never mind, one day it might. - */ - header_len = (int) (p - start); - switch(bom->code_page) { - case CP_UTF8: - nchars = MultiByteToWideChar(bom->code_page, - 0, - start, header_len, shebang_line, - BUFSIZE); - break; - case CP_UTF16BE: - if (header_len % 2 != 0) { - debug(L"maybe_handle_shebang: UTF-16BE, but an odd number \ -of bytes: %d\n", header_len); - /* nchars = 0; Not needed - initialised to 0. */ - } - else { - for (i = header_len; i > 0; i -= 2) { - shebang_alias[i - 1] = start[i - 2]; - shebang_alias[i - 2] = start[i - 1]; - } - nchars = header_len / sizeof(wchar_t); - } - break; - case CP_UTF16LE: - if ((header_len % 2) != 0) { - debug(L"UTF-16LE, but an odd number of bytes: %d\n", - header_len); - /* nchars = 0; Not needed - initialised to 0. */ - } - else { - /* no actual conversion needed. */ - memcpy(shebang_line, start, header_len); - nchars = header_len / sizeof(wchar_t); - } - break; - case CP_UTF32BE: - if (header_len % 4 != 0) { - debug(L"UTF-32BE, but not divisible by 4: %d\n", - header_len); - /* nchars = 0; Not needed - initialised to 0. */ - } - else { - for (i = header_len, j = header_len / 2; i > 0; i -= 4, - j -= 2) { - shebang_alias[j - 1] = start[i - 2]; - shebang_alias[j - 2] = start[i - 1]; - } - nchars = header_len / sizeof(wchar_t); - } - break; - case CP_UTF32LE: - if (header_len % 4 != 0) { - debug(L"UTF-32LE, but not divisible by 4: %d\n", - header_len); - /* nchars = 0; Not needed - initialised to 0. */ - } - else { - for (i = header_len, j = header_len / 2; i > 0; i -= 4, - j -= 2) { - shebang_alias[j - 1] = start[i - 3]; - shebang_alias[j - 2] = start[i - 4]; - } - nchars = header_len / sizeof(wchar_t); - } - break; - } - if (nchars > 0) { - shebang_line[--nchars] = L'\0'; - is_virt = parse_shebang(shebang_line, nchars, &command, - &suffix, &search); - if (command != NULL) { - debug(L"parse_shebang: found command: %ls\n", command); - if (!is_virt) { - invoke_child(command, suffix, cmdline); - } - else { - suffix = wcschr(command, L' '); - if (suffix != NULL) { - *suffix++ = L'\0'; - suffix = skip_whitespace(suffix); - } - if (wcsncmp(command, L"python", 6)) - error(RC_BAD_VIRTUAL_PATH, L"Unknown virtual \ -path '%ls'", command); - command += 6; /* skip past "python" */ - if (search && ((*command == L'\0') || isspace(*command))) { - /* Command is eligible for path search, and there - * is no version specification. - */ - debug(L"searching PATH for python executable\n"); - cmd = find_on_path(PYTHON_EXECUTABLE); - debug(L"Python on path: %ls\n", cmd ? cmd->value : L""); - if (cmd) { - debug(L"located python on PATH: %ls\n", cmd->value); - invoke_child(cmd->value, suffix, cmdline); - /* Exit here, as we have found the command */ - return; - } - /* FALL THROUGH: No python found on PATH, so fall - * back to locating the correct installed python. - */ - } - if (*command && !validate_version(command)) - error(RC_BAD_VIRTUAL_PATH, L"Invalid version \ -specification: '%ls'.\nIn the first line of the script, 'python' needs to be \ -followed by a valid version specifier.\nPlease check the documentation.", - command); - /* TODO could call validate_version(command) */ - ip = locate_python(command, TRUE); - if (ip == NULL) { - error(RC_NO_PYTHON, L"Requested Python version \ -(%ls) is not installed", command); - } - else { - invoke_child(ip->executable, suffix, cmdline); - } - } - } - } - } - } -} - -static wchar_t * -skip_me(wchar_t * cmdline) -{ - BOOL quoted; - wchar_t c; - wchar_t * result = cmdline; - - quoted = cmdline[0] == L'\"'; - if (!quoted) - c = L' '; - else { - c = L'\"'; - ++result; - } - result = wcschr(result, c); - if (result == NULL) /* when, for example, just exe name on command line */ - result = L""; - else { - ++result; /* skip past space or closing quote */ - result = skip_whitespace(result); - } - return result; -} - -static DWORD version_high = 0; -static DWORD version_low = 0; - -static void -get_version_info(wchar_t * version_text, size_t size) -{ - WORD maj, min, rel, bld; - - if (!version_high && !version_low) - wcsncpy_s(version_text, size, L"0.1", _TRUNCATE); /* fallback */ - else { - maj = HIWORD(version_high); - min = LOWORD(version_high); - rel = HIWORD(version_low); - bld = LOWORD(version_low); - _snwprintf_s(version_text, size, _TRUNCATE, L"%d.%d.%d.%d", maj, - min, rel, bld); - } -} - -static void -show_help_text(wchar_t ** argv) -{ - wchar_t version_text [MAX_PATH]; -#if defined(_M_X64) - BOOL canDo64bit = TRUE; -#else - /* If we are a 32bit process on a 64bit Windows, first hit the 64bit keys. */ - BOOL canDo64bit = FALSE; - IsWow64Process(GetCurrentProcess(), &canDo64bit); -#endif - - get_version_info(version_text, MAX_PATH); - fwprintf(stdout, L"\ -Python Launcher for Windows Version %ls\n\n", version_text); - fwprintf(stdout, L"\ -usage:\n\ -%ls [launcher-args] [python-args] [script [script-args]]\n\n", argv[0]); - fputws(L"\ -Launcher arguments:\n\n\ --2 : Launch the latest Python 2.x version\n\ --3 : Launch the latest Python 3.x version\n\ --X.Y : Launch the specified Python version\n", stdout); - if (canDo64bit) { - fputws(L"\ - The above all default to 64 bit if a matching 64 bit python is present.\n\ --X.Y-32: Launch the specified 32bit Python version\n\ --X-32 : Launch the latest 32bit Python X version\n\ --X.Y-64: Launch the specified 64bit Python version\n\ --X-64 : Launch the latest 64bit Python X version", stdout); - } - fputws(L"\n-0 --list : List the available pythons", stdout); - fputws(L"\n-0p --list-paths : List with paths", stdout); - fputws(L"\n\n If no script is specified the specified interpreter is opened.", stdout); - fputws(L"\nIf an exact version is not given, using the latest version can be overridden by", stdout); - fputws(L"\nany of the following, (in priority order):", stdout); - fputws(L"\n An active virtual environment", stdout); - fputws(L"\n A shebang line in the script (if present)", stdout); - fputws(L"\n With -2 or -3 flag a matching PY_PYTHON2 or PY_PYTHON3 Environment variable", stdout); - fputws(L"\n A PY_PYTHON Environment variable", stdout); - fputws(L"\n From [defaults] in py.ini in your %LOCALAPPDATA%\\py.ini", stdout); - fputws(L"\n From [defaults] in py.ini beside py.exe (use `where py` to locate)", stdout); - fputws(L"\n\nThe following help text is from Python:\n\n", stdout); - fflush(stdout); -} - -static BOOL -show_python_list(wchar_t ** argv) -{ - /* - * Display options -0 - */ - INSTALLED_PYTHON * result = NULL; - INSTALLED_PYTHON * ip = installed_pythons; /* List of installed pythons */ - INSTALLED_PYTHON * defpy = locate_python(L"", FALSE); - size_t i = 0; - wchar_t *p = argv[1]; - wchar_t *ver_fmt = L"-%ls-%d"; - wchar_t *fmt = L"\n %ls"; - wchar_t *defind = L" *"; /* Default indicator */ - - /* - * Output informational messages to stderr to keep output - * clean for use in pipes, etc. - */ - fwprintf(stderr, - L"Installed Pythons found by %s Launcher for Windows", argv[0]); - if (!_wcsicmp(p, L"-0p") || !_wcsicmp(p, L"--list-paths")) - fmt = L"\n %-15ls%ls"; /* include path */ - - if (num_installed_pythons == 0) /* We have somehow got here without searching for pythons */ - locate_all_pythons(); /* Find them, Populates installed_pythons */ - - if (num_installed_pythons == 0) /* No pythons found */ - fwprintf(stderr, L"\nNo Installed Pythons Found!"); - else - { - for (i = 0; i < num_installed_pythons; i++, ip++) { - wchar_t version[BUFSIZ]; - if (wcscmp(ip->version, L"venv") == 0) { - wcscpy_s(version, BUFSIZ, L"(venv)"); - } - else { - swprintf_s(version, BUFSIZ, ver_fmt, ip->version, ip->bits); - } - - if (ip->exe_display[0]) { - fwprintf(stdout, fmt, version, ip->exe_display); - } - else { - fwprintf(stdout, fmt, version, ip->executable); - } - /* If there is a default indicate it */ - if (defpy == ip) - fwprintf(stderr, defind); - } - } - - if ((defpy == NULL) && (num_installed_pythons > 0)) - /* We have pythons but none is the default */ - fwprintf(stderr, L"\n\nCan't find a Default Python.\n\n"); - else - fwprintf(stderr, L"\n\n"); /* End with a blank line */ - return FALSE; /* If this has been called we cannot continue */ -} - -#if defined(VENV_REDIRECT) - -static int -find_home_value(const char *buffer, const char **start, DWORD *length) -{ - for (const char *s = strstr(buffer, "home"); s; s = strstr(s + 1, "\nhome")) { - if (*s == '\n') { - ++s; - } - for (int i = 4; i > 0 && *s; --i, ++s); - - while (*s && iswspace(*s)) { - ++s; - } - if (*s != L'=') { - continue; - } - - do { - ++s; - } while (*s && iswspace(*s)); - - *start = s; - char *nl = strchr(s, '\n'); - if (nl) { - *length = (DWORD)((ptrdiff_t)nl - (ptrdiff_t)s); - } else { - *length = (DWORD)strlen(s); - } - return 1; - } - return 0; -} -#endif - -static wchar_t * -wcsdup_pad(const wchar_t *s, int padding, int *newlen) -{ - size_t len = wcslen(s); - len += 1 + padding; - wchar_t *r = (wchar_t *)malloc(len * sizeof(wchar_t)); - if (!r) { - return NULL; - } - if (wcscpy_s(r, len, s)) { - free(r); - return NULL; - } - *newlen = len < MAXINT ? (int)len : MAXINT; - return r; -} - -static wchar_t * -get_process_name() -{ - DWORD bufferLen = MAX_PATH; - DWORD len = bufferLen; - wchar_t *r = NULL; - - while (!r) { - r = (wchar_t *)malloc(bufferLen * sizeof(wchar_t)); - if (!r) { - error(RC_NO_MEMORY, L"out of memory"); - return NULL; - } - len = GetModuleFileNameW(NULL, r, bufferLen); - if (len == 0) { - free(r); - error(0, L"Failed to get module name"); - return NULL; - } else if (len == bufferLen && - GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - free(r); - r = NULL; - bufferLen *= 2; - } - } - - return r; -} - -static int -process(int argc, wchar_t ** argv) -{ - wchar_t * wp; - wchar_t * command; - wchar_t * executable; - wchar_t * p; - wchar_t * argv0; - int rc = 0; - INSTALLED_PYTHON * ip; - BOOL valid; - DWORD size, attrs; - wchar_t message[MSGSIZE]; - void * version_data; - VS_FIXEDFILEINFO * file_info; - UINT block_size; -#if defined(VENV_REDIRECT) - wchar_t * venv_cfg_path; - int newlen; -#elif defined(SCRIPT_WRAPPER) - wchar_t * newcommand; - wchar_t * av[2]; - int newlen; - HRESULT hr; - int index; -#else - HRESULT hr; - int index; -#endif - - setvbuf(stderr, (char *)NULL, _IONBF, 0); - wp = get_env(L"PYLAUNCH_DEBUG"); - if ((wp != NULL) && (*wp != L'\0')) - log_fp = stderr; - -#if defined(_M_X64) - debug(L"launcher build: 64bit\n"); -#else - debug(L"launcher build: 32bit\n"); -#endif -#if defined(_WINDOWS) - debug(L"launcher executable: Windows\n"); -#else - debug(L"launcher executable: Console\n"); -#endif -#if !defined(VENV_REDIRECT) - /* Get the local appdata folder (non-roaming) */ - hr = SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, - NULL, 0, appdata_ini_path); - if (hr != S_OK) { - debug(L"SHGetFolderPath failed: %X\n", hr); - appdata_ini_path[0] = L'\0'; - } - else { - wcsncat_s(appdata_ini_path, MAX_PATH, L"\\py.ini", _TRUNCATE); - attrs = GetFileAttributesW(appdata_ini_path); - if (attrs == INVALID_FILE_ATTRIBUTES) { - debug(L"File '%ls' non-existent\n", appdata_ini_path); - appdata_ini_path[0] = L'\0'; - } else { - debug(L"Using local configuration file '%ls'\n", appdata_ini_path); - } - } -#endif - argv0 = get_process_name(); - size = GetFileVersionInfoSizeW(argv0, &size); - if (size == 0) { - winerror(GetLastError(), message, MSGSIZE); - debug(L"GetFileVersionInfoSize failed: %ls\n", message); - } - else { - version_data = malloc(size); - if (version_data) { - valid = GetFileVersionInfoW(argv0, 0, size, - version_data); - if (!valid) - debug(L"GetFileVersionInfo failed: %X\n", GetLastError()); - else { - valid = VerQueryValueW(version_data, L"\\", - (LPVOID *) &file_info, &block_size); - if (!valid) - debug(L"VerQueryValue failed: %X\n", GetLastError()); - else { - version_high = file_info->dwFileVersionMS; - version_low = file_info->dwFileVersionLS; - } - } - free(version_data); - } - } - -#if defined(VENV_REDIRECT) - /* Allocate some extra space for new filenames */ - venv_cfg_path = wcsdup_pad(argv0, 32, &newlen); - if (!venv_cfg_path) { - error(RC_NO_MEMORY, L"Failed to copy module name"); - } - p = wcsrchr(venv_cfg_path, L'\\'); - - if (p == NULL) { - error(RC_NO_VENV_CFG, L"No pyvenv.cfg file"); - } - p[0] = L'\0'; - wcscat_s(venv_cfg_path, newlen, L"\\pyvenv.cfg"); - attrs = GetFileAttributesW(venv_cfg_path); - if (attrs == INVALID_FILE_ATTRIBUTES) { - debug(L"File '%ls' non-existent\n", venv_cfg_path); - p[0] = '\0'; - p = wcsrchr(venv_cfg_path, L'\\'); - if (p != NULL) { - p[0] = '\0'; - wcscat_s(venv_cfg_path, newlen, L"\\pyvenv.cfg"); - attrs = GetFileAttributesW(venv_cfg_path); - if (attrs == INVALID_FILE_ATTRIBUTES) { - debug(L"File '%ls' non-existent\n", venv_cfg_path); - error(RC_NO_VENV_CFG, L"No pyvenv.cfg file"); - } - } - } - debug(L"Using venv configuration file '%ls'\n", venv_cfg_path); -#else - /* Allocate some extra space for new filenames */ - if (wcscpy_s(launcher_ini_path, MAX_PATH, argv0)) { - error(RC_NO_MEMORY, L"Failed to copy module name"); - } - p = wcsrchr(launcher_ini_path, L'\\'); - - if (p == NULL) { - debug(L"GetModuleFileNameW returned value has no backslash: %ls\n", - launcher_ini_path); - launcher_ini_path[0] = L'\0'; - } - else { - p[0] = L'\0'; - wcscat_s(launcher_ini_path, MAX_PATH, L"\\py.ini"); - attrs = GetFileAttributesW(launcher_ini_path); - if (attrs == INVALID_FILE_ATTRIBUTES) { - debug(L"File '%ls' non-existent\n", launcher_ini_path); - launcher_ini_path[0] = L'\0'; - } else { - debug(L"Using global configuration file '%ls'\n", launcher_ini_path); - } - } -#endif - - command = skip_me(GetCommandLineW()); - debug(L"Called with command line: %ls\n", command); - -#if !defined(VENV_REDIRECT) - /* bpo-35811: The __PYVENV_LAUNCHER__ variable is used to - * override sys.executable and locate the original prefix path. - * However, if it is silently inherited by a non-venv Python - * process, that process will believe it is running in the venv - * still. This is the only place where *we* can clear it (that is, - * when py.exe is being used to launch Python), so we do. - */ - SetEnvironmentVariableW(L"__PYVENV_LAUNCHER__", NULL); -#endif - -#if defined(SCRIPT_WRAPPER) - /* The launcher is being used in "script wrapper" mode. - * There should therefore be a Python script named -script.py in - * the same directory as the launcher executable. - * Put the script name into argv as the first (script name) argument. - */ - - /* Get the wrapped script name - if the script is not present, this will - * terminate the program with an error. - */ - locate_wrapped_script(); - - /* Add the wrapped script to the start of command */ - newlen = wcslen(wrapped_script_path) + wcslen(command) + 2; /* ' ' + NUL */ - newcommand = malloc(sizeof(wchar_t) * newlen); - if (!newcommand) { - error(RC_NO_MEMORY, L"Could not allocate new command line"); - } - else { - wcscpy_s(newcommand, newlen, wrapped_script_path); - wcscat_s(newcommand, newlen, L" "); - wcscat_s(newcommand, newlen, command); - debug(L"Running wrapped script with command line '%ls'\n", newcommand); - read_commands(); - av[0] = wrapped_script_path; - av[1] = NULL; - maybe_handle_shebang(av, newcommand); - /* Returns if no shebang line - pass to default processing */ - command = newcommand; - valid = FALSE; - } -#elif defined(VENV_REDIRECT) - { - FILE *f; - char buffer[4096]; /* 4KB should be enough for anybody */ - char *start; - DWORD len, cch, cch_actual; - size_t cb; - if (_wfopen_s(&f, venv_cfg_path, L"r")) { - error(RC_BAD_VENV_CFG, L"Cannot read '%ls'", venv_cfg_path); - } - cb = fread_s(buffer, sizeof(buffer), sizeof(buffer[0]), - sizeof(buffer) / sizeof(buffer[0]), f); - fclose(f); - - if (!find_home_value(buffer, &start, &len)) { - error(RC_BAD_VENV_CFG, L"Cannot find home in '%ls'", - venv_cfg_path); - } - - cch = MultiByteToWideChar(CP_UTF8, 0, start, len, NULL, 0); - if (!cch) { - error(0, L"Cannot determine memory for home path"); - } - cch += (DWORD)wcslen(PYTHON_EXECUTABLE) + 4; /* include sep, null and quotes */ - executable = (wchar_t *)malloc(cch * sizeof(wchar_t)); - if (executable == NULL) { - error(RC_NO_MEMORY, L"A memory allocation failed"); - } - /* start with a quote - we'll skip this ahead, but want it for the final string */ - executable[0] = L'"'; - cch_actual = MultiByteToWideChar(CP_UTF8, 0, start, len, &executable[1], cch - 1); - if (!cch_actual) { - error(RC_BAD_VENV_CFG, L"Cannot decode home path in '%ls'", - venv_cfg_path); - } - cch_actual += 1; /* account for the first quote */ - executable[cch_actual] = L'\0'; - if (executable[cch_actual - 1] != L'\\') { - executable[cch_actual++] = L'\\'; - executable[cch_actual] = L'\0'; - } - if (wcscat_s(&executable[1], cch - 1, PYTHON_EXECUTABLE)) { - error(RC_BAD_VENV_CFG, L"Cannot create executable path from '%ls'", - venv_cfg_path); - } - /* there's no trailing quote, so we only have to skip one character for the test */ - if (GetFileAttributesW(&executable[1]) == INVALID_FILE_ATTRIBUTES) { - error(RC_NO_PYTHON, L"No Python at '%ls'", executable); - } - /* now append the final quote */ - wcscat_s(executable, cch, L"\""); - /* smuggle our original path through */ - if (!SetEnvironmentVariableW(L"__PYVENV_LAUNCHER__", argv0)) { - error(0, L"Failed to set launcher environment"); - } - valid = 1; - } -#else - if (argc <= 1) { - valid = FALSE; - p = NULL; - } - else { - p = argv[1]; - if ((argc == 2) && // list version args - (!wcsncmp(p, L"-0", wcslen(L"-0")) || - !wcsncmp(p, L"--list", wcslen(L"--list")))) - { - show_python_list(argv); - return rc; - } - valid = valid && (*p == L'-') && validate_version(&p[1]); - if (valid) { - ip = locate_python(&p[1], FALSE); - if (ip == NULL) - { - fwprintf(stdout, \ - L"Python %ls not found!\n", &p[1]); - valid = show_python_list(argv); - error(RC_NO_PYTHON, L"Requested Python version (%ls) not \ -installed, use -0 for available pythons", &p[1]); - } - executable = ip->executable; - command += wcslen(p); - command = skip_whitespace(command); - } - else { - for (index = 1; index < argc; ++index) { - if (*argv[index] != L'-') - break; - } - if (index < argc) { - read_commands(); - maybe_handle_shebang(&argv[index], command); - } - } - } -#endif - - if (!valid) { - if ((argc == 2) && (!_wcsicmp(p, L"-h") || !_wcsicmp(p, L"--help"))) - show_help_text(argv); - if ((argc == 2) && - (!_wcsicmp(p, L"-0") || !_wcsicmp(p, L"--list") || - !_wcsicmp(p, L"-0p") || !_wcsicmp(p, L"--list-paths"))) - { - executable = NULL; /* Info call only */ - } - else { - /* look for the default Python */ - ip = locate_python(L"", FALSE); - if (ip == NULL) - error(RC_NO_PYTHON, L"Can't find a default Python."); - executable = ip->executable; - } - } - if (executable != NULL) - invoke_child(executable, NULL, command); - else - rc = RC_NO_PYTHON; - return rc; -} - -#if defined(_WINDOWS) - -int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, - LPWSTR lpstrCmd, int nShow) -{ - return process(__argc, __wargv); -} - -#else - -int cdecl wmain(int argc, wchar_t ** argv) -{ - return process(argc, argv); -} - -#endif diff --git a/PC/layout/__init__.py b/PC/layout/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/PC/layout/__main__.py b/PC/layout/__main__.py deleted file mode 100644 index f7aa1e6d261f4a2668ad85b9fffe62d054c84caa..0000000000000000000000000000000000000000 --- a/PC/layout/__main__.py +++ /dev/null @@ -1,14 +0,0 @@ -import sys - -try: - import layout -except ImportError: - # Failed to import our package, which likely means we were started directly - # Add the additional search path needed to locate our module. - from pathlib import Path - - sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) - -from layout.main import main - -sys.exit(int(main() or 0)) diff --git a/PC/layout/main.py b/PC/layout/main.py deleted file mode 100644 index fb6f5265859ff64dd7ec9d2dc1486b069834745e..0000000000000000000000000000000000000000 --- a/PC/layout/main.py +++ /dev/null @@ -1,647 +0,0 @@ -""" -Generates a layout of Python for Windows from a build. - -See python make_layout.py --help for usage. -""" - -__author__ = "Steve Dower " -__version__ = "3.8" - -import argparse -import functools -import os -import re -import shutil -import subprocess -import sys -import tempfile -import zipfile - -from pathlib import Path - -if __name__ == "__main__": - # Started directly, so enable relative imports - __path__ = [str(Path(__file__).resolve().parent)] - -from .support.appxmanifest import * -from .support.catalog import * -from .support.constants import * -from .support.filesets import * -from .support.logging import * -from .support.options import * -from .support.pip import * -from .support.props import * -from .support.nuspec import * - -TEST_PYDS_ONLY = FileStemSet("xxlimited", "xxlimited_35", "_ctypes_test", "_test*") -TEST_DIRS_ONLY = FileNameSet("test", "tests") - -IDLE_DIRS_ONLY = FileNameSet("idlelib") - -TCLTK_PYDS_ONLY = FileStemSet("tcl*", "tk*", "_tkinter") -TCLTK_DIRS_ONLY = FileNameSet("tkinter", "turtledemo") -TCLTK_FILES_ONLY = FileNameSet("turtle.py") - -VENV_DIRS_ONLY = FileNameSet("venv", "ensurepip") - -EXCLUDE_FROM_PYDS = FileStemSet("python*", "pyshellext", "vcruntime*") -EXCLUDE_FROM_LIB = FileNameSet("*.pyc", "__pycache__", "*.pickle") -EXCLUDE_FROM_PACKAGED_LIB = FileNameSet("readme.txt") -EXCLUDE_FROM_COMPILE = FileNameSet("badsyntax_*", "bad_*") -EXCLUDE_FROM_CATALOG = FileSuffixSet(".exe", ".pyd", ".dll") - -REQUIRED_DLLS = FileStemSet("libcrypto*", "libssl*", "libffi*") - -LIB2TO3_GRAMMAR_FILES = FileNameSet("Grammar.txt", "PatternGrammar.txt") - -PY_FILES = FileSuffixSet(".py") -PYC_FILES = FileSuffixSet(".pyc") -CAT_FILES = FileSuffixSet(".cat") -CDF_FILES = FileSuffixSet(".cdf") - -DATA_DIRS = FileNameSet("data") - -TOOLS_DIRS = FileNameSet("scripts", "i18n", "pynche", "demo", "parser") -TOOLS_FILES = FileSuffixSet(".py", ".pyw", ".txt") - - -def copy_if_modified(src, dest): - try: - dest_stat = os.stat(dest) - except FileNotFoundError: - do_copy = True - else: - src_stat = os.stat(src) - do_copy = ( - src_stat.st_mtime != dest_stat.st_mtime - or src_stat.st_size != dest_stat.st_size - ) - - if do_copy: - shutil.copy2(src, dest) - - -def get_lib_layout(ns): - def _c(f): - if f in EXCLUDE_FROM_LIB: - return False - if f.is_dir(): - if f in TEST_DIRS_ONLY: - return ns.include_tests - if f in TCLTK_DIRS_ONLY: - return ns.include_tcltk - if f in IDLE_DIRS_ONLY: - return ns.include_idle - if f in VENV_DIRS_ONLY: - return ns.include_venv - else: - if f in TCLTK_FILES_ONLY: - return ns.include_tcltk - return True - - for dest, src in rglob(ns.source / "Lib", "**/*", _c): - yield dest, src - - -def get_tcltk_lib(ns): - if not ns.include_tcltk: - return - - tcl_lib = os.getenv("TCL_LIBRARY") - if not tcl_lib or not os.path.isdir(tcl_lib): - try: - with open(ns.build / "TCL_LIBRARY.env", "r", encoding="utf-8-sig") as f: - tcl_lib = f.read().strip() - except FileNotFoundError: - pass - if not tcl_lib or not os.path.isdir(tcl_lib): - log_warning("Failed to find TCL_LIBRARY") - return - - for dest, src in rglob(Path(tcl_lib).parent, "**/*"): - yield "tcl/{}".format(dest), src - - -def get_layout(ns): - def in_build(f, dest="", new_name=None): - n, _, x = f.rpartition(".") - n = new_name or n - src = ns.build / f - if ns.debug and src not in REQUIRED_DLLS: - if not src.stem.endswith("_d"): - src = src.parent / (src.stem + "_d" + src.suffix) - if not n.endswith("_d"): - n += "_d" - f = n + "." + x - yield dest + n + "." + x, src - if ns.include_symbols: - pdb = src.with_suffix(".pdb") - if pdb.is_file(): - yield dest + n + ".pdb", pdb - if ns.include_dev: - lib = src.with_suffix(".lib") - if lib.is_file(): - yield "libs/" + n + ".lib", lib - - if ns.include_appxmanifest: - yield from in_build("python_uwp.exe", new_name="python{}".format(VER_DOT)) - yield from in_build("pythonw_uwp.exe", new_name="pythonw{}".format(VER_DOT)) - # For backwards compatibility, but we don't reference these ourselves. - yield from in_build("python_uwp.exe", new_name="python") - yield from in_build("pythonw_uwp.exe", new_name="pythonw") - else: - yield from in_build("python.exe", new_name="python") - yield from in_build("pythonw.exe", new_name="pythonw") - - yield from in_build(PYTHON_DLL_NAME) - - if ns.include_launchers and ns.include_appxmanifest: - if ns.include_pip: - yield from in_build("python_uwp.exe", new_name="pip{}".format(VER_DOT)) - if ns.include_idle: - yield from in_build("pythonw_uwp.exe", new_name="idle{}".format(VER_DOT)) - - if ns.include_stable: - yield from in_build(PYTHON_STABLE_DLL_NAME) - - found_any = False - for dest, src in rglob(ns.build, "vcruntime*.dll"): - found_any = True - yield dest, src - if not found_any: - log_error("Failed to locate vcruntime DLL in the build.") - - yield "LICENSE.txt", ns.build / "LICENSE.txt" - - for dest, src in rglob(ns.build, ("*.pyd", "*.dll")): - if src.stem.endswith("_d") != bool(ns.debug) and src not in REQUIRED_DLLS: - continue - if src in EXCLUDE_FROM_PYDS: - continue - if src in TEST_PYDS_ONLY and not ns.include_tests: - continue - if src in TCLTK_PYDS_ONLY and not ns.include_tcltk: - continue - - yield from in_build(src.name, dest="" if ns.flat_dlls else "DLLs/") - - if ns.zip_lib: - zip_name = PYTHON_ZIP_NAME - yield zip_name, ns.temp / zip_name - else: - for dest, src in get_lib_layout(ns): - yield "Lib/{}".format(dest), src - - if ns.include_venv: - yield from in_build("venvlauncher.exe", "Lib/venv/scripts/nt/", "python") - yield from in_build("venvwlauncher.exe", "Lib/venv/scripts/nt/", "pythonw") - - if ns.include_tools: - - def _c(d): - if d.is_dir(): - return d in TOOLS_DIRS - return d in TOOLS_FILES - - for dest, src in rglob(ns.source / "Tools", "**/*", _c): - yield "Tools/{}".format(dest), src - - if ns.include_underpth: - yield PYTHON_PTH_NAME, ns.temp / PYTHON_PTH_NAME - - if ns.include_dev: - - for dest, src in rglob(ns.source / "Include", "**/*.h"): - yield "include/{}".format(dest), src - src = ns.source / "PC" / "pyconfig.h" - yield "include/pyconfig.h", src - - for dest, src in get_tcltk_lib(ns): - yield dest, src - - if ns.include_pip: - for dest, src in get_pip_layout(ns): - if not isinstance(src, tuple) and ( - src in EXCLUDE_FROM_LIB or src in EXCLUDE_FROM_PACKAGED_LIB - ): - continue - yield dest, src - - if ns.include_chm: - for dest, src in rglob(ns.doc_build / "htmlhelp", PYTHON_CHM_NAME): - yield "Doc/{}".format(dest), src - - if ns.include_html_doc: - for dest, src in rglob(ns.doc_build / "html", "**/*"): - yield "Doc/html/{}".format(dest), src - - if ns.include_props: - for dest, src in get_props_layout(ns): - yield dest, src - - if ns.include_nuspec: - for dest, src in get_nuspec_layout(ns): - yield dest, src - - for dest, src in get_appx_layout(ns): - yield dest, src - - if ns.include_cat: - if ns.flat_dlls: - yield ns.include_cat.name, ns.include_cat - else: - yield "DLLs/{}".format(ns.include_cat.name), ns.include_cat - - -def _compile_one_py(src, dest, name, optimize, checked=True): - import py_compile - - if dest is not None: - dest = str(dest) - - mode = ( - py_compile.PycInvalidationMode.CHECKED_HASH - if checked - else py_compile.PycInvalidationMode.UNCHECKED_HASH - ) - - try: - return Path( - py_compile.compile( - str(src), - dest, - str(name), - doraise=True, - optimize=optimize, - invalidation_mode=mode, - ) - ) - except py_compile.PyCompileError: - log_warning("Failed to compile {}", src) - return None - - -# name argument added to address bpo-37641 -def _py_temp_compile(src, name, ns, dest_dir=None, checked=True): - if not ns.precompile or src not in PY_FILES or src.parent in DATA_DIRS: - return None - dest = (dest_dir or ns.temp) / (src.stem + ".pyc") - return _compile_one_py(src, dest, name, optimize=2, checked=checked) - - -def _write_to_zip(zf, dest, src, ns, checked=True): - pyc = _py_temp_compile(src, dest, ns, checked=checked) - if pyc: - try: - zf.write(str(pyc), dest.with_suffix(".pyc")) - finally: - try: - pyc.unlink() - except: - log_exception("Failed to delete {}", pyc) - return - - if src in LIB2TO3_GRAMMAR_FILES: - from lib2to3.pgen2.driver import load_grammar - - tmp = ns.temp / src.name - try: - shutil.copy(src, tmp) - load_grammar(str(tmp)) - for f in ns.temp.glob(src.stem + "*.pickle"): - zf.write(str(f), str(dest.parent / f.name)) - try: - f.unlink() - except: - log_exception("Failed to delete {}", f) - except: - log_exception("Failed to compile {}", src) - finally: - try: - tmp.unlink() - except: - log_exception("Failed to delete {}", tmp) - - zf.write(str(src), str(dest)) - - -def generate_source_files(ns): - if ns.zip_lib: - zip_name = PYTHON_ZIP_NAME - zip_path = ns.temp / zip_name - if zip_path.is_file(): - zip_path.unlink() - elif zip_path.is_dir(): - log_error( - "Cannot create zip file because a directory exists by the same name" - ) - return - log_info("Generating {} in {}", zip_name, ns.temp) - ns.temp.mkdir(parents=True, exist_ok=True) - with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zf: - for dest, src in get_lib_layout(ns): - _write_to_zip(zf, dest, src, ns, checked=False) - - if ns.include_underpth: - log_info("Generating {} in {}", PYTHON_PTH_NAME, ns.temp) - ns.temp.mkdir(parents=True, exist_ok=True) - with open(ns.temp / PYTHON_PTH_NAME, "w", encoding="utf-8") as f: - if ns.zip_lib: - print(PYTHON_ZIP_NAME, file=f) - if ns.include_pip: - print("packages", file=f) - else: - print("Lib", file=f) - print("Lib/site-packages", file=f) - if not ns.flat_dlls: - print("DLLs", file=f) - print(".", file=f) - print(file=f) - print("# Uncomment to run site.main() automatically", file=f) - print("#import site", file=f) - - if ns.include_pip: - log_info("Extracting pip") - extract_pip_files(ns) - - -def _create_zip_file(ns): - if not ns.zip: - return None - - if ns.zip.is_file(): - try: - ns.zip.unlink() - except OSError: - log_exception("Unable to remove {}", ns.zip) - sys.exit(8) - elif ns.zip.is_dir(): - log_error("Cannot create ZIP file because {} is a directory", ns.zip) - sys.exit(8) - - ns.zip.parent.mkdir(parents=True, exist_ok=True) - return zipfile.ZipFile(ns.zip, "w", zipfile.ZIP_DEFLATED) - - -def copy_files(files, ns): - if ns.copy: - ns.copy.mkdir(parents=True, exist_ok=True) - - try: - total = len(files) - except TypeError: - total = None - count = 0 - - zip_file = _create_zip_file(ns) - try: - need_compile = [] - in_catalog = [] - - for dest, src in files: - count += 1 - if count % 10 == 0: - if total: - log_info("Processed {:>4} of {} files", count, total) - else: - log_info("Processed {} files", count) - log_debug("Processing {!s}", src) - - if isinstance(src, tuple): - src, content = src - if ns.copy: - log_debug("Copy {} -> {}", src, ns.copy / dest) - (ns.copy / dest).parent.mkdir(parents=True, exist_ok=True) - with open(ns.copy / dest, "wb") as f: - f.write(content) - if ns.zip: - log_debug("Zip {} into {}", src, ns.zip) - zip_file.writestr(str(dest), content) - continue - - if ( - ns.precompile - and src in PY_FILES - and src not in EXCLUDE_FROM_COMPILE - and src.parent not in DATA_DIRS - and os.path.normcase(str(dest)).startswith(os.path.normcase("Lib")) - ): - if ns.copy: - need_compile.append((dest, ns.copy / dest)) - else: - (ns.temp / "Lib" / dest).parent.mkdir(parents=True, exist_ok=True) - copy_if_modified(src, ns.temp / "Lib" / dest) - need_compile.append((dest, ns.temp / "Lib" / dest)) - - if src not in EXCLUDE_FROM_CATALOG: - in_catalog.append((src.name, src)) - - if ns.copy: - log_debug("Copy {} -> {}", src, ns.copy / dest) - (ns.copy / dest).parent.mkdir(parents=True, exist_ok=True) - try: - copy_if_modified(src, ns.copy / dest) - except shutil.SameFileError: - pass - - if ns.zip: - log_debug("Zip {} into {}", src, ns.zip) - zip_file.write(src, str(dest)) - - if need_compile: - for dest, src in need_compile: - compiled = [ - _compile_one_py(src, None, dest, optimize=0), - _compile_one_py(src, None, dest, optimize=1), - _compile_one_py(src, None, dest, optimize=2), - ] - for c in compiled: - if not c: - continue - cdest = Path(dest).parent / Path(c).relative_to(src.parent) - if ns.zip: - log_debug("Zip {} into {}", c, ns.zip) - zip_file.write(c, str(cdest)) - in_catalog.append((cdest.name, cdest)) - - if ns.catalog: - # Just write out the CDF now. Compilation and signing is - # an extra step - log_info("Generating {}", ns.catalog) - ns.catalog.parent.mkdir(parents=True, exist_ok=True) - write_catalog(ns.catalog, in_catalog) - - finally: - if zip_file: - zip_file.close() - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument("-v", help="Increase verbosity", action="count") - parser.add_argument( - "-s", - "--source", - metavar="dir", - help="The directory containing the repository root", - type=Path, - default=None, - ) - parser.add_argument( - "-b", "--build", metavar="dir", help="Specify the build directory", type=Path - ) - parser.add_argument( - "--arch", - metavar="architecture", - help="Specify the target architecture", - type=str, - default=None, - ) - parser.add_argument( - "--doc-build", - metavar="dir", - help="Specify the docs build directory", - type=Path, - default=None, - ) - parser.add_argument( - "--copy", - metavar="directory", - help="The name of the directory to copy an extracted layout to", - type=Path, - default=None, - ) - parser.add_argument( - "--zip", - metavar="file", - help="The ZIP file to write all files to", - type=Path, - default=None, - ) - parser.add_argument( - "--catalog", - metavar="file", - help="The CDF file to write catalog entries to", - type=Path, - default=None, - ) - parser.add_argument( - "--log", - metavar="file", - help="Write all operations to the specified file", - type=Path, - default=None, - ) - parser.add_argument( - "-t", - "--temp", - metavar="file", - help="A temporary working directory", - type=Path, - default=None, - ) - parser.add_argument( - "-d", "--debug", help="Include debug build", action="store_true" - ) - parser.add_argument( - "-p", - "--precompile", - help="Include .pyc files instead of .py", - action="store_true", - ) - parser.add_argument( - "-z", "--zip-lib", help="Include library in a ZIP file", action="store_true" - ) - parser.add_argument( - "--flat-dlls", help="Does not create a DLLs directory", action="store_true" - ) - parser.add_argument( - "-a", - "--include-all", - help="Include all optional components", - action="store_true", - ) - parser.add_argument( - "--include-cat", - metavar="file", - help="Specify the catalog file to include", - type=Path, - default=None, - ) - for opt, help in get_argparse_options(): - parser.add_argument(opt, help=help, action="store_true") - - ns = parser.parse_args() - update_presets(ns) - - ns.source = ns.source or (Path(__file__).resolve().parent.parent.parent) - ns.build = ns.build or Path(sys.executable).parent - ns.temp = ns.temp or Path(tempfile.mkdtemp()) - ns.doc_build = ns.doc_build or (ns.source / "Doc" / "build") - if not ns.source.is_absolute(): - ns.source = (Path.cwd() / ns.source).resolve() - if not ns.build.is_absolute(): - ns.build = (Path.cwd() / ns.build).resolve() - if not ns.temp.is_absolute(): - ns.temp = (Path.cwd() / ns.temp).resolve() - if not ns.doc_build.is_absolute(): - ns.doc_build = (Path.cwd() / ns.doc_build).resolve() - if ns.include_cat and not ns.include_cat.is_absolute(): - ns.include_cat = (Path.cwd() / ns.include_cat).resolve() - if not ns.arch: - ns.arch = "amd64" if sys.maxsize > 2 ** 32 else "win32" - - if ns.copy and not ns.copy.is_absolute(): - ns.copy = (Path.cwd() / ns.copy).resolve() - if ns.zip and not ns.zip.is_absolute(): - ns.zip = (Path.cwd() / ns.zip).resolve() - if ns.catalog and not ns.catalog.is_absolute(): - ns.catalog = (Path.cwd() / ns.catalog).resolve() - - configure_logger(ns) - - log_info( - """OPTIONS -Source: {ns.source} -Build: {ns.build} -Temp: {ns.temp} -Arch: {ns.arch} - -Copy to: {ns.copy} -Zip to: {ns.zip} -Catalog: {ns.catalog}""", - ns=ns, - ) - - if ns.arch not in ("win32", "amd64", "arm32", "arm64"): - log_error("--arch is not a valid value (win32, amd64, arm32, arm64)") - return 4 - if ns.arch in ("arm32", "arm64"): - for n in ("include_idle", "include_tcltk"): - if getattr(ns, n): - log_warning(f"Disabling --{n.replace('_', '-')} on unsupported platform") - setattr(ns, n, False) - - if ns.include_idle and not ns.include_tcltk: - log_warning("Assuming --include-tcltk to support --include-idle") - ns.include_tcltk = True - - try: - generate_source_files(ns) - files = list(get_layout(ns)) - copy_files(files, ns) - except KeyboardInterrupt: - log_info("Interrupted by Ctrl+C") - return 3 - except SystemExit: - raise - except: - log_exception("Unhandled error") - - if error_was_logged(): - log_error("Errors occurred.") - return 1 - - -if __name__ == "__main__": - sys.exit(int(main() or 0)) diff --git a/PC/layout/support/__init__.py b/PC/layout/support/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/PC/layout/support/appxmanifest.py b/PC/layout/support/appxmanifest.py deleted file mode 100644 index 427a36f31c8f9edb5f1059d84235198cf63dc00c..0000000000000000000000000000000000000000 --- a/PC/layout/support/appxmanifest.py +++ /dev/null @@ -1,519 +0,0 @@ -""" -File generation for APPX/MSIX manifests. -""" - -__author__ = "Steve Dower " -__version__ = "3.8" - - -import collections -import ctypes -import io -import os -import sys - -from pathlib import Path, PureWindowsPath -from xml.etree import ElementTree as ET - -from .constants import * - -__all__ = ["get_appx_layout"] - - -APPX_DATA = dict( - Name="PythonSoftwareFoundation.Python.{}".format(VER_DOT), - Version="{}.{}.{}.0".format(VER_MAJOR, VER_MINOR, VER_FIELD3), - Publisher=os.getenv( - "APPX_DATA_PUBLISHER", "CN=4975D53F-AA7E-49A5-8B49-EA4FDC1BB66B" - ), - DisplayName="Python {}".format(VER_DOT), - Description="The Python {} runtime and console.".format(VER_DOT), -) - -APPX_PLATFORM_DATA = dict( - _keys=("ProcessorArchitecture",), - win32=("x86",), - amd64=("x64",), - arm32=("arm",), - arm64=("arm64",), -) - -PYTHON_VE_DATA = dict( - DisplayName="Python {}".format(VER_DOT), - Description="Python interactive console", - Square150x150Logo="_resources/pythonx150.png", - Square44x44Logo="_resources/pythonx44.png", - BackgroundColor="transparent", -) - -PYTHONW_VE_DATA = dict( - DisplayName="Python {} (Windowed)".format(VER_DOT), - Description="Python windowed app launcher", - Square150x150Logo="_resources/pythonwx150.png", - Square44x44Logo="_resources/pythonwx44.png", - BackgroundColor="transparent", - AppListEntry="none", -) - -PIP_VE_DATA = dict( - DisplayName="pip (Python {})".format(VER_DOT), - Description="pip package manager for Python {}".format(VER_DOT), - Square150x150Logo="_resources/pythonx150.png", - Square44x44Logo="_resources/pythonx44.png", - BackgroundColor="transparent", - AppListEntry="none", -) - -IDLE_VE_DATA = dict( - DisplayName="IDLE (Python {})".format(VER_DOT), - Description="IDLE editor for Python {}".format(VER_DOT), - Square150x150Logo="_resources/idlex150.png", - Square44x44Logo="_resources/idlex44.png", - BackgroundColor="transparent", -) - -PY_PNG = "_resources/py.png" - -APPXMANIFEST_NS = { - "": "http://schemas.microsoft.com/appx/manifest/foundation/windows10", - "m": "http://schemas.microsoft.com/appx/manifest/foundation/windows10", - "uap": "http://schemas.microsoft.com/appx/manifest/uap/windows10", - "rescap": "http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities", - "rescap4": "http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities/4", - "desktop4": "http://schemas.microsoft.com/appx/manifest/desktop/windows10/4", - "desktop6": "http://schemas.microsoft.com/appx/manifest/desktop/windows10/6", - "uap3": "http://schemas.microsoft.com/appx/manifest/uap/windows10/3", - "uap4": "http://schemas.microsoft.com/appx/manifest/uap/windows10/4", - "uap5": "http://schemas.microsoft.com/appx/manifest/uap/windows10/5", -} - -APPXMANIFEST_TEMPLATE = """ - - - - - Python Software Foundation - - _resources/pythonx50.png - - - - - - - - - - - - - - -""" - - -RESOURCES_XML_TEMPLATE = r""" - - - - - - - - - - - - - - - - - - - - - - - - - - - -""" - - -SCCD_FILENAME = "PC/classicAppCompat.sccd" - -SPECIAL_LOOKUP = object() - -REGISTRY = { - "HKCU\\Software\\Python\\PythonCore": { - VER_DOT: { - "DisplayName": APPX_DATA["DisplayName"], - "SupportUrl": "https://www.python.org/", - "SysArchitecture": SPECIAL_LOOKUP, - "SysVersion": VER_DOT, - "Version": "{}.{}.{}".format(VER_MAJOR, VER_MINOR, VER_MICRO), - "InstallPath": { - "": "[{AppVPackageRoot}]", - "ExecutablePath": "[{{AppVPackageRoot}}]\\python{}.exe".format(VER_DOT), - "WindowedExecutablePath": "[{{AppVPackageRoot}}]\\pythonw{}.exe".format( - VER_DOT - ), - }, - "Help": { - "Main Python Documentation": { - "_condition": lambda ns: ns.include_chm, - "": "[{{AppVPackageRoot}}]\\Doc\\{}".format(PYTHON_CHM_NAME), - }, - "Local Python Documentation": { - "_condition": lambda ns: ns.include_html_doc, - "": "[{AppVPackageRoot}]\\Doc\\html\\index.html", - }, - "Online Python Documentation": { - "": "https://docs.python.org/{}".format(VER_DOT) - }, - }, - "Idle": { - "_condition": lambda ns: ns.include_idle, - "": "[{AppVPackageRoot}]\\Lib\\idlelib\\idle.pyw", - }, - } - } -} - - -def get_packagefamilyname(name, publisher_id): - class PACKAGE_ID(ctypes.Structure): - _fields_ = [ - ("reserved", ctypes.c_uint32), - ("processorArchitecture", ctypes.c_uint32), - ("version", ctypes.c_uint64), - ("name", ctypes.c_wchar_p), - ("publisher", ctypes.c_wchar_p), - ("resourceId", ctypes.c_wchar_p), - ("publisherId", ctypes.c_wchar_p), - ] - _pack_ = 4 - - pid = PACKAGE_ID(0, 0, 0, name, publisher_id, None, None) - result = ctypes.create_unicode_buffer(256) - result_len = ctypes.c_uint32(256) - r = ctypes.windll.kernel32.PackageFamilyNameFromId( - pid, ctypes.byref(result_len), result - ) - if r: - raise OSError(r, "failed to get package family name") - return result.value[: result_len.value] - - -def _fixup_sccd(ns, sccd, new_hash=None): - if not new_hash: - return sccd - - NS = dict(s="http://schemas.microsoft.com/appx/2016/sccd") - with open(sccd, "rb") as f: - xml = ET.parse(f) - - pfn = get_packagefamilyname(APPX_DATA["Name"], APPX_DATA["Publisher"]) - - ae = xml.find("s:AuthorizedEntities", NS) - ae.clear() - - e = ET.SubElement(ae, ET.QName(NS["s"], "AuthorizedEntity")) - e.set("AppPackageFamilyName", pfn) - e.set("CertificateSignatureHash", new_hash) - - for e in xml.findall("s:Catalog", NS): - e.text = "FFFF" - - sccd = ns.temp / sccd.name - sccd.parent.mkdir(parents=True, exist_ok=True) - with open(sccd, "wb") as f: - xml.write(f, encoding="utf-8") - - return sccd - - -def find_or_add(xml, element, attr=None, always_add=False): - if always_add: - e = None - else: - q = element - if attr: - q += "[@{}='{}']".format(*attr) - e = xml.find(q, APPXMANIFEST_NS) - if e is None: - prefix, _, name = element.partition(":") - name = ET.QName(APPXMANIFEST_NS[prefix or ""], name) - e = ET.SubElement(xml, name) - if attr: - e.set(*attr) - return e - - -def _get_app(xml, appid): - if appid: - app = xml.find( - "m:Applications/m:Application[@Id='{}']".format(appid), APPXMANIFEST_NS - ) - if app is None: - raise LookupError(appid) - else: - app = xml - return app - - -def add_visual(xml, appid, data): - app = _get_app(xml, appid) - e = find_or_add(app, "uap:VisualElements") - for i in data.items(): - e.set(*i) - return e - - -def add_alias(xml, appid, alias, subsystem="windows"): - app = _get_app(xml, appid) - e = find_or_add(app, "m:Extensions") - e = find_or_add(e, "uap5:Extension", ("Category", "windows.appExecutionAlias")) - e = find_or_add(e, "uap5:AppExecutionAlias") - e.set(ET.QName(APPXMANIFEST_NS["desktop4"], "Subsystem"), subsystem) - e = find_or_add(e, "uap5:ExecutionAlias", ("Alias", alias)) - - -def add_file_type(xml, appid, name, suffix, parameters='"%1"', info=None, logo=None): - app = _get_app(xml, appid) - e = find_or_add(app, "m:Extensions") - e = find_or_add(e, "uap3:Extension", ("Category", "windows.fileTypeAssociation")) - e = find_or_add(e, "uap3:FileTypeAssociation", ("Name", name)) - e.set("Parameters", parameters) - if info: - find_or_add(e, "uap:DisplayName").text = info - if logo: - find_or_add(e, "uap:Logo").text = logo - e = find_or_add(e, "uap:SupportedFileTypes") - if isinstance(suffix, str): - suffix = [suffix] - for s in suffix: - ET.SubElement(e, ET.QName(APPXMANIFEST_NS["uap"], "FileType")).text = s - - -def add_application( - ns, xml, appid, executable, aliases, visual_element, subsystem, file_types -): - node = xml.find("m:Applications", APPXMANIFEST_NS) - suffix = "_d.exe" if ns.debug else ".exe" - app = ET.SubElement( - node, - ET.QName(APPXMANIFEST_NS[""], "Application"), - { - "Id": appid, - "Executable": executable + suffix, - "EntryPoint": "Windows.FullTrustApplication", - ET.QName(APPXMANIFEST_NS["desktop4"], "SupportsMultipleInstances"): "true", - }, - ) - if visual_element: - add_visual(app, None, visual_element) - for alias in aliases: - add_alias(app, None, alias + suffix, subsystem) - if file_types: - add_file_type(app, None, *file_types) - return app - - -def _get_registry_entries(ns, root="", d=None): - r = root if root else PureWindowsPath("") - if d is None: - d = REGISTRY - for key, value in d.items(): - if key == "_condition": - continue - if value is SPECIAL_LOOKUP: - if key == "SysArchitecture": - value = { - "win32": "32bit", - "amd64": "64bit", - "arm32": "32bit", - "arm64": "64bit", - }[ns.arch] - else: - raise ValueError(f"Key '{key}' unhandled for special lookup") - if isinstance(value, dict): - cond = value.get("_condition") - if cond and not cond(ns): - continue - fullkey = r - for part in PureWindowsPath(key).parts: - fullkey /= part - if len(fullkey.parts) > 1: - yield str(fullkey), None, None - yield from _get_registry_entries(ns, fullkey, value) - elif len(r.parts) > 1: - yield str(r), key, value - - -def add_registry_entries(ns, xml): - e = find_or_add(xml, "m:Extensions") - e = find_or_add(e, "rescap4:Extension") - e.set("Category", "windows.classicAppCompatKeys") - e.set("EntryPoint", "Windows.FullTrustApplication") - e = ET.SubElement(e, ET.QName(APPXMANIFEST_NS["rescap4"], "ClassicAppCompatKeys")) - for name, valuename, value in _get_registry_entries(ns): - k = ET.SubElement( - e, ET.QName(APPXMANIFEST_NS["rescap4"], "ClassicAppCompatKey") - ) - k.set("Name", name) - if value: - k.set("ValueName", valuename) - k.set("Value", value) - k.set("ValueType", "REG_SZ") - - -def disable_registry_virtualization(xml): - e = find_or_add(xml, "m:Properties") - e = find_or_add(e, "desktop6:RegistryWriteVirtualization") - e.text = "disabled" - e = find_or_add(xml, "m:Capabilities") - e = find_or_add(e, "rescap:Capability", ("Name", "unvirtualizedResources")) - - -def get_appxmanifest(ns): - for k, v in APPXMANIFEST_NS.items(): - ET.register_namespace(k, v) - ET.register_namespace("", APPXMANIFEST_NS["m"]) - - xml = ET.parse(io.StringIO(APPXMANIFEST_TEMPLATE)) - NS = APPXMANIFEST_NS - QN = ET.QName - - data = dict(APPX_DATA) - for k, v in zip(APPX_PLATFORM_DATA["_keys"], APPX_PLATFORM_DATA[ns.arch]): - data[k] = v - - node = xml.find("m:Identity", NS) - for k in node.keys(): - value = data.get(k) - if value: - node.set(k, value) - - for node in xml.find("m:Properties", NS): - value = data.get(node.tag.rpartition("}")[2]) - if value: - node.text = value - - try: - winver = tuple(int(i) for i in os.getenv("APPX_DATA_WINVER", "").split(".", maxsplit=3)) - except (TypeError, ValueError): - winver = () - - # Default "known good" version is 10.0.22000, first Windows 11 release - winver = winver or (10, 0, 22000) - - if winver < (10, 0, 17763): - winver = 10, 0, 17763 - find_or_add(xml, "m:Dependencies/m:TargetDeviceFamily").set( - "MaxVersionTested", "{}.{}.{}.{}".format(*(winver + (0, 0, 0, 0)[:4])) - ) - - # Only for Python 3.11 and later. Older versions do not disable virtualization - if (VER_MAJOR, VER_MINOR) >= (3, 11) and winver > (10, 0, 17763): - disable_registry_virtualization(xml) - - app = add_application( - ns, - xml, - "Python", - "python{}".format(VER_DOT), - ["python", "python{}".format(VER_MAJOR), "python{}".format(VER_DOT)], - PYTHON_VE_DATA, - "console", - ("python.file", [".py"], '"%1" %*', "Python File", PY_PNG), - ) - - add_application( - ns, - xml, - "PythonW", - "pythonw{}".format(VER_DOT), - ["pythonw", "pythonw{}".format(VER_MAJOR), "pythonw{}".format(VER_DOT)], - PYTHONW_VE_DATA, - "windows", - ("python.windowedfile", [".pyw"], '"%1" %*', "Python File (no console)", PY_PNG), - ) - - if ns.include_pip and ns.include_launchers: - add_application( - ns, - xml, - "Pip", - "pip{}".format(VER_DOT), - ["pip", "pip{}".format(VER_MAJOR), "pip{}".format(VER_DOT)], - PIP_VE_DATA, - "console", - ("python.wheel", [".whl"], 'install "%1"', "Python Wheel"), - ) - - if ns.include_idle and ns.include_launchers: - add_application( - ns, - xml, - "Idle", - "idle{}".format(VER_DOT), - ["idle", "idle{}".format(VER_MAJOR), "idle{}".format(VER_DOT)], - IDLE_VE_DATA, - "windows", - None, - ) - - if (ns.source / SCCD_FILENAME).is_file(): - add_registry_entries(ns, xml) - node = xml.find("m:Capabilities", NS) - node = ET.SubElement(node, QN(NS["uap4"], "CustomCapability")) - node.set("Name", "Microsoft.classicAppCompat_8wekyb3d8bbwe") - - buffer = io.BytesIO() - xml.write(buffer, encoding="utf-8", xml_declaration=True) - return buffer.getbuffer() - - -def get_resources_xml(ns): - return RESOURCES_XML_TEMPLATE.encode("utf-8") - - -def get_appx_layout(ns): - if not ns.include_appxmanifest: - return - - yield "AppxManifest.xml", ("AppxManifest.xml", get_appxmanifest(ns)) - yield "_resources.xml", ("_resources.xml", get_resources_xml(ns)) - icons = ns.source / "PC" / "icons" - for px in [44, 50, 150]: - src = icons / "pythonx{}.png".format(px) - yield f"_resources/pythonx{px}.png", src - yield f"_resources/pythonx{px}$targetsize-{px}_altform-unplated.png", src - for px in [44, 150]: - src = icons / "pythonwx{}.png".format(px) - yield f"_resources/pythonwx{px}.png", src - yield f"_resources/pythonwx{px}$targetsize-{px}_altform-unplated.png", src - if ns.include_idle and ns.include_launchers: - for px in [44, 150]: - src = icons / "idlex{}.png".format(px) - yield f"_resources/idlex{px}.png", src - yield f"_resources/idlex{px}$targetsize-{px}_altform-unplated.png", src - yield f"_resources/py.png", icons / "py.png" - sccd = ns.source / SCCD_FILENAME - if sccd.is_file(): - # This should only be set for side-loading purposes. - sccd = _fixup_sccd(ns, sccd, os.getenv("APPX_DATA_SHA256")) - yield sccd.name, sccd diff --git a/PC/layout/support/catalog.py b/PC/layout/support/catalog.py deleted file mode 100644 index 43121187ed180c8971e37cae4ec45c33b0283f31..0000000000000000000000000000000000000000 --- a/PC/layout/support/catalog.py +++ /dev/null @@ -1,44 +0,0 @@ -""" -File generation for catalog signing non-binary contents. -""" - -__author__ = "Steve Dower " -__version__ = "3.8" - - -import sys - -__all__ = ["PYTHON_CAT_NAME", "PYTHON_CDF_NAME"] - - -def public(f): - __all__.append(f.__name__) - return f - - -PYTHON_CAT_NAME = "python.cat" -PYTHON_CDF_NAME = "python.cdf" - - -CATALOG_TEMPLATE = r"""[CatalogHeader] -Name={target.stem}.cat -ResultDir={target.parent} -PublicVersion=1 -CatalogVersion=2 -HashAlgorithms=SHA256 -PageHashes=false -EncodingType= - -[CatalogFiles] -""" - - -def can_sign(file): - return file.is_file() and file.stat().st_size - - -@public -def write_catalog(target, files): - with target.open("w", encoding="utf-8") as cat: - cat.write(CATALOG_TEMPLATE.format(target=target)) - cat.writelines("{}={}\n".format(n, f) for n, f in files if can_sign(f)) diff --git a/PC/layout/support/constants.py b/PC/layout/support/constants.py deleted file mode 100644 index 6efd8bcd5cbb5ef41622b4530795ac9253491f95..0000000000000000000000000000000000000000 --- a/PC/layout/support/constants.py +++ /dev/null @@ -1,42 +0,0 @@ -""" -Constants for generating the layout. -""" - -__author__ = "Steve Dower " -__version__ = "3.8" - -import os -import re -import struct -import sys - - -def _unpack_hexversion(): - try: - hexversion = int(os.getenv("PYTHON_HEXVERSION"), 16) - except (TypeError, ValueError): - hexversion = sys.hexversion - return struct.pack(">i", hexversion) - - -def _get_suffix(field4): - name = {0xA0: "a", 0xB0: "b", 0xC0: "rc"}.get(field4 & 0xF0, "") - if name: - serial = field4 & 0x0F - return f"{name}{serial}" - return "" - - -VER_MAJOR, VER_MINOR, VER_MICRO, VER_FIELD4 = _unpack_hexversion() -VER_SUFFIX = _get_suffix(VER_FIELD4) -VER_FIELD3 = VER_MICRO << 8 | VER_FIELD4 -VER_DOT = "{}.{}".format(VER_MAJOR, VER_MINOR) - -PYTHON_DLL_NAME = "python{}{}.dll".format(VER_MAJOR, VER_MINOR) -PYTHON_STABLE_DLL_NAME = "python{}.dll".format(VER_MAJOR) -PYTHON_ZIP_NAME = "python{}{}.zip".format(VER_MAJOR, VER_MINOR) -PYTHON_PTH_NAME = "python{}{}._pth".format(VER_MAJOR, VER_MINOR) - -PYTHON_CHM_NAME = "python{}{}{}{}.chm".format( - VER_MAJOR, VER_MINOR, VER_MICRO, VER_SUFFIX -) diff --git a/PC/layout/support/filesets.py b/PC/layout/support/filesets.py deleted file mode 100644 index 47f727c057844c8b42819547bc0a0188c6d66959..0000000000000000000000000000000000000000 --- a/PC/layout/support/filesets.py +++ /dev/null @@ -1,100 +0,0 @@ -""" -File sets and globbing helper for make_layout. -""" - -__author__ = "Steve Dower " -__version__ = "3.8" - -import os - - -class FileStemSet: - def __init__(self, *patterns): - self._names = set() - self._prefixes = [] - self._suffixes = [] - for p in map(os.path.normcase, patterns): - if p.endswith("*"): - self._prefixes.append(p[:-1]) - elif p.startswith("*"): - self._suffixes.append(p[1:]) - else: - self._names.add(p) - - def _make_name(self, f): - return os.path.normcase(f.stem) - - def __contains__(self, f): - bn = self._make_name(f) - return ( - bn in self._names - or any(map(bn.startswith, self._prefixes)) - or any(map(bn.endswith, self._suffixes)) - ) - - -class FileNameSet(FileStemSet): - def _make_name(self, f): - return os.path.normcase(f.name) - - -class FileSuffixSet: - def __init__(self, *patterns): - self._names = set() - self._prefixes = [] - self._suffixes = [] - for p in map(os.path.normcase, patterns): - if p.startswith("*."): - self._names.add(p[1:]) - elif p.startswith("*"): - self._suffixes.append(p[1:]) - elif p.endswith("*"): - self._prefixes.append(p[:-1]) - elif p.startswith("."): - self._names.add(p) - else: - self._names.add("." + p) - - def _make_name(self, f): - return os.path.normcase(f.suffix) - - def __contains__(self, f): - bn = self._make_name(f) - return ( - bn in self._names - or any(map(bn.startswith, self._prefixes)) - or any(map(bn.endswith, self._suffixes)) - ) - - -def _rglob(root, pattern, condition): - dirs = [root] - recurse = pattern[:3] in {"**/", "**\\"} - if recurse: - pattern = pattern[3:] - - while dirs: - d = dirs.pop(0) - if recurse: - dirs.extend( - filter( - condition, (type(root)(f2) for f2 in os.scandir(d) if f2.is_dir()) - ) - ) - yield from ( - (f.relative_to(root), f) - for f in d.glob(pattern) - if f.is_file() and condition(f) - ) - - -def _return_true(f): - return True - - -def rglob(root, patterns, condition=None): - if isinstance(patterns, tuple): - for p in patterns: - yield from _rglob(root, p, condition or _return_true) - else: - yield from _rglob(root, patterns, condition or _return_true) diff --git a/PC/layout/support/logging.py b/PC/layout/support/logging.py deleted file mode 100644 index 30869b949a1c33ec0cfb421ec8c8524cfb8842de..0000000000000000000000000000000000000000 --- a/PC/layout/support/logging.py +++ /dev/null @@ -1,93 +0,0 @@ -""" -Logging support for make_layout. -""" - -__author__ = "Steve Dower " -__version__ = "3.8" - -import logging -import sys - -__all__ = [] - -LOG = None -HAS_ERROR = False - - -def public(f): - __all__.append(f.__name__) - return f - - -@public -def configure_logger(ns): - global LOG - if LOG: - return - - LOG = logging.getLogger("make_layout") - LOG.level = logging.DEBUG - - if ns.v: - s_level = max(logging.ERROR - ns.v * 10, logging.DEBUG) - f_level = max(logging.WARNING - ns.v * 10, logging.DEBUG) - else: - s_level = logging.ERROR - f_level = logging.INFO - - handler = logging.StreamHandler(sys.stdout) - handler.setFormatter(logging.Formatter("{levelname:8s} {message}", style="{")) - handler.setLevel(s_level) - LOG.addHandler(handler) - - if ns.log: - handler = logging.FileHandler(ns.log, encoding="utf-8", delay=True) - handler.setFormatter( - logging.Formatter("[{asctime}]{levelname:8s}: {message}", style="{") - ) - handler.setLevel(f_level) - LOG.addHandler(handler) - - -class BraceMessage: - def __init__(self, fmt, *args, **kwargs): - self.fmt = fmt - self.args = args - self.kwargs = kwargs - - def __str__(self): - return self.fmt.format(*self.args, **self.kwargs) - - -@public -def log_debug(msg, *args, **kwargs): - return LOG.debug(BraceMessage(msg, *args, **kwargs)) - - -@public -def log_info(msg, *args, **kwargs): - return LOG.info(BraceMessage(msg, *args, **kwargs)) - - -@public -def log_warning(msg, *args, **kwargs): - return LOG.warning(BraceMessage(msg, *args, **kwargs)) - - -@public -def log_error(msg, *args, **kwargs): - global HAS_ERROR - HAS_ERROR = True - return LOG.error(BraceMessage(msg, *args, **kwargs)) - - -@public -def log_exception(msg, *args, **kwargs): - global HAS_ERROR - HAS_ERROR = True - return LOG.exception(BraceMessage(msg, *args, **kwargs)) - - -@public -def error_was_logged(): - return HAS_ERROR diff --git a/PC/layout/support/nuspec.py b/PC/layout/support/nuspec.py deleted file mode 100644 index dbcb713ef9d0c00c0153bb3b98b739a98abdc709..0000000000000000000000000000000000000000 --- a/PC/layout/support/nuspec.py +++ /dev/null @@ -1,78 +0,0 @@ -""" -Provides .props file. -""" - -import os -import sys - -from .constants import * - -__all__ = ["get_nuspec_layout"] - -PYTHON_NUSPEC_NAME = "python.nuspec" - -NUSPEC_DATA = { - "PYTHON_TAG": VER_DOT, - "PYTHON_VERSION": os.getenv("PYTHON_NUSPEC_VERSION"), - "FILELIST": r' ', - "GIT": sys._git, -} - -NUSPEC_PLATFORM_DATA = dict( - _keys=("PYTHON_BITNESS", "PACKAGENAME", "PACKAGETITLE"), - win32=("32-bit", "pythonx86", "Python (32-bit)"), - amd64=("64-bit", "python", "Python"), - arm32=("ARM", "pythonarm", "Python (ARM)"), - arm64=("ARM64", "pythonarm64", "Python (ARM64)"), -) - -if not NUSPEC_DATA["PYTHON_VERSION"]: - NUSPEC_DATA["PYTHON_VERSION"] = "{}.{}{}{}".format( - VER_DOT, VER_MICRO, "-" if VER_SUFFIX else "", VER_SUFFIX - ) - -FILELIST_WITH_PROPS = r""" - """ - -NUSPEC_TEMPLATE = r""" - - - {PACKAGENAME} - {PACKAGETITLE} - {PYTHON_VERSION} - Python Software Foundation - tools\LICENSE.txt - https://www.python.org/ - Installs {PYTHON_BITNESS} Python for use in build scenarios. - images\python.png - https://www.python.org/static/favicon.ico - python - - - - -{FILELIST} - - -""" - - -def _get_nuspec_data_overrides(ns): - for k, v in zip(NUSPEC_PLATFORM_DATA["_keys"], NUSPEC_PLATFORM_DATA[ns.arch]): - ev = os.getenv("PYTHON_NUSPEC_" + k) - if ev: - yield k, ev - yield k, v - - -def get_nuspec_layout(ns): - if ns.include_all or ns.include_nuspec: - data = dict(NUSPEC_DATA) - for k, v in _get_nuspec_data_overrides(ns): - if not data.get(k): - data[k] = v - if ns.include_all or ns.include_props: - data["FILELIST"] = FILELIST_WITH_PROPS - nuspec = NUSPEC_TEMPLATE.format_map(data) - yield "python.nuspec", ("python.nuspec", nuspec.encode("utf-8")) - yield "python.png", ns.source / "PC" / "icons" / "logox128.png" diff --git a/PC/layout/support/options.py b/PC/layout/support/options.py deleted file mode 100644 index 9faf20c0fdc7a1b2a804f7872f69dc6223222d7d..0000000000000000000000000000000000000000 --- a/PC/layout/support/options.py +++ /dev/null @@ -1,133 +0,0 @@ -""" -List of optional components. -""" - -__author__ = "Steve Dower " -__version__ = "3.8" - - -__all__ = [] - - -def public(f): - __all__.append(f.__name__) - return f - - -OPTIONS = { - "stable": {"help": "stable ABI stub"}, - "pip": {"help": "pip"}, - "pip-user": {"help": "pip.ini file for default --user"}, - "distutils": {"help": "distutils"}, - "tcltk": {"help": "Tcl, Tk and tkinter"}, - "idle": {"help": "Idle"}, - "tests": {"help": "test suite"}, - "tools": {"help": "tools"}, - "venv": {"help": "venv"}, - "dev": {"help": "headers and libs"}, - "symbols": {"help": "symbols"}, - "underpth": {"help": "a python._pth file", "not-in-all": True}, - "launchers": {"help": "specific launchers"}, - "appxmanifest": {"help": "an appxmanifest"}, - "props": {"help": "a python.props file"}, - "nuspec": {"help": "a python.nuspec file"}, - "chm": {"help": "the CHM documentation"}, - "html-doc": {"help": "the HTML documentation"}, -} - - -PRESETS = { - "appx": { - "help": "APPX package", - "options": [ - "stable", - "pip", - "pip-user", - "distutils", - "tcltk", - "idle", - "venv", - "dev", - "launchers", - "appxmanifest", - # XXX: Disabled for now "precompile", - ], - }, - "nuget": { - "help": "nuget package", - "options": [ - "dev", - "tools", - "pip", - "stable", - "distutils", - "venv", - "props", - "nuspec", - ], - }, - "iot": {"help": "Windows IoT Core", "options": ["stable", "pip"]}, - "default": { - "help": "development kit package", - "options": [ - "stable", - "pip", - "distutils", - "tcltk", - "idle", - "tests", - "tools", - "venv", - "dev", - "symbols", - "chm", - ], - }, - "embed": { - "help": "embeddable package", - "options": ["stable", "zip-lib", "flat-dlls", "underpth", "precompile"], - }, -} - - -@public -def get_argparse_options(): - for opt, info in OPTIONS.items(): - help = "When specified, includes {}".format(info["help"]) - if info.get("not-in-all"): - help = "{}. Not affected by --include-all".format(help) - - yield "--include-{}".format(opt), help - - for opt, info in PRESETS.items(): - help = "When specified, includes default options for {}".format(info["help"]) - yield "--preset-{}".format(opt), help - - -def ns_get(ns, key, default=False): - return getattr(ns, key.replace("-", "_"), default) - - -def ns_set(ns, key, value=True): - k1 = key.replace("-", "_") - k2 = "include_{}".format(k1) - if hasattr(ns, k2): - setattr(ns, k2, value) - elif hasattr(ns, k1): - setattr(ns, k1, value) - else: - raise AttributeError("no argument named '{}'".format(k1)) - - -@public -def update_presets(ns): - for preset, info in PRESETS.items(): - if ns_get(ns, "preset-{}".format(preset)): - for opt in info["options"]: - ns_set(ns, opt) - - if ns.include_all: - for opt in OPTIONS: - if OPTIONS[opt].get("not-in-all"): - continue - ns_set(ns, opt) diff --git a/PC/layout/support/pip.py b/PC/layout/support/pip.py deleted file mode 100644 index c54acb250a252ed53965001104a7519875a79651..0000000000000000000000000000000000000000 --- a/PC/layout/support/pip.py +++ /dev/null @@ -1,94 +0,0 @@ -""" -Extraction and file list generation for pip. -""" - -__author__ = "Steve Dower " -__version__ = "3.8" - - -import os -import shutil -import subprocess -import sys - -from .filesets import * - -__all__ = ["extract_pip_files", "get_pip_layout"] - - -def get_pip_dir(ns): - if ns.copy: - if ns.zip_lib: - return ns.copy / "packages" - return ns.copy / "Lib" / "site-packages" - else: - return ns.temp / "packages" - - -def get_pip_layout(ns): - pip_dir = get_pip_dir(ns) - if not pip_dir.is_dir(): - log_warning("Failed to find {} - pip will not be included", pip_dir) - else: - pkg_root = "packages/{}" if ns.zip_lib else "Lib/site-packages/{}" - for dest, src in rglob(pip_dir, "**/*"): - yield pkg_root.format(dest), src - if ns.include_pip_user: - content = "\n".join( - "[{}]\nuser=yes".format(n) - for n in ["install", "uninstall", "freeze", "list"] - ) - yield "pip.ini", ("pip.ini", content.encode()) - - -def extract_pip_files(ns): - dest = get_pip_dir(ns) - try: - dest.mkdir(parents=True, exist_ok=False) - except IOError: - return - - src = ns.source / "Lib" / "ensurepip" / "_bundled" - - ns.temp.mkdir(parents=True, exist_ok=True) - wheels = [shutil.copy(whl, ns.temp) for whl in src.glob("*.whl")] - search_path = os.pathsep.join(wheels) - if os.environ.get("PYTHONPATH"): - search_path += ";" + os.environ["PYTHONPATH"] - - env = os.environ.copy() - env["PYTHONPATH"] = search_path - - output = subprocess.check_output( - [ - sys.executable, - "-m", - "pip", - "--no-color", - "install", - "pip", - "setuptools", - "--upgrade", - "--target", - str(dest), - "--no-index", - "--no-compile", - "--no-cache-dir", - "-f", - str(src), - "--only-binary", - ":all:", - ], - env=env, - ) - - try: - shutil.rmtree(dest / "bin") - except OSError: - pass - - for file in wheels: - try: - os.remove(file) - except OSError: - pass diff --git a/PC/layout/support/props.py b/PC/layout/support/props.py deleted file mode 100644 index 1eb9b7c06da513ff61cd61dca272e07b6225d1d8..0000000000000000000000000000000000000000 --- a/PC/layout/support/props.py +++ /dev/null @@ -1,99 +0,0 @@ -""" -Provides .props file. -""" - -import os - -from .constants import * - -__all__ = ["get_props_layout"] - -PYTHON_PROPS_NAME = "python.props" - -PROPS_DATA = { - "PYTHON_TAG": VER_DOT, - "PYTHON_VERSION": os.getenv("PYTHON_NUSPEC_VERSION"), - "PYTHON_PLATFORM": os.getenv("PYTHON_PROPS_PLATFORM"), - "PYTHON_TARGET": "", -} - -if not PROPS_DATA["PYTHON_VERSION"]: - PROPS_DATA["PYTHON_VERSION"] = "{}.{}{}{}".format( - VER_DOT, VER_MICRO, "-" if VER_SUFFIX else "", VER_SUFFIX - ) - -PROPS_DATA["PYTHON_TARGET"] = "_GetPythonRuntimeFilesDependsOn{}{}_{}".format( - VER_MAJOR, VER_MINOR, PROPS_DATA["PYTHON_PLATFORM"] -) - -PROPS_TEMPLATE = r""" - - - $([System.IO.Path]::GetFullPath("$(MSBuildThisFileDirectory)\..\..\tools")) - $(PythonHome)\include - $(PythonHome)\libs - {PYTHON_TAG} - {PYTHON_VERSION} - - true - false - false - false - - {PYTHON_TARGET};$(GetPythonRuntimeFilesDependsOn) - - - - - $(PythonInclude);%(AdditionalIncludeDirectories) - MultiThreadedDLL - - - $(PythonLibs);%(AdditionalLibraryDirectories) - - - - - - - - <_PythonRuntimeExe Include="$(PythonHome)\python*.dll" /> - <_PythonRuntimeExe Include="$(PythonHome)\python*.exe" Condition="$(IncludePythonExe) == 'true'" /> - <_PythonRuntimeExe> - %(Filename)%(Extension) - - <_PythonRuntimeDlls Include="$(PythonHome)\DLLs\*.pyd" /> - <_PythonRuntimeDlls Include="$(PythonHome)\DLLs\*.dll" /> - <_PythonRuntimeDlls> - DLLs\%(Filename)%(Extension) - - <_PythonRuntimeLib Include="$(PythonHome)\Lib\**\*" Exclude="$(PythonHome)\Lib\**\*.pyc;$(PythonHome)\Lib\site-packages\**\*" /> - <_PythonRuntimeLib Remove="$(PythonHome)\Lib\distutils\**\*" Condition="$(IncludeDistutils) != 'true'" /> - <_PythonRuntimeLib Remove="$(PythonHome)\Lib\lib2to3\**\*" Condition="$(IncludeLib2To3) != 'true'" /> - <_PythonRuntimeLib Remove="$(PythonHome)\Lib\ensurepip\**\*" Condition="$(IncludeVEnv) != 'true'" /> - <_PythonRuntimeLib Remove="$(PythonHome)\Lib\venv\**\*" Condition="$(IncludeVEnv) != 'true'" /> - <_PythonRuntimeLib> - Lib\%(RecursiveDir)%(Filename)%(Extension) - - - - - - - -""" - - -def get_props_layout(ns): - if ns.include_all or ns.include_props: - # TODO: Filter contents of props file according to included/excluded items - d = dict(PROPS_DATA) - if not d.get("PYTHON_PLATFORM"): - d["PYTHON_PLATFORM"] = { - "win32": "Win32", - "amd64": "X64", - "arm32": "ARM", - "arm64": "ARM64", - }[ns.arch] - props = PROPS_TEMPLATE.format_map(d) - yield "python.props", ("python.props", props.encode("utf-8")) diff --git a/PC/layout/support/python.props b/PC/layout/support/python.props deleted file mode 100644 index b5ef67b2693b6546339afcafbf34b7131f5578ff..0000000000000000000000000000000000000000 --- a/PC/layout/support/python.props +++ /dev/null @@ -1,56 +0,0 @@ - - - - $(MSBuildThisFileDirectory)\..\..\tools - $(PythonHome)\include - $(PythonHome)\libs - $$PYTHON_TAG$$ - $$PYTHON_VERSION$$ - - true - false - false - false - - $$PYTHON_TARGET$$;$(GetPythonRuntimeFilesDependsOn) - - - - - $(PythonInclude);%(AdditionalIncludeDirectories) - MultiThreadedDLL - - - $(PythonLibs);%(AdditionalLibraryDirectories) - - - - - - - - <_PythonRuntimeExe Include="$(PythonHome)\python*.dll" /> - <_PythonRuntimeExe Include="$(PythonHome)\vcruntime140.dll" /> - <_PythonRuntimeExe Include="$(PythonHome)\python*.exe" Condition="$(IncludePythonExe) == 'true'" /> - <_PythonRuntimeExe> - %(Filename)%(Extension) - - <_PythonRuntimeDlls Include="$(PythonHome)\DLLs\*.pyd" /> - <_PythonRuntimeDlls Include="$(PythonHome)\DLLs\*.dll" /> - <_PythonRuntimeDlls> - DLLs\%(Filename)%(Extension) - - <_PythonRuntimeLib Include="$(PythonHome)\Lib\**\*" Exclude="$(PythonHome)\Lib\**\*.pyc;$(PythonHome)\Lib\site-packages\**\*" /> - <_PythonRuntimeLib Remove="$(PythonHome)\Lib\distutils\**\*" Condition="$(IncludeDistutils) != 'true'" /> - <_PythonRuntimeLib Remove="$(PythonHome)\Lib\lib2to3\**\*" Condition="$(IncludeLib2To3) != 'true'" /> - <_PythonRuntimeLib Remove="$(PythonHome)\Lib\ensurepip\**\*" Condition="$(IncludeVEnv) != 'true'" /> - <_PythonRuntimeLib Remove="$(PythonHome)\Lib\venv\**\*" Condition="$(IncludeVEnv) != 'true'" /> - <_PythonRuntimeLib> - Lib\%(RecursiveDir)%(Filename)%(Extension) - - - - - - - diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c deleted file mode 100644 index 0591497871cadc29039dbafd4c5dec3f7755858b..0000000000000000000000000000000000000000 --- a/PC/msvcrtmodule.c +++ /dev/null @@ -1,642 +0,0 @@ -/********************************************************* - - msvcrtmodule.c - - A Python interface to the Microsoft Visual C Runtime - Library, providing access to those non-portable, but - still useful routines. - - Only ever compiled with an MS compiler, so no attempt - has been made to avoid MS language extensions, etc... - - This may only work on NT or 95... - - Author: Mark Hammond and Guido van Rossum. - Maintenance: Guido van Rossum. - -***********************************************************/ - -#include "Python.h" -#include "malloc.h" -#include -#include -#include -#include -#include - -#ifdef _MSC_VER -#if _MSC_VER >= 1500 && _MSC_VER < 1600 -#include -#elif _MSC_VER >= 1600 -#include -#endif -#endif - -/*[python input] -class HANDLE_converter(CConverter): - type = 'void *' - format_unit = '"_Py_PARSE_UINTPTR"' - -class HANDLE_return_converter(CReturnConverter): - type = 'void *' - - def render(self, function, data): - self.declare(data) - self.err_occurred_if( - "_return_value == NULL || _return_value == INVALID_HANDLE_VALUE", - data) - data.return_conversion.append( - 'return_value = PyLong_FromVoidPtr(_return_value);\n') - -class byte_char_return_converter(CReturnConverter): - type = 'int' - - def render(self, function, data): - data.declarations.append('char s[1];') - data.return_value = 's[0]' - data.return_conversion.append( - 'return_value = PyBytes_FromStringAndSize(s, 1);\n') - -class wchar_t_return_converter(CReturnConverter): - type = 'wchar_t' - - def render(self, function, data): - self.declare(data) - data.return_conversion.append( - 'return_value = PyUnicode_FromOrdinal(_return_value);\n') -[python start generated code]*/ -/*[python end generated code: output=da39a3ee5e6b4b0d input=d102511df3cda2eb]*/ - -/*[clinic input] -module msvcrt -[clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=f31a87a783d036cd]*/ - -#include "clinic/msvcrtmodule.c.h" - -/*[clinic input] -msvcrt.heapmin - -Minimize the malloc() heap. - -Force the malloc() heap to clean itself up and return unused blocks -to the operating system. On failure, this raises OSError. -[clinic start generated code]*/ - -static PyObject * -msvcrt_heapmin_impl(PyObject *module) -/*[clinic end generated code: output=1ba00f344782dc19 input=82e1771d21bde2d8]*/ -{ - if (_heapmin() != 0) - return PyErr_SetFromErrno(PyExc_OSError); - - Py_RETURN_NONE; -} -/*[clinic input] -msvcrt.locking - - fd: int - mode: int - nbytes: long - / - -Lock part of a file based on file descriptor fd from the C runtime. - -Raises OSError on failure. The locked region of the file extends from -the current file position for nbytes bytes, and may continue beyond -the end of the file. mode must be one of the LK_* constants listed -below. Multiple regions in a file may be locked at the same time, but -may not overlap. Adjacent regions are not merged; they must be unlocked -individually. -[clinic start generated code]*/ - -static PyObject * -msvcrt_locking_impl(PyObject *module, int fd, int mode, long nbytes) -/*[clinic end generated code: output=a4a90deca9785a03 input=e97bd15fc4a04fef]*/ -{ - int err; - - if (PySys_Audit("msvcrt.locking", "iil", fd, mode, nbytes) < 0) { - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - _Py_BEGIN_SUPPRESS_IPH - err = _locking(fd, mode, nbytes); - _Py_END_SUPPRESS_IPH - Py_END_ALLOW_THREADS - if (err != 0) - return PyErr_SetFromErrno(PyExc_OSError); - - Py_RETURN_NONE; -} - -/*[clinic input] -msvcrt.setmode -> long - - fd: int - mode as flags: int - / - -Set the line-end translation mode for the file descriptor fd. - -To set it to text mode, flags should be os.O_TEXT; for binary, it -should be os.O_BINARY. - -Return value is the previous mode. -[clinic start generated code]*/ - -static long -msvcrt_setmode_impl(PyObject *module, int fd, int flags) -/*[clinic end generated code: output=24a9be5ea07ccb9b input=76e7c01f6b137f75]*/ -{ - _Py_BEGIN_SUPPRESS_IPH - flags = _setmode(fd, flags); - _Py_END_SUPPRESS_IPH - if (flags == -1) - PyErr_SetFromErrno(PyExc_OSError); - - return flags; -} - -/*[clinic input] -msvcrt.open_osfhandle -> long - - handle: HANDLE - flags: int - / - -Create a C runtime file descriptor from the file handle handle. - -The flags parameter should be a bitwise OR of os.O_APPEND, os.O_RDONLY, -and os.O_TEXT. The returned file descriptor may be used as a parameter -to os.fdopen() to create a file object. -[clinic start generated code]*/ - -static long -msvcrt_open_osfhandle_impl(PyObject *module, void *handle, int flags) -/*[clinic end generated code: output=b2fb97c4b515e4e6 input=d5db190a307cf4bb]*/ -{ - if (PySys_Audit("msvcrt.open_osfhandle", "Ki", handle, flags) < 0) { - return -1; - } - - return _Py_open_osfhandle(handle, flags); -} - -/*[clinic input] -msvcrt.get_osfhandle -> HANDLE - - fd: int - / - -Return the file handle for the file descriptor fd. - -Raises OSError if fd is not recognized. -[clinic start generated code]*/ - -static void * -msvcrt_get_osfhandle_impl(PyObject *module, int fd) -/*[clinic end generated code: output=aca01dfe24637374 input=5fcfde9b17136aa2]*/ -{ - if (PySys_Audit("msvcrt.get_osfhandle", "(i)", fd) < 0) { - return NULL; - } - - return _Py_get_osfhandle(fd); -} - -/* Console I/O */ -/*[clinic input] -msvcrt.kbhit -> long - -Return true if a keypress is waiting to be read. -[clinic start generated code]*/ - -static long -msvcrt_kbhit_impl(PyObject *module) -/*[clinic end generated code: output=940dfce6587c1890 input=e70d678a5c2f6acc]*/ -{ - return _kbhit(); -} - -/*[clinic input] -msvcrt.getch -> byte_char - -Read a keypress and return the resulting character as a byte string. - -Nothing is echoed to the console. This call will block if a keypress is -not already available, but will not wait for Enter to be pressed. If the -pressed key was a special function key, this will return '\000' or -'\xe0'; the next call will return the keycode. The Control-C keypress -cannot be read with this function. -[clinic start generated code]*/ - -static int -msvcrt_getch_impl(PyObject *module) -/*[clinic end generated code: output=a4e51f0565064a7d input=37a40cf0ed0d1153]*/ -{ - int ch; - - Py_BEGIN_ALLOW_THREADS - ch = _getch(); - Py_END_ALLOW_THREADS - return ch; -} - -/*[clinic input] -msvcrt.getwch -> wchar_t - -Wide char variant of getch(), returning a Unicode value. -[clinic start generated code]*/ - -static wchar_t -msvcrt_getwch_impl(PyObject *module) -/*[clinic end generated code: output=be9937494e22f007 input=27b3dec8ad823d7c]*/ -{ - wchar_t ch; - - Py_BEGIN_ALLOW_THREADS - ch = _getwch(); - Py_END_ALLOW_THREADS - return ch; -} - -/*[clinic input] -msvcrt.getche -> byte_char - -Similar to getch(), but the keypress will be echoed if possible. -[clinic start generated code]*/ - -static int -msvcrt_getche_impl(PyObject *module) -/*[clinic end generated code: output=d8f7db4fd2990401 input=43311ade9ed4a9c0]*/ -{ - int ch; - - Py_BEGIN_ALLOW_THREADS - ch = _getche(); - Py_END_ALLOW_THREADS - return ch; -} - -/*[clinic input] -msvcrt.getwche -> wchar_t - -Wide char variant of getche(), returning a Unicode value. -[clinic start generated code]*/ - -static wchar_t -msvcrt_getwche_impl(PyObject *module) -/*[clinic end generated code: output=d0dae5ba3829d596 input=49337d59d1a591f8]*/ -{ - wchar_t ch; - - Py_BEGIN_ALLOW_THREADS - ch = _getwche(); - Py_END_ALLOW_THREADS - return ch; -} - -/*[clinic input] -msvcrt.putch - - char: char - / - -Print the byte string char to the console without buffering. -[clinic start generated code]*/ - -static PyObject * -msvcrt_putch_impl(PyObject *module, char char_value) -/*[clinic end generated code: output=92ec9b81012d8f60 input=ec078dd10cb054d6]*/ -{ - _Py_BEGIN_SUPPRESS_IPH - _putch(char_value); - _Py_END_SUPPRESS_IPH - Py_RETURN_NONE; -} - -/*[clinic input] -msvcrt.putwch - - unicode_char: int(accept={str}) - / - -Wide char variant of putch(), accepting a Unicode value. -[clinic start generated code]*/ - -static PyObject * -msvcrt_putwch_impl(PyObject *module, int unicode_char) -/*[clinic end generated code: output=a3bd1a8951d28eee input=996ccd0bbcbac4c3]*/ -{ - _Py_BEGIN_SUPPRESS_IPH - _putwch(unicode_char); - _Py_END_SUPPRESS_IPH - Py_RETURN_NONE; - -} - -/*[clinic input] -msvcrt.ungetch - - char: char - / - -Opposite of getch. - -Cause the byte string char to be "pushed back" into the -console buffer; it will be the next character read by -getch() or getche(). -[clinic start generated code]*/ - -static PyObject * -msvcrt_ungetch_impl(PyObject *module, char char_value) -/*[clinic end generated code: output=c6942a0efa119000 input=22f07ee9001bbf0f]*/ -{ - int res; - - _Py_BEGIN_SUPPRESS_IPH - res = _ungetch(char_value); - _Py_END_SUPPRESS_IPH - - if (res == EOF) - return PyErr_SetFromErrno(PyExc_OSError); - Py_RETURN_NONE; -} - -/*[clinic input] -msvcrt.ungetwch - - unicode_char: int(accept={str}) - / - -Wide char variant of ungetch(), accepting a Unicode value. -[clinic start generated code]*/ - -static PyObject * -msvcrt_ungetwch_impl(PyObject *module, int unicode_char) -/*[clinic end generated code: output=e63af05438b8ba3d input=83ec0492be04d564]*/ -{ - int res; - - _Py_BEGIN_SUPPRESS_IPH - res = _ungetwch(unicode_char); - _Py_END_SUPPRESS_IPH - - if (res == WEOF) - return PyErr_SetFromErrno(PyExc_OSError); - Py_RETURN_NONE; -} - -#ifdef _DEBUG -/*[clinic input] -msvcrt.CrtSetReportFile -> HANDLE - - type: int - file: HANDLE - / - -Wrapper around _CrtSetReportFile. - -Only available on Debug builds. -[clinic start generated code]*/ - -static void * -msvcrt_CrtSetReportFile_impl(PyObject *module, int type, void *file) -/*[clinic end generated code: output=9393e8c77088bbe9 input=290809b5f19e65b9]*/ -{ - HANDLE res; - - _Py_BEGIN_SUPPRESS_IPH - res = _CrtSetReportFile(type, file); - _Py_END_SUPPRESS_IPH - - return res; -} - -/*[clinic input] -msvcrt.CrtSetReportMode -> long - - type: int - mode: int - / - -Wrapper around _CrtSetReportMode. - -Only available on Debug builds. -[clinic start generated code]*/ - -static long -msvcrt_CrtSetReportMode_impl(PyObject *module, int type, int mode) -/*[clinic end generated code: output=b2863761523de317 input=9319d29b4319426b]*/ -{ - int res; - - _Py_BEGIN_SUPPRESS_IPH - res = _CrtSetReportMode(type, mode); - _Py_END_SUPPRESS_IPH - if (res == -1) - PyErr_SetFromErrno(PyExc_OSError); - return res; -} - -/*[clinic input] -msvcrt.set_error_mode -> long - - mode: int - / - -Wrapper around _set_error_mode. - -Only available on Debug builds. -[clinic start generated code]*/ - -static long -msvcrt_set_error_mode_impl(PyObject *module, int mode) -/*[clinic end generated code: output=ac4a09040d8ac4e3 input=046fca59c0f20872]*/ -{ - long res; - - _Py_BEGIN_SUPPRESS_IPH - res = _set_error_mode(mode); - _Py_END_SUPPRESS_IPH - - return res; -} -#endif /* _DEBUG */ - -/*[clinic input] -msvcrt.GetErrorMode - -Wrapper around GetErrorMode. -[clinic start generated code]*/ - -static PyObject * -msvcrt_GetErrorMode_impl(PyObject *module) -/*[clinic end generated code: output=3103fc6145913591 input=5a7fb083b6dd71fd]*/ -{ - unsigned int res; - - _Py_BEGIN_SUPPRESS_IPH - res = GetErrorMode(); - _Py_END_SUPPRESS_IPH - - return PyLong_FromUnsignedLong(res); -} - -/*[clinic input] -msvcrt.SetErrorMode - - mode: unsigned_int(bitwise=True) - / - -Wrapper around SetErrorMode. -[clinic start generated code]*/ - -static PyObject * -msvcrt_SetErrorMode_impl(PyObject *module, unsigned int mode) -/*[clinic end generated code: output=01d529293f00da8f input=d8b167258d32d907]*/ -{ - unsigned int res; - - _Py_BEGIN_SUPPRESS_IPH - res = SetErrorMode(mode); - _Py_END_SUPPRESS_IPH - - return PyLong_FromUnsignedLong(res); -} - -/*[clinic input] -[clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=da39a3ee5e6b4b0d]*/ - -/* List of functions exported by this module */ -static struct PyMethodDef msvcrt_functions[] = { - MSVCRT_HEAPMIN_METHODDEF - MSVCRT_LOCKING_METHODDEF - MSVCRT_SETMODE_METHODDEF - MSVCRT_OPEN_OSFHANDLE_METHODDEF - MSVCRT_GET_OSFHANDLE_METHODDEF - MSVCRT_KBHIT_METHODDEF - MSVCRT_GETCH_METHODDEF - MSVCRT_GETCHE_METHODDEF - MSVCRT_PUTCH_METHODDEF - MSVCRT_UNGETCH_METHODDEF - MSVCRT_GETERRORMODE_METHODDEF - MSVCRT_SETERRORMODE_METHODDEF - MSVCRT_CRTSETREPORTFILE_METHODDEF - MSVCRT_CRTSETREPORTMODE_METHODDEF - MSVCRT_SET_ERROR_MODE_METHODDEF - MSVCRT_GETWCH_METHODDEF - MSVCRT_GETWCHE_METHODDEF - MSVCRT_PUTWCH_METHODDEF - MSVCRT_UNGETWCH_METHODDEF - {NULL, NULL} -}; - - -static struct PyModuleDef msvcrtmodule = { - PyModuleDef_HEAD_INIT, - "msvcrt", - NULL, - -1, - msvcrt_functions, - NULL, - NULL, - NULL, - NULL -}; - -static void -insertint(PyObject *d, char *name, int value) -{ - PyObject *v = PyLong_FromLong((long) value); - if (v == NULL) { - /* Don't bother reporting this error */ - PyErr_Clear(); - } - else { - PyDict_SetItemString(d, name, v); - Py_DECREF(v); - } -} - -static void -insertptr(PyObject *d, char *name, void *value) -{ - PyObject *v = PyLong_FromVoidPtr(value); - if (v == NULL) { - /* Don't bother reporting this error */ - PyErr_Clear(); - } - else { - PyDict_SetItemString(d, name, v); - Py_DECREF(v); - } -} - -PyMODINIT_FUNC -PyInit_msvcrt(void) -{ - int st; - PyObject *d, *version; - PyObject *m = PyModule_Create(&msvcrtmodule); - if (m == NULL) - return NULL; - d = PyModule_GetDict(m); - - /* constants for the locking() function's mode argument */ - insertint(d, "LK_LOCK", _LK_LOCK); - insertint(d, "LK_NBLCK", _LK_NBLCK); - insertint(d, "LK_NBRLCK", _LK_NBRLCK); - insertint(d, "LK_RLCK", _LK_RLCK); - insertint(d, "LK_UNLCK", _LK_UNLCK); - insertint(d, "SEM_FAILCRITICALERRORS", SEM_FAILCRITICALERRORS); - insertint(d, "SEM_NOALIGNMENTFAULTEXCEPT", SEM_NOALIGNMENTFAULTEXCEPT); - insertint(d, "SEM_NOGPFAULTERRORBOX", SEM_NOGPFAULTERRORBOX); - insertint(d, "SEM_NOOPENFILEERRORBOX", SEM_NOOPENFILEERRORBOX); -#ifdef _DEBUG - insertint(d, "CRT_WARN", _CRT_WARN); - insertint(d, "CRT_ERROR", _CRT_ERROR); - insertint(d, "CRT_ASSERT", _CRT_ASSERT); - insertint(d, "CRTDBG_MODE_DEBUG", _CRTDBG_MODE_DEBUG); - insertint(d, "CRTDBG_MODE_FILE", _CRTDBG_MODE_FILE); - insertint(d, "CRTDBG_MODE_WNDW", _CRTDBG_MODE_WNDW); - insertint(d, "CRTDBG_REPORT_MODE", _CRTDBG_REPORT_MODE); - insertptr(d, "CRTDBG_FILE_STDERR", _CRTDBG_FILE_STDERR); - insertptr(d, "CRTDBG_FILE_STDOUT", _CRTDBG_FILE_STDOUT); - insertptr(d, "CRTDBG_REPORT_FILE", _CRTDBG_REPORT_FILE); -#endif - - /* constants for the crt versions */ -#ifdef _VC_ASSEMBLY_PUBLICKEYTOKEN - st = PyModule_AddStringConstant(m, "VC_ASSEMBLY_PUBLICKEYTOKEN", - _VC_ASSEMBLY_PUBLICKEYTOKEN); - if (st < 0) return NULL; -#endif -#ifdef _CRT_ASSEMBLY_VERSION - st = PyModule_AddStringConstant(m, "CRT_ASSEMBLY_VERSION", - _CRT_ASSEMBLY_VERSION); - if (st < 0) return NULL; -#endif -#ifdef __LIBRARIES_ASSEMBLY_NAME_PREFIX - st = PyModule_AddStringConstant(m, "LIBRARIES_ASSEMBLY_NAME_PREFIX", - __LIBRARIES_ASSEMBLY_NAME_PREFIX); - if (st < 0) return NULL; -#endif - - /* constants for the 2010 crt versions */ -#if defined(_VC_CRT_MAJOR_VERSION) && defined (_VC_CRT_MINOR_VERSION) && defined(_VC_CRT_BUILD_VERSION) && defined(_VC_CRT_RBUILD_VERSION) - version = PyUnicode_FromFormat("%d.%d.%d.%d", _VC_CRT_MAJOR_VERSION, - _VC_CRT_MINOR_VERSION, - _VC_CRT_BUILD_VERSION, - _VC_CRT_RBUILD_VERSION); - st = PyModule_AddObject(m, "CRT_ASSEMBLY_VERSION", version); - if (st < 0) return NULL; -#endif - /* make compiler warning quiet if st is unused */ - (void)st; - - return m; -} diff --git a/PC/pyconfig.h b/PC/pyconfig.h deleted file mode 100644 index 103e647ac832124f9f5ddb70b09f8312f360b91c..0000000000000000000000000000000000000000 --- a/PC/pyconfig.h +++ /dev/null @@ -1,690 +0,0 @@ -#ifndef Py_CONFIG_H -#define Py_CONFIG_H - -/* pyconfig.h. NOT Generated automatically by configure. - -This is a manually maintained version used for the Watcom, -Borland and Microsoft Visual C++ compilers. It is a -standard part of the Python distribution. - -WINDOWS DEFINES: -The code specific to Windows should be wrapped around one of -the following #defines - -MS_WIN64 - Code specific to the MS Win64 API -MS_WIN32 - Code specific to the MS Win32 (and Win64) API (obsolete, this covers all supported APIs) -MS_WINDOWS - Code specific to Windows, but all versions. -Py_ENABLE_SHARED - Code if the Python core is built as a DLL. - -Also note that neither "_M_IX86" or "_MSC_VER" should be used for -any purpose other than "Windows Intel x86 specific" and "Microsoft -compiler specific". Therefore, these should be very rare. - - -NOTE: The following symbols are deprecated: -NT, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT -MS_CORE_DLL. - -WIN32 is still required for the locale module. - -*/ - -/* Deprecated USE_DL_EXPORT macro - please use Py_BUILD_CORE */ -#ifdef USE_DL_EXPORT -# define Py_BUILD_CORE -#endif /* USE_DL_EXPORT */ - -/* Visual Studio 2005 introduces deprecation warnings for - "insecure" and POSIX functions. The insecure functions should - be replaced by *_s versions (according to Microsoft); the - POSIX functions by _* versions (which, according to Microsoft, - would be ISO C conforming). Neither renaming is feasible, so - we just silence the warnings. */ - -#ifndef _CRT_SECURE_NO_DEPRECATE -#define _CRT_SECURE_NO_DEPRECATE 1 -#endif -#ifndef _CRT_NONSTDC_NO_DEPRECATE -#define _CRT_NONSTDC_NO_DEPRECATE 1 -#endif - -#define HAVE_IO_H -#define HAVE_SYS_UTIME_H -#define HAVE_TEMPNAM -#define HAVE_TMPFILE -#define HAVE_TMPNAM -#define HAVE_CLOCK -#define HAVE_STRERROR - -#include - -#define HAVE_HYPOT -#define HAVE_STRFTIME -#define DONT_HAVE_SIG_ALARM -#define DONT_HAVE_SIG_PAUSE -#define LONG_BIT 32 -#define WORD_BIT 32 - -#define MS_WIN32 /* only support win32 and greater. */ -#define MS_WINDOWS -#ifndef PYTHONPATH -# define PYTHONPATH L".\\DLLs;.\\lib" -#endif -#define NT_THREADS -#define WITH_THREAD -#ifndef NETSCAPE_PI -#define USE_SOCKET -#endif - - -/* Compiler specific defines */ - -/* ------------------------------------------------------------------------*/ -/* Microsoft C defines _MSC_VER */ -#ifdef _MSC_VER - -/* We want COMPILER to expand to a string containing _MSC_VER's *value*. - * This is horridly tricky, because the stringization operator only works - * on macro arguments, and doesn't evaluate macros passed *as* arguments. - * Attempts simpler than the following appear doomed to produce "_MSC_VER" - * literally in the string. - */ -#define _Py_PASTE_VERSION(SUFFIX) \ - ("[MSC v." _Py_STRINGIZE(_MSC_VER) " " SUFFIX "]") -/* e.g., this produces, after compile-time string catenation, - * ("[MSC v.1200 32 bit (Intel)]") - * - * _Py_STRINGIZE(_MSC_VER) expands to - * _Py_STRINGIZE1((_MSC_VER)) expands to - * _Py_STRINGIZE2(_MSC_VER) but as this call is the result of token-pasting - * it's scanned again for macros and so further expands to (under MSVC 6) - * _Py_STRINGIZE2(1200) which then expands to - * "1200" - */ -#define _Py_STRINGIZE(X) _Py_STRINGIZE1((X)) -#define _Py_STRINGIZE1(X) _Py_STRINGIZE2 ## X -#define _Py_STRINGIZE2(X) #X - -/* MSVC defines _WINxx to differentiate the windows platform types - - Note that for compatibility reasons _WIN32 is defined on Win32 - *and* on Win64. For the same reasons, in Python, MS_WIN32 is - defined on Win32 *and* Win64. Win32 only code must therefore be - guarded as follows: - #if defined(MS_WIN32) && !defined(MS_WIN64) -*/ -#ifdef _WIN64 -#define MS_WIN64 -#endif - -/* set the COMPILER */ -#ifdef MS_WIN64 -#if defined(_M_X64) || defined(_M_AMD64) -#if defined(__INTEL_COMPILER) -#define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 64 bit (amd64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") -#else -#define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)") -#endif /* __INTEL_COMPILER */ -#define PYD_PLATFORM_TAG "win_amd64" -#elif defined(_M_ARM64) -#define COMPILER _Py_PASTE_VERSION("64 bit (ARM64)") -#define PYD_PLATFORM_TAG "win_arm64" -#else -#define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)") -#endif -#endif /* MS_WIN64 */ - -/* set the version macros for the windows headers */ -/* Python 3.9+ requires Windows 8 or greater */ -#define Py_WINVER 0x0602 /* _WIN32_WINNT_WIN8 */ -#define Py_NTDDI NTDDI_WIN8 - -/* We only set these values when building Python - we don't want to force - these values on extensions, as that will affect the prototypes and - structures exposed in the Windows headers. Even when building Python, we - allow a single source file to override this - they may need access to - structures etc so it can optionally use new Windows features if it - determines at runtime they are available. -*/ -#if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_BUILTIN) || defined(Py_BUILD_CORE_MODULE) -#ifndef NTDDI_VERSION -#define NTDDI_VERSION Py_NTDDI -#endif -#ifndef WINVER -#define WINVER Py_WINVER -#endif -#ifndef _WIN32_WINNT -#define _WIN32_WINNT Py_WINVER -#endif -#endif - -/* _W64 is not defined for VC6 or eVC4 */ -#ifndef _W64 -#define _W64 -#endif - -/* Define like size_t, omitting the "unsigned" */ -#ifdef MS_WIN64 -typedef __int64 Py_ssize_t; -#else -typedef _W64 int Py_ssize_t; -#endif -#define HAVE_PY_SSIZE_T 1 - -#if defined(MS_WIN32) && !defined(MS_WIN64) -#if defined(_M_IX86) -#if defined(__INTEL_COMPILER) -#define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") -#else -#define COMPILER _Py_PASTE_VERSION("32 bit (Intel)") -#endif /* __INTEL_COMPILER */ -#define PYD_PLATFORM_TAG "win32" -#elif defined(_M_ARM) -#define COMPILER _Py_PASTE_VERSION("32 bit (ARM)") -#define PYD_PLATFORM_TAG "win_arm32" -#else -#define COMPILER _Py_PASTE_VERSION("32 bit (Unknown)") -#endif -#endif /* MS_WIN32 && !MS_WIN64 */ - -typedef int pid_t; - -#include -#define Py_IS_NAN _isnan -#define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X)) -#define Py_IS_FINITE(X) _finite(X) - -/* define some ANSI types that are not defined in earlier Win headers */ -#if _MSC_VER >= 1200 -/* This file only exists in VC 6.0 or higher */ -#include -#endif - -#endif /* _MSC_VER */ - -/* ------------------------------------------------------------------------*/ -/* egcs/gnu-win32 defines __GNUC__ and _WIN32 */ -#if defined(__GNUC__) && defined(_WIN32) -/* XXX These defines are likely incomplete, but should be easy to fix. - They should be complete enough to build extension modules. */ -/* Suggested by Rene Liebscher to avoid a GCC 2.91.* - bug that requires structure imports. More recent versions of the - compiler don't exhibit this bug. -*/ -#if (__GNUC__==2) && (__GNUC_MINOR__<=91) -#warning "Please use an up-to-date version of gcc! (>2.91 recommended)" -#endif - -#define COMPILER "[gcc]" -#define PY_LONG_LONG long long -#define PY_LLONG_MIN LLONG_MIN -#define PY_LLONG_MAX LLONG_MAX -#define PY_ULLONG_MAX ULLONG_MAX -#endif /* GNUC */ - -/* ------------------------------------------------------------------------*/ -/* lcc-win32 defines __LCC__ */ -#if defined(__LCC__) -/* XXX These defines are likely incomplete, but should be easy to fix. - They should be complete enough to build extension modules. */ - -#define COMPILER "[lcc-win32]" -typedef int pid_t; -/* __declspec() is supported here too - do nothing to get the defaults */ - -#endif /* LCC */ - -/* ------------------------------------------------------------------------*/ -/* End of compilers - finish up */ - -#ifndef NO_STDIO_H -# include -#endif - -/* 64 bit ints are usually spelt __int64 unless compiler has overridden */ -#ifndef PY_LONG_LONG -# define PY_LONG_LONG __int64 -# define PY_LLONG_MAX _I64_MAX -# define PY_LLONG_MIN _I64_MIN -# define PY_ULLONG_MAX _UI64_MAX -#endif - -/* For Windows the Python core is in a DLL by default. Test -Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ -#if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED) -# define Py_ENABLE_SHARED 1 /* standard symbol for shared library */ -# define MS_COREDLL /* deprecated old symbol */ -#endif /* !MS_NO_COREDLL && ... */ - -/* All windows compilers that use this header support __declspec */ -#define HAVE_DECLSPEC_DLL - -/* For an MSVC DLL, we can nominate the .lib files used by extensions */ -#ifdef MS_COREDLL -# if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN) - /* not building the core - must be an ext */ -# if defined(_MSC_VER) - /* So MSVC users need not specify the .lib - file in their Makefile (other compilers are - generally taken care of by distutils.) */ -# if defined(_DEBUG) -# pragma comment(lib,"python310_d.lib") -# elif defined(Py_LIMITED_API) -# pragma comment(lib,"python3.lib") -# else -# pragma comment(lib,"python310.lib") -# endif /* _DEBUG */ -# endif /* _MSC_VER */ -# endif /* Py_BUILD_CORE */ -#endif /* MS_COREDLL */ - -#if defined(MS_WIN64) -/* maintain "win32" sys.platform for backward compatibility of Python code, - the Win64 API should be close enough to the Win32 API to make this - preferable */ -# define PLATFORM "win32" -# define SIZEOF_VOID_P 8 -# define SIZEOF_TIME_T 8 -# define SIZEOF_OFF_T 4 -# define SIZEOF_FPOS_T 8 -# define SIZEOF_HKEY 8 -# define SIZEOF_SIZE_T 8 -# define ALIGNOF_SIZE_T 8 -/* configure.ac defines HAVE_LARGEFILE_SUPPORT iff - sizeof(off_t) > sizeof(long), and sizeof(long long) >= sizeof(off_t). - On Win64 the second condition is not true, but if fpos_t replaces off_t - then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64 - should define this. */ -# define HAVE_LARGEFILE_SUPPORT -#elif defined(MS_WIN32) -# define PLATFORM "win32" -# define HAVE_LARGEFILE_SUPPORT -# define SIZEOF_VOID_P 4 -# define SIZEOF_OFF_T 4 -# define SIZEOF_FPOS_T 8 -# define SIZEOF_HKEY 4 -# define SIZEOF_SIZE_T 4 -# define ALIGNOF_SIZE_T 4 - /* MS VS2005 changes time_t to a 64-bit type on all platforms */ -# if defined(_MSC_VER) && _MSC_VER >= 1400 -# define SIZEOF_TIME_T 8 -# else -# define SIZEOF_TIME_T 4 -# endif -#endif - -#ifdef _DEBUG -# define Py_DEBUG -#endif - - -#ifdef MS_WIN32 - -#define SIZEOF_SHORT 2 -#define SIZEOF_INT 4 -#define SIZEOF_LONG 4 -#define ALIGNOF_LONG 4 -#define SIZEOF_LONG_LONG 8 -#define SIZEOF_DOUBLE 8 -#define SIZEOF_FLOAT 4 - -/* VC 7.1 has them and VC 6.0 does not. VC 6.0 has a version number of 1200. - Microsoft eMbedded Visual C++ 4.0 has a version number of 1201 and doesn't - define these. - If some compiler does not provide them, modify the #if appropriately. */ -#if defined(_MSC_VER) -#if _MSC_VER > 1300 -#define HAVE_UINTPTR_T 1 -#define HAVE_INTPTR_T 1 -#else -/* VC6, VS 2002 and eVC4 don't support the C99 LL suffix for 64-bit integer literals */ -#define Py_LL(x) x##I64 -#endif /* _MSC_VER > 1300 */ -#endif /* _MSC_VER */ - -#endif - -/* define signed and unsigned exact-width 32-bit and 64-bit types, used in the - implementation of Python integers. */ -#define PY_UINT32_T uint32_t -#define PY_UINT64_T uint64_t -#define PY_INT32_T int32_t -#define PY_INT64_T int64_t - -/* Fairly standard from here! */ - -/* Define to 1 if you have the `copysign' function. */ -#define HAVE_COPYSIGN 1 - -/* Define to 1 if you have the `round' function. */ -#if _MSC_VER >= 1800 -#define HAVE_ROUND 1 -#endif - -/* Define to 1 if you have the `isinf' macro. */ -#define HAVE_DECL_ISINF 1 - -/* Define to 1 if you have the `isnan' function. */ -#define HAVE_DECL_ISNAN 1 - -/* Define if on AIX 3. - System headers sometimes define this. - We just want to avoid a redefinition error message. */ -#ifndef _ALL_SOURCE -/* #undef _ALL_SOURCE */ -#endif - -/* Define to empty if the keyword does not work. */ -/* #define const */ - -/* Define to 1 if you have the header file. */ -#define HAVE_CONIO_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_DIRECT_H 1 - -/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. - */ -#define HAVE_DECL_TZNAME 1 - -/* Define if you have dirent.h. */ -/* #define DIRENT 1 */ - -/* Define to the type of elements in the array set by `getgroups'. - Usually this is either `int' or `gid_t'. */ -/* #undef GETGROUPS_T */ - -/* Define to `int' if doesn't define. */ -/* #undef gid_t */ - -/* Define if your struct tm has tm_zone. */ -/* #undef HAVE_TM_ZONE */ - -/* Define if you don't have tm_zone but do have the external array - tzname. */ -#define HAVE_TZNAME - -/* Define to `int' if doesn't define. */ -/* #undef mode_t */ - -/* Define if you don't have dirent.h, but have ndir.h. */ -/* #undef NDIR */ - -/* Define to `long' if doesn't define. */ -/* #undef off_t */ - -/* Define to `int' if doesn't define. */ -/* #undef pid_t */ - -/* Define if the system does not provide POSIX.1 features except - with this defined. */ -/* #undef _POSIX_1_SOURCE */ - -/* Define if you need to in order for stat and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define if you don't have dirent.h, but have sys/dir.h. */ -/* #undef SYSDIR */ - -/* Define if you don't have dirent.h, but have sys/ndir.h. */ -/* #undef SYSNDIR */ - -/* Define if you can safely include both and . */ -/* #undef TIME_WITH_SYS_TIME */ - -/* Define if your declares struct tm. */ -/* #define TM_IN_SYS_TIME 1 */ - -/* Define to `int' if doesn't define. */ -/* #undef uid_t */ - -/* Define if the closedir function returns void instead of int. */ -/* #undef VOID_CLOSEDIR */ - -/* Define if getpgrp() must be called as getpgrp(0) - and (consequently) setpgrp() as setpgrp(0, 0). */ -/* #undef GETPGRP_HAVE_ARGS */ - -/* Define this if your time.h defines altzone */ -/* #define HAVE_ALTZONE */ - -/* Define if you have the putenv function. */ -#define HAVE_PUTENV - -/* Define if your compiler supports function prototypes */ -#define HAVE_PROTOTYPES - -/* Define if you can safely include both and - (which you can't on SCO ODT 3.0). */ -/* #undef SYS_SELECT_WITH_SYS_TIME */ - -/* Define if you want build the _decimal module using a coroutine-local rather - than a thread-local context */ -#define WITH_DECIMAL_CONTEXTVAR 1 - -/* Define if you want documentation strings in extension modules */ -#define WITH_DOC_STRINGS 1 - -/* Define if you want to compile in rudimentary thread support */ -/* #undef WITH_THREAD */ - -/* Define if you want to use the GNU readline library */ -/* #define WITH_READLINE 1 */ - -/* Use Python's own small-block memory-allocator. */ -#define WITH_PYMALLOC 1 - -/* Define if you have clock. */ -/* #define HAVE_CLOCK */ - -/* Define when any dynamic module loading is enabled */ -#define HAVE_DYNAMIC_LOADING - -/* Define if you have ftime. */ -#define HAVE_FTIME - -/* Define if you have getpeername. */ -#define HAVE_GETPEERNAME - -/* Define if you have getpgrp. */ -/* #undef HAVE_GETPGRP */ - -/* Define if you have getpid. */ -#define HAVE_GETPID - -/* Define if you have gettimeofday. */ -/* #undef HAVE_GETTIMEOFDAY */ - -/* Define if you have getwd. */ -/* #undef HAVE_GETWD */ - -/* Define if you have lstat. */ -/* #undef HAVE_LSTAT */ - -/* Define if you have the mktime function. */ -#define HAVE_MKTIME - -/* Define if you have nice. */ -/* #undef HAVE_NICE */ - -/* Define if you have readlink. */ -/* #undef HAVE_READLINK */ - -/* Define if you have setpgid. */ -/* #undef HAVE_SETPGID */ - -/* Define if you have setpgrp. */ -/* #undef HAVE_SETPGRP */ - -/* Define if you have setsid. */ -/* #undef HAVE_SETSID */ - -/* Define if you have setvbuf. */ -#define HAVE_SETVBUF - -/* Define if you have siginterrupt. */ -/* #undef HAVE_SIGINTERRUPT */ - -/* Define if you have symlink. */ -/* #undef HAVE_SYMLINK */ - -/* Define if you have tcgetpgrp. */ -/* #undef HAVE_TCGETPGRP */ - -/* Define if you have tcsetpgrp. */ -/* #undef HAVE_TCSETPGRP */ - -/* Define if you have times. */ -/* #undef HAVE_TIMES */ - -/* Define if you have uname. */ -/* #undef HAVE_UNAME */ - -/* Define if you have waitpid. */ -/* #undef HAVE_WAITPID */ - -/* Define to 1 if you have the `wcsftime' function. */ -#if defined(_MSC_VER) && _MSC_VER >= 1310 -#define HAVE_WCSFTIME 1 -#endif - -/* Define to 1 if you have the `wcscoll' function. */ -#define HAVE_WCSCOLL 1 - -/* Define to 1 if you have the `wcsxfrm' function. */ -#define HAVE_WCSXFRM 1 - -/* Define if the zlib library has inflateCopy */ -#define HAVE_ZLIB_COPY 1 - -/* Define if you have the header file. */ -/* #undef HAVE_DLFCN_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_ERRNO_H 1 - -/* Define if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_PROCESS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SIGNAL_H 1 - -/* Define if you have the prototypes. */ -#define HAVE_STDARG_PROTOTYPES - -/* Define if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_AUDIOIO_H */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_PARAM_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_SELECT_H 1 */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define if you have the header file. */ -/* #define HAVE_SYS_TIME_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_TIMES_H 1 */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define if you have the header file. */ -/* #define HAVE_SYS_UN_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_UTIME_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_UTSNAME_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_UNISTD_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_UTIME_H 1 */ - -/* Define if the compiler provides a wchar.h header file. */ -#define HAVE_WCHAR_H 1 - -/* The size of `wchar_t', as computed by sizeof. */ -#define SIZEOF_WCHAR_T 2 - -/* The size of `_Bool', as computed by sizeof. */ -#define SIZEOF__BOOL 1 - -/* The size of `pid_t', as computed by sizeof. */ -#define SIZEOF_PID_T SIZEOF_INT - -/* Define if you have the dl library (-ldl). */ -/* #undef HAVE_LIBDL */ - -/* Define if you have the mpc library (-lmpc). */ -/* #undef HAVE_LIBMPC */ - -/* Define if you have the nsl library (-lnsl). */ -#define HAVE_LIBNSL 1 - -/* Define if you have the seq library (-lseq). */ -/* #undef HAVE_LIBSEQ */ - -/* Define if you have the socket library (-lsocket). */ -#define HAVE_LIBSOCKET 1 - -/* Define if you have the sun library (-lsun). */ -/* #undef HAVE_LIBSUN */ - -/* Define if you have the termcap library (-ltermcap). */ -/* #undef HAVE_LIBTERMCAP */ - -/* Define if you have the termlib library (-ltermlib). */ -/* #undef HAVE_LIBTERMLIB */ - -/* Define if you have the thread library (-lthread). */ -/* #undef HAVE_LIBTHREAD */ - -/* WinSock does not use a bitmask in select, and uses - socket handles greater than FD_SETSIZE */ -#define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE - -/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the - least significant byte first */ -#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1 - -/* Define to 1 if you have the `erf' function. */ -#define HAVE_ERF 1 - -/* Define to 1 if you have the `erfc' function. */ -#define HAVE_ERFC 1 - -/* Define if you have the 'inet_pton' function. */ -#define HAVE_INET_PTON 1 - -/* framework name */ -#define _PYTHONFRAMEWORK "" - -/* Define if libssl has X509_VERIFY_PARAM_set1_host and related function */ -#define HAVE_X509_VERIFY_PARAM_SET1_HOST 1 - -#define PLATLIBDIR "lib" - -#endif /* !Py_CONFIG_H */ diff --git a/PC/pylauncher.rc b/PC/pylauncher.rc deleted file mode 100644 index ff7e71e0fdb4e1d52e3892dff1dfc802e85eedc0..0000000000000000000000000000000000000000 --- a/PC/pylauncher.rc +++ /dev/null @@ -1,64 +0,0 @@ -#include - -#include "python_ver_rc.h" - -#ifndef RT_MANIFEST -// bpo-45220: Cannot reliably #include RT_MANIFEST from -// anywhere, so we hardcode it -#define RT_MANIFEST 24 -#endif -// Include the manifest file that indicates we support all -// current versions of Windows. -1 RT_MANIFEST "python.manifest" - -#if defined(PY_ICON) -1 ICON DISCARDABLE "icons\python.ico" -#elif defined(PYW_ICON) -1 ICON DISCARDABLE "icons\pythonw.ico" -#else -1 ICON DISCARDABLE "icons\launcher.ico" -2 ICON DISCARDABLE "icons\py.ico" -3 ICON DISCARDABLE "icons\pyc.ico" -4 ICON DISCARDABLE "icons\pyd.ico" -5 ICON DISCARDABLE "icons\python.ico" -6 ICON DISCARDABLE "icons\pythonw.ico" -7 ICON DISCARDABLE "icons\setup.ico" -#endif - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION PYVERSION64 - PRODUCTVERSION PYVERSION64 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_APP - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "CompanyName", PYTHON_COMPANY "\0" - VALUE "FileDescription", "Python\0" - VALUE "FileVersion", PYTHON_VERSION - VALUE "InternalName", "Python Launcher\0" - VALUE "LegalCopyright", PYTHON_COPYRIGHT "\0" - VALUE "OriginalFilename", "py" PYTHON_DEBUG_EXT ".exe\0" - VALUE "ProductName", "Python\0" - VALUE "ProductVersion", PYTHON_VERSION - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END \ No newline at end of file diff --git a/PC/pyshellext.cpp b/PC/pyshellext.cpp deleted file mode 100644 index ffca169857c37596e0cf216fbd0c5e84c5a00552..0000000000000000000000000000000000000000 --- a/PC/pyshellext.cpp +++ /dev/null @@ -1,608 +0,0 @@ -// Support back to Vista -#define _WIN32_WINNT _WIN32_WINNT_VISTA -#include - -// Use WRL to define a classic COM class -#define __WRL_CLASSIC_COM__ -#include - -#include -#include -#include -#include -#include - -#define DDWM_UPDATEWINDOW (WM_USER+3) - -static HINSTANCE hModule; -static CLIPFORMAT cfDropDescription; -static CLIPFORMAT cfDragWindow; - -#define CLASS_GUID "{BEA218D2-6950-497B-9434-61683EC065FE}" -static const LPCWSTR CLASS_SUBKEY = L"Software\\Classes\\CLSID\\" CLASS_GUID; -static const LPCWSTR DRAG_MESSAGE = L"Open with %1"; - -using namespace Microsoft::WRL; - -HRESULT FilenameListCchLengthA(LPCSTR pszSource, size_t cchMax, size_t *pcchLength, size_t *pcchCount) { - HRESULT hr = S_OK; - size_t count = 0; - size_t length = 0; - - while (pszSource && pszSource[0]) { - size_t oneLength; - hr = StringCchLengthA(pszSource, cchMax - length, &oneLength); - if (FAILED(hr)) { - return hr; - } - count += 1; - length += oneLength + (strchr(pszSource, ' ') ? 3 : 1); - pszSource = &pszSource[oneLength + 1]; - } - - *pcchCount = count; - *pcchLength = length; - return hr; -} - -HRESULT FilenameListCchLengthW(LPCWSTR pszSource, size_t cchMax, size_t *pcchLength, size_t *pcchCount) { - HRESULT hr = S_OK; - size_t count = 0; - size_t length = 0; - - while (pszSource && pszSource[0]) { - size_t oneLength; - hr = StringCchLengthW(pszSource, cchMax - length, &oneLength); - if (FAILED(hr)) { - return hr; - } - count += 1; - length += oneLength + (wcschr(pszSource, ' ') ? 3 : 1); - pszSource = &pszSource[oneLength + 1]; - } - - *pcchCount = count; - *pcchLength = length; - return hr; -} - -HRESULT FilenameListCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, LPCSTR pszSource, LPCSTR pszSeparator) { - HRESULT hr = S_OK; - size_t count = 0; - size_t length = 0; - - while (pszSource[0]) { - STRSAFE_LPSTR newDest; - - hr = StringCchCopyExA(pszDest, cchDest, pszSource, &newDest, &cchDest, 0); - if (FAILED(hr)) { - return hr; - } - pszSource += (newDest - pszDest) + 1; - pszDest = PathQuoteSpacesA(pszDest) ? newDest + 2 : newDest; - - if (pszSource[0]) { - hr = StringCchCopyExA(pszDest, cchDest, pszSeparator, &newDest, &cchDest, 0); - if (FAILED(hr)) { - return hr; - } - pszDest = newDest; - } - } - - return hr; -} - -HRESULT FilenameListCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, LPCWSTR pszSource, LPCWSTR pszSeparator) { - HRESULT hr = S_OK; - size_t count = 0; - size_t length = 0; - - while (pszSource[0]) { - STRSAFE_LPWSTR newDest; - - hr = StringCchCopyExW(pszDest, cchDest, pszSource, &newDest, &cchDest, 0); - if (FAILED(hr)) { - return hr; - } - pszSource += (newDest - pszDest) + 1; - pszDest = PathQuoteSpacesW(pszDest) ? newDest + 2 : newDest; - - if (pszSource[0]) { - hr = StringCchCopyExW(pszDest, cchDest, pszSeparator, &newDest, &cchDest, 0); - if (FAILED(hr)) { - return hr; - } - pszDest = newDest; - } - } - - return hr; -} - -class DECLSPEC_UUID(CLASS_GUID) PyShellExt : public RuntimeClass< - RuntimeClassFlags, - IDropTarget, - IPersistFile -> -{ - LPOLESTR target, target_dir; - DWORD target_mode; - - IDataObject *data_obj; - -public: - PyShellExt() : target(NULL), target_dir(NULL), target_mode(0), data_obj(NULL) { - OutputDebugString(L"PyShellExt::PyShellExt"); - } - - ~PyShellExt() { - if (target) { - CoTaskMemFree(target); - } - if (target_dir) { - CoTaskMemFree(target_dir); - } - if (data_obj) { - data_obj->Release(); - } - } - -private: - HRESULT UpdateDropDescription(IDataObject *pDataObj) { - STGMEDIUM medium; - FORMATETC fmt = { - cfDropDescription, - NULL, - DVASPECT_CONTENT, - -1, - TYMED_HGLOBAL - }; - - auto hr = pDataObj->GetData(&fmt, &medium); - if (FAILED(hr)) { - OutputDebugString(L"PyShellExt::UpdateDropDescription - failed to get DROPDESCRIPTION format"); - return hr; - } - if (!medium.hGlobal) { - OutputDebugString(L"PyShellExt::UpdateDropDescription - DROPDESCRIPTION format had NULL hGlobal"); - ReleaseStgMedium(&medium); - return E_FAIL; - } - auto dd = (DROPDESCRIPTION*)GlobalLock(medium.hGlobal); - if (!dd) { - OutputDebugString(L"PyShellExt::UpdateDropDescription - failed to lock DROPDESCRIPTION hGlobal"); - ReleaseStgMedium(&medium); - return E_FAIL; - } - StringCchCopy(dd->szMessage, sizeof(dd->szMessage) / sizeof(dd->szMessage[0]), DRAG_MESSAGE); - StringCchCopy(dd->szInsert, sizeof(dd->szInsert) / sizeof(dd->szInsert[0]), PathFindFileNameW(target)); - dd->type = DROPIMAGE_MOVE; - - GlobalUnlock(medium.hGlobal); - ReleaseStgMedium(&medium); - - return S_OK; - } - - HRESULT GetDragWindow(IDataObject *pDataObj, HWND *phWnd) { - HRESULT hr; - HWND *pMem; - STGMEDIUM medium; - FORMATETC fmt = { - cfDragWindow, - NULL, - DVASPECT_CONTENT, - -1, - TYMED_HGLOBAL - }; - - hr = pDataObj->GetData(&fmt, &medium); - if (FAILED(hr)) { - OutputDebugString(L"PyShellExt::GetDragWindow - failed to get DragWindow format"); - return hr; - } - if (!medium.hGlobal) { - OutputDebugString(L"PyShellExt::GetDragWindow - DragWindow format had NULL hGlobal"); - ReleaseStgMedium(&medium); - return E_FAIL; - } - - pMem = (HWND*)GlobalLock(medium.hGlobal); - if (!pMem) { - OutputDebugString(L"PyShellExt::GetDragWindow - failed to lock DragWindow hGlobal"); - ReleaseStgMedium(&medium); - return E_FAIL; - } - - *phWnd = *pMem; - - GlobalUnlock(medium.hGlobal); - ReleaseStgMedium(&medium); - - return S_OK; - } - - HRESULT GetArguments(IDataObject *pDataObj, LPCWSTR *pArguments) { - HRESULT hr; - DROPFILES *pdropfiles; - - STGMEDIUM medium; - FORMATETC fmt = { - CF_HDROP, - NULL, - DVASPECT_CONTENT, - -1, - TYMED_HGLOBAL - }; - - hr = pDataObj->GetData(&fmt, &medium); - if (FAILED(hr)) { - OutputDebugString(L"PyShellExt::GetArguments - failed to get CF_HDROP format"); - return hr; - } - if (!medium.hGlobal) { - OutputDebugString(L"PyShellExt::GetArguments - CF_HDROP format had NULL hGlobal"); - ReleaseStgMedium(&medium); - return E_FAIL; - } - - pdropfiles = (DROPFILES*)GlobalLock(medium.hGlobal); - if (!pdropfiles) { - OutputDebugString(L"PyShellExt::GetArguments - failed to lock CF_HDROP hGlobal"); - ReleaseStgMedium(&medium); - return E_FAIL; - } - - if (pdropfiles->fWide) { - LPCWSTR files = (LPCWSTR)((char*)pdropfiles + pdropfiles->pFiles); - size_t len, count; - hr = FilenameListCchLengthW(files, 32767, &len, &count); - if (SUCCEEDED(hr)) { - LPWSTR args = (LPWSTR)CoTaskMemAlloc(sizeof(WCHAR) * (len + 1)); - if (args) { - hr = FilenameListCchCopyW(args, 32767, files, L" "); - if (SUCCEEDED(hr)) { - *pArguments = args; - } else { - CoTaskMemFree(args); - } - } else { - hr = E_OUTOFMEMORY; - } - } - } else { - LPCSTR files = (LPCSTR)((char*)pdropfiles + pdropfiles->pFiles); - size_t len, count; - hr = FilenameListCchLengthA(files, 32767, &len, &count); - if (SUCCEEDED(hr)) { - LPSTR temp = (LPSTR)CoTaskMemAlloc(sizeof(CHAR) * (len + 1)); - if (temp) { - hr = FilenameListCchCopyA(temp, 32767, files, " "); - if (SUCCEEDED(hr)) { - int wlen = MultiByteToWideChar(CP_ACP, 0, temp, (int)len, NULL, 0); - if (wlen) { - LPWSTR args = (LPWSTR)CoTaskMemAlloc(sizeof(WCHAR) * (wlen + 1)); - if (MultiByteToWideChar(CP_ACP, 0, temp, (int)len, args, wlen + 1)) { - *pArguments = args; - } else { - OutputDebugString(L"PyShellExt::GetArguments - failed to convert multi-byte to wide-char path"); - CoTaskMemFree(args); - hr = E_FAIL; - } - } else { - OutputDebugString(L"PyShellExt::GetArguments - failed to get length of wide-char path"); - hr = E_FAIL; - } - } - CoTaskMemFree(temp); - } else { - hr = E_OUTOFMEMORY; - } - } - } - - GlobalUnlock(medium.hGlobal); - ReleaseStgMedium(&medium); - - return hr; - } - - HRESULT NotifyDragWindow(HWND hwnd) { - LRESULT res; - - if (!hwnd) { - return S_FALSE; - } - - res = SendMessage(hwnd, DDWM_UPDATEWINDOW, 0, NULL); - - if (res) { - OutputDebugString(L"PyShellExt::NotifyDragWindow - failed to post DDWM_UPDATEWINDOW"); - return E_FAIL; - } - - return S_OK; - } - -public: - // IDropTarget implementation - - STDMETHODIMP DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) { - HWND hwnd; - - OutputDebugString(L"PyShellExt::DragEnter"); - - pDataObj->AddRef(); - data_obj = pDataObj; - - *pdwEffect = DROPEFFECT_MOVE; - - if (FAILED(UpdateDropDescription(data_obj))) { - OutputDebugString(L"PyShellExt::DragEnter - failed to update drop description"); - } - if (FAILED(GetDragWindow(data_obj, &hwnd))) { - OutputDebugString(L"PyShellExt::DragEnter - failed to get drag window"); - } - if (FAILED(NotifyDragWindow(hwnd))) { - OutputDebugString(L"PyShellExt::DragEnter - failed to notify drag window"); - } - - return S_OK; - } - - STDMETHODIMP DragLeave() { - return S_OK; - } - - STDMETHODIMP DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) { - return S_OK; - } - - STDMETHODIMP Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) { - LPCWSTR args; - - OutputDebugString(L"PyShellExt::Drop"); - *pdwEffect = DROPEFFECT_NONE; - - if (pDataObj != data_obj) { - OutputDebugString(L"PyShellExt::Drop - unexpected data object"); - return E_FAIL; - } - - data_obj->Release(); - data_obj = NULL; - - if (SUCCEEDED(GetArguments(pDataObj, &args))) { - OutputDebugString(args); - ShellExecute(NULL, NULL, target, args, target_dir, SW_NORMAL); - - CoTaskMemFree((LPVOID)args); - } else { - OutputDebugString(L"PyShellExt::Drop - failed to get launch arguments"); - } - - return S_OK; - } - - // IPersistFile implementation - - STDMETHODIMP GetCurFile(LPOLESTR *ppszFileName) { - HRESULT hr; - size_t len; - - if (!ppszFileName) { - return E_POINTER; - } - - hr = StringCchLength(target, STRSAFE_MAX_CCH - 1, &len); - if (FAILED(hr)) { - return E_FAIL; - } - - *ppszFileName = (LPOLESTR)CoTaskMemAlloc(sizeof(WCHAR) * (len + 1)); - if (!*ppszFileName) { - return E_OUTOFMEMORY; - } - - hr = StringCchCopy(*ppszFileName, len + 1, target); - if (FAILED(hr)) { - CoTaskMemFree(*ppszFileName); - *ppszFileName = NULL; - return E_FAIL; - } - - return S_OK; - } - - STDMETHODIMP IsDirty() { - return S_FALSE; - } - - STDMETHODIMP Load(LPCOLESTR pszFileName, DWORD dwMode) { - HRESULT hr; - size_t len; - - OutputDebugString(L"PyShellExt::Load"); - OutputDebugString(pszFileName); - - hr = StringCchLength(pszFileName, STRSAFE_MAX_CCH - 1, &len); - if (FAILED(hr)) { - OutputDebugString(L"PyShellExt::Load - failed to get string length"); - return hr; - } - - if (target) { - CoTaskMemFree(target); - } - if (target_dir) { - CoTaskMemFree(target_dir); - } - - target = (LPOLESTR)CoTaskMemAlloc(sizeof(WCHAR) * (len + 1)); - if (!target) { - OutputDebugString(L"PyShellExt::Load - E_OUTOFMEMORY"); - return E_OUTOFMEMORY; - } - target_dir = (LPOLESTR)CoTaskMemAlloc(sizeof(WCHAR) * (len + 1)); - if (!target_dir) { - OutputDebugString(L"PyShellExt::Load - E_OUTOFMEMORY"); - return E_OUTOFMEMORY; - } - - hr = StringCchCopy(target, len + 1, pszFileName); - if (FAILED(hr)) { - OutputDebugString(L"PyShellExt::Load - failed to copy string"); - return hr; - } - - hr = StringCchCopy(target_dir, len + 1, pszFileName); - if (FAILED(hr)) { - OutputDebugString(L"PyShellExt::Load - failed to copy string"); - return hr; - } - if (!PathRemoveFileSpecW(target_dir)) { - OutputDebugStringW(L"PyShellExt::Load - failed to remove filespec from target"); - return E_FAIL; - } - - OutputDebugString(target); - target_mode = dwMode; - OutputDebugString(L"PyShellExt::Load - S_OK"); - return S_OK; - } - - STDMETHODIMP Save(LPCOLESTR pszFileName, BOOL fRemember) { - return E_NOTIMPL; - } - - STDMETHODIMP SaveCompleted(LPCOLESTR pszFileName) { - return E_NOTIMPL; - } - - STDMETHODIMP GetClassID(CLSID *pClassID) { - *pClassID = __uuidof(PyShellExt); - return S_OK; - } -}; - -CoCreatableClass(PyShellExt); - -STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, _COM_Outptr_ void** ppv) { - return Module::GetModule().GetClassObject(rclsid, riid, ppv); -} - -STDAPI DllCanUnloadNow() { - return Module::GetModule().Terminate() ? S_OK : S_FALSE; -} - -STDAPI DllRegisterServer() { - LONG res; - SECURITY_ATTRIBUTES secattr = { sizeof(SECURITY_ATTRIBUTES), NULL, FALSE }; - LPSECURITY_ATTRIBUTES psecattr = NULL; - HKEY key, ipsKey; - WCHAR modname[MAX_PATH]; - DWORD modname_len; - - OutputDebugString(L"PyShellExt::DllRegisterServer"); - if (!hModule) { - OutputDebugString(L"PyShellExt::DllRegisterServer - module handle was not set"); - return SELFREG_E_CLASS; - } - modname_len = GetModuleFileName(hModule, modname, MAX_PATH); - if (modname_len == 0 || - (modname_len == MAX_PATH && GetLastError() == ERROR_INSUFFICIENT_BUFFER)) { - OutputDebugString(L"PyShellExt::DllRegisterServer - failed to get module file name"); - return SELFREG_E_CLASS; - } - - DWORD disp; - res = RegCreateKeyEx(HKEY_LOCAL_MACHINE, CLASS_SUBKEY, 0, NULL, 0, - KEY_ALL_ACCESS, psecattr, &key, &disp); - if (res == ERROR_ACCESS_DENIED) { - OutputDebugString(L"PyShellExt::DllRegisterServer - failed to write per-machine registration. Attempting per-user instead."); - res = RegCreateKeyEx(HKEY_CURRENT_USER, CLASS_SUBKEY, 0, NULL, 0, - KEY_ALL_ACCESS, psecattr, &key, &disp); - } - if (res != ERROR_SUCCESS) { - OutputDebugString(L"PyShellExt::DllRegisterServer - failed to create class key"); - return SELFREG_E_CLASS; - } - - res = RegCreateKeyEx(key, L"InProcServer32", 0, NULL, 0, - KEY_ALL_ACCESS, psecattr, &ipsKey, NULL); - if (res != ERROR_SUCCESS) { - RegCloseKey(key); - OutputDebugString(L"PyShellExt::DllRegisterServer - failed to create InProcServer32 key"); - return SELFREG_E_CLASS; - } - - res = RegSetValueEx(ipsKey, NULL, 0, - REG_SZ, (LPBYTE)modname, modname_len * sizeof(modname[0])); - - if (res != ERROR_SUCCESS) { - RegCloseKey(ipsKey); - RegCloseKey(key); - OutputDebugString(L"PyShellExt::DllRegisterServer - failed to set server path"); - return SELFREG_E_CLASS; - } - - res = RegSetValueEx(ipsKey, L"ThreadingModel", 0, - REG_SZ, (LPBYTE)(L"Apartment"), sizeof(L"Apartment")); - - RegCloseKey(ipsKey); - RegCloseKey(key); - if (res != ERROR_SUCCESS) { - OutputDebugString(L"PyShellExt::DllRegisterServer - failed to set threading model"); - return SELFREG_E_CLASS; - } - - SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); - - OutputDebugString(L"PyShellExt::DllRegisterServer - S_OK"); - return S_OK; -} - -STDAPI DllUnregisterServer() { - LONG res_lm, res_cu; - - res_lm = RegDeleteTree(HKEY_LOCAL_MACHINE, CLASS_SUBKEY); - if (res_lm != ERROR_SUCCESS && res_lm != ERROR_FILE_NOT_FOUND) { - OutputDebugString(L"PyShellExt::DllUnregisterServer - failed to delete per-machine registration"); - return SELFREG_E_CLASS; - } - - res_cu = RegDeleteTree(HKEY_CURRENT_USER, CLASS_SUBKEY); - if (res_cu != ERROR_SUCCESS && res_cu != ERROR_FILE_NOT_FOUND) { - OutputDebugString(L"PyShellExt::DllUnregisterServer - failed to delete per-user registration"); - return SELFREG_E_CLASS; - } - - if (res_lm == ERROR_FILE_NOT_FOUND && res_cu == ERROR_FILE_NOT_FOUND) { - OutputDebugString(L"PyShellExt::DllUnregisterServer - extension was not registered"); - return SELFREG_E_CLASS; - } - - SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); - - OutputDebugString(L"PyShellExt::DllUnregisterServer - S_OK"); - return S_OK; -} - -STDAPI_(BOOL) DllMain(_In_opt_ HINSTANCE hinst, DWORD reason, _In_opt_ void*) { - if (reason == DLL_PROCESS_ATTACH) { - hModule = hinst; - - cfDropDescription = RegisterClipboardFormat(CFSTR_DROPDESCRIPTION); - if (!cfDropDescription) { - OutputDebugString(L"PyShellExt::DllMain - failed to get CFSTR_DROPDESCRIPTION format"); - } - cfDragWindow = RegisterClipboardFormat(L"DragWindow"); - if (!cfDragWindow) { - OutputDebugString(L"PyShellExt::DllMain - failed to get DragWindow format"); - } - - DisableThreadLibraryCalls(hinst); - } - return TRUE; -} \ No newline at end of file diff --git a/PC/pyshellext.def b/PC/pyshellext.def deleted file mode 100644 index 288a9adf982f19718f51b610bf8169e5e6f0f2e4..0000000000000000000000000000000000000000 --- a/PC/pyshellext.def +++ /dev/null @@ -1,5 +0,0 @@ -EXPORTS - DllRegisterServer PRIVATE - DllUnregisterServer PRIVATE - DllGetClassObject PRIVATE - DllCanUnloadNow PRIVATE diff --git a/PC/pyshellext.rc b/PC/pyshellext.rc deleted file mode 100644 index af797ce95d5077e36a79f09dc6f1510ebdec6ab7..0000000000000000000000000000000000000000 --- a/PC/pyshellext.rc +++ /dev/null @@ -1,51 +0,0 @@ -#include - -#include "python_ver_rc.h" - -#ifndef RT_MANIFEST -// bpo-45220: Cannot reliably #include RT_MANIFEST from -// anywhere, so we hardcode it -#define RT_MANIFEST 24 -#endif - -// Include the manifest file that indicates we support all -// current versions of Windows. -1 RT_MANIFEST "python.manifest" - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION PYVERSION64 - PRODUCTVERSION PYVERSION64 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_APP - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "CompanyName", PYTHON_COMPANY "\0" - VALUE "FileDescription", "Python\0" - VALUE "FileVersion", PYTHON_VERSION - VALUE "InternalName", "Python Launcher Shell Extension\0" - VALUE "LegalCopyright", PYTHON_COPYRIGHT "\0" - VALUE "OriginalFilename", "pyshellext" PYTHON_DEBUG_EXT ".dll\0" - VALUE "ProductName", "Python\0" - VALUE "ProductVersion", PYTHON_VERSION - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END \ No newline at end of file diff --git a/PC/python.manifest b/PC/python.manifest deleted file mode 100644 index 8e1bc022adfb4fb31c46aa633e3ceeca44b7ef02..0000000000000000000000000000000000000000 --- a/PC/python.manifest +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - diff --git a/PC/python3dll.c b/PC/python3dll.c deleted file mode 100755 index 08d3c524e49575c91f1fcc9fb433d356fd4b651b..0000000000000000000000000000000000000000 --- a/PC/python3dll.c +++ /dev/null @@ -1,855 +0,0 @@ - -/* Re-export stable Python ABI */ - -/* Generated by Tools/scripts/stable_abi.py */ - -#ifdef _M_IX86 -#define DECORATE "_" -#else -#define DECORATE -#endif - -#define EXPORT_FUNC(name) \ - __pragma(comment(linker, "/EXPORT:" DECORATE #name "=" PYTHON_DLL_NAME "." #name)) -#define EXPORT_DATA(name) \ - __pragma(comment(linker, "/EXPORT:" DECORATE #name "=" PYTHON_DLL_NAME "." #name ",DATA")) - -EXPORT_FUNC(_Py_BuildValue_SizeT) -EXPORT_FUNC(_Py_CheckRecursiveCall) -EXPORT_FUNC(_Py_Dealloc) -EXPORT_FUNC(_Py_DecRef) -EXPORT_FUNC(_Py_IncRef) -EXPORT_FUNC(_Py_VaBuildValue_SizeT) -EXPORT_FUNC(_PyArg_Parse_SizeT) -EXPORT_FUNC(_PyArg_ParseTuple_SizeT) -EXPORT_FUNC(_PyArg_ParseTupleAndKeywords_SizeT) -EXPORT_FUNC(_PyArg_VaParse_SizeT) -EXPORT_FUNC(_PyArg_VaParseTupleAndKeywords_SizeT) -EXPORT_FUNC(_PyErr_BadInternalCall) -EXPORT_FUNC(_PyObject_CallFunction_SizeT) -EXPORT_FUNC(_PyObject_CallMethod_SizeT) -EXPORT_FUNC(_PyObject_GC_Malloc) -EXPORT_FUNC(_PyObject_GC_New) -EXPORT_FUNC(_PyObject_GC_NewVar) -EXPORT_FUNC(_PyObject_GC_Resize) -EXPORT_FUNC(_PyObject_New) -EXPORT_FUNC(_PyObject_NewVar) -EXPORT_FUNC(_PyState_AddModule) -EXPORT_FUNC(_PyThreadState_Init) -EXPORT_FUNC(_PyThreadState_Prealloc) -EXPORT_FUNC(_PyTrash_deposit_object) -EXPORT_FUNC(_PyTrash_destroy_chain) -EXPORT_FUNC(_PyTrash_thread_deposit_object) -EXPORT_FUNC(_PyTrash_thread_destroy_chain) -EXPORT_FUNC(Py_AddPendingCall) -EXPORT_FUNC(Py_AtExit) -EXPORT_FUNC(Py_BuildValue) -EXPORT_FUNC(Py_BytesMain) -EXPORT_FUNC(Py_CompileString) -EXPORT_FUNC(Py_DecodeLocale) -EXPORT_FUNC(Py_DecRef) -EXPORT_FUNC(Py_EncodeLocale) -EXPORT_FUNC(Py_EndInterpreter) -EXPORT_FUNC(Py_EnterRecursiveCall) -EXPORT_FUNC(Py_Exit) -EXPORT_FUNC(Py_FatalError) -EXPORT_FUNC(Py_Finalize) -EXPORT_FUNC(Py_FinalizeEx) -EXPORT_FUNC(Py_GenericAlias) -EXPORT_FUNC(Py_GetArgcArgv) -EXPORT_FUNC(Py_GetBuildInfo) -EXPORT_FUNC(Py_GetCompiler) -EXPORT_FUNC(Py_GetCopyright) -EXPORT_FUNC(Py_GetExecPrefix) -EXPORT_FUNC(Py_GetPath) -EXPORT_FUNC(Py_GetPlatform) -EXPORT_FUNC(Py_GetPrefix) -EXPORT_FUNC(Py_GetProgramFullPath) -EXPORT_FUNC(Py_GetProgramName) -EXPORT_FUNC(Py_GetPythonHome) -EXPORT_FUNC(Py_GetRecursionLimit) -EXPORT_FUNC(Py_GetVersion) -EXPORT_FUNC(Py_IncRef) -EXPORT_FUNC(Py_Initialize) -EXPORT_FUNC(Py_InitializeEx) -EXPORT_FUNC(Py_Is) -EXPORT_FUNC(Py_IsFalse) -EXPORT_FUNC(Py_IsInitialized) -EXPORT_FUNC(Py_IsNone) -EXPORT_FUNC(Py_IsTrue) -EXPORT_FUNC(Py_LeaveRecursiveCall) -EXPORT_FUNC(Py_Main) -EXPORT_FUNC(Py_MakePendingCalls) -EXPORT_FUNC(Py_NewInterpreter) -EXPORT_FUNC(Py_NewRef) -EXPORT_FUNC(Py_ReprEnter) -EXPORT_FUNC(Py_ReprLeave) -EXPORT_FUNC(Py_SetPath) -EXPORT_FUNC(Py_SetProgramName) -EXPORT_FUNC(Py_SetPythonHome) -EXPORT_FUNC(Py_SetRecursionLimit) -EXPORT_FUNC(Py_VaBuildValue) -EXPORT_FUNC(Py_XNewRef) -EXPORT_FUNC(PyAIter_Check) -EXPORT_FUNC(PyArg_Parse) -EXPORT_FUNC(PyArg_ParseTuple) -EXPORT_FUNC(PyArg_ParseTupleAndKeywords) -EXPORT_FUNC(PyArg_UnpackTuple) -EXPORT_FUNC(PyArg_ValidateKeywordArguments) -EXPORT_FUNC(PyArg_VaParse) -EXPORT_FUNC(PyArg_VaParseTupleAndKeywords) -EXPORT_FUNC(PyBool_FromLong) -EXPORT_FUNC(PyByteArray_AsString) -EXPORT_FUNC(PyByteArray_Concat) -EXPORT_FUNC(PyByteArray_FromObject) -EXPORT_FUNC(PyByteArray_FromStringAndSize) -EXPORT_FUNC(PyByteArray_Resize) -EXPORT_FUNC(PyByteArray_Size) -EXPORT_FUNC(PyBytes_AsString) -EXPORT_FUNC(PyBytes_AsStringAndSize) -EXPORT_FUNC(PyBytes_Concat) -EXPORT_FUNC(PyBytes_ConcatAndDel) -EXPORT_FUNC(PyBytes_DecodeEscape) -EXPORT_FUNC(PyBytes_FromFormat) -EXPORT_FUNC(PyBytes_FromFormatV) -EXPORT_FUNC(PyBytes_FromObject) -EXPORT_FUNC(PyBytes_FromString) -EXPORT_FUNC(PyBytes_FromStringAndSize) -EXPORT_FUNC(PyBytes_Repr) -EXPORT_FUNC(PyBytes_Size) -EXPORT_FUNC(PyCallable_Check) -EXPORT_FUNC(PyCallIter_New) -EXPORT_FUNC(PyCapsule_GetContext) -EXPORT_FUNC(PyCapsule_GetDestructor) -EXPORT_FUNC(PyCapsule_GetName) -EXPORT_FUNC(PyCapsule_GetPointer) -EXPORT_FUNC(PyCapsule_Import) -EXPORT_FUNC(PyCapsule_IsValid) -EXPORT_FUNC(PyCapsule_New) -EXPORT_FUNC(PyCapsule_SetContext) -EXPORT_FUNC(PyCapsule_SetDestructor) -EXPORT_FUNC(PyCapsule_SetName) -EXPORT_FUNC(PyCapsule_SetPointer) -EXPORT_FUNC(PyCFunction_Call) -EXPORT_FUNC(PyCFunction_GetFlags) -EXPORT_FUNC(PyCFunction_GetFunction) -EXPORT_FUNC(PyCFunction_GetSelf) -EXPORT_FUNC(PyCFunction_New) -EXPORT_FUNC(PyCFunction_NewEx) -EXPORT_FUNC(PyCMethod_New) -EXPORT_FUNC(PyCodec_BackslashReplaceErrors) -EXPORT_FUNC(PyCodec_Decode) -EXPORT_FUNC(PyCodec_Decoder) -EXPORT_FUNC(PyCodec_Encode) -EXPORT_FUNC(PyCodec_Encoder) -EXPORT_FUNC(PyCodec_IgnoreErrors) -EXPORT_FUNC(PyCodec_IncrementalDecoder) -EXPORT_FUNC(PyCodec_IncrementalEncoder) -EXPORT_FUNC(PyCodec_KnownEncoding) -EXPORT_FUNC(PyCodec_LookupError) -EXPORT_FUNC(PyCodec_NameReplaceErrors) -EXPORT_FUNC(PyCodec_Register) -EXPORT_FUNC(PyCodec_RegisterError) -EXPORT_FUNC(PyCodec_ReplaceErrors) -EXPORT_FUNC(PyCodec_StreamReader) -EXPORT_FUNC(PyCodec_StreamWriter) -EXPORT_FUNC(PyCodec_StrictErrors) -EXPORT_FUNC(PyCodec_Unregister) -EXPORT_FUNC(PyCodec_XMLCharRefReplaceErrors) -EXPORT_FUNC(PyComplex_FromDoubles) -EXPORT_FUNC(PyComplex_ImagAsDouble) -EXPORT_FUNC(PyComplex_RealAsDouble) -EXPORT_FUNC(PyDescr_NewClassMethod) -EXPORT_FUNC(PyDescr_NewGetSet) -EXPORT_FUNC(PyDescr_NewMember) -EXPORT_FUNC(PyDescr_NewMethod) -EXPORT_FUNC(PyDict_Clear) -EXPORT_FUNC(PyDict_Contains) -EXPORT_FUNC(PyDict_Copy) -EXPORT_FUNC(PyDict_DelItem) -EXPORT_FUNC(PyDict_DelItemString) -EXPORT_FUNC(PyDict_GetItem) -EXPORT_FUNC(PyDict_GetItemString) -EXPORT_FUNC(PyDict_GetItemWithError) -EXPORT_FUNC(PyDict_Items) -EXPORT_FUNC(PyDict_Keys) -EXPORT_FUNC(PyDict_Merge) -EXPORT_FUNC(PyDict_MergeFromSeq2) -EXPORT_FUNC(PyDict_New) -EXPORT_FUNC(PyDict_Next) -EXPORT_FUNC(PyDict_SetItem) -EXPORT_FUNC(PyDict_SetItemString) -EXPORT_FUNC(PyDict_Size) -EXPORT_FUNC(PyDict_Update) -EXPORT_FUNC(PyDict_Values) -EXPORT_FUNC(PyDictProxy_New) -EXPORT_FUNC(PyErr_BadArgument) -EXPORT_FUNC(PyErr_BadInternalCall) -EXPORT_FUNC(PyErr_CheckSignals) -EXPORT_FUNC(PyErr_Clear) -EXPORT_FUNC(PyErr_Display) -EXPORT_FUNC(PyErr_ExceptionMatches) -EXPORT_FUNC(PyErr_Fetch) -EXPORT_FUNC(PyErr_Format) -EXPORT_FUNC(PyErr_FormatV) -EXPORT_FUNC(PyErr_GetExcInfo) -EXPORT_FUNC(PyErr_GivenExceptionMatches) -EXPORT_FUNC(PyErr_NewException) -EXPORT_FUNC(PyErr_NewExceptionWithDoc) -EXPORT_FUNC(PyErr_NoMemory) -EXPORT_FUNC(PyErr_NormalizeException) -EXPORT_FUNC(PyErr_Occurred) -EXPORT_FUNC(PyErr_Print) -EXPORT_FUNC(PyErr_PrintEx) -EXPORT_FUNC(PyErr_ProgramText) -EXPORT_FUNC(PyErr_ResourceWarning) -EXPORT_FUNC(PyErr_Restore) -EXPORT_FUNC(PyErr_SetExcFromWindowsErr) -EXPORT_FUNC(PyErr_SetExcFromWindowsErrWithFilename) -EXPORT_FUNC(PyErr_SetExcFromWindowsErrWithFilenameObject) -EXPORT_FUNC(PyErr_SetExcFromWindowsErrWithFilenameObjects) -EXPORT_FUNC(PyErr_SetExcInfo) -EXPORT_FUNC(PyErr_SetFromErrno) -EXPORT_FUNC(PyErr_SetFromErrnoWithFilename) -EXPORT_FUNC(PyErr_SetFromErrnoWithFilenameObject) -EXPORT_FUNC(PyErr_SetFromErrnoWithFilenameObjects) -EXPORT_FUNC(PyErr_SetFromWindowsErr) -EXPORT_FUNC(PyErr_SetFromWindowsErrWithFilename) -EXPORT_FUNC(PyErr_SetImportError) -EXPORT_FUNC(PyErr_SetImportErrorSubclass) -EXPORT_FUNC(PyErr_SetInterrupt) -EXPORT_FUNC(PyErr_SetInterruptEx) -EXPORT_FUNC(PyErr_SetNone) -EXPORT_FUNC(PyErr_SetObject) -EXPORT_FUNC(PyErr_SetString) -EXPORT_FUNC(PyErr_SyntaxLocation) -EXPORT_FUNC(PyErr_SyntaxLocationEx) -EXPORT_FUNC(PyErr_WarnEx) -EXPORT_FUNC(PyErr_WarnExplicit) -EXPORT_FUNC(PyErr_WarnFormat) -EXPORT_FUNC(PyErr_WriteUnraisable) -EXPORT_FUNC(PyEval_AcquireLock) -EXPORT_FUNC(PyEval_AcquireThread) -EXPORT_FUNC(PyEval_CallFunction) -EXPORT_FUNC(PyEval_CallMethod) -EXPORT_FUNC(PyEval_CallObjectWithKeywords) -EXPORT_FUNC(PyEval_EvalCode) -EXPORT_FUNC(PyEval_EvalCodeEx) -EXPORT_FUNC(PyEval_EvalFrame) -EXPORT_FUNC(PyEval_EvalFrameEx) -EXPORT_FUNC(PyEval_GetBuiltins) -EXPORT_FUNC(PyEval_GetFrame) -EXPORT_FUNC(PyEval_GetFuncDesc) -EXPORT_FUNC(PyEval_GetFuncName) -EXPORT_FUNC(PyEval_GetGlobals) -EXPORT_FUNC(PyEval_GetLocals) -EXPORT_FUNC(PyEval_InitThreads) -EXPORT_FUNC(PyEval_ReleaseLock) -EXPORT_FUNC(PyEval_ReleaseThread) -EXPORT_FUNC(PyEval_RestoreThread) -EXPORT_FUNC(PyEval_SaveThread) -EXPORT_FUNC(PyEval_ThreadsInitialized) -EXPORT_FUNC(PyException_GetCause) -EXPORT_FUNC(PyException_GetContext) -EXPORT_FUNC(PyException_GetTraceback) -EXPORT_FUNC(PyException_SetCause) -EXPORT_FUNC(PyException_SetContext) -EXPORT_FUNC(PyException_SetTraceback) -EXPORT_FUNC(PyExceptionClass_Name) -EXPORT_FUNC(PyFile_FromFd) -EXPORT_FUNC(PyFile_GetLine) -EXPORT_FUNC(PyFile_WriteObject) -EXPORT_FUNC(PyFile_WriteString) -EXPORT_FUNC(PyFloat_AsDouble) -EXPORT_FUNC(PyFloat_FromDouble) -EXPORT_FUNC(PyFloat_FromString) -EXPORT_FUNC(PyFloat_GetInfo) -EXPORT_FUNC(PyFloat_GetMax) -EXPORT_FUNC(PyFloat_GetMin) -EXPORT_FUNC(PyFrame_GetCode) -EXPORT_FUNC(PyFrame_GetLineNumber) -EXPORT_FUNC(PyFrozenSet_New) -EXPORT_FUNC(PyGC_Collect) -EXPORT_FUNC(PyGC_Disable) -EXPORT_FUNC(PyGC_Enable) -EXPORT_FUNC(PyGC_IsEnabled) -EXPORT_FUNC(PyGILState_Ensure) -EXPORT_FUNC(PyGILState_GetThisThreadState) -EXPORT_FUNC(PyGILState_Release) -EXPORT_FUNC(PyImport_AddModule) -EXPORT_FUNC(PyImport_AddModuleObject) -EXPORT_FUNC(PyImport_AppendInittab) -EXPORT_FUNC(PyImport_ExecCodeModule) -EXPORT_FUNC(PyImport_ExecCodeModuleEx) -EXPORT_FUNC(PyImport_ExecCodeModuleObject) -EXPORT_FUNC(PyImport_ExecCodeModuleWithPathnames) -EXPORT_FUNC(PyImport_GetImporter) -EXPORT_FUNC(PyImport_GetMagicNumber) -EXPORT_FUNC(PyImport_GetMagicTag) -EXPORT_FUNC(PyImport_GetModule) -EXPORT_FUNC(PyImport_GetModuleDict) -EXPORT_FUNC(PyImport_Import) -EXPORT_FUNC(PyImport_ImportFrozenModule) -EXPORT_FUNC(PyImport_ImportFrozenModuleObject) -EXPORT_FUNC(PyImport_ImportModule) -EXPORT_FUNC(PyImport_ImportModuleLevel) -EXPORT_FUNC(PyImport_ImportModuleLevelObject) -EXPORT_FUNC(PyImport_ImportModuleNoBlock) -EXPORT_FUNC(PyImport_ReloadModule) -EXPORT_FUNC(PyIndex_Check) -EXPORT_FUNC(PyInterpreterState_Clear) -EXPORT_FUNC(PyInterpreterState_Delete) -EXPORT_FUNC(PyInterpreterState_Get) -EXPORT_FUNC(PyInterpreterState_GetDict) -EXPORT_FUNC(PyInterpreterState_GetID) -EXPORT_FUNC(PyInterpreterState_New) -EXPORT_FUNC(PyIter_Check) -EXPORT_FUNC(PyIter_Next) -EXPORT_FUNC(PyIter_Send) -EXPORT_FUNC(PyList_Append) -EXPORT_FUNC(PyList_AsTuple) -EXPORT_FUNC(PyList_GetItem) -EXPORT_FUNC(PyList_GetSlice) -EXPORT_FUNC(PyList_Insert) -EXPORT_FUNC(PyList_New) -EXPORT_FUNC(PyList_Reverse) -EXPORT_FUNC(PyList_SetItem) -EXPORT_FUNC(PyList_SetSlice) -EXPORT_FUNC(PyList_Size) -EXPORT_FUNC(PyList_Sort) -EXPORT_FUNC(PyLong_AsDouble) -EXPORT_FUNC(PyLong_AsLong) -EXPORT_FUNC(PyLong_AsLongAndOverflow) -EXPORT_FUNC(PyLong_AsLongLong) -EXPORT_FUNC(PyLong_AsLongLongAndOverflow) -EXPORT_FUNC(PyLong_AsSize_t) -EXPORT_FUNC(PyLong_AsSsize_t) -EXPORT_FUNC(PyLong_AsUnsignedLong) -EXPORT_FUNC(PyLong_AsUnsignedLongLong) -EXPORT_FUNC(PyLong_AsUnsignedLongLongMask) -EXPORT_FUNC(PyLong_AsUnsignedLongMask) -EXPORT_FUNC(PyLong_AsVoidPtr) -EXPORT_FUNC(PyLong_FromDouble) -EXPORT_FUNC(PyLong_FromLong) -EXPORT_FUNC(PyLong_FromLongLong) -EXPORT_FUNC(PyLong_FromSize_t) -EXPORT_FUNC(PyLong_FromSsize_t) -EXPORT_FUNC(PyLong_FromString) -EXPORT_FUNC(PyLong_FromUnsignedLong) -EXPORT_FUNC(PyLong_FromUnsignedLongLong) -EXPORT_FUNC(PyLong_FromVoidPtr) -EXPORT_FUNC(PyLong_GetInfo) -EXPORT_FUNC(PyMapping_Check) -EXPORT_FUNC(PyMapping_GetItemString) -EXPORT_FUNC(PyMapping_HasKey) -EXPORT_FUNC(PyMapping_HasKeyString) -EXPORT_FUNC(PyMapping_Items) -EXPORT_FUNC(PyMapping_Keys) -EXPORT_FUNC(PyMapping_Length) -EXPORT_FUNC(PyMapping_SetItemString) -EXPORT_FUNC(PyMapping_Size) -EXPORT_FUNC(PyMapping_Values) -EXPORT_FUNC(PyMarshal_ReadObjectFromString) -EXPORT_FUNC(PyMarshal_WriteObjectToString) -EXPORT_FUNC(PyMem_Calloc) -EXPORT_FUNC(PyMem_Free) -EXPORT_FUNC(PyMem_Malloc) -EXPORT_FUNC(PyMem_Realloc) -EXPORT_FUNC(PyMember_GetOne) -EXPORT_FUNC(PyMember_SetOne) -EXPORT_FUNC(PyMemoryView_FromMemory) -EXPORT_FUNC(PyMemoryView_FromObject) -EXPORT_FUNC(PyMemoryView_GetContiguous) -EXPORT_FUNC(PyModule_AddFunctions) -EXPORT_FUNC(PyModule_AddIntConstant) -EXPORT_FUNC(PyModule_AddObject) -EXPORT_FUNC(PyModule_AddObjectRef) -EXPORT_FUNC(PyModule_AddStringConstant) -EXPORT_FUNC(PyModule_AddType) -EXPORT_FUNC(PyModule_Create2) -EXPORT_FUNC(PyModule_ExecDef) -EXPORT_FUNC(PyModule_FromDefAndSpec2) -EXPORT_FUNC(PyModule_GetDef) -EXPORT_FUNC(PyModule_GetDict) -EXPORT_FUNC(PyModule_GetFilename) -EXPORT_FUNC(PyModule_GetFilenameObject) -EXPORT_FUNC(PyModule_GetName) -EXPORT_FUNC(PyModule_GetNameObject) -EXPORT_FUNC(PyModule_GetState) -EXPORT_FUNC(PyModule_New) -EXPORT_FUNC(PyModule_NewObject) -EXPORT_FUNC(PyModule_SetDocString) -EXPORT_FUNC(PyModuleDef_Init) -EXPORT_FUNC(PyNumber_Absolute) -EXPORT_FUNC(PyNumber_Add) -EXPORT_FUNC(PyNumber_And) -EXPORT_FUNC(PyNumber_AsSsize_t) -EXPORT_FUNC(PyNumber_Check) -EXPORT_FUNC(PyNumber_Divmod) -EXPORT_FUNC(PyNumber_Float) -EXPORT_FUNC(PyNumber_FloorDivide) -EXPORT_FUNC(PyNumber_Index) -EXPORT_FUNC(PyNumber_InPlaceAdd) -EXPORT_FUNC(PyNumber_InPlaceAnd) -EXPORT_FUNC(PyNumber_InPlaceFloorDivide) -EXPORT_FUNC(PyNumber_InPlaceLshift) -EXPORT_FUNC(PyNumber_InPlaceMatrixMultiply) -EXPORT_FUNC(PyNumber_InPlaceMultiply) -EXPORT_FUNC(PyNumber_InPlaceOr) -EXPORT_FUNC(PyNumber_InPlacePower) -EXPORT_FUNC(PyNumber_InPlaceRemainder) -EXPORT_FUNC(PyNumber_InPlaceRshift) -EXPORT_FUNC(PyNumber_InPlaceSubtract) -EXPORT_FUNC(PyNumber_InPlaceTrueDivide) -EXPORT_FUNC(PyNumber_InPlaceXor) -EXPORT_FUNC(PyNumber_Invert) -EXPORT_FUNC(PyNumber_Long) -EXPORT_FUNC(PyNumber_Lshift) -EXPORT_FUNC(PyNumber_MatrixMultiply) -EXPORT_FUNC(PyNumber_Multiply) -EXPORT_FUNC(PyNumber_Negative) -EXPORT_FUNC(PyNumber_Or) -EXPORT_FUNC(PyNumber_Positive) -EXPORT_FUNC(PyNumber_Power) -EXPORT_FUNC(PyNumber_Remainder) -EXPORT_FUNC(PyNumber_Rshift) -EXPORT_FUNC(PyNumber_Subtract) -EXPORT_FUNC(PyNumber_ToBase) -EXPORT_FUNC(PyNumber_TrueDivide) -EXPORT_FUNC(PyNumber_Xor) -EXPORT_FUNC(PyObject_AsCharBuffer) -EXPORT_FUNC(PyObject_ASCII) -EXPORT_FUNC(PyObject_AsFileDescriptor) -EXPORT_FUNC(PyObject_AsReadBuffer) -EXPORT_FUNC(PyObject_AsWriteBuffer) -EXPORT_FUNC(PyObject_Bytes) -EXPORT_FUNC(PyObject_Call) -EXPORT_FUNC(PyObject_CallFunction) -EXPORT_FUNC(PyObject_CallFunctionObjArgs) -EXPORT_FUNC(PyObject_CallMethod) -EXPORT_FUNC(PyObject_CallMethodObjArgs) -EXPORT_FUNC(PyObject_CallNoArgs) -EXPORT_FUNC(PyObject_CallObject) -EXPORT_FUNC(PyObject_Calloc) -EXPORT_FUNC(PyObject_CheckReadBuffer) -EXPORT_FUNC(PyObject_ClearWeakRefs) -EXPORT_FUNC(PyObject_DelItem) -EXPORT_FUNC(PyObject_DelItemString) -EXPORT_FUNC(PyObject_Dir) -EXPORT_FUNC(PyObject_Format) -EXPORT_FUNC(PyObject_Free) -EXPORT_FUNC(PyObject_GC_Del) -EXPORT_FUNC(PyObject_GC_IsFinalized) -EXPORT_FUNC(PyObject_GC_IsTracked) -EXPORT_FUNC(PyObject_GC_Track) -EXPORT_FUNC(PyObject_GC_UnTrack) -EXPORT_FUNC(PyObject_GenericGetAttr) -EXPORT_FUNC(PyObject_GenericGetDict) -EXPORT_FUNC(PyObject_GenericSetAttr) -EXPORT_FUNC(PyObject_GenericSetDict) -EXPORT_FUNC(PyObject_GetAIter) -EXPORT_FUNC(PyObject_GetAttr) -EXPORT_FUNC(PyObject_GetAttrString) -EXPORT_FUNC(PyObject_GetItem) -EXPORT_FUNC(PyObject_GetIter) -EXPORT_FUNC(PyObject_HasAttr) -EXPORT_FUNC(PyObject_HasAttrString) -EXPORT_FUNC(PyObject_Hash) -EXPORT_FUNC(PyObject_HashNotImplemented) -EXPORT_FUNC(PyObject_Init) -EXPORT_FUNC(PyObject_InitVar) -EXPORT_FUNC(PyObject_IsInstance) -EXPORT_FUNC(PyObject_IsSubclass) -EXPORT_FUNC(PyObject_IsTrue) -EXPORT_FUNC(PyObject_Length) -EXPORT_FUNC(PyObject_Malloc) -EXPORT_FUNC(PyObject_Not) -EXPORT_FUNC(PyObject_Realloc) -EXPORT_FUNC(PyObject_Repr) -EXPORT_FUNC(PyObject_RichCompare) -EXPORT_FUNC(PyObject_RichCompareBool) -EXPORT_FUNC(PyObject_SelfIter) -EXPORT_FUNC(PyObject_SetAttr) -EXPORT_FUNC(PyObject_SetAttrString) -EXPORT_FUNC(PyObject_SetItem) -EXPORT_FUNC(PyObject_Size) -EXPORT_FUNC(PyObject_Str) -EXPORT_FUNC(PyObject_Type) -EXPORT_FUNC(PyOS_double_to_string) -EXPORT_FUNC(PyOS_FSPath) -EXPORT_FUNC(PyOS_getsig) -EXPORT_FUNC(PyOS_InterruptOccurred) -EXPORT_FUNC(PyOS_mystricmp) -EXPORT_FUNC(PyOS_mystrnicmp) -EXPORT_FUNC(PyOS_setsig) -EXPORT_FUNC(PyOS_snprintf) -EXPORT_FUNC(PyOS_string_to_double) -EXPORT_FUNC(PyOS_strtol) -EXPORT_FUNC(PyOS_strtoul) -EXPORT_FUNC(PyOS_vsnprintf) -EXPORT_FUNC(PySeqIter_New) -EXPORT_FUNC(PySequence_Check) -EXPORT_FUNC(PySequence_Concat) -EXPORT_FUNC(PySequence_Contains) -EXPORT_FUNC(PySequence_Count) -EXPORT_FUNC(PySequence_DelItem) -EXPORT_FUNC(PySequence_DelSlice) -EXPORT_FUNC(PySequence_Fast) -EXPORT_FUNC(PySequence_GetItem) -EXPORT_FUNC(PySequence_GetSlice) -EXPORT_FUNC(PySequence_In) -EXPORT_FUNC(PySequence_Index) -EXPORT_FUNC(PySequence_InPlaceConcat) -EXPORT_FUNC(PySequence_InPlaceRepeat) -EXPORT_FUNC(PySequence_Length) -EXPORT_FUNC(PySequence_List) -EXPORT_FUNC(PySequence_Repeat) -EXPORT_FUNC(PySequence_SetItem) -EXPORT_FUNC(PySequence_SetSlice) -EXPORT_FUNC(PySequence_Size) -EXPORT_FUNC(PySequence_Tuple) -EXPORT_FUNC(PySet_Add) -EXPORT_FUNC(PySet_Clear) -EXPORT_FUNC(PySet_Contains) -EXPORT_FUNC(PySet_Discard) -EXPORT_FUNC(PySet_New) -EXPORT_FUNC(PySet_Pop) -EXPORT_FUNC(PySet_Size) -EXPORT_FUNC(PySlice_AdjustIndices) -EXPORT_FUNC(PySlice_GetIndices) -EXPORT_FUNC(PySlice_GetIndicesEx) -EXPORT_FUNC(PySlice_New) -EXPORT_FUNC(PySlice_Unpack) -EXPORT_FUNC(PyState_AddModule) -EXPORT_FUNC(PyState_FindModule) -EXPORT_FUNC(PyState_RemoveModule) -EXPORT_FUNC(PyStructSequence_GetItem) -EXPORT_FUNC(PyStructSequence_New) -EXPORT_FUNC(PyStructSequence_NewType) -EXPORT_FUNC(PyStructSequence_SetItem) -EXPORT_FUNC(PySys_AddWarnOption) -EXPORT_FUNC(PySys_AddWarnOptionUnicode) -EXPORT_FUNC(PySys_AddXOption) -EXPORT_FUNC(PySys_FormatStderr) -EXPORT_FUNC(PySys_FormatStdout) -EXPORT_FUNC(PySys_GetObject) -EXPORT_FUNC(PySys_GetXOptions) -EXPORT_FUNC(PySys_HasWarnOptions) -EXPORT_FUNC(PySys_ResetWarnOptions) -EXPORT_FUNC(PySys_SetArgv) -EXPORT_FUNC(PySys_SetArgvEx) -EXPORT_FUNC(PySys_SetObject) -EXPORT_FUNC(PySys_SetPath) -EXPORT_FUNC(PySys_WriteStderr) -EXPORT_FUNC(PySys_WriteStdout) -EXPORT_FUNC(PyThread_acquire_lock) -EXPORT_FUNC(PyThread_acquire_lock_timed) -EXPORT_FUNC(PyThread_allocate_lock) -EXPORT_FUNC(PyThread_create_key) -EXPORT_FUNC(PyThread_delete_key) -EXPORT_FUNC(PyThread_delete_key_value) -EXPORT_FUNC(PyThread_exit_thread) -EXPORT_FUNC(PyThread_free_lock) -EXPORT_FUNC(PyThread_get_key_value) -EXPORT_FUNC(PyThread_get_stacksize) -EXPORT_FUNC(PyThread_get_thread_ident) -EXPORT_FUNC(PyThread_get_thread_native_id) -EXPORT_FUNC(PyThread_GetInfo) -EXPORT_FUNC(PyThread_init_thread) -EXPORT_FUNC(PyThread_ReInitTLS) -EXPORT_FUNC(PyThread_release_lock) -EXPORT_FUNC(PyThread_set_key_value) -EXPORT_FUNC(PyThread_set_stacksize) -EXPORT_FUNC(PyThread_start_new_thread) -EXPORT_FUNC(PyThread_tss_alloc) -EXPORT_FUNC(PyThread_tss_create) -EXPORT_FUNC(PyThread_tss_delete) -EXPORT_FUNC(PyThread_tss_free) -EXPORT_FUNC(PyThread_tss_get) -EXPORT_FUNC(PyThread_tss_is_created) -EXPORT_FUNC(PyThread_tss_set) -EXPORT_FUNC(PyThreadState_Clear) -EXPORT_FUNC(PyThreadState_Delete) -EXPORT_FUNC(PyThreadState_DeleteCurrent) -EXPORT_FUNC(PyThreadState_Get) -EXPORT_FUNC(PyThreadState_GetDict) -EXPORT_FUNC(PyThreadState_GetFrame) -EXPORT_FUNC(PyThreadState_GetID) -EXPORT_FUNC(PyThreadState_GetInterpreter) -EXPORT_FUNC(PyThreadState_New) -EXPORT_FUNC(PyThreadState_SetAsyncExc) -EXPORT_FUNC(PyThreadState_Swap) -EXPORT_FUNC(PyTraceBack_Here) -EXPORT_FUNC(PyTraceBack_Print) -EXPORT_FUNC(PyTuple_GetItem) -EXPORT_FUNC(PyTuple_GetSlice) -EXPORT_FUNC(PyTuple_New) -EXPORT_FUNC(PyTuple_Pack) -EXPORT_FUNC(PyTuple_SetItem) -EXPORT_FUNC(PyTuple_Size) -EXPORT_FUNC(PyType_ClearCache) -EXPORT_FUNC(PyType_FromModuleAndSpec) -EXPORT_FUNC(PyType_FromSpec) -EXPORT_FUNC(PyType_FromSpecWithBases) -EXPORT_FUNC(PyType_GenericAlloc) -EXPORT_FUNC(PyType_GenericNew) -EXPORT_FUNC(PyType_GetFlags) -EXPORT_FUNC(PyType_GetModule) -EXPORT_FUNC(PyType_GetModuleState) -EXPORT_FUNC(PyType_GetSlot) -EXPORT_FUNC(PyType_IsSubtype) -EXPORT_FUNC(PyType_Modified) -EXPORT_FUNC(PyType_Ready) -EXPORT_FUNC(PyUnicode_Append) -EXPORT_FUNC(PyUnicode_AppendAndDel) -EXPORT_FUNC(PyUnicode_AsASCIIString) -EXPORT_FUNC(PyUnicode_AsCharmapString) -EXPORT_FUNC(PyUnicode_AsDecodedObject) -EXPORT_FUNC(PyUnicode_AsDecodedUnicode) -EXPORT_FUNC(PyUnicode_AsEncodedObject) -EXPORT_FUNC(PyUnicode_AsEncodedString) -EXPORT_FUNC(PyUnicode_AsEncodedUnicode) -EXPORT_FUNC(PyUnicode_AsLatin1String) -EXPORT_FUNC(PyUnicode_AsMBCSString) -EXPORT_FUNC(PyUnicode_AsRawUnicodeEscapeString) -EXPORT_FUNC(PyUnicode_AsUCS4) -EXPORT_FUNC(PyUnicode_AsUCS4Copy) -EXPORT_FUNC(PyUnicode_AsUnicodeEscapeString) -EXPORT_FUNC(PyUnicode_AsUTF16String) -EXPORT_FUNC(PyUnicode_AsUTF32String) -EXPORT_FUNC(PyUnicode_AsUTF8AndSize) -EXPORT_FUNC(PyUnicode_AsUTF8String) -EXPORT_FUNC(PyUnicode_AsWideChar) -EXPORT_FUNC(PyUnicode_AsWideCharString) -EXPORT_FUNC(PyUnicode_BuildEncodingMap) -EXPORT_FUNC(PyUnicode_Compare) -EXPORT_FUNC(PyUnicode_CompareWithASCIIString) -EXPORT_FUNC(PyUnicode_Concat) -EXPORT_FUNC(PyUnicode_Contains) -EXPORT_FUNC(PyUnicode_Count) -EXPORT_FUNC(PyUnicode_Decode) -EXPORT_FUNC(PyUnicode_DecodeASCII) -EXPORT_FUNC(PyUnicode_DecodeCharmap) -EXPORT_FUNC(PyUnicode_DecodeCodePageStateful) -EXPORT_FUNC(PyUnicode_DecodeFSDefault) -EXPORT_FUNC(PyUnicode_DecodeFSDefaultAndSize) -EXPORT_FUNC(PyUnicode_DecodeLatin1) -EXPORT_FUNC(PyUnicode_DecodeLocale) -EXPORT_FUNC(PyUnicode_DecodeLocaleAndSize) -EXPORT_FUNC(PyUnicode_DecodeMBCS) -EXPORT_FUNC(PyUnicode_DecodeMBCSStateful) -EXPORT_FUNC(PyUnicode_DecodeRawUnicodeEscape) -EXPORT_FUNC(PyUnicode_DecodeUnicodeEscape) -EXPORT_FUNC(PyUnicode_DecodeUTF16) -EXPORT_FUNC(PyUnicode_DecodeUTF16Stateful) -EXPORT_FUNC(PyUnicode_DecodeUTF32) -EXPORT_FUNC(PyUnicode_DecodeUTF32Stateful) -EXPORT_FUNC(PyUnicode_DecodeUTF7) -EXPORT_FUNC(PyUnicode_DecodeUTF7Stateful) -EXPORT_FUNC(PyUnicode_DecodeUTF8) -EXPORT_FUNC(PyUnicode_DecodeUTF8Stateful) -EXPORT_FUNC(PyUnicode_EncodeCodePage) -EXPORT_FUNC(PyUnicode_EncodeFSDefault) -EXPORT_FUNC(PyUnicode_EncodeLocale) -EXPORT_FUNC(PyUnicode_Find) -EXPORT_FUNC(PyUnicode_FindChar) -EXPORT_FUNC(PyUnicode_Format) -EXPORT_FUNC(PyUnicode_FromEncodedObject) -EXPORT_FUNC(PyUnicode_FromFormat) -EXPORT_FUNC(PyUnicode_FromFormatV) -EXPORT_FUNC(PyUnicode_FromObject) -EXPORT_FUNC(PyUnicode_FromOrdinal) -EXPORT_FUNC(PyUnicode_FromString) -EXPORT_FUNC(PyUnicode_FromStringAndSize) -EXPORT_FUNC(PyUnicode_FromWideChar) -EXPORT_FUNC(PyUnicode_FSConverter) -EXPORT_FUNC(PyUnicode_FSDecoder) -EXPORT_FUNC(PyUnicode_GetDefaultEncoding) -EXPORT_FUNC(PyUnicode_GetLength) -EXPORT_FUNC(PyUnicode_GetSize) -EXPORT_FUNC(PyUnicode_InternFromString) -EXPORT_FUNC(PyUnicode_InternImmortal) -EXPORT_FUNC(PyUnicode_InternInPlace) -EXPORT_FUNC(PyUnicode_IsIdentifier) -EXPORT_FUNC(PyUnicode_Join) -EXPORT_FUNC(PyUnicode_Partition) -EXPORT_FUNC(PyUnicode_ReadChar) -EXPORT_FUNC(PyUnicode_Replace) -EXPORT_FUNC(PyUnicode_Resize) -EXPORT_FUNC(PyUnicode_RichCompare) -EXPORT_FUNC(PyUnicode_RPartition) -EXPORT_FUNC(PyUnicode_RSplit) -EXPORT_FUNC(PyUnicode_Split) -EXPORT_FUNC(PyUnicode_Splitlines) -EXPORT_FUNC(PyUnicode_Substring) -EXPORT_FUNC(PyUnicode_Tailmatch) -EXPORT_FUNC(PyUnicode_Translate) -EXPORT_FUNC(PyUnicode_WriteChar) -EXPORT_FUNC(PyUnicodeDecodeError_Create) -EXPORT_FUNC(PyUnicodeDecodeError_GetEncoding) -EXPORT_FUNC(PyUnicodeDecodeError_GetEnd) -EXPORT_FUNC(PyUnicodeDecodeError_GetObject) -EXPORT_FUNC(PyUnicodeDecodeError_GetReason) -EXPORT_FUNC(PyUnicodeDecodeError_GetStart) -EXPORT_FUNC(PyUnicodeDecodeError_SetEnd) -EXPORT_FUNC(PyUnicodeDecodeError_SetReason) -EXPORT_FUNC(PyUnicodeDecodeError_SetStart) -EXPORT_FUNC(PyUnicodeEncodeError_GetEncoding) -EXPORT_FUNC(PyUnicodeEncodeError_GetEnd) -EXPORT_FUNC(PyUnicodeEncodeError_GetObject) -EXPORT_FUNC(PyUnicodeEncodeError_GetReason) -EXPORT_FUNC(PyUnicodeEncodeError_GetStart) -EXPORT_FUNC(PyUnicodeEncodeError_SetEnd) -EXPORT_FUNC(PyUnicodeEncodeError_SetReason) -EXPORT_FUNC(PyUnicodeEncodeError_SetStart) -EXPORT_FUNC(PyUnicodeTranslateError_GetEnd) -EXPORT_FUNC(PyUnicodeTranslateError_GetObject) -EXPORT_FUNC(PyUnicodeTranslateError_GetReason) -EXPORT_FUNC(PyUnicodeTranslateError_GetStart) -EXPORT_FUNC(PyUnicodeTranslateError_SetEnd) -EXPORT_FUNC(PyUnicodeTranslateError_SetReason) -EXPORT_FUNC(PyUnicodeTranslateError_SetStart) -EXPORT_FUNC(PyWeakref_GetObject) -EXPORT_FUNC(PyWeakref_NewProxy) -EXPORT_FUNC(PyWeakref_NewRef) -EXPORT_FUNC(PyWrapper_New) - -EXPORT_DATA(_Py_EllipsisObject) -EXPORT_DATA(_Py_FalseStruct) -EXPORT_DATA(_Py_NoneStruct) -EXPORT_DATA(_Py_NotImplementedStruct) -EXPORT_DATA(_Py_SwappedOp) -EXPORT_DATA(_Py_TrueStruct) -EXPORT_DATA(_PyWeakref_CallableProxyType) -EXPORT_DATA(_PyWeakref_ProxyType) -EXPORT_DATA(_PyWeakref_RefType) -EXPORT_DATA(Py_FileSystemDefaultEncodeErrors) -EXPORT_DATA(Py_FileSystemDefaultEncoding) -EXPORT_DATA(Py_GenericAliasType) -EXPORT_DATA(Py_HasFileSystemDefaultEncoding) -EXPORT_DATA(Py_UTF8Mode) -EXPORT_DATA(PyBaseObject_Type) -EXPORT_DATA(PyBool_Type) -EXPORT_DATA(PyByteArray_Type) -EXPORT_DATA(PyByteArrayIter_Type) -EXPORT_DATA(PyBytes_Type) -EXPORT_DATA(PyBytesIter_Type) -EXPORT_DATA(PyCallIter_Type) -EXPORT_DATA(PyCapsule_Type) -EXPORT_DATA(PyCFunction_Type) -EXPORT_DATA(PyClassMethodDescr_Type) -EXPORT_DATA(PyComplex_Type) -EXPORT_DATA(PyDict_Type) -EXPORT_DATA(PyDictItems_Type) -EXPORT_DATA(PyDictIterItem_Type) -EXPORT_DATA(PyDictIterKey_Type) -EXPORT_DATA(PyDictIterValue_Type) -EXPORT_DATA(PyDictKeys_Type) -EXPORT_DATA(PyDictProxy_Type) -EXPORT_DATA(PyDictRevIterItem_Type) -EXPORT_DATA(PyDictRevIterKey_Type) -EXPORT_DATA(PyDictRevIterValue_Type) -EXPORT_DATA(PyDictValues_Type) -EXPORT_DATA(PyEllipsis_Type) -EXPORT_DATA(PyEnum_Type) -EXPORT_DATA(PyExc_ArithmeticError) -EXPORT_DATA(PyExc_AssertionError) -EXPORT_DATA(PyExc_AttributeError) -EXPORT_DATA(PyExc_BaseException) -EXPORT_DATA(PyExc_BlockingIOError) -EXPORT_DATA(PyExc_BrokenPipeError) -EXPORT_DATA(PyExc_BufferError) -EXPORT_DATA(PyExc_BytesWarning) -EXPORT_DATA(PyExc_ChildProcessError) -EXPORT_DATA(PyExc_ConnectionAbortedError) -EXPORT_DATA(PyExc_ConnectionError) -EXPORT_DATA(PyExc_ConnectionRefusedError) -EXPORT_DATA(PyExc_ConnectionResetError) -EXPORT_DATA(PyExc_DeprecationWarning) -EXPORT_DATA(PyExc_EncodingWarning) -EXPORT_DATA(PyExc_EnvironmentError) -EXPORT_DATA(PyExc_EOFError) -EXPORT_DATA(PyExc_Exception) -EXPORT_DATA(PyExc_FileExistsError) -EXPORT_DATA(PyExc_FileNotFoundError) -EXPORT_DATA(PyExc_FloatingPointError) -EXPORT_DATA(PyExc_FutureWarning) -EXPORT_DATA(PyExc_GeneratorExit) -EXPORT_DATA(PyExc_ImportError) -EXPORT_DATA(PyExc_ImportWarning) -EXPORT_DATA(PyExc_IndentationError) -EXPORT_DATA(PyExc_IndexError) -EXPORT_DATA(PyExc_InterruptedError) -EXPORT_DATA(PyExc_IOError) -EXPORT_DATA(PyExc_IsADirectoryError) -EXPORT_DATA(PyExc_KeyboardInterrupt) -EXPORT_DATA(PyExc_KeyError) -EXPORT_DATA(PyExc_LookupError) -EXPORT_DATA(PyExc_MemoryError) -EXPORT_DATA(PyExc_ModuleNotFoundError) -EXPORT_DATA(PyExc_NameError) -EXPORT_DATA(PyExc_NotADirectoryError) -EXPORT_DATA(PyExc_NotImplementedError) -EXPORT_DATA(PyExc_OSError) -EXPORT_DATA(PyExc_OverflowError) -EXPORT_DATA(PyExc_PendingDeprecationWarning) -EXPORT_DATA(PyExc_PermissionError) -EXPORT_DATA(PyExc_ProcessLookupError) -EXPORT_DATA(PyExc_RecursionError) -EXPORT_DATA(PyExc_ReferenceError) -EXPORT_DATA(PyExc_ResourceWarning) -EXPORT_DATA(PyExc_RuntimeError) -EXPORT_DATA(PyExc_RuntimeWarning) -EXPORT_DATA(PyExc_StopAsyncIteration) -EXPORT_DATA(PyExc_StopIteration) -EXPORT_DATA(PyExc_SyntaxError) -EXPORT_DATA(PyExc_SyntaxWarning) -EXPORT_DATA(PyExc_SystemError) -EXPORT_DATA(PyExc_SystemExit) -EXPORT_DATA(PyExc_TabError) -EXPORT_DATA(PyExc_TimeoutError) -EXPORT_DATA(PyExc_TypeError) -EXPORT_DATA(PyExc_UnboundLocalError) -EXPORT_DATA(PyExc_UnicodeDecodeError) -EXPORT_DATA(PyExc_UnicodeEncodeError) -EXPORT_DATA(PyExc_UnicodeError) -EXPORT_DATA(PyExc_UnicodeTranslateError) -EXPORT_DATA(PyExc_UnicodeWarning) -EXPORT_DATA(PyExc_UserWarning) -EXPORT_DATA(PyExc_ValueError) -EXPORT_DATA(PyExc_Warning) -EXPORT_DATA(PyExc_WindowsError) -EXPORT_DATA(PyExc_ZeroDivisionError) -EXPORT_DATA(PyFilter_Type) -EXPORT_DATA(PyFloat_Type) -EXPORT_DATA(PyFrozenSet_Type) -EXPORT_DATA(PyGetSetDescr_Type) -EXPORT_DATA(PyList_Type) -EXPORT_DATA(PyListIter_Type) -EXPORT_DATA(PyListRevIter_Type) -EXPORT_DATA(PyLong_Type) -EXPORT_DATA(PyLongRangeIter_Type) -EXPORT_DATA(PyMap_Type) -EXPORT_DATA(PyMemberDescr_Type) -EXPORT_DATA(PyMemoryView_Type) -EXPORT_DATA(PyMethodDescr_Type) -EXPORT_DATA(PyModule_Type) -EXPORT_DATA(PyModuleDef_Type) -EXPORT_DATA(PyOS_InputHook) -EXPORT_DATA(PyProperty_Type) -EXPORT_DATA(PyRange_Type) -EXPORT_DATA(PyRangeIter_Type) -EXPORT_DATA(PyReversed_Type) -EXPORT_DATA(PySeqIter_Type) -EXPORT_DATA(PySet_Type) -EXPORT_DATA(PySetIter_Type) -EXPORT_DATA(PySlice_Type) -EXPORT_DATA(PySuper_Type) -EXPORT_DATA(PyTraceBack_Type) -EXPORT_DATA(PyTuple_Type) -EXPORT_DATA(PyTupleIter_Type) -EXPORT_DATA(PyType_Type) -EXPORT_DATA(PyUnicode_Type) -EXPORT_DATA(PyUnicodeIter_Type) -EXPORT_DATA(PyWrapperDescr_Type) -EXPORT_DATA(PyZip_Type) diff --git a/PC/python_exe.rc b/PC/python_exe.rc deleted file mode 100644 index c3d3bff019895e90ef64b289342720b63799f2e6..0000000000000000000000000000000000000000 --- a/PC/python_exe.rc +++ /dev/null @@ -1,54 +0,0 @@ -// Resource script for Python console EXEs. - -#include "python_ver_rc.h" - -#ifndef RT_MANIFEST -// bpo-45220: Cannot reliably #include RT_MANIFEST from -// anywhere, so we hardcode it -#define RT_MANIFEST 24 -#endif - -// Include the manifest file that indicates we support all -// current versions of Windows. -1 RT_MANIFEST "python.manifest" - -1 ICON DISCARDABLE "icons\python.ico" - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION PYVERSION64 - PRODUCTVERSION PYVERSION64 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_APP - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "CompanyName", PYTHON_COMPANY "\0" - VALUE "FileDescription", "Python\0" - VALUE "FileVersion", PYTHON_VERSION - VALUE "InternalName", "Python Console\0" - VALUE "LegalCopyright", PYTHON_COPYRIGHT "\0" - VALUE "OriginalFilename", "python" PYTHON_DEBUG_EXT ".exe\0" - VALUE "ProductName", "Python\0" - VALUE "ProductVersion", PYTHON_VERSION - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END diff --git a/PC/python_nt.rc b/PC/python_nt.rc deleted file mode 100644 index ae64fbd217af740254c79528f4a55ecab79c9b2e..0000000000000000000000000000000000000000 --- a/PC/python_nt.rc +++ /dev/null @@ -1,51 +0,0 @@ -// Resource script for Python core DLL. - -#include "python_ver_rc.h" - -#ifndef RT_MANIFEST -// bpo-45220: Cannot reliably #include RT_MANIFEST from -// anywhere, so we hardcode it -#define RT_MANIFEST 24 -#endif - -// Include the manifest file that indicates we support all -// current versions of Windows. -2 RT_MANIFEST "python.manifest" - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION PYVERSION64 - PRODUCTVERSION PYVERSION64 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "CompanyName", PYTHON_COMPANY "\0" - VALUE "FileDescription", "Python Core\0" - VALUE "FileVersion", PYTHON_VERSION - VALUE "InternalName", "Python DLL\0" - VALUE "LegalCopyright", PYTHON_COPYRIGHT "\0" - VALUE "OriginalFilename", ORIGINAL_FILENAME "\0" - VALUE "ProductName", "Python\0" - VALUE "ProductVersion", PYTHON_VERSION - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END diff --git a/PC/python_uwp.cpp b/PC/python_uwp.cpp deleted file mode 100644 index 88369e8fbfeb38da48c975b7d1a60ebad41a8d4f..0000000000000000000000000000000000000000 --- a/PC/python_uwp.cpp +++ /dev/null @@ -1,263 +0,0 @@ -/* Main program when embedded in a UWP application on Windows */ - -#include "Python.h" -#include - -#define WIN32_LEAN_AND_MEAN -#include -#include -#include - -#include - -#include -#include - -#ifdef PYTHONW -#ifdef _DEBUG -const wchar_t *PROGNAME = L"pythonw_d.exe"; -#else -const wchar_t *PROGNAME = L"pythonw.exe"; -#endif -#else -#ifdef _DEBUG -const wchar_t *PROGNAME = L"python_d.exe"; -#else -const wchar_t *PROGNAME = L"python.exe"; -#endif -#endif - -static std::wstring -get_user_base() -{ - try { - const auto appData = winrt::Windows::Storage::ApplicationData::Current(); - if (appData) { - const auto localCache = appData.LocalCacheFolder(); - if (localCache) { - auto path = localCache.Path(); - if (!path.empty()) { - return std::wstring(path) + L"\\local-packages"; - } - } - } - } catch (...) { - } - return std::wstring(); -} - -static std::wstring -get_package_family() -{ - try { - const auto package = winrt::Windows::ApplicationModel::Package::Current(); - if (package) { - const auto id = package.Id(); - if (id) { - return std::wstring(id.FamilyName()); - } - } - } - catch (...) { - } - - return std::wstring(); -} - -static std::wstring -get_package_home() -{ - try { - const auto package = winrt::Windows::ApplicationModel::Package::Current(); - if (package) { - const auto path = package.InstalledLocation(); - if (path) { - return std::wstring(path.Path()); - } - } - } - catch (...) { - } - - return std::wstring(); -} - -static PyStatus -set_process_name(PyConfig *config) -{ - PyStatus status = PyStatus_Ok(); - std::wstring executable; - - const auto home = get_package_home(); - const auto family = get_package_family(); - - if (!family.empty()) { - PWSTR localAppData; - if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, - NULL, &localAppData))) { - executable = std::wstring(localAppData) - + L"\\Microsoft\\WindowsApps\\" - + family - + L"\\" - + PROGNAME; - - CoTaskMemFree(localAppData); - } - } - - /* Only use module filename if we don't have a home */ - if (home.empty() && executable.empty()) { - executable.resize(MAX_PATH); - while (true) { - DWORD len = GetModuleFileNameW( - NULL, executable.data(), (DWORD)executable.size()); - if (len == 0) { - executable.clear(); - break; - } else if (len == executable.size() && - GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - executable.resize(len * 2); - } else { - executable.resize(len); - break; - } - } - size_t i = executable.find_last_of(L"/\\"); - if (i == std::wstring::npos) { - executable = PROGNAME; - } else { - executable.replace(i + 1, std::wstring::npos, PROGNAME); - } - } - - if (!home.empty()) { - status = PyConfig_SetString(config, &config->home, home.c_str()); - if (PyStatus_Exception(status)) { - return status; - } - } - - const wchar_t *launcherPath = _wgetenv(L"__PYVENV_LAUNCHER__"); - if (launcherPath) { - if (!executable.empty()) { - status = PyConfig_SetString(config, &config->base_executable, - executable.c_str()); - if (PyStatus_Exception(status)) { - return status; - } - } - - status = PyConfig_SetString( - config, &config->executable, launcherPath); - - /* bpo-35873: Clear the environment variable to avoid it being - * inherited by child processes. */ - _wputenv_s(L"__PYVENV_LAUNCHER__", L""); - } else if (!executable.empty()) { - status = PyConfig_SetString( - config, &config->executable, executable.c_str()); - } - - return status; -} - -int -wmain(int argc, wchar_t **argv) -{ - PyStatus status; - PyPreConfig preconfig; - PyConfig config; - - const wchar_t *moduleName = NULL; - const wchar_t *p = wcsrchr(argv[0], L'\\'); - if (!p) { - p = argv[0]; - } - if (p) { - if (*p == L'\\') { - p++; - } - - if (wcsnicmp(p, L"pip", 3) == 0) { - moduleName = L"pip"; - } else if (wcsnicmp(p, L"idle", 4) == 0) { - moduleName = L"idlelib"; - } - } - - PyPreConfig_InitPythonConfig(&preconfig); - if (!moduleName) { - status = Py_PreInitializeFromArgs(&preconfig, argc, argv); - if (PyStatus_Exception(status)) { - goto fail_without_config; - } - } - - PyConfig_InitPythonConfig(&config); - - status = PyConfig_SetArgv(&config, argc, argv); - if (PyStatus_Exception(status)) { - goto fail; - } - if (moduleName) { - config.parse_argv = 0; - } - - status = set_process_name(&config); - if (PyStatus_Exception(status)) { - goto fail; - } - - p = _wgetenv(L"PYTHONUSERBASE"); - if (!p || !*p) { - _wputenv_s(L"PYTHONUSERBASE", get_user_base().c_str()); - } - - if (moduleName) { - status = PyConfig_SetString(&config, &config.run_module, moduleName); - if (PyStatus_Exception(status)) { - goto fail; - } - status = PyConfig_SetString(&config, &config.run_filename, NULL); - if (PyStatus_Exception(status)) { - goto fail; - } - status = PyConfig_SetString(&config, &config.run_command, NULL); - if (PyStatus_Exception(status)) { - goto fail; - } - } - - status = Py_InitializeFromConfig(&config); - if (PyStatus_Exception(status)) { - goto fail; - } - PyConfig_Clear(&config); - - return Py_RunMain(); - -fail: - PyConfig_Clear(&config); -fail_without_config: - if (PyStatus_IsExit(status)) { - return status.exitcode; - } - assert(PyStatus_Exception(status)); - Py_ExitStatusException(status); - /* Unreachable code */ - return 0; -} - -#ifdef PYTHONW - -int WINAPI wWinMain( - HINSTANCE hInstance, /* handle to current instance */ - HINSTANCE hPrevInstance, /* handle to previous instance */ - LPWSTR lpCmdLine, /* pointer to command line */ - int nCmdShow /* show state of window */ -) -{ - return wmain(__argc, __wargv); -} - -#endif diff --git a/PC/python_ver_rc.h b/PC/python_ver_rc.h deleted file mode 100644 index e6c1d2437041541d0428cc414ccc6a64047d3ff7..0000000000000000000000000000000000000000 --- a/PC/python_ver_rc.h +++ /dev/null @@ -1,34 +0,0 @@ -// Resource script for Python core DLL. -// Currently only holds version information. -// -#pragma code_page(1252) -#include "winver.h" - -#define PYTHON_COMPANY "Python Software Foundation" -#define PYTHON_COPYRIGHT "Copyright \xA9 2001-2022 Python Software Foundation. Copyright \xA9 2000 BeOpen.com. Copyright \xA9 1995-2001 CNRI. Copyright \xA9 1991-1995 SMC." - -#define MS_WINDOWS -#include "modsupport.h" -#include "patchlevel.h" -#ifdef _DEBUG -# define PYTHON_DEBUG_EXT "_d" -#else -# define PYTHON_DEBUG_EXT -#endif - -/* e.g., 3.3.0a1 - * PY_VERSION comes from patchlevel.h - */ -#define PYTHON_VERSION PY_VERSION "\0" - -/* 64-bit version number as comma-separated list of 4 16-bit ints */ -#if PY_MICRO_VERSION > 64 -# error "PY_MICRO_VERSION > 64" -#endif -#if PY_RELEASE_LEVEL > 99 -# error "PY_RELEASE_LEVEL > 99" -#endif -#if PY_RELEASE_SERIAL > 9 -# error "PY_RELEASE_SERIAL > 9" -#endif -#define PYVERSION64 PY_MAJOR_VERSION, PY_MINOR_VERSION, FIELD3, PYTHON_API_VERSION diff --git a/PC/pythonw_exe.rc b/PC/pythonw_exe.rc deleted file mode 100644 index 38570b74fa3e0204cbee99df4e702556d4f5dde0..0000000000000000000000000000000000000000 --- a/PC/pythonw_exe.rc +++ /dev/null @@ -1,54 +0,0 @@ -// Resource script for Python console EXEs. - -#include "python_ver_rc.h" - -#ifndef RT_MANIFEST -// bpo-45220: Cannot reliably #include RT_MANIFEST from -// anywhere, so we hardcode it -#define RT_MANIFEST 24 -#endif - -// Include the manifest file that indicates we support all -// current versions of Windows. -1 RT_MANIFEST "python.manifest" - -1 ICON DISCARDABLE "icons\pythonw.ico" - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION PYVERSION64 - PRODUCTVERSION PYVERSION64 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_APP - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "CompanyName", PYTHON_COMPANY "\0" - VALUE "FileDescription", "Python\0" - VALUE "FileVersion", PYTHON_VERSION - VALUE "InternalName", "Python Application\0" - VALUE "LegalCopyright", PYTHON_COPYRIGHT "\0" - VALUE "OriginalFilename", "pythonw" PYTHON_DEBUG_EXT ".exe\0" - VALUE "ProductName", "Python\0" - VALUE "ProductVersion", PYTHON_VERSION - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END diff --git a/PC/readme.txt b/PC/readme.txt deleted file mode 100644 index e1af101f64f187a2fe22c292caeee5dc6e316e18..0000000000000000000000000000000000000000 --- a/PC/readme.txt +++ /dev/null @@ -1,81 +0,0 @@ -Welcome to the "PC" subdirectory of the Python distribution -*********************************************************** - -This "PC" subdirectory contains complete project files to make -several older PC ports of Python, as well as all the PC-specific -Python source files. It should be located in the root of the -Python distribution, and there should be directories "Modules", -"Objects", "Python", etc. in the parent directory of this "PC" -subdirectory. Be sure to read the documentation in the Python -distribution. - -Python requires library files such as string.py to be available in -one or more library directories. The search path of libraries is -set up when Python starts. To see the current Python library search -path, start Python and enter "import sys" and "print sys.path". - -All PC ports use this scheme to try to set up a module search path: - - 1) The script location; the current directory without script. - 2) The PYTHONPATH variable, if set. - 3) Paths specified in the Registry. - 4) Default directories lib, lib/win, lib/test, lib/tkinter; - these are searched relative to the environment variable - PYTHONHOME, if set, or relative to the executable and its - ancestors, if a landmark file (Lib/string.py) is found , - or the current directory (not useful). - 5) The directory containing the executable. - -The best installation strategy is to put the Python executable and -DLL in some convenient directory such as -C:/python, and copy all library files and subdirectories (using XCOPY) -to C:/python/lib. Then you don't need to set PYTHONPATH. Otherwise, -set the environment variable PYTHONPATH to your Python search path. -For example, - set PYTHONPATH=.;d:\python\lib;d:\python\lib\win;d:\python\lib\dos-8x3 - -There are several add-in modules to build Python programs which use -the native Windows operating environment. The ports here just make -"QuickWin" and DOS Python versions which support a character-mode -(console) environment. Look in www.python.org for Tkinter, PythonWin, -WPY and wxPython. - -To make a Python port, start the Integrated Development Environment -(IDE) of your compiler, and read in the native "project file" -(or makefile) provided. This will enable you to change any source -files or build settings so you can make custom builds. - -pyconfig.h An important configuration file specific to PC's. - -config.c The list of C modules to include in the Python PC - version. Manually edit this file to add or - remove Python modules. - -testpy.py A Python test program. Run this to test your - Python port. It should produce copious output, - ending in a report on how many tests were OK, how many - failed, and how many were skipped. Don't worry about - skipped tests (these test unavailable optional features). - - -Additional files and subdirectories for 32-bit Windows -====================================================== - -python_nt.rc Resource compiler input for python15.dll. - -dl_nt.c - Additional sources used for 32-bit Windows features. - -getpathp.c Default sys.path calculations (for all PC platforms). - -dllbase_nt.txt A (manually maintained) list of base addresses for - various DLLs, to avoid run-time relocation. - - -Note for Windows 3.x and DOS users -================================== - -Neither Windows 3.x nor DOS is supported any more. The last Python -version that supported these was Python 1.5.2; the support files were -present in Python 2.0 but weren't updated, and it is not our intention -to support these platforms for Python 2.x. diff --git a/PC/sqlite3.rc b/PC/sqlite3.rc deleted file mode 100644 index 9ae2aa0f6f2f2cc1a0d3331d979fd8feb6c51d52..0000000000000000000000000000000000000000 --- a/PC/sqlite3.rc +++ /dev/null @@ -1,54 +0,0 @@ -// Resource script for Sqlite DLL. - -#include - -#ifndef RT_MANIFEST -// bpo-45220: Cannot reliably #include RT_MANIFEST from -// anywhere, so we hardcode it -#define RT_MANIFEST 24 -#endif - -// Include the manifest file that indicates we support all -// current versions of Windows. -2 RT_MANIFEST "python.manifest" - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -#define _S(x) #x -#define S(x) _S(x) - -VS_VERSION_INFO VERSIONINFO - FILEVERSION SQLITE_MAJOR_VERSION, SQLITE_MINOR_VERSION, SQLITE_MICRO_VERSION, SQLITE_PATCH_VERSION - PRODUCTVERSION SQLITE_MAJOR_VERSION, SQLITE_MINOR_VERSION, SQLITE_MICRO_VERSION, SQLITE_PATCH_VERSION - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "CompanyName", "SQLite3\0" - VALUE "FileDescription", "SQLite3\0" - VALUE "FileVersion", S(SQLITE_VERSION) "\0" - VALUE "InternalName", "SQLite3 DLL\0" - VALUE "LegalCopyright", "Unspecified\0" - VALUE "OriginalFilename", "sqlite3.dll\0" - VALUE "ProductName", "SQLite3\0" - VALUE "ProductVersion", S(SQLITE_VERSION) "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END diff --git a/PC/store_info.txt b/PC/store_info.txt deleted file mode 100644 index f6a85cb8ebec1fde03dd814277b291e78b7d8910..0000000000000000000000000000000000000000 --- a/PC/store_info.txt +++ /dev/null @@ -1,156 +0,0 @@ -# Overview - -NOTE: This file requires more content. - -Since Python 3.7.2, releases have been made through the Microsoft Store -to allow easy installation on Windows 10.0.17763.0 and later. - -# Building - -To build the store package, the PC/layout script should be used. -Execute the directory with the build of Python to package, and pass -"-h" for full command-line options. - -To sideload test builds, you will need a local certificate. -Instructions are available at -https://docs.microsoft.com/windows/uwp/packaging/create-certificate-package-signing. - -After exporting your certificate, you will need the subject name and -SHA256 hash. The `certutil -dump ` command will display this -information. - -To build for sideloading, use these commands in PowerShell: - -``` -$env:APPX_DATA_PUBLISHER= -$env:APPX_DATA_SHA256= -$env:SigningCertificateFile= - -python PC/layout --copy --include-appxmanifest -Tools/msi/make_appx.ps1 python.msix -sign - -Add-AppxPackage python.msix -``` - -(Note that only the last command requires PowerShell, and the others -can be used from Command Prompt. You can also double-click to install -the final package.) - -To build for publishing to the Store, use these commands: - -``` -$env:APPX_DATA_PUBLISHER = $null -$env:APPX_DATA_SHA256 = $null - -python PC/layout --copy --preset-appxmanifest --precompile -Tools/msi/make_appx.ps1 python.msix -``` - -Note that this package cannot be installed locally. It may only be -added to a submission for the store. - - -# Submission Metadata - -This file contains the text that we use to fill out the store listing -for the Microsoft Store. It needs to be entered manually when creating -a new submission via the dashboard at -https://partner.microsoft.com/dashboard. - -We keep it here for convenience and to allow it to be updated via pull -requests. - -When submitting a new app, the HeadlessAppBypass waiver will be needed. -To request this, send an email to PartnerOps@microsoft.com with the app -ID (12 character token available from the dashboard). The waiver needs -to be applied *before* uploading the package (as of November 2019). - -Ensure that the new app is named "Python.3.X", where X is the minor -version of the release. If the name provided initially does not match -the name used when building the package, the upload will fail. The -display name shown to users can be set later. - -## Title - -Python 3.9 - -## Short Title - -Python - -## Description - -Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms. - -The Python interpreter and the extensive standard library are freely available in source or binary form for all major platforms from the Python web site, https://www.python.org/, and may be freely distributed. The same site also contains distributions of and pointers to many free third party Python modules, programs and tools, and additional documentation. - -The Python interpreter is easily extended with new functions and data types implemented in C or C++ (or other languages callable from C). Python is also suitable as an extension language for customizable applications. - -## ShortDescription - -The Python 3.9 interpreter and runtime. - -## Copyright Trademark Information - -(c) Python Software Foundation - -## Additional License Terms - -Visit https://docs.python.org/3.9/license.html for latest license terms. - -PSF LICENSE AGREEMENT FOR PYTHON 3.9 - -1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"), and - the Individual or Organization ("Licensee") accessing and otherwise using Python - 3.9 software in source or binary form and its associated documentation. - -2. Subject to the terms and conditions of this License Agreement, PSF hereby - grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, - analyze, test, perform and/or display publicly, prepare derivative works, - distribute, and otherwise use Python 3.9 alone or in any derivative - version, provided, however, that PSF's License Agreement and PSF's notice of - copyright, i.e., "Copyright © 2001-2018 Python Software Foundation; All Rights - Reserved" are retained in Python 3.9 alone or in any derivative version - prepared by Licensee. - -3. In the event Licensee prepares a derivative work that is based on or - incorporates Python 3.9 or any part thereof, and wants to make the - derivative work available to others as provided herein, then Licensee hereby - agrees to include in any such work a brief summary of the changes made to Python - 3.9. - -4. PSF is making Python 3.9 available to Licensee on an "AS IS" basis. - PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF - EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR - WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE - USE OF PYTHON 3.9 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. - -5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 3.9 - FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF - MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 3.9, OR ANY DERIVATIVE - THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - -6. This License Agreement will automatically terminate upon a material breach of - its terms and conditions. - -7. Nothing in this License Agreement shall be deemed to create any relationship - of agency, partnership, or joint venture between PSF and Licensee. This License - Agreement does not grant permission to use PSF trademarks or trade name in a - trademark sense to endorse or promote products or services of Licensee, or any - third party. - -8. By copying, installing or otherwise using Python 3.9, Licensee agrees - to be bound by the terms and conditions of this License Agreement. - -## Features - -* Easy to install Python runtime -* Supported by core CPython team -* Find Python, Pip and Idle on PATH - -## Search Terms - -* Python -* Scripting -* Interpreter - diff --git a/PC/testpy.py b/PC/testpy.py deleted file mode 100644 index 709f35c4525877275269703f23974aa0727661aa..0000000000000000000000000000000000000000 --- a/PC/testpy.py +++ /dev/null @@ -1,30 +0,0 @@ -import sys - -# This is a test module for Python. It looks in the standard -# places for various *.py files. If these are moved, you must -# change this module too. - -try: - import os -except: - print("""Could not import the standard "os" module. - Please check your PYTHONPATH environment variable.""") - sys.exit(1) - -try: - import symbol -except: - print("""Could not import the standard "symbol" module. If this is - a PC, you should add the dos_8x3 directory to your PYTHONPATH.""") - sys.exit(1) - -for dir in sys.path: - file = os.path.join(dir, "os.py") - if os.path.isfile(file): - test = os.path.join(dir, "test") - if os.path.isdir(test): - # Add the "test" directory to PYTHONPATH. - sys.path = sys.path + [test] - -import libregrtest # Standard Python tester. -libregrtest.main() diff --git a/PC/validate_ucrtbase.py b/PC/validate_ucrtbase.py deleted file mode 100644 index 0ba54ab3bb42df8ea3c8954b0ad5ab628e3222ec..0000000000000000000000000000000000000000 --- a/PC/validate_ucrtbase.py +++ /dev/null @@ -1,89 +0,0 @@ -''' -This script gets the version number from ucrtbased.dll and checks -whether it is a version with a known issue. -''' - -import sys - -from ctypes import (c_buffer, POINTER, byref, create_unicode_buffer, - Structure, WinDLL) -from ctypes.wintypes import DWORD, HANDLE - -class VS_FIXEDFILEINFO(Structure): - _fields_ = [ - ("dwSignature", DWORD), - ("dwStrucVersion", DWORD), - ("dwFileVersionMS", DWORD), - ("dwFileVersionLS", DWORD), - ("dwProductVersionMS", DWORD), - ("dwProductVersionLS", DWORD), - ("dwFileFlagsMask", DWORD), - ("dwFileFlags", DWORD), - ("dwFileOS", DWORD), - ("dwFileType", DWORD), - ("dwFileSubtype", DWORD), - ("dwFileDateMS", DWORD), - ("dwFileDateLS", DWORD), - ] - -kernel32 = WinDLL('kernel32') -version = WinDLL('version') - -if len(sys.argv) < 2: - print('Usage: validate_ucrtbase.py ') - sys.exit(2) - -try: - ucrtbased = WinDLL(sys.argv[1]) -except OSError: - print('Cannot find ucrtbased.dll') - # This likely means that VS is not installed, but that is an - # obvious enough problem if you're trying to produce a debug - # build that we don't need to fail here. - sys.exit(0) - -# We will immediately double the length up to MAX_PATH, but the -# path may be longer, so we retry until the returned string is -# shorter than our buffer. -name_len = actual_len = 130 -while actual_len == name_len: - name_len *= 2 - name = create_unicode_buffer(name_len) - actual_len = kernel32.GetModuleFileNameW(HANDLE(ucrtbased._handle), - name, len(name)) - if not actual_len: - print('Failed to get full module name.') - sys.exit(2) - -size = version.GetFileVersionInfoSizeW(name, None) -if not size: - print('Failed to get size of version info.') - sys.exit(2) - -ver_block = c_buffer(size) -if (not version.GetFileVersionInfoW(name, None, size, ver_block) or - not ver_block): - print('Failed to get version info.') - sys.exit(2) - -pvi = POINTER(VS_FIXEDFILEINFO)() -if not version.VerQueryValueW(ver_block, "", byref(pvi), byref(DWORD())): - print('Failed to get version value from info.') - sys.exit(2) - -ver = ( - pvi.contents.dwProductVersionMS >> 16, - pvi.contents.dwProductVersionMS & 0xFFFF, - pvi.contents.dwProductVersionLS >> 16, - pvi.contents.dwProductVersionLS & 0xFFFF, -) - -print('{} is version {}.{}.{}.{}'.format(name.value, *ver)) - -if ver < (10, 0, 10586): - print('WARN: ucrtbased contains known issues. ' - 'Please update the Windows 10 SDK.') - print('See:') - print(' http://bugs.python.org/issue27705') - print(' https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk') - sys.exit(1) diff --git a/PC/winreg.c b/PC/winreg.c deleted file mode 100644 index 4fefcdcc942ff9521eee5ed9b0ba22f77bb37a35..0000000000000000000000000000000000000000 --- a/PC/winreg.c +++ /dev/null @@ -1,2108 +0,0 @@ -/* - winreg.c - - Windows Registry access module for Python. - - * Simple registry access written by Mark Hammond in win32api - module circa 1995. - * Bill Tutt expanded the support significantly not long after. - * Numerous other people have submitted patches since then. - * Ripped from win32api module 03-Feb-2000 by Mark Hammond, and - basic Unicode support added. - -*/ - -#define PY_SSIZE_T_CLEAN -#include "Python.h" -#include "pycore_object.h" // _PyObject_Init() -#include "structmember.h" // PyMemberDef -#include - -static BOOL PyHKEY_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK); -static BOOL clinic_HKEY_converter(PyObject *ob, void *p); -static PyObject *PyHKEY_FromHKEY(HKEY h); -static BOOL PyHKEY_Close(PyObject *obHandle); - -static char errNotAHandle[] = "Object is not a handle"; - -/* The win32api module reports the function name that failed, - but this concept is not in the Python core. - Hopefully it will one day, and in the meantime I don't - want to lose this info... -*/ -#define PyErr_SetFromWindowsErrWithFunction(rc, fnname) \ - PyErr_SetFromWindowsErr(rc) - -/* Forward declares */ - -/* Doc strings */ -PyDoc_STRVAR(module_doc, -"This module provides access to the Windows registry API.\n" -"\n" -"Functions:\n" -"\n" -"CloseKey() - Closes a registry key.\n" -"ConnectRegistry() - Establishes a connection to a predefined registry handle\n" -" on another computer.\n" -"CreateKey() - Creates the specified key, or opens it if it already exists.\n" -"DeleteKey() - Deletes the specified key.\n" -"DeleteValue() - Removes a named value from the specified registry key.\n" -"EnumKey() - Enumerates subkeys of the specified open registry key.\n" -"EnumValue() - Enumerates values of the specified open registry key.\n" -"ExpandEnvironmentStrings() - Expand the env strings in a REG_EXPAND_SZ\n" -" string.\n" -"FlushKey() - Writes all the attributes of the specified key to the registry.\n" -"LoadKey() - Creates a subkey under HKEY_USER or HKEY_LOCAL_MACHINE and\n" -" stores registration information from a specified file into that\n" -" subkey.\n" -"OpenKey() - Opens the specified key.\n" -"OpenKeyEx() - Alias of OpenKey().\n" -"QueryValue() - Retrieves the value associated with the unnamed value for a\n" -" specified key in the registry.\n" -"QueryValueEx() - Retrieves the type and data for a specified value name\n" -" associated with an open registry key.\n" -"QueryInfoKey() - Returns information about the specified key.\n" -"SaveKey() - Saves the specified key, and all its subkeys a file.\n" -"SetValue() - Associates a value with a specified key.\n" -"SetValueEx() - Stores data in the value field of an open registry key.\n" -"\n" -"Special objects:\n" -"\n" -"HKEYType -- type object for HKEY objects\n" -"error -- exception raised for Win32 errors\n" -"\n" -"Integer constants:\n" -"Many constants are defined - see the documentation for each function\n" -"to see what constants are used, and where."); - - - -/* PyHKEY docstrings */ -PyDoc_STRVAR(PyHKEY_doc, -"PyHKEY Object - A Python object, representing a win32 registry key.\n" -"\n" -"This object wraps a Windows HKEY object, automatically closing it when\n" -"the object is destroyed. To guarantee cleanup, you can call either\n" -"the Close() method on the PyHKEY, or the CloseKey() method.\n" -"\n" -"All functions which accept a handle object also accept an integer --\n" -"however, use of the handle object is encouraged.\n" -"\n" -"Functions:\n" -"Close() - Closes the underlying handle.\n" -"Detach() - Returns the integer Win32 handle, detaching it from the object\n" -"\n" -"Properties:\n" -"handle - The integer Win32 handle.\n" -"\n" -"Operations:\n" -"__bool__ - Handles with an open object return true, otherwise false.\n" -"__int__ - Converting a handle to an integer returns the Win32 handle.\n" -"rich comparison - Handle objects are compared using the handle value."); - - - -/************************************************************************ - - The PyHKEY object definition - -************************************************************************/ -typedef struct { - PyObject_VAR_HEAD - HKEY hkey; -} PyHKEYObject; - -#define PyHKEY_Check(op) Py_IS_TYPE(op, &PyHKEY_Type) - -static char *failMsg = "bad operand type"; - -static PyObject * -PyHKEY_unaryFailureFunc(PyObject *ob) -{ - PyErr_SetString(PyExc_TypeError, failMsg); - return NULL; -} -static PyObject * -PyHKEY_binaryFailureFunc(PyObject *ob1, PyObject *ob2) -{ - PyErr_SetString(PyExc_TypeError, failMsg); - return NULL; -} -static PyObject * -PyHKEY_ternaryFailureFunc(PyObject *ob1, PyObject *ob2, PyObject *ob3) -{ - PyErr_SetString(PyExc_TypeError, failMsg); - return NULL; -} - -static void -PyHKEY_deallocFunc(PyObject *ob) -{ - /* Can not call PyHKEY_Close, as the ob->tp_type - has already been cleared, thus causing the type - check to fail! - */ - PyHKEYObject *obkey = (PyHKEYObject *)ob; - if (obkey->hkey) - RegCloseKey((HKEY)obkey->hkey); - PyObject_Free(ob); -} - -static int -PyHKEY_boolFunc(PyObject *ob) -{ - return ((PyHKEYObject *)ob)->hkey != 0; -} - -static PyObject * -PyHKEY_intFunc(PyObject *ob) -{ - PyHKEYObject *pyhkey = (PyHKEYObject *)ob; - return PyLong_FromVoidPtr(pyhkey->hkey); -} - -static PyObject * -PyHKEY_strFunc(PyObject *ob) -{ - PyHKEYObject *pyhkey = (PyHKEYObject *)ob; - return PyUnicode_FromFormat("", pyhkey->hkey); -} - -static int -PyHKEY_compareFunc(PyObject *ob1, PyObject *ob2) -{ - PyHKEYObject *pyhkey1 = (PyHKEYObject *)ob1; - PyHKEYObject *pyhkey2 = (PyHKEYObject *)ob2; - return pyhkey1 == pyhkey2 ? 0 : - (pyhkey1 < pyhkey2 ? -1 : 1); -} - -static Py_hash_t -PyHKEY_hashFunc(PyObject *ob) -{ - /* Just use the address. - XXX - should we use the handle value? - */ - return _Py_HashPointer(ob); -} - - -static PyNumberMethods PyHKEY_NumberMethods = -{ - PyHKEY_binaryFailureFunc, /* nb_add */ - PyHKEY_binaryFailureFunc, /* nb_subtract */ - PyHKEY_binaryFailureFunc, /* nb_multiply */ - PyHKEY_binaryFailureFunc, /* nb_remainder */ - PyHKEY_binaryFailureFunc, /* nb_divmod */ - PyHKEY_ternaryFailureFunc, /* nb_power */ - PyHKEY_unaryFailureFunc, /* nb_negative */ - PyHKEY_unaryFailureFunc, /* nb_positive */ - PyHKEY_unaryFailureFunc, /* nb_absolute */ - PyHKEY_boolFunc, /* nb_bool */ - PyHKEY_unaryFailureFunc, /* nb_invert */ - PyHKEY_binaryFailureFunc, /* nb_lshift */ - PyHKEY_binaryFailureFunc, /* nb_rshift */ - PyHKEY_binaryFailureFunc, /* nb_and */ - PyHKEY_binaryFailureFunc, /* nb_xor */ - PyHKEY_binaryFailureFunc, /* nb_or */ - PyHKEY_intFunc, /* nb_int */ - 0, /* nb_reserved */ - PyHKEY_unaryFailureFunc, /* nb_float */ -}; - -/*[clinic input] -module winreg -class winreg.HKEYType "PyHKEYObject *" "&PyHKEY_Type" -[clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=4c964eba3bf914d6]*/ - -/*[python input] -class REGSAM_converter(CConverter): - type = 'REGSAM' - format_unit = 'i' - -class DWORD_converter(CConverter): - type = 'DWORD' - format_unit = 'k' - -class HKEY_converter(CConverter): - type = 'HKEY' - converter = 'clinic_HKEY_converter' - -class HKEY_return_converter(CReturnConverter): - type = 'HKEY' - - def render(self, function, data): - self.declare(data) - self.err_occurred_if_null_pointer("_return_value", data) - data.return_conversion.append( - 'return_value = PyHKEY_FromHKEY(_return_value);\n') - -# HACK: this only works for PyHKEYObjects, nothing else. -# Should this be generalized and enshrined in clinic.py, -# destroy this converter with prejudice. -class self_return_converter(CReturnConverter): - type = 'PyHKEYObject *' - - def render(self, function, data): - self.declare(data) - data.return_conversion.append( - 'return_value = (PyObject *)_return_value;\n') -[python start generated code]*/ -/*[python end generated code: output=da39a3ee5e6b4b0d input=22f7aedc6d68e80e]*/ - -#include "clinic/winreg.c.h" - -/************************************************************************ - - The PyHKEY object methods - -************************************************************************/ -/*[clinic input] -winreg.HKEYType.Close - -Closes the underlying Windows handle. - -If the handle is already closed, no error is raised. -[clinic start generated code]*/ - -static PyObject * -winreg_HKEYType_Close_impl(PyHKEYObject *self) -/*[clinic end generated code: output=fced3a624fb0c344 input=6786ac75f6b89de6]*/ -{ - if (!PyHKEY_Close((PyObject *)self)) - return NULL; - Py_RETURN_NONE; -} - -/*[clinic input] -winreg.HKEYType.Detach - -Detaches the Windows handle from the handle object. - -The result is the value of the handle before it is detached. If the -handle is already detached, this will return zero. - -After calling this function, the handle is effectively invalidated, -but the handle is not closed. You would call this function when you -need the underlying win32 handle to exist beyond the lifetime of the -handle object. -[clinic start generated code]*/ - -static PyObject * -winreg_HKEYType_Detach_impl(PyHKEYObject *self) -/*[clinic end generated code: output=dda5a9e1a01ae78f input=dd2cc09e6c6ba833]*/ -{ - void* ret; - if (PySys_Audit("winreg.PyHKEY.Detach", "n", (Py_ssize_t)self->hkey) < 0) { - return NULL; - } - ret = (void*)self->hkey; - self->hkey = 0; - return PyLong_FromVoidPtr(ret); -} - -/*[clinic input] -winreg.HKEYType.__enter__ -> self -[clinic start generated code]*/ - -static PyHKEYObject * -winreg_HKEYType___enter___impl(PyHKEYObject *self) -/*[clinic end generated code: output=52c34986dab28990 input=c40fab1f0690a8e2]*/ -{ - Py_XINCREF(self); - return self; -} - - -/*[clinic input] -winreg.HKEYType.__exit__ - - exc_type: object - exc_value: object - traceback: object -[clinic start generated code]*/ - -static PyObject * -winreg_HKEYType___exit___impl(PyHKEYObject *self, PyObject *exc_type, - PyObject *exc_value, PyObject *traceback) -/*[clinic end generated code: output=923ebe7389e6a263 input=fb32489ee92403c7]*/ -{ - if (!PyHKEY_Close((PyObject *)self)) - return NULL; - Py_RETURN_NONE; -} - -/*[clinic input] -[clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=da39a3ee5e6b4b0d]*/ - -static struct PyMethodDef PyHKEY_methods[] = { - WINREG_HKEYTYPE_CLOSE_METHODDEF - WINREG_HKEYTYPE_DETACH_METHODDEF - WINREG_HKEYTYPE___ENTER___METHODDEF - WINREG_HKEYTYPE___EXIT___METHODDEF - {NULL} -}; - -#define OFF(e) offsetof(PyHKEYObject, e) -static PyMemberDef PyHKEY_memberlist[] = { - {"handle", T_INT, OFF(hkey), READONLY}, - {NULL} /* Sentinel */ -}; - -/* The type itself */ -PyTypeObject PyHKEY_Type = -{ - PyVarObject_HEAD_INIT(0, 0) /* fill in type at module init */ - "PyHKEY", - sizeof(PyHKEYObject), - 0, - PyHKEY_deallocFunc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_as_async */ - 0, /* tp_repr */ - &PyHKEY_NumberMethods, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - PyHKEY_hashFunc, /* tp_hash */ - 0, /* tp_call */ - PyHKEY_strFunc, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - 0, /* tp_flags */ - PyHKEY_doc, /* tp_doc */ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - PyHKEY_methods, /*tp_methods*/ - PyHKEY_memberlist, /*tp_members*/ -}; - -/************************************************************************ - The public PyHKEY API (well, not public yet :-) -************************************************************************/ -PyObject * -PyHKEY_New(HKEY hInit) -{ - PyHKEYObject *key = PyObject_New(PyHKEYObject, &PyHKEY_Type); - if (key) - key->hkey = hInit; - return (PyObject *)key; -} - -BOOL -PyHKEY_Close(PyObject *ob_handle) -{ - LONG rc; - HKEY key; - - if (!PyHKEY_AsHKEY(ob_handle, &key, TRUE)) { - return FALSE; - } - if (PyHKEY_Check(ob_handle)) { - ((PyHKEYObject*)ob_handle)->hkey = 0; - } - rc = key ? RegCloseKey(key) : ERROR_SUCCESS; - if (rc != ERROR_SUCCESS) - PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); - return rc == ERROR_SUCCESS; -} - -BOOL -PyHKEY_AsHKEY(PyObject *ob, HKEY *pHANDLE, BOOL bNoneOK) -{ - if (ob == Py_None) { - if (!bNoneOK) { - PyErr_SetString( - PyExc_TypeError, - "None is not a valid HKEY in this context"); - return FALSE; - } - *pHANDLE = (HKEY)0; - } - else if (PyHKEY_Check(ob)) { - PyHKEYObject *pH = (PyHKEYObject *)ob; - *pHANDLE = pH->hkey; - } - else if (PyLong_Check(ob)) { - /* We also support integers */ - PyErr_Clear(); - *pHANDLE = (HKEY)PyLong_AsVoidPtr(ob); - if (PyErr_Occurred()) - return FALSE; - } - else { - PyErr_SetString( - PyExc_TypeError, - "The object is not a PyHKEY object"); - return FALSE; - } - return TRUE; -} - -BOOL -clinic_HKEY_converter(PyObject *ob, void *p) -{ - if (!PyHKEY_AsHKEY(ob, (HKEY *)p, FALSE)) - return FALSE; - return TRUE; -} - -PyObject * -PyHKEY_FromHKEY(HKEY h) -{ - /* Inline PyObject_New */ - PyHKEYObject *op = (PyHKEYObject *) PyObject_Malloc(sizeof(PyHKEYObject)); - if (op == NULL) { - return PyErr_NoMemory(); - } - _PyObject_Init((PyObject*)op, &PyHKEY_Type); - op->hkey = h; - return (PyObject *)op; -} - - -/************************************************************************ - The module methods -************************************************************************/ -BOOL -PyWinObject_CloseHKEY(PyObject *obHandle) -{ - BOOL ok; - if (PyHKEY_Check(obHandle)) { - ok = PyHKEY_Close(obHandle); - } -#if SIZEOF_LONG >= SIZEOF_HKEY - else if (PyLong_Check(obHandle)) { - long rc = RegCloseKey((HKEY)PyLong_AsLong(obHandle)); - ok = (rc == ERROR_SUCCESS); - if (!ok) - PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); - } -#else - else if (PyLong_Check(obHandle)) { - long rc = RegCloseKey((HKEY)PyLong_AsVoidPtr(obHandle)); - ok = (rc == ERROR_SUCCESS); - if (!ok) - PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); - } -#endif - else { - PyErr_SetString( - PyExc_TypeError, - "A handle must be a HKEY object or an integer"); - return FALSE; - } - return ok; -} - - -/* - Private Helper functions for the registry interfaces - -** Note that fixupMultiSZ and countString have both had changes -** made to support "incorrect strings". The registry specification -** calls for strings to be terminated with 2 null bytes. It seems -** some commercial packages install strings which don't conform, -** causing this code to fail - however, "regedit" etc still work -** with these strings (ie only we don't!). -*/ -static void -fixupMultiSZ(wchar_t **str, wchar_t *data, int len) -{ - wchar_t *P; - int i; - wchar_t *Q; - - if (len > 0 && data[len - 1] == '\0') { - Q = data + len - 1; - } - else { - Q = data + len; - } - - for (P = data, i = 0; P < Q; P++, i++) { - str[i] = P; - for (; P < Q && *P != '\0'; P++) { - ; - } - } -} - -static int -countStrings(wchar_t *data, int len) -{ - int strings; - wchar_t *P, *Q; - - if (len > 0 && data[len - 1] == '\0') { - Q = data + len - 1; - } - else { - Q = data + len; - } - - for (P = data, strings = 0; P < Q; P++, strings++) { - for (; P < Q && *P != '\0'; P++) { - ; - } - } - return strings; -} - -/* Convert PyObject into Registry data. - Allocates space as needed. */ -static BOOL -Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize) -{ - Py_ssize_t i,j; - switch (typ) { - case REG_DWORD: - if (value != Py_None && !PyLong_Check(value)) - return FALSE; - *retDataBuf = (BYTE *)PyMem_NEW(DWORD, 1); - if (*retDataBuf == NULL){ - PyErr_NoMemory(); - return FALSE; - } - *retDataSize = sizeof(DWORD); - if (value == Py_None) { - DWORD zero = 0; - memcpy(*retDataBuf, &zero, sizeof(DWORD)); - } - else { - DWORD d = PyLong_AsUnsignedLong(value); - memcpy(*retDataBuf, &d, sizeof(DWORD)); - } - break; - case REG_QWORD: - if (value != Py_None && !PyLong_Check(value)) - return FALSE; - *retDataBuf = (BYTE *)PyMem_NEW(DWORD64, 1); - if (*retDataBuf == NULL){ - PyErr_NoMemory(); - return FALSE; - } - *retDataSize = sizeof(DWORD64); - if (value == Py_None) { - DWORD64 zero = 0; - memcpy(*retDataBuf, &zero, sizeof(DWORD64)); - } - else { - DWORD64 d = PyLong_AsUnsignedLongLong(value); - memcpy(*retDataBuf, &d, sizeof(DWORD64)); - } - break; - case REG_SZ: - case REG_EXPAND_SZ: - { - if (value != Py_None) { - Py_ssize_t len; - if (!PyUnicode_Check(value)) - return FALSE; - *retDataBuf = (BYTE*)PyUnicode_AsWideCharString(value, &len); - if (*retDataBuf == NULL) - return FALSE; - *retDataSize = Py_SAFE_DOWNCAST( - (len + 1) * sizeof(wchar_t), - Py_ssize_t, DWORD); - } - else { - *retDataBuf = (BYTE *)PyMem_NEW(wchar_t, 1); - if (*retDataBuf == NULL) { - PyErr_NoMemory(); - return FALSE; - } - ((wchar_t *)*retDataBuf)[0] = L'\0'; - *retDataSize = 1 * sizeof(wchar_t); - } - break; - } - case REG_MULTI_SZ: - { - DWORD size = 0; - wchar_t *P; - - if (value == Py_None) - i = 0; - else { - if (!PyList_Check(value)) - return FALSE; - i = PyList_Size(value); - } - for (j = 0; j < i; j++) - { - PyObject *t; - Py_ssize_t len; - - t = PyList_GET_ITEM(value, j); - if (!PyUnicode_Check(t)) - return FALSE; -#if USE_UNICODE_WCHAR_CACHE -_Py_COMP_DIAG_PUSH -_Py_COMP_DIAG_IGNORE_DEPR_DECLS - len = PyUnicode_GetSize(t); - if (len < 0) - return FALSE; - len++; -_Py_COMP_DIAG_POP -#else /* USE_UNICODE_WCHAR_CACHE */ - len = PyUnicode_AsWideChar(t, NULL, 0); - if (len < 0) - return FALSE; -#endif /* USE_UNICODE_WCHAR_CACHE */ - size += Py_SAFE_DOWNCAST(len * sizeof(wchar_t), - size_t, DWORD); - } - - *retDataSize = size + 2; - *retDataBuf = (BYTE *)PyMem_NEW(char, - *retDataSize); - if (*retDataBuf == NULL){ - PyErr_NoMemory(); - return FALSE; - } - P = (wchar_t *)*retDataBuf; - - for (j = 0; j < i; j++) - { - PyObject *t; - Py_ssize_t len; - - t = PyList_GET_ITEM(value, j); - assert(size > 0); - len = PyUnicode_AsWideChar(t, P, size); - assert(len >= 0); - assert((unsigned)len < size); - size -= (DWORD)len + 1; - P += len + 1; - } - /* And doubly-terminate the list... */ - *P = L'\0'; - break; - } - case REG_BINARY: - /* ALSO handle ALL unknown data types here. Even if we can't - support it natively, we should handle the bits. */ - default: - if (value == Py_None) { - *retDataSize = 0; - *retDataBuf = NULL; - } - else { - Py_buffer view; - - if (!PyObject_CheckBuffer(value)) { - PyErr_Format(PyExc_TypeError, - "Objects of type '%s' can not " - "be used as binary registry values", - Py_TYPE(value)->tp_name); - return FALSE; - } - - if (PyObject_GetBuffer(value, &view, PyBUF_SIMPLE) < 0) - return FALSE; - - *retDataBuf = (BYTE *)PyMem_NEW(char, view.len); - if (*retDataBuf == NULL){ - PyBuffer_Release(&view); - PyErr_NoMemory(); - return FALSE; - } - *retDataSize = Py_SAFE_DOWNCAST(view.len, Py_ssize_t, DWORD); - memcpy(*retDataBuf, view.buf, view.len); - PyBuffer_Release(&view); - } - break; - } - return TRUE; -} - -/* Convert Registry data into PyObject*/ -static PyObject * -Reg2Py(BYTE *retDataBuf, DWORD retDataSize, DWORD typ) -{ - PyObject *obData; - - switch (typ) { - case REG_DWORD: - if (retDataSize == 0) - obData = PyLong_FromUnsignedLong(0); - else - obData = PyLong_FromUnsignedLong(*(DWORD *)retDataBuf); - break; - case REG_QWORD: - if (retDataSize == 0) - obData = PyLong_FromUnsignedLongLong(0); - else - obData = PyLong_FromUnsignedLongLong(*(DWORD64 *)retDataBuf); - break; - case REG_SZ: - case REG_EXPAND_SZ: - { - /* REG_SZ should be a NUL terminated string, but only by - * convention. The buffer may have been saved without a NUL - * or with embedded NULs. To be consistent with reg.exe and - * regedit.exe, consume only up to the first NUL. */ - wchar_t *data = (wchar_t *)retDataBuf; - size_t len = wcsnlen(data, retDataSize / sizeof(wchar_t)); - obData = PyUnicode_FromWideChar(data, len); - break; - } - case REG_MULTI_SZ: - if (retDataSize == 0) - obData = PyList_New(0); - else - { - int index = 0; - wchar_t *data = (wchar_t *)retDataBuf; - int len = retDataSize / 2; - int s = countStrings(data, len); - wchar_t **str = PyMem_New(wchar_t *, s); - if (str == NULL) - return PyErr_NoMemory(); - - fixupMultiSZ(str, data, len); - obData = PyList_New(s); - if (obData == NULL) { - PyMem_Free(str); - return NULL; - } - for (index = 0; index < s; index++) - { - size_t slen = wcsnlen(str[index], len); - PyObject *uni = PyUnicode_FromWideChar(str[index], slen); - if (uni == NULL) { - Py_DECREF(obData); - PyMem_Free(str); - return NULL; - } - PyList_SET_ITEM(obData, index, uni); - len -= Py_SAFE_DOWNCAST(slen + 1, size_t, int); - } - PyMem_Free(str); - - break; - } - case REG_BINARY: - /* ALSO handle ALL unknown data types here. Even if we can't - support it natively, we should handle the bits. */ - default: - if (retDataSize == 0) { - Py_INCREF(Py_None); - obData = Py_None; - } - else - obData = PyBytes_FromStringAndSize( - (char *)retDataBuf, retDataSize); - break; - } - return obData; -} - -/* The Python methods */ - -/*[clinic input] -winreg.CloseKey - - hkey: object - A previously opened key. - / - -Closes a previously opened registry key. - -Note that if the key is not closed using this method, it will be -closed when the hkey object is destroyed by Python. -[clinic start generated code]*/ - -static PyObject * -winreg_CloseKey(PyObject *module, PyObject *hkey) -/*[clinic end generated code: output=a4fa537019a80d15 input=5b1aac65ba5127ad]*/ -{ - if (!PyHKEY_Close(hkey)) - return NULL; - Py_RETURN_NONE; -} - -/*[clinic input] -winreg.ConnectRegistry -> HKEY - - computer_name: Py_UNICODE(accept={str, NoneType}) - The name of the remote computer, of the form r"\\computername". If - None, the local computer is used. - key: HKEY - The predefined key to connect to. - / - -Establishes a connection to the registry on another computer. - -The return value is the handle of the opened key. -If the function fails, an OSError exception is raised. -[clinic start generated code]*/ - -static HKEY -winreg_ConnectRegistry_impl(PyObject *module, - const Py_UNICODE *computer_name, HKEY key) -/*[clinic end generated code: output=cd4f70fb9ec901fb input=5f98a891a347e68e]*/ -{ - HKEY retKey; - long rc; - if (PySys_Audit("winreg.ConnectRegistry", "un", - computer_name, (Py_ssize_t)key) < 0) { - return NULL; - } - Py_BEGIN_ALLOW_THREADS - rc = RegConnectRegistryW(computer_name, key, &retKey); - Py_END_ALLOW_THREADS - if (rc != ERROR_SUCCESS) { - PyErr_SetFromWindowsErrWithFunction(rc, "ConnectRegistry"); - return NULL; - } - return retKey; -} - -/*[clinic input] -winreg.CreateKey -> HKEY - - key: HKEY - An already open key, or one of the predefined HKEY_* constants. - sub_key: Py_UNICODE(accept={str, NoneType}) - The name of the key this method opens or creates. - / - -Creates or opens the specified key. - -If key is one of the predefined keys, sub_key may be None. In that case, -the handle returned is the same key handle passed in to the function. - -If the key already exists, this function opens the existing key. - -The return value is the handle of the opened key. -If the function fails, an OSError exception is raised. -[clinic start generated code]*/ - -static HKEY -winreg_CreateKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key) -/*[clinic end generated code: output=2af13910d56eae26 input=3cdd1622488acea2]*/ -{ - HKEY retKey; - long rc; - - if (PySys_Audit("winreg.CreateKey", "nun", - (Py_ssize_t)key, sub_key, - (Py_ssize_t)KEY_WRITE) < 0) { - return NULL; - } - rc = RegCreateKeyW(key, sub_key, &retKey); - if (rc != ERROR_SUCCESS) { - PyErr_SetFromWindowsErrWithFunction(rc, "CreateKey"); - return NULL; - } - if (PySys_Audit("winreg.OpenKey/result", "n", - (Py_ssize_t)retKey) < 0) { - return NULL; - } - return retKey; -} - -/*[clinic input] -winreg.CreateKeyEx -> HKEY - - key: HKEY - An already open key, or one of the predefined HKEY_* constants. - sub_key: Py_UNICODE(accept={str, NoneType}) - The name of the key this method opens or creates. - reserved: int = 0 - A reserved integer, and must be zero. Default is zero. - access: REGSAM(c_default='KEY_WRITE') = winreg.KEY_WRITE - An integer that specifies an access mask that describes the - desired security access for the key. Default is KEY_WRITE. - -Creates or opens the specified key. - -If key is one of the predefined keys, sub_key may be None. In that case, -the handle returned is the same key handle passed in to the function. - -If the key already exists, this function opens the existing key - -The return value is the handle of the opened key. -If the function fails, an OSError exception is raised. -[clinic start generated code]*/ - -static HKEY -winreg_CreateKeyEx_impl(PyObject *module, HKEY key, - const Py_UNICODE *sub_key, int reserved, - REGSAM access) -/*[clinic end generated code: output=643a70ad6a361a97 input=42c2b03f98406b66]*/ -{ - HKEY retKey; - long rc; - - if (PySys_Audit("winreg.CreateKey", "nun", - (Py_ssize_t)key, sub_key, - (Py_ssize_t)access) < 0) { - return NULL; - } - rc = RegCreateKeyExW(key, sub_key, reserved, NULL, 0, - access, NULL, &retKey, NULL); - if (rc != ERROR_SUCCESS) { - PyErr_SetFromWindowsErrWithFunction(rc, "CreateKeyEx"); - return NULL; - } - if (PySys_Audit("winreg.OpenKey/result", "n", - (Py_ssize_t)retKey) < 0) { - return NULL; - } - return retKey; -} - -/*[clinic input] -winreg.DeleteKey - key: HKEY - An already open key, or any one of the predefined HKEY_* constants. - sub_key: Py_UNICODE - A string that must be the name of a subkey of the key identified by - the key parameter. This value must not be None, and the key may not - have subkeys. - / - -Deletes the specified key. - -This method can not delete keys with subkeys. - -If the function succeeds, the entire key, including all of its values, -is removed. If the function fails, an OSError exception is raised. -[clinic start generated code]*/ - -static PyObject * -winreg_DeleteKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key) -/*[clinic end generated code: output=d2652a84f70e0862 input=b31d225b935e4211]*/ -{ - long rc; - if (PySys_Audit("winreg.DeleteKey", "nun", - (Py_ssize_t)key, sub_key, - (Py_ssize_t)0) < 0) { - return NULL; - } - Py_BEGIN_ALLOW_THREADS - rc = RegDeleteKeyW(key, sub_key); - Py_END_ALLOW_THREADS - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKey"); - Py_RETURN_NONE; -} - -/*[clinic input] -winreg.DeleteKeyEx - - key: HKEY - An already open key, or any one of the predefined HKEY_* constants. - sub_key: Py_UNICODE - A string that must be the name of a subkey of the key identified by - the key parameter. This value must not be None, and the key may not - have subkeys. - access: REGSAM(c_default='KEY_WOW64_64KEY') = winreg.KEY_WOW64_64KEY - An integer that specifies an access mask that describes the - desired security access for the key. Default is KEY_WOW64_64KEY. - reserved: int = 0 - A reserved integer, and must be zero. Default is zero. - -Deletes the specified key (intended for 64-bit OS). - -While this function is intended to be used for 64-bit OS, it is also - available on 32-bit systems. - -This method can not delete keys with subkeys. - -If the function succeeds, the entire key, including all of its values, -is removed. If the function fails, an OSError exception is raised. -On unsupported Windows versions, NotImplementedError is raised. -[clinic start generated code]*/ - -static PyObject * -winreg_DeleteKeyEx_impl(PyObject *module, HKEY key, - const Py_UNICODE *sub_key, REGSAM access, - int reserved) -/*[clinic end generated code: output=52a1c8b374ebc003 input=a3186db079b3bf85]*/ -{ - long rc; - if (PySys_Audit("winreg.DeleteKey", "nun", - (Py_ssize_t)key, sub_key, - (Py_ssize_t)access) < 0) { - return NULL; - } - Py_BEGIN_ALLOW_THREADS - rc = RegDeleteKeyExW(key, sub_key, access, reserved); - Py_END_ALLOW_THREADS - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKeyEx"); - Py_RETURN_NONE; -} - -/*[clinic input] -winreg.DeleteValue - - key: HKEY - An already open key, or any one of the predefined HKEY_* constants. - value: Py_UNICODE(accept={str, NoneType}) - A string that identifies the value to remove. - / - -Removes a named value from a registry key. -[clinic start generated code]*/ - -static PyObject * -winreg_DeleteValue_impl(PyObject *module, HKEY key, const Py_UNICODE *value) -/*[clinic end generated code: output=56fa9d21f3a54371 input=a78d3407a4197b21]*/ -{ - long rc; - if (PySys_Audit("winreg.DeleteValue", "nu", - (Py_ssize_t)key, value) < 0) { - return NULL; - } - Py_BEGIN_ALLOW_THREADS - rc = RegDeleteValueW(key, value); - Py_END_ALLOW_THREADS - if (rc !=ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegDeleteValue"); - Py_RETURN_NONE; -} - -/*[clinic input] -winreg.EnumKey - - key: HKEY - An already open key, or any one of the predefined HKEY_* constants. - index: int - An integer that identifies the index of the key to retrieve. - / - -Enumerates subkeys of an open registry key. - -The function retrieves the name of one subkey each time it is called. -It is typically called repeatedly until an OSError exception is -raised, indicating no more values are available. -[clinic start generated code]*/ - -static PyObject * -winreg_EnumKey_impl(PyObject *module, HKEY key, int index) -/*[clinic end generated code: output=25a6ec52cd147bc4 input=fad9a7c00ab0e04b]*/ -{ - long rc; - PyObject *retStr; - - if (PySys_Audit("winreg.EnumKey", "ni", - (Py_ssize_t)key, index) < 0) { - return NULL; - } - /* The Windows docs claim that the max key name length is 255 - * characters, plus a terminating nul character. However, - * empirical testing demonstrates that it is possible to - * create a 256 character key that is missing the terminating - * nul. RegEnumKeyEx requires a 257 character buffer to - * retrieve such a key name. */ - wchar_t tmpbuf[257]; - DWORD len = sizeof(tmpbuf)/sizeof(wchar_t); /* includes NULL terminator */ - - Py_BEGIN_ALLOW_THREADS - rc = RegEnumKeyExW(key, index, tmpbuf, &len, NULL, NULL, NULL, NULL); - Py_END_ALLOW_THREADS - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, "RegEnumKeyEx"); - - retStr = PyUnicode_FromWideChar(tmpbuf, len); - return retStr; /* can be NULL */ -} - -/*[clinic input] -winreg.EnumValue - - key: HKEY - An already open key, or any one of the predefined HKEY_* constants. - index: int - An integer that identifies the index of the value to retrieve. - / - -Enumerates values of an open registry key. - -The function retrieves the name of one subkey each time it is called. -It is typically called repeatedly, until an OSError exception -is raised, indicating no more values. - -The result is a tuple of 3 items: - value_name - A string that identifies the value. - value_data - An object that holds the value data, and whose type depends - on the underlying registry type. - data_type - An integer that identifies the type of the value data. -[clinic start generated code]*/ - -static PyObject * -winreg_EnumValue_impl(PyObject *module, HKEY key, int index) -/*[clinic end generated code: output=d363b5a06f8789ac input=4414f47a6fb238b5]*/ -{ - long rc; - wchar_t *retValueBuf; - BYTE *tmpBuf; - BYTE *retDataBuf; - DWORD retValueSize, bufValueSize; - DWORD retDataSize, bufDataSize; - DWORD typ; - PyObject *obData; - PyObject *retVal; - - if (PySys_Audit("winreg.EnumValue", "ni", - (Py_ssize_t)key, index) < 0) { - return NULL; - } - if ((rc = RegQueryInfoKeyW(key, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, - &retValueSize, &retDataSize, NULL, NULL)) - != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegQueryInfoKey"); - ++retValueSize; /* include null terminators */ - ++retDataSize; - bufDataSize = retDataSize; - bufValueSize = retValueSize; - retValueBuf = PyMem_New(wchar_t, retValueSize); - if (retValueBuf == NULL) - return PyErr_NoMemory(); - retDataBuf = (BYTE *)PyMem_Malloc(retDataSize); - if (retDataBuf == NULL) { - PyMem_Free(retValueBuf); - return PyErr_NoMemory(); - } - - while (1) { - Py_BEGIN_ALLOW_THREADS - rc = RegEnumValueW(key, - index, - retValueBuf, - &retValueSize, - NULL, - &typ, - (BYTE *)retDataBuf, - &retDataSize); - Py_END_ALLOW_THREADS - - if (rc != ERROR_MORE_DATA) - break; - - bufDataSize *= 2; - tmpBuf = (BYTE *)PyMem_Realloc(retDataBuf, bufDataSize); - if (tmpBuf == NULL) { - PyErr_NoMemory(); - retVal = NULL; - goto fail; - } - retDataBuf = tmpBuf; - retDataSize = bufDataSize; - retValueSize = bufValueSize; - } - - if (rc != ERROR_SUCCESS) { - retVal = PyErr_SetFromWindowsErrWithFunction(rc, - "PyRegEnumValue"); - goto fail; - } - obData = Reg2Py(retDataBuf, retDataSize, typ); - if (obData == NULL) { - retVal = NULL; - goto fail; - } - retVal = Py_BuildValue("uOi", retValueBuf, obData, typ); - Py_DECREF(obData); - fail: - PyMem_Free(retValueBuf); - PyMem_Free(retDataBuf); - return retVal; -} - -/*[clinic input] -winreg.ExpandEnvironmentStrings - - string: Py_UNICODE - / - -Expand environment vars. -[clinic start generated code]*/ - -static PyObject * -winreg_ExpandEnvironmentStrings_impl(PyObject *module, - const Py_UNICODE *string) -/*[clinic end generated code: output=8fa4e959747a7312 input=b2a9714d2b751aa6]*/ -{ - wchar_t *retValue = NULL; - DWORD retValueSize; - DWORD rc; - PyObject *o; - - if (PySys_Audit("winreg.ExpandEnvironmentStrings", "u", - string) < 0) { - return NULL; - } - - retValueSize = ExpandEnvironmentStringsW(string, retValue, 0); - if (retValueSize == 0) { - return PyErr_SetFromWindowsErrWithFunction(retValueSize, - "ExpandEnvironmentStrings"); - } - retValue = PyMem_New(wchar_t, retValueSize); - if (retValue == NULL) { - return PyErr_NoMemory(); - } - - rc = ExpandEnvironmentStringsW(string, retValue, retValueSize); - if (rc == 0) { - PyMem_Free(retValue); - return PyErr_SetFromWindowsErrWithFunction(retValueSize, - "ExpandEnvironmentStrings"); - } - o = PyUnicode_FromWideChar(retValue, wcslen(retValue)); - PyMem_Free(retValue); - return o; -} - -/*[clinic input] -winreg.FlushKey - - key: HKEY - An already open key, or any one of the predefined HKEY_* constants. - / - -Writes all the attributes of a key to the registry. - -It is not necessary to call FlushKey to change a key. Registry changes -are flushed to disk by the registry using its lazy flusher. Registry -changes are also flushed to disk at system shutdown. Unlike -CloseKey(), the FlushKey() method returns only when all the data has -been written to the registry. - -An application should only call FlushKey() if it requires absolute -certainty that registry changes are on disk. If you don't know whether -a FlushKey() call is required, it probably isn't. -[clinic start generated code]*/ - -static PyObject * -winreg_FlushKey_impl(PyObject *module, HKEY key) -/*[clinic end generated code: output=e6fc230d4c5dc049 input=f57457c12297d82f]*/ -{ - long rc; - Py_BEGIN_ALLOW_THREADS - rc = RegFlushKey(key); - Py_END_ALLOW_THREADS - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, "RegFlushKey"); - Py_RETURN_NONE; -} - - -/*[clinic input] -winreg.LoadKey - - key: HKEY - An already open key, or any one of the predefined HKEY_* constants. - sub_key: Py_UNICODE - A string that identifies the sub-key to load. - file_name: Py_UNICODE - The name of the file to load registry data from. This file must - have been created with the SaveKey() function. Under the file - allocation table (FAT) file system, the filename may not have an - extension. - / - -Insert data into the registry from a file. - -Creates a subkey under the specified key and stores registration -information from a specified file into that subkey. - -A call to LoadKey() fails if the calling process does not have the -SE_RESTORE_PRIVILEGE privilege. - -If key is a handle returned by ConnectRegistry(), then the path -specified in fileName is relative to the remote computer. - -The MSDN docs imply key must be in the HKEY_USER or HKEY_LOCAL_MACHINE -tree. -[clinic start generated code]*/ - -static PyObject * -winreg_LoadKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, - const Py_UNICODE *file_name) -/*[clinic end generated code: output=65f89f2548cb27c7 input=e3b5b45ade311582]*/ -{ - long rc; - - if (PySys_Audit("winreg.LoadKey", "nuu", - (Py_ssize_t)key, sub_key, file_name) < 0) { - return NULL; - } - Py_BEGIN_ALLOW_THREADS - rc = RegLoadKeyW(key, sub_key, file_name ); - Py_END_ALLOW_THREADS - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, "RegLoadKey"); - Py_RETURN_NONE; -} - -/*[clinic input] -winreg.OpenKey -> HKEY - - key: HKEY - An already open key, or any one of the predefined HKEY_* constants. - sub_key: Py_UNICODE(accept={str, NoneType}) - A string that identifies the sub_key to open. - reserved: int = 0 - A reserved integer that must be zero. Default is zero. - access: REGSAM(c_default='KEY_READ') = winreg.KEY_READ - An integer that specifies an access mask that describes the desired - security access for the key. Default is KEY_READ. - -Opens the specified key. - -The result is a new handle to the specified key. -If the function fails, an OSError exception is raised. -[clinic start generated code]*/ - -static HKEY -winreg_OpenKey_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, - int reserved, REGSAM access) -/*[clinic end generated code: output=8849bff2c30104ad input=098505ac36a9ae28]*/ -{ - HKEY retKey; - long rc; - - if (PySys_Audit("winreg.OpenKey", "nun", - (Py_ssize_t)key, sub_key, - (Py_ssize_t)access) < 0) { - return NULL; - } - Py_BEGIN_ALLOW_THREADS - rc = RegOpenKeyExW(key, sub_key, reserved, access, &retKey); - Py_END_ALLOW_THREADS - if (rc != ERROR_SUCCESS) { - PyErr_SetFromWindowsErrWithFunction(rc, "RegOpenKeyEx"); - return NULL; - } - if (PySys_Audit("winreg.OpenKey/result", "n", - (Py_ssize_t)retKey) < 0) { - return NULL; - } - return retKey; -} - -/*[clinic input] -winreg.OpenKeyEx = winreg.OpenKey - -Opens the specified key. - -The result is a new handle to the specified key. -If the function fails, an OSError exception is raised. -[clinic start generated code]*/ - -static HKEY -winreg_OpenKeyEx_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, - int reserved, REGSAM access) -/*[clinic end generated code: output=81bc2bd684bc77ae input=c6c4972af8622959]*/ -{ - return winreg_OpenKey_impl(module, key, sub_key, reserved, access); -} - -/*[clinic input] -winreg.QueryInfoKey - - key: HKEY - An already open key, or any one of the predefined HKEY_* constants. - / - -Returns information about a key. - -The result is a tuple of 3 items: -An integer that identifies the number of sub keys this key has. -An integer that identifies the number of values this key has. -An integer that identifies when the key was last modified (if available) -as 100's of nanoseconds since Jan 1, 1600. -[clinic start generated code]*/ - -static PyObject * -winreg_QueryInfoKey_impl(PyObject *module, HKEY key) -/*[clinic end generated code: output=dc657b8356a4f438 input=c3593802390cde1f]*/ -{ - long rc; - DWORD nSubKeys, nValues; - FILETIME ft; - LARGE_INTEGER li; - PyObject *l; - PyObject *ret; - - if (PySys_Audit("winreg.QueryInfoKey", "n", (Py_ssize_t)key) < 0) { - return NULL; - } - if ((rc = RegQueryInfoKeyW(key, NULL, NULL, 0, &nSubKeys, NULL, NULL, - &nValues, NULL, NULL, NULL, &ft)) - != ERROR_SUCCESS) { - return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryInfoKey"); - } - li.LowPart = ft.dwLowDateTime; - li.HighPart = ft.dwHighDateTime; - l = PyLong_FromLongLong(li.QuadPart); - if (l == NULL) { - return NULL; - } - ret = Py_BuildValue("iiO", nSubKeys, nValues, l); - Py_DECREF(l); - return ret; -} - -/*[clinic input] -winreg.QueryValue - - key: HKEY - An already open key, or any one of the predefined HKEY_* constants. - sub_key: Py_UNICODE(accept={str, NoneType}) - A string that holds the name of the subkey with which the value - is associated. If this parameter is None or empty, the function - retrieves the value set by the SetValue() method for the key - identified by key. - / - -Retrieves the unnamed value for a key. - -Values in the registry have name, type, and data components. This method -retrieves the data for a key's first value that has a NULL name. -But since the underlying API call doesn't return the type, you'll -probably be happier using QueryValueEx; this function is just here for -completeness. -[clinic start generated code]*/ - -static PyObject * -winreg_QueryValue_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key) -/*[clinic end generated code: output=c655810ae50c63a9 input=41cafbbf423b21d6]*/ -{ - long rc; - PyObject *retStr; - wchar_t *retBuf; - DWORD bufSize = 0; - DWORD retSize = 0; - wchar_t *tmp; - - if (PySys_Audit("winreg.QueryValue", "nuu", - (Py_ssize_t)key, sub_key, NULL) < 0) { - return NULL; - } - rc = RegQueryValueW(key, sub_key, NULL, &retSize); - if (rc == ERROR_MORE_DATA) - retSize = 256; - else if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegQueryValue"); - - bufSize = retSize; - retBuf = (wchar_t *) PyMem_Malloc(bufSize); - if (retBuf == NULL) - return PyErr_NoMemory(); - - while (1) { - retSize = bufSize; - rc = RegQueryValueW(key, sub_key, retBuf, &retSize); - if (rc != ERROR_MORE_DATA) - break; - - bufSize *= 2; - tmp = (wchar_t *) PyMem_Realloc(retBuf, bufSize); - if (tmp == NULL) { - PyMem_Free(retBuf); - return PyErr_NoMemory(); - } - retBuf = tmp; - } - - if (rc != ERROR_SUCCESS) { - PyMem_Free(retBuf); - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegQueryValue"); - } - - retStr = PyUnicode_FromWideChar(retBuf, wcslen(retBuf)); - PyMem_Free(retBuf); - return retStr; -} - - -/*[clinic input] -winreg.QueryValueEx - - key: HKEY - An already open key, or any one of the predefined HKEY_* constants. - name: Py_UNICODE(accept={str, NoneType}) - A string indicating the value to query. - / - -Retrieves the type and value of a specified sub-key. - -Behaves mostly like QueryValue(), but also returns the type of the -specified value name associated with the given open registry key. - -The return value is a tuple of the value and the type_id. -[clinic start generated code]*/ - -static PyObject * -winreg_QueryValueEx_impl(PyObject *module, HKEY key, const Py_UNICODE *name) -/*[clinic end generated code: output=f1b85b1c3d887ec7 input=cf366cada4836891]*/ -{ - long rc; - BYTE *retBuf, *tmp; - DWORD bufSize = 0, retSize; - DWORD typ; - PyObject *obData; - PyObject *result; - - if (PySys_Audit("winreg.QueryValue", "nuu", - (Py_ssize_t)key, NULL, name) < 0) { - return NULL; - } - rc = RegQueryValueExW(key, name, NULL, NULL, NULL, &bufSize); - if (rc == ERROR_MORE_DATA) - bufSize = 256; - else if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegQueryValueEx"); - retBuf = (BYTE *)PyMem_Malloc(bufSize); - if (retBuf == NULL) - return PyErr_NoMemory(); - - while (1) { - retSize = bufSize; - rc = RegQueryValueExW(key, name, NULL, &typ, - (BYTE *)retBuf, &retSize); - if (rc != ERROR_MORE_DATA) - break; - - bufSize *= 2; - tmp = (char *) PyMem_Realloc(retBuf, bufSize); - if (tmp == NULL) { - PyMem_Free(retBuf); - return PyErr_NoMemory(); - } - retBuf = tmp; - } - - if (rc != ERROR_SUCCESS) { - PyMem_Free(retBuf); - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegQueryValueEx"); - } - obData = Reg2Py(retBuf, bufSize, typ); - PyMem_Free(retBuf); - if (obData == NULL) - return NULL; - result = Py_BuildValue("Oi", obData, typ); - Py_DECREF(obData); - return result; -} - -/*[clinic input] -winreg.SaveKey - - key: HKEY - An already open key, or any one of the predefined HKEY_* constants. - file_name: Py_UNICODE - The name of the file to save registry data to. This file cannot - already exist. If this filename includes an extension, it cannot be - used on file allocation table (FAT) file systems by the LoadKey(), - ReplaceKey() or RestoreKey() methods. - / - -Saves the specified key, and all its subkeys to the specified file. - -If key represents a key on a remote computer, the path described by -file_name is relative to the remote computer. - -The caller of this method must possess the SeBackupPrivilege -security privilege. This function passes NULL for security_attributes -to the API. -[clinic start generated code]*/ - -static PyObject * -winreg_SaveKey_impl(PyObject *module, HKEY key, const Py_UNICODE *file_name) -/*[clinic end generated code: output=ca94b835c88f112b input=da735241f91ac7a2]*/ -{ - LPSECURITY_ATTRIBUTES pSA = NULL; - - long rc; -/* One day we may get security into the core? - if (!PyWinObject_AsSECURITY_ATTRIBUTES(obSA, &pSA, TRUE)) - return NULL; -*/ - if (PySys_Audit("winreg.SaveKey", "nu", - (Py_ssize_t)key, file_name) < 0) { - return NULL; - } - Py_BEGIN_ALLOW_THREADS - rc = RegSaveKeyW(key, file_name, pSA ); - Py_END_ALLOW_THREADS - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, "RegSaveKey"); - Py_RETURN_NONE; -} - -/*[clinic input] -winreg.SetValue - - key: HKEY - An already open key, or any one of the predefined HKEY_* constants. - sub_key: Py_UNICODE(accept={str, NoneType}) - A string that names the subkey with which the value is associated. - type: DWORD - An integer that specifies the type of the data. Currently this must - be REG_SZ, meaning only strings are supported. - value as value_obj: unicode - A string that specifies the new value. - / - -Associates a value with a specified key. - -If the key specified by the sub_key parameter does not exist, the -SetValue function creates it. - -Value lengths are limited by available memory. Long values (more than -2048 bytes) should be stored as files with the filenames stored in -the configuration registry to help the registry perform efficiently. - -The key identified by the key parameter must have been opened with -KEY_SET_VALUE access. -[clinic start generated code]*/ - -static PyObject * -winreg_SetValue_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key, - DWORD type, PyObject *value_obj) -/*[clinic end generated code: output=d4773dc9c372311a input=bf088494ae2d24fd]*/ -{ - Py_ssize_t value_length; - long rc; - - if (type != REG_SZ) { - PyErr_SetString(PyExc_TypeError, "type must be winreg.REG_SZ"); - return NULL; - } - -#if USE_UNICODE_WCHAR_CACHE -_Py_COMP_DIAG_PUSH -_Py_COMP_DIAG_IGNORE_DEPR_DECLS - const wchar_t *value = PyUnicode_AsUnicodeAndSize(value_obj, &value_length); -_Py_COMP_DIAG_POP -#else /* USE_UNICODE_WCHAR_CACHE */ - wchar_t *value = PyUnicode_AsWideCharString(value_obj, &value_length); -#endif /* USE_UNICODE_WCHAR_CACHE */ - if (value == NULL) { - return NULL; - } - if ((Py_ssize_t)(DWORD)value_length != value_length) { - PyErr_SetString(PyExc_OverflowError, "value is too long"); -#if !USE_UNICODE_WCHAR_CACHE - PyMem_Free(value); -#endif /* USE_UNICODE_WCHAR_CACHE */ - return NULL; - } - - if (PySys_Audit("winreg.SetValue", "nunu#", - (Py_ssize_t)key, sub_key, (Py_ssize_t)type, - value, value_length) < 0) { -#if !USE_UNICODE_WCHAR_CACHE - PyMem_Free(value); -#endif /* USE_UNICODE_WCHAR_CACHE */ - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - rc = RegSetValueW(key, sub_key, REG_SZ, value, (DWORD)(value_length + 1)); - Py_END_ALLOW_THREADS -#if !USE_UNICODE_WCHAR_CACHE - PyMem_Free(value); -#endif /* USE_UNICODE_WCHAR_CACHE */ - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, "RegSetValue"); - Py_RETURN_NONE; -} - -/*[clinic input] -winreg.SetValueEx - - key: HKEY - An already open key, or any one of the predefined HKEY_* constants. - value_name: Py_UNICODE(accept={str, NoneType}) - A string containing the name of the value to set, or None. - reserved: object - Can be anything - zero is always passed to the API. - type: DWORD - An integer that specifies the type of the data, one of: - REG_BINARY -- Binary data in any form. - REG_DWORD -- A 32-bit number. - REG_DWORD_LITTLE_ENDIAN -- A 32-bit number in little-endian format. Equivalent to REG_DWORD - REG_DWORD_BIG_ENDIAN -- A 32-bit number in big-endian format. - REG_EXPAND_SZ -- A null-terminated string that contains unexpanded - references to environment variables (for example, - %PATH%). - REG_LINK -- A Unicode symbolic link. - REG_MULTI_SZ -- A sequence of null-terminated strings, terminated - by two null characters. Note that Python handles - this termination automatically. - REG_NONE -- No defined value type. - REG_QWORD -- A 64-bit number. - REG_QWORD_LITTLE_ENDIAN -- A 64-bit number in little-endian format. Equivalent to REG_QWORD. - REG_RESOURCE_LIST -- A device-driver resource list. - REG_SZ -- A null-terminated string. - value: object - A string that specifies the new value. - / - -Stores data in the value field of an open registry key. - -This method can also set additional value and type information for the -specified key. The key identified by the key parameter must have been -opened with KEY_SET_VALUE access. - -To open the key, use the CreateKeyEx() or OpenKeyEx() methods. - -Value lengths are limited by available memory. Long values (more than -2048 bytes) should be stored as files with the filenames stored in -the configuration registry to help the registry perform efficiently. -[clinic start generated code]*/ - -static PyObject * -winreg_SetValueEx_impl(PyObject *module, HKEY key, - const Py_UNICODE *value_name, PyObject *reserved, - DWORD type, PyObject *value) -/*[clinic end generated code: output=811b769a66ae11b7 input=900a9e3990bfb196]*/ -{ - BYTE *data; - DWORD len; - - LONG rc; - - if (!Py2Reg(value, type, &data, &len)) - { - if (!PyErr_Occurred()) - PyErr_SetString(PyExc_ValueError, - "Could not convert the data to the specified type."); - return NULL; - } - if (PySys_Audit("winreg.SetValue", "nunO", - (Py_ssize_t)key, value_name, (Py_ssize_t)type, - value) < 0) { - PyMem_Free(data); - return NULL; - } - Py_BEGIN_ALLOW_THREADS - rc = RegSetValueExW(key, value_name, 0, type, data, len); - Py_END_ALLOW_THREADS - PyMem_Free(data); - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegSetValueEx"); - Py_RETURN_NONE; -} - -/*[clinic input] -winreg.DisableReflectionKey - - key: HKEY - An already open key, or any one of the predefined HKEY_* constants. - / - -Disables registry reflection for 32bit processes running on a 64bit OS. - -Will generally raise NotImplementedError if executed on a 32bit OS. - -If the key is not on the reflection list, the function succeeds but has -no effect. Disabling reflection for a key does not affect reflection -of any subkeys. -[clinic start generated code]*/ - -static PyObject * -winreg_DisableReflectionKey_impl(PyObject *module, HKEY key) -/*[clinic end generated code: output=830cce504cc764b4 input=70bece2dee02e073]*/ -{ - HMODULE hMod; - typedef LONG (WINAPI *RDRKFunc)(HKEY); - RDRKFunc pfn = NULL; - LONG rc; - - if (PySys_Audit("winreg.DisableReflectionKey", "n", (Py_ssize_t)key) < 0) { - return NULL; - } - - /* Only available on 64bit platforms, so we must load it - dynamically.*/ - Py_BEGIN_ALLOW_THREADS - hMod = GetModuleHandleW(L"advapi32.dll"); - if (hMod) - pfn = (RDRKFunc)GetProcAddress(hMod, - "RegDisableReflectionKey"); - Py_END_ALLOW_THREADS - if (!pfn) { - PyErr_SetString(PyExc_NotImplementedError, - "not implemented on this platform"); - return NULL; - } - Py_BEGIN_ALLOW_THREADS - rc = (*pfn)(key); - Py_END_ALLOW_THREADS - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegDisableReflectionKey"); - Py_RETURN_NONE; -} - -/*[clinic input] -winreg.EnableReflectionKey - - key: HKEY - An already open key, or any one of the predefined HKEY_* constants. - / - -Restores registry reflection for the specified disabled key. - -Will generally raise NotImplementedError if executed on a 32bit OS. -Restoring reflection for a key does not affect reflection of any -subkeys. -[clinic start generated code]*/ - -static PyObject * -winreg_EnableReflectionKey_impl(PyObject *module, HKEY key) -/*[clinic end generated code: output=86fa1385fdd9ce57 input=eeae770c6eb9f559]*/ -{ - HMODULE hMod; - typedef LONG (WINAPI *RERKFunc)(HKEY); - RERKFunc pfn = NULL; - LONG rc; - - if (PySys_Audit("winreg.EnableReflectionKey", "n", (Py_ssize_t)key) < 0) { - return NULL; - } - - /* Only available on 64bit platforms, so we must load it - dynamically.*/ - Py_BEGIN_ALLOW_THREADS - hMod = GetModuleHandleW(L"advapi32.dll"); - if (hMod) - pfn = (RERKFunc)GetProcAddress(hMod, - "RegEnableReflectionKey"); - Py_END_ALLOW_THREADS - if (!pfn) { - PyErr_SetString(PyExc_NotImplementedError, - "not implemented on this platform"); - return NULL; - } - Py_BEGIN_ALLOW_THREADS - rc = (*pfn)(key); - Py_END_ALLOW_THREADS - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegEnableReflectionKey"); - Py_RETURN_NONE; -} - -/*[clinic input] -winreg.QueryReflectionKey - - key: HKEY - An already open key, or any one of the predefined HKEY_* constants. - / - -Returns the reflection state for the specified key as a bool. - -Will generally raise NotImplementedError if executed on a 32bit OS. -[clinic start generated code]*/ - -static PyObject * -winreg_QueryReflectionKey_impl(PyObject *module, HKEY key) -/*[clinic end generated code: output=4e774af288c3ebb9 input=a98fa51d55ade186]*/ -{ - HMODULE hMod; - typedef LONG (WINAPI *RQRKFunc)(HKEY, BOOL *); - RQRKFunc pfn = NULL; - BOOL result; - LONG rc; - - if (PySys_Audit("winreg.QueryReflectionKey", "n", (Py_ssize_t)key) < 0) { - return NULL; - } - - /* Only available on 64bit platforms, so we must load it - dynamically.*/ - Py_BEGIN_ALLOW_THREADS - hMod = GetModuleHandleW(L"advapi32.dll"); - if (hMod) - pfn = (RQRKFunc)GetProcAddress(hMod, - "RegQueryReflectionKey"); - Py_END_ALLOW_THREADS - if (!pfn) { - PyErr_SetString(PyExc_NotImplementedError, - "not implemented on this platform"); - return NULL; - } - Py_BEGIN_ALLOW_THREADS - rc = (*pfn)(key, &result); - Py_END_ALLOW_THREADS - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, - "RegQueryReflectionKey"); - return PyBool_FromLong(result); -} - -static struct PyMethodDef winreg_methods[] = { - WINREG_CLOSEKEY_METHODDEF - WINREG_CONNECTREGISTRY_METHODDEF - WINREG_CREATEKEY_METHODDEF - WINREG_CREATEKEYEX_METHODDEF - WINREG_DELETEKEY_METHODDEF - WINREG_DELETEKEYEX_METHODDEF - WINREG_DELETEVALUE_METHODDEF - WINREG_DISABLEREFLECTIONKEY_METHODDEF - WINREG_ENABLEREFLECTIONKEY_METHODDEF - WINREG_ENUMKEY_METHODDEF - WINREG_ENUMVALUE_METHODDEF - WINREG_EXPANDENVIRONMENTSTRINGS_METHODDEF - WINREG_FLUSHKEY_METHODDEF - WINREG_LOADKEY_METHODDEF - WINREG_OPENKEY_METHODDEF - WINREG_OPENKEYEX_METHODDEF - WINREG_QUERYVALUE_METHODDEF - WINREG_QUERYVALUEEX_METHODDEF - WINREG_QUERYINFOKEY_METHODDEF - WINREG_QUERYREFLECTIONKEY_METHODDEF - WINREG_SAVEKEY_METHODDEF - WINREG_SETVALUE_METHODDEF - WINREG_SETVALUEEX_METHODDEF - NULL, -}; - -static void -insint(PyObject * d, char * name, long value) -{ - PyObject *v = PyLong_FromLong(value); - if (!v || PyDict_SetItemString(d, name, v)) - PyErr_Clear(); - Py_XDECREF(v); -} - -#define ADD_INT(val) insint(d, #val, val) - -static void -inskey(PyObject * d, char * name, HKEY key) -{ - PyObject *v = PyLong_FromVoidPtr(key); - if (!v || PyDict_SetItemString(d, name, v)) - PyErr_Clear(); - Py_XDECREF(v); -} - -#define ADD_KEY(val) inskey(d, #val, val) - - -static struct PyModuleDef winregmodule = { - PyModuleDef_HEAD_INIT, - "winreg", - module_doc, - -1, - winreg_methods, - NULL, - NULL, - NULL, - NULL -}; - -PyMODINIT_FUNC PyInit_winreg(void) -{ - PyObject *m, *d; - m = PyModule_Create(&winregmodule); - if (m == NULL) - return NULL; - d = PyModule_GetDict(m); - PyHKEY_Type.tp_doc = PyHKEY_doc; - if (PyType_Ready(&PyHKEY_Type) < 0) - return NULL; - Py_INCREF(&PyHKEY_Type); - if (PyDict_SetItemString(d, "HKEYType", - (PyObject *)&PyHKEY_Type) != 0) - return NULL; - Py_INCREF(PyExc_OSError); - if (PyDict_SetItemString(d, "error", - PyExc_OSError) != 0) - return NULL; - - /* Add the relevant constants */ - ADD_KEY(HKEY_CLASSES_ROOT); - ADD_KEY(HKEY_CURRENT_USER); - ADD_KEY(HKEY_LOCAL_MACHINE); - ADD_KEY(HKEY_USERS); - ADD_KEY(HKEY_PERFORMANCE_DATA); -#ifdef HKEY_CURRENT_CONFIG - ADD_KEY(HKEY_CURRENT_CONFIG); -#endif -#ifdef HKEY_DYN_DATA - ADD_KEY(HKEY_DYN_DATA); -#endif - ADD_INT(KEY_QUERY_VALUE); - ADD_INT(KEY_SET_VALUE); - ADD_INT(KEY_CREATE_SUB_KEY); - ADD_INT(KEY_ENUMERATE_SUB_KEYS); - ADD_INT(KEY_NOTIFY); - ADD_INT(KEY_CREATE_LINK); - ADD_INT(KEY_READ); - ADD_INT(KEY_WRITE); - ADD_INT(KEY_EXECUTE); - ADD_INT(KEY_ALL_ACCESS); -#ifdef KEY_WOW64_64KEY - ADD_INT(KEY_WOW64_64KEY); -#endif -#ifdef KEY_WOW64_32KEY - ADD_INT(KEY_WOW64_32KEY); -#endif - ADD_INT(REG_OPTION_RESERVED); - ADD_INT(REG_OPTION_NON_VOLATILE); - ADD_INT(REG_OPTION_VOLATILE); - ADD_INT(REG_OPTION_CREATE_LINK); - ADD_INT(REG_OPTION_BACKUP_RESTORE); - ADD_INT(REG_OPTION_OPEN_LINK); - ADD_INT(REG_LEGAL_OPTION); - ADD_INT(REG_CREATED_NEW_KEY); - ADD_INT(REG_OPENED_EXISTING_KEY); - ADD_INT(REG_WHOLE_HIVE_VOLATILE); - ADD_INT(REG_REFRESH_HIVE); - ADD_INT(REG_NO_LAZY_FLUSH); - ADD_INT(REG_NOTIFY_CHANGE_NAME); - ADD_INT(REG_NOTIFY_CHANGE_ATTRIBUTES); - ADD_INT(REG_NOTIFY_CHANGE_LAST_SET); - ADD_INT(REG_NOTIFY_CHANGE_SECURITY); - ADD_INT(REG_LEGAL_CHANGE_FILTER); - ADD_INT(REG_NONE); - ADD_INT(REG_SZ); - ADD_INT(REG_EXPAND_SZ); - ADD_INT(REG_BINARY); - ADD_INT(REG_DWORD); - ADD_INT(REG_DWORD_LITTLE_ENDIAN); - ADD_INT(REG_DWORD_BIG_ENDIAN); - ADD_INT(REG_QWORD); - ADD_INT(REG_QWORD_LITTLE_ENDIAN); - ADD_INT(REG_LINK); - ADD_INT(REG_MULTI_SZ); - ADD_INT(REG_RESOURCE_LIST); - ADD_INT(REG_FULL_RESOURCE_DESCRIPTOR); - ADD_INT(REG_RESOURCE_REQUIREMENTS_LIST); - return m; -} - - diff --git a/PC/winsound.c b/PC/winsound.c deleted file mode 100644 index fd04e1e55b5fc8343b2ce4cb562010ea19eb8823..0000000000000000000000000000000000000000 --- a/PC/winsound.c +++ /dev/null @@ -1,250 +0,0 @@ -/* Author: Toby Dickenson - * - * Copyright (c) 1999 Toby Dickenson - * - * Permission to use this software in any way is granted without - * fee, provided that the copyright notice above appears in all - * copies. This software is provided "as is" without any warranty. - */ - -/* Modified by Guido van Rossum */ -/* Beep added by Mark Hammond */ -/* Win9X Beep and platform identification added by Uncle Timmy */ - -/* Example: - - import winsound - import time - - # Play wav file - winsound.PlaySound('c:/windows/media/Chord.wav', winsound.SND_FILENAME) - - # Play sound from control panel settings - winsound.PlaySound('SystemQuestion', winsound.SND_ALIAS) - - # Play wav file from memory - data=open('c:/windows/media/Chimes.wav',"rb").read() - winsound.PlaySound(data, winsound.SND_MEMORY) - - # Start playing the first bit of wav file asynchronously - winsound.PlaySound('c:/windows/media/Chord.wav', - winsound.SND_FILENAME|winsound.SND_ASYNC) - # But don't let it go for too long... - time.sleep(0.1) - # ...Before stopping it - winsound.PlaySound(None, 0) -*/ - -#include -#include -#include - -PyDoc_STRVAR(sound_module_doc, -"PlaySound(sound, flags) - play a sound\n" -"SND_FILENAME - sound is a wav file name\n" -"SND_ALIAS - sound is a registry sound association name\n" -"SND_LOOP - Play the sound repeatedly; must also specify SND_ASYNC\n" -"SND_MEMORY - sound is a memory image of a wav file\n" -"SND_PURGE - stop all instances of the specified sound\n" -"SND_ASYNC - PlaySound returns immediately\n" -"SND_NODEFAULT - Do not play a default beep if the sound can not be found\n" -"SND_NOSTOP - Do not interrupt any sounds currently playing\n" // Raising RuntimeError if needed -"SND_NOWAIT - Return immediately if the sound driver is busy\n" // Without any errors -"\n" -"Beep(frequency, duration) - Make a beep through the PC speaker.\n" -"MessageBeep(type) - Call Windows MessageBeep."); - -/*[clinic input] -module winsound -[clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=a18401142d97b8d5]*/ - -#include "clinic/winsound.c.h" - -/*[clinic input] -winsound.PlaySound - - sound: object - The sound to play; a filename, data, or None. - flags: int - Flag values, ored together. See module documentation. - -A wrapper around the Windows PlaySound API. -[clinic start generated code]*/ - -static PyObject * -winsound_PlaySound_impl(PyObject *module, PyObject *sound, int flags) -/*[clinic end generated code: output=49a0fd16a372ebeb input=c63e1f2d848da2f2]*/ -{ - int ok; - wchar_t *wsound; - Py_buffer view = {NULL, NULL}; - - if (sound == Py_None) { - wsound = NULL; - } else if (flags & SND_MEMORY) { - if (flags & SND_ASYNC) { - /* Sidestep reference counting headache; unfortunately this also - prevent SND_LOOP from memory. */ - PyErr_SetString(PyExc_RuntimeError, - "Cannot play asynchronously from memory"); - return NULL; - } - if (PyObject_GetBuffer(sound, &view, PyBUF_SIMPLE) < 0) { - return NULL; - } - wsound = (wchar_t *)view.buf; - } else { - if (!PyUnicode_Check(sound)) { - PyErr_Format(PyExc_TypeError, - "'sound' must be str or None, not '%s'", - Py_TYPE(sound)->tp_name); - return NULL; - } - wsound = PyUnicode_AsWideCharString(sound, NULL); - if (wsound == NULL) { - return NULL; - } - } - - - Py_BEGIN_ALLOW_THREADS - ok = PlaySoundW(wsound, NULL, flags); - Py_END_ALLOW_THREADS - if (view.obj) { - PyBuffer_Release(&view); - } else if (sound != Py_None) { - PyMem_Free(wsound); - } - if (!ok) { - PyErr_SetString(PyExc_RuntimeError, "Failed to play sound"); - return NULL; - } - Py_RETURN_NONE; -} - -/*[clinic input] -winsound.Beep - - frequency: int - Frequency of the sound in hertz. - Must be in the range 37 through 32,767. - duration: int - How long the sound should play, in milliseconds. - -A wrapper around the Windows Beep API. -[clinic start generated code]*/ - -static PyObject * -winsound_Beep_impl(PyObject *module, int frequency, int duration) -/*[clinic end generated code: output=f32382e52ee9b2fb input=40e360cfa00a5cf0]*/ -{ - BOOL ok; - - if (frequency < 37 || frequency > 32767) { - PyErr_SetString(PyExc_ValueError, - "frequency must be in 37 thru 32767"); - return NULL; - } - - Py_BEGIN_ALLOW_THREADS - ok = Beep(frequency, duration); - Py_END_ALLOW_THREADS - if (!ok) { - PyErr_SetString(PyExc_RuntimeError,"Failed to beep"); - return NULL; - } - - Py_RETURN_NONE; -} - -/*[clinic input] -winsound.MessageBeep - - type: int(c_default="MB_OK") = MB_OK - -Call Windows MessageBeep(x). - -x defaults to MB_OK. -[clinic start generated code]*/ - -static PyObject * -winsound_MessageBeep_impl(PyObject *module, int type) -/*[clinic end generated code: output=120875455121121f input=db185f741ae21401]*/ -{ - BOOL ok; - - Py_BEGIN_ALLOW_THREADS - ok = MessageBeep(type); - Py_END_ALLOW_THREADS - - if (!ok) { - PyErr_SetExcFromWindowsErr(PyExc_RuntimeError, 0); - return NULL; - } - - Py_RETURN_NONE; -} - -static struct PyMethodDef sound_methods[] = -{ - WINSOUND_PLAYSOUND_METHODDEF - WINSOUND_BEEP_METHODDEF - WINSOUND_MESSAGEBEEP_METHODDEF - {NULL, NULL} -}; - -static void -add_define(PyObject *dict, const char *key, long value) -{ - PyObject *k = PyUnicode_FromString(key); - PyObject *v = PyLong_FromLong(value); - if (v && k) { - PyDict_SetItem(dict, k, v); - } - Py_XDECREF(k); - Py_XDECREF(v); -} - -#define ADD_DEFINE(tok) add_define(dict,#tok,tok) - - -static struct PyModuleDef winsoundmodule = { - PyModuleDef_HEAD_INIT, - "winsound", - sound_module_doc, - -1, - sound_methods, - NULL, - NULL, - NULL, - NULL -}; - -PyMODINIT_FUNC -PyInit_winsound(void) -{ - PyObject *dict; - PyObject *module = PyModule_Create(&winsoundmodule); - if (module == NULL) - return NULL; - dict = PyModule_GetDict(module); - - ADD_DEFINE(SND_ASYNC); - ADD_DEFINE(SND_NODEFAULT); - ADD_DEFINE(SND_NOSTOP); - ADD_DEFINE(SND_NOWAIT); - ADD_DEFINE(SND_ALIAS); - ADD_DEFINE(SND_FILENAME); - ADD_DEFINE(SND_MEMORY); - ADD_DEFINE(SND_PURGE); - ADD_DEFINE(SND_LOOP); - ADD_DEFINE(SND_APPLICATION); - - ADD_DEFINE(MB_OK); - ADD_DEFINE(MB_ICONASTERISK); - ADD_DEFINE(MB_ICONEXCLAMATION); - ADD_DEFINE(MB_ICONHAND); - ADD_DEFINE(MB_ICONQUESTION); - return module; -}