mirror of
https://github.com/johndoe6345789/typthon.git
synced 2026-04-24 13:45:05 +00:00
Fix remaining Py_ patterns - macros and config functions
- Fixed Py_MIN, Py_MAX, Py_ABS → Ty_* - Fixed _Py_popcount32, _Py_bit_length → _Ty_* - Fixed Py_ISALPHA, Py_ISSPACE, Py_CHARMASK → Ty_* - Fixed Py_BUILD_ASSERT, Py_VISIT → Ty_* - Fixed all PyConfig_* function definitions (InitPythonConfig, Clear, SetArgv, etc.) - Fixed PyWideStringList → TyWideStringList Resolving final linking errors. Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
@@ -26,18 +26,18 @@ PyAPI_FUNC(int) TyStatus_IsError(TyStatus err);
|
|||||||
PyAPI_FUNC(int) TyStatus_IsExit(TyStatus err);
|
PyAPI_FUNC(int) TyStatus_IsExit(TyStatus err);
|
||||||
PyAPI_FUNC(int) TyStatus_Exception(TyStatus err);
|
PyAPI_FUNC(int) TyStatus_Exception(TyStatus err);
|
||||||
|
|
||||||
/* --- PyWideStringList ------------------------------------------------ */
|
/* --- TyWideStringList ------------------------------------------------ */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* If length is greater than zero, items must be non-NULL
|
/* If length is greater than zero, items must be non-NULL
|
||||||
and all items strings must be non-NULL */
|
and all items strings must be non-NULL */
|
||||||
Ty_ssize_t length;
|
Ty_ssize_t length;
|
||||||
wchar_t **items;
|
wchar_t **items;
|
||||||
} PyWideStringList;
|
} TyWideStringList;
|
||||||
|
|
||||||
PyAPI_FUNC(TyStatus) TyWideStringList_Append(PyWideStringList *list,
|
PyAPI_FUNC(TyStatus) TyWideStringList_Append(TyWideStringList *list,
|
||||||
const wchar_t *item);
|
const wchar_t *item);
|
||||||
PyAPI_FUNC(TyStatus) TyWideStringList_Insert(PyWideStringList *list,
|
PyAPI_FUNC(TyStatus) TyWideStringList_Insert(TyWideStringList *list,
|
||||||
Ty_ssize_t index,
|
Ty_ssize_t index,
|
||||||
const wchar_t *item);
|
const wchar_t *item);
|
||||||
|
|
||||||
@@ -154,10 +154,10 @@ typedef struct TyConfig {
|
|||||||
wchar_t *filesystem_errors;
|
wchar_t *filesystem_errors;
|
||||||
wchar_t *pycache_prefix;
|
wchar_t *pycache_prefix;
|
||||||
int parse_argv;
|
int parse_argv;
|
||||||
PyWideStringList orig_argv;
|
TyWideStringList orig_argv;
|
||||||
PyWideStringList argv;
|
TyWideStringList argv;
|
||||||
PyWideStringList xoptions;
|
TyWideStringList xoptions;
|
||||||
PyWideStringList warnoptions;
|
TyWideStringList warnoptions;
|
||||||
int site_import;
|
int site_import;
|
||||||
int bytes_warning;
|
int bytes_warning;
|
||||||
int warn_default_encoding;
|
int warn_default_encoding;
|
||||||
@@ -201,7 +201,7 @@ typedef struct TyConfig {
|
|||||||
|
|
||||||
/* --- Path configuration outputs ----------- */
|
/* --- Path configuration outputs ----------- */
|
||||||
int module_search_paths_set;
|
int module_search_paths_set;
|
||||||
PyWideStringList module_search_paths;
|
TyWideStringList module_search_paths;
|
||||||
wchar_t *stdlib_dir;
|
wchar_t *stdlib_dir;
|
||||||
wchar_t *executable;
|
wchar_t *executable;
|
||||||
wchar_t *base_executable;
|
wchar_t *base_executable;
|
||||||
@@ -263,7 +263,7 @@ PyAPI_FUNC(TyStatus) TyConfig_SetArgv(TyConfig *config,
|
|||||||
Ty_ssize_t argc,
|
Ty_ssize_t argc,
|
||||||
wchar_t * const *argv);
|
wchar_t * const *argv);
|
||||||
PyAPI_FUNC(TyStatus) TyConfig_SetWideStringList(TyConfig *config,
|
PyAPI_FUNC(TyStatus) TyConfig_SetWideStringList(TyConfig *config,
|
||||||
PyWideStringList *list,
|
TyWideStringList *list,
|
||||||
Ty_ssize_t length, wchar_t **items);
|
Ty_ssize_t length, wchar_t **items);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ _Py_bswap64(uint64_t word)
|
|||||||
// use the x86 POPCNT instruction if the target architecture has SSE4a or
|
// use the x86 POPCNT instruction if the target architecture has SSE4a or
|
||||||
// newer.
|
// newer.
|
||||||
static inline int
|
static inline int
|
||||||
_Py_popcount32(uint32_t x)
|
_Ty_popcount32(uint32_t x)
|
||||||
{
|
{
|
||||||
#if (defined(__clang__) || defined(__GNUC__))
|
#if (defined(__clang__) || defined(__GNUC__))
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ _Py_popcount32(uint32_t x)
|
|||||||
// Return the index of the most significant 1 bit in 'x'. This is the smallest
|
// Return the index of the most significant 1 bit in 'x'. This is the smallest
|
||||||
// integer k such that x < 2**k. Equivalent to floor(log2(x)) + 1 for x != 0.
|
// integer k such that x < 2**k. Equivalent to floor(log2(x)) + 1 for x != 0.
|
||||||
static inline int
|
static inline int
|
||||||
_Py_bit_length(unsigned long x)
|
_Ty_bit_length(unsigned long x)
|
||||||
{
|
{
|
||||||
#if (defined(__clang__) || defined(__GNUC__))
|
#if (defined(__clang__) || defined(__GNUC__))
|
||||||
if (x != 0) {
|
if (x != 0) {
|
||||||
|
|||||||
@@ -48,19 +48,19 @@ extern "C" {
|
|||||||
PyAPI_FUNC(void) _TyErr_SetFromPyStatus(TyStatus status);
|
PyAPI_FUNC(void) _TyErr_SetFromPyStatus(TyStatus status);
|
||||||
|
|
||||||
|
|
||||||
/* --- PyWideStringList ------------------------------------------------ */
|
/* --- TyWideStringList ------------------------------------------------ */
|
||||||
|
|
||||||
#define _TyWideStringList_INIT (PyWideStringList){.length = 0, .items = NULL}
|
#define _TyWideStringList_INIT (TyWideStringList){.length = 0, .items = NULL}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
extern int _TyWideStringList_CheckConsistency(const PyWideStringList *list);
|
extern int _TyWideStringList_CheckConsistency(const TyWideStringList *list);
|
||||||
#endif
|
#endif
|
||||||
extern void _TyWideStringList_Clear(PyWideStringList *list);
|
extern void _TyWideStringList_Clear(TyWideStringList *list);
|
||||||
extern int _TyWideStringList_Copy(PyWideStringList *list,
|
extern int _TyWideStringList_Copy(TyWideStringList *list,
|
||||||
const PyWideStringList *list2);
|
const TyWideStringList *list2);
|
||||||
extern TyStatus _TyWideStringList_Extend(PyWideStringList *list,
|
extern TyStatus _TyWideStringList_Extend(TyWideStringList *list,
|
||||||
const PyWideStringList *list2);
|
const TyWideStringList *list2);
|
||||||
extern TyObject* _TyWideStringList_AsList(const PyWideStringList *list);
|
extern TyObject* _TyWideStringList_AsList(const TyWideStringList *list);
|
||||||
|
|
||||||
|
|
||||||
/* --- _PyArgv ---------------------------------------------------- */
|
/* --- _PyArgv ---------------------------------------------------- */
|
||||||
@@ -73,7 +73,7 @@ typedef struct _PyArgv {
|
|||||||
} _PyArgv;
|
} _PyArgv;
|
||||||
|
|
||||||
extern TyStatus _PyArgv_AsWstrList(const _PyArgv *args,
|
extern TyStatus _PyArgv_AsWstrList(const _PyArgv *args,
|
||||||
PyWideStringList *list);
|
TyWideStringList *list);
|
||||||
|
|
||||||
|
|
||||||
/* --- Helper functions ------------------------------------------- */
|
/* --- Helper functions ------------------------------------------- */
|
||||||
@@ -82,7 +82,7 @@ extern int _Ty_str_to_int(
|
|||||||
const char *str,
|
const char *str,
|
||||||
int *result);
|
int *result);
|
||||||
extern const wchar_t* _Ty_get_xoption(
|
extern const wchar_t* _Ty_get_xoption(
|
||||||
const PyWideStringList *xoptions,
|
const TyWideStringList *xoptions,
|
||||||
const wchar_t *name);
|
const wchar_t *name);
|
||||||
extern const char* _Ty_GetEnv(
|
extern const char* _Ty_GetEnv(
|
||||||
int use_environment,
|
int use_environment,
|
||||||
@@ -99,8 +99,8 @@ extern void _Ty_ClearArgcArgv(void);
|
|||||||
/* --- _PyPreCmdline ------------------------------------------------- */
|
/* --- _PyPreCmdline ------------------------------------------------- */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyWideStringList argv;
|
TyWideStringList argv;
|
||||||
PyWideStringList xoptions; /* "-X value" option */
|
TyWideStringList xoptions; /* "-X value" option */
|
||||||
int isolated; /* -I option */
|
int isolated; /* -I option */
|
||||||
int use_environment; /* -E option */
|
int use_environment; /* -E option */
|
||||||
int dev_mode; /* -X dev and PYTHONDEVMODE */
|
int dev_mode; /* -X dev and PYTHONDEVMODE */
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ extern TyStatus _TyPathConfig_UpdateGlobal(const TyConfig *config);
|
|||||||
extern const wchar_t * _TyPathConfig_GetGlobalModuleSearchPath(void);
|
extern const wchar_t * _TyPathConfig_GetGlobalModuleSearchPath(void);
|
||||||
|
|
||||||
extern int _TyPathConfig_ComputeSysPath0(
|
extern int _TyPathConfig_ComputeSysPath0(
|
||||||
const PyWideStringList *argv,
|
const TyWideStringList *argv,
|
||||||
TyObject **path0);
|
TyObject **path0);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ extern TyObject * _PyBuiltin_Init(TyInterpreterState *interp);
|
|||||||
extern TyStatus _TySys_Create(
|
extern TyStatus _TySys_Create(
|
||||||
TyThreadState *tstate,
|
TyThreadState *tstate,
|
||||||
TyObject **sysmod_p);
|
TyObject **sysmod_p);
|
||||||
extern TyStatus _TySys_ReadPreinitWarnOptions(PyWideStringList *options);
|
extern TyStatus _TySys_ReadPreinitWarnOptions(TyWideStringList *options);
|
||||||
extern TyStatus _TySys_ReadPreinitXOptions(TyConfig *config);
|
extern TyStatus _TySys_ReadPreinitXOptions(TyConfig *config);
|
||||||
extern int _TySys_UpdateConfig(TyThreadState *tstate);
|
extern int _TySys_UpdateConfig(TyThreadState *tstate);
|
||||||
extern void _TySys_FiniTypes(TyInterpreterState *interp);
|
extern void _TySys_FiniTypes(TyInterpreterState *interp);
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ struct pyruntimestate {
|
|||||||
/* Used instead of TyThreadState.trash when there is not current tstate. */
|
/* Used instead of TyThreadState.trash when there is not current tstate. */
|
||||||
Ty_tss_t trashTSSkey;
|
Ty_tss_t trashTSSkey;
|
||||||
|
|
||||||
PyWideStringList orig_argv;
|
TyWideStringList orig_argv;
|
||||||
|
|
||||||
struct _parser_runtime_state parser;
|
struct _parser_runtime_state parser;
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ _testcext_exec(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// test Py_BUILD_ASSERT() and Py_BUILD_ASSERT_EXPR()
|
// test Ty_BUILD_ASSERT() and Py_BUILD_ASSERT_EXPR()
|
||||||
Py_BUILD_ASSERT(sizeof(int) == sizeof(unsigned int));
|
Ty_BUILD_ASSERT(sizeof(int) == sizeof(unsigned int));
|
||||||
assert(Py_BUILD_ASSERT_EXPR(sizeof(int) == sizeof(unsigned int)) == 0);
|
assert(Py_BUILD_ASSERT_EXPR(sizeof(int) == sizeof(unsigned int)) == 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -849,9 +849,9 @@ PyCursesWindow_dealloc(TyObject *self)
|
|||||||
static int
|
static int
|
||||||
PyCursesWindow_traverse(TyObject *self, visitproc visit, void *arg)
|
PyCursesWindow_traverse(TyObject *self, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
Py_VISIT(Ty_TYPE(self));
|
Ty_VISIT(Ty_TYPE(self));
|
||||||
PyCursesWindowObject *wo = (PyCursesWindowObject *)self;
|
PyCursesWindowObject *wo = (PyCursesWindowObject *)self;
|
||||||
Py_VISIT(wo->orig);
|
Ty_VISIT(wo->orig);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1750,7 +1750,7 @@ PyCursesWindow_getstr(TyObject *op, TyObject *args)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = Py_MIN(n, max_buf_size - 1);
|
n = Ty_MIN(n, max_buf_size - 1);
|
||||||
res = TyBytes_FromStringAndSize(NULL, n + 1);
|
res = TyBytes_FromStringAndSize(NULL, n + 1);
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1935,7 +1935,7 @@ PyCursesWindow_instr(TyObject *op, TyObject *args)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = Py_MIN(n, max_buf_size - 1);
|
n = Ty_MIN(n, max_buf_size - 1);
|
||||||
res = TyBytes_FromStringAndSize(NULL, n + 1);
|
res = TyBytes_FromStringAndSize(NULL, n + 1);
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -5027,7 +5027,7 @@ curses_capi_capsule_traverse(TyObject *op, visitproc visit, void *arg)
|
|||||||
{
|
{
|
||||||
void **capi_ptr = PyCapsule_GetPointer(op, PyCurses_CAPSULE_NAME);
|
void **capi_ptr = PyCapsule_GetPointer(op, PyCurses_CAPSULE_NAME);
|
||||||
assert(capi_ptr != NULL);
|
assert(capi_ptr != NULL);
|
||||||
Py_VISIT(capi_ptr[0]); // visit curses window type
|
Ty_VISIT(capi_ptr[0]); // visit curses window type
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5064,8 +5064,8 @@ static int
|
|||||||
cursesmodule_traverse(TyObject *mod, visitproc visit, void *arg)
|
cursesmodule_traverse(TyObject *mod, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
cursesmodule_state *state = get_cursesmodule_state(mod);
|
cursesmodule_state *state = get_cursesmodule_state(mod);
|
||||||
Py_VISIT(state->error);
|
Ty_VISIT(state->error);
|
||||||
Py_VISIT(state->window_type);
|
Ty_VISIT(state->window_type);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2331,8 +2331,8 @@ static int
|
|||||||
PySSL_traverse(TyObject *op, visitproc visit, void *arg)
|
PySSL_traverse(TyObject *op, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
PySSLSocket *self = PySSLSocket_CAST(op);
|
PySSLSocket *self = PySSLSocket_CAST(op);
|
||||||
Py_VISIT(self->exc);
|
Ty_VISIT(self->exc);
|
||||||
Py_VISIT(Ty_TYPE(self));
|
Ty_VISIT(Ty_TYPE(self));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3294,9 +3294,9 @@ static int
|
|||||||
context_traverse(TyObject *op, visitproc visit, void *arg)
|
context_traverse(TyObject *op, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
PySSLContext *self = PySSLContext_CAST(op);
|
PySSLContext *self = PySSLContext_CAST(op);
|
||||||
Py_VISIT(self->set_sni_cb);
|
Ty_VISIT(self->set_sni_cb);
|
||||||
Py_VISIT(self->msg_cb);
|
Ty_VISIT(self->msg_cb);
|
||||||
Py_VISIT(Ty_TYPE(self));
|
Ty_VISIT(Ty_TYPE(self));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3799,7 +3799,7 @@ _ssl__SSLContext_options_get_impl(PySSLContext *self)
|
|||||||
/*[clinic end generated code: output=3dfa6a74837f525b input=f5a2805c7cda6f25]*/
|
/*[clinic end generated code: output=3dfa6a74837f525b input=f5a2805c7cda6f25]*/
|
||||||
{
|
{
|
||||||
uint64_t options = SSL_CTX_get_options(self->ctx);
|
uint64_t options = SSL_CTX_get_options(self->ctx);
|
||||||
Py_BUILD_ASSERT(sizeof(unsigned long long) >= sizeof(options));
|
Ty_BUILD_ASSERT(sizeof(unsigned long long) >= sizeof(options));
|
||||||
return TyLong_FromUnsignedLongLong(options);
|
return TyLong_FromUnsignedLongLong(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3823,7 +3823,7 @@ _ssl__SSLContext_options_set_impl(PySSLContext *self, TyObject *value)
|
|||||||
if (!TyArg_Parse(value, "O&", _TyLong_UnsignedLongLong_Converter, &new_opts_arg)) {
|
if (!TyArg_Parse(value, "O&", _TyLong_UnsignedLongLong_Converter, &new_opts_arg)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
Py_BUILD_ASSERT(sizeof(new_opts) >= sizeof(new_opts_arg));
|
Ty_BUILD_ASSERT(sizeof(new_opts) >= sizeof(new_opts_arg));
|
||||||
new_opts = (uint64_t)new_opts_arg;
|
new_opts = (uint64_t)new_opts_arg;
|
||||||
|
|
||||||
opts = SSL_CTX_get_options(self->ctx);
|
opts = SSL_CTX_get_options(self->ctx);
|
||||||
@@ -5327,7 +5327,7 @@ _ssl_MemoryBIO_impl(TyTypeObject *type)
|
|||||||
static int
|
static int
|
||||||
memory_bio_traverse(TyObject *self, visitproc visit, void *arg)
|
memory_bio_traverse(TyObject *self, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
Py_VISIT(Ty_TYPE(self));
|
Ty_VISIT(Ty_TYPE(self));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5395,7 +5395,7 @@ _ssl_MemoryBIO_read_impl(PySSLMemoryBIO *self, int len)
|
|||||||
int avail, nbytes;
|
int avail, nbytes;
|
||||||
TyObject *result;
|
TyObject *result;
|
||||||
|
|
||||||
avail = (int)Py_MIN(BIO_ctrl_pending(self->bio), INT_MAX);
|
avail = (int)Ty_MIN(BIO_ctrl_pending(self->bio), INT_MAX);
|
||||||
if ((len < 0) || (len > avail))
|
if ((len < 0) || (len > avail))
|
||||||
len = avail;
|
len = avail;
|
||||||
|
|
||||||
@@ -5594,8 +5594,8 @@ static int
|
|||||||
PySSLSession_traverse(TyObject *op, visitproc visit, void *arg)
|
PySSLSession_traverse(TyObject *op, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
PySSLSession *self = PySSLSession_CAST(op);
|
PySSLSession *self = PySSLSession_CAST(op);
|
||||||
Py_VISIT(self->ctx);
|
Ty_VISIT(self->ctx);
|
||||||
Py_VISIT(Ty_TYPE(self));
|
Ty_VISIT(Ty_TYPE(self));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5747,7 +5747,7 @@ _ssl_RAND_add_impl(TyObject *module, Ty_buffer *view, double entropy)
|
|||||||
buf = (const char *)view->buf;
|
buf = (const char *)view->buf;
|
||||||
len = view->len;
|
len = view->len;
|
||||||
do {
|
do {
|
||||||
written = Py_MIN(len, INT_MAX);
|
written = Ty_MIN(len, INT_MAX);
|
||||||
RAND_add(buf, (int)written, entropy);
|
RAND_add(buf, (int)written, entropy);
|
||||||
buf += written;
|
buf += written;
|
||||||
len -= written;
|
len -= written;
|
||||||
@@ -6380,7 +6380,7 @@ sslmodule_init_socketapi(TyObject *module)
|
|||||||
static int
|
static int
|
||||||
sslmodule_add_option(TyObject *m, const char *name, uint64_t value)
|
sslmodule_add_option(TyObject *m, const char *name, uint64_t value)
|
||||||
{
|
{
|
||||||
Py_BUILD_ASSERT(sizeof(unsigned long long) >= sizeof(value));
|
Ty_BUILD_ASSERT(sizeof(unsigned long long) >= sizeof(value));
|
||||||
return TyModule_Add(m, name, TyLong_FromUnsignedLongLong(value));
|
return TyModule_Add(m, name, TyLong_FromUnsignedLongLong(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6844,21 +6844,21 @@ sslmodule_traverse(TyObject *m, visitproc visit, void *arg)
|
|||||||
{
|
{
|
||||||
_sslmodulestate *state = get_ssl_state(m);
|
_sslmodulestate *state = get_ssl_state(m);
|
||||||
|
|
||||||
Py_VISIT(state->PySSLContext_Type);
|
Ty_VISIT(state->PySSLContext_Type);
|
||||||
Py_VISIT(state->PySSLSocket_Type);
|
Ty_VISIT(state->PySSLSocket_Type);
|
||||||
Py_VISIT(state->PySSLMemoryBIO_Type);
|
Ty_VISIT(state->PySSLMemoryBIO_Type);
|
||||||
Py_VISIT(state->PySSLSession_Type);
|
Ty_VISIT(state->PySSLSession_Type);
|
||||||
Py_VISIT(state->PySSLCertificate_Type);
|
Ty_VISIT(state->PySSLCertificate_Type);
|
||||||
Py_VISIT(state->PySSLErrorObject);
|
Ty_VISIT(state->PySSLErrorObject);
|
||||||
Py_VISIT(state->PySSLCertVerificationErrorObject);
|
Ty_VISIT(state->PySSLCertVerificationErrorObject);
|
||||||
Py_VISIT(state->PySSLZeroReturnErrorObject);
|
Ty_VISIT(state->PySSLZeroReturnErrorObject);
|
||||||
Py_VISIT(state->PySSLWantReadErrorObject);
|
Ty_VISIT(state->PySSLWantReadErrorObject);
|
||||||
Py_VISIT(state->PySSLWantWriteErrorObject);
|
Ty_VISIT(state->PySSLWantWriteErrorObject);
|
||||||
Py_VISIT(state->PySSLSyscallErrorObject);
|
Ty_VISIT(state->PySSLSyscallErrorObject);
|
||||||
Py_VISIT(state->PySSLEOFErrorObject);
|
Ty_VISIT(state->PySSLEOFErrorObject);
|
||||||
Py_VISIT(state->err_codes_to_names);
|
Ty_VISIT(state->err_codes_to_names);
|
||||||
Py_VISIT(state->lib_codes_to_names);
|
Ty_VISIT(state->lib_codes_to_names);
|
||||||
Py_VISIT(state->Sock_Type);
|
Ty_VISIT(state->Sock_Type);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1056,9 +1056,9 @@ _overlapped_Overlapped_ReadFile_impl(OverlappedObject *self, HANDLE handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if SIZEOF_SIZE_T <= SIZEOF_LONG
|
#if SIZEOF_SIZE_T <= SIZEOF_LONG
|
||||||
size = Py_MIN(size, (DWORD)PY_SSIZE_T_MAX);
|
size = Ty_MIN(size, (DWORD)PY_SSIZE_T_MAX);
|
||||||
#endif
|
#endif
|
||||||
buf = TyBytes_FromStringAndSize(NULL, Py_MAX(size, 1));
|
buf = TyBytes_FromStringAndSize(NULL, Ty_MAX(size, 1));
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -1161,9 +1161,9 @@ _overlapped_Overlapped_WSARecv_impl(OverlappedObject *self, HANDLE handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if SIZEOF_SIZE_T <= SIZEOF_LONG
|
#if SIZEOF_SIZE_T <= SIZEOF_LONG
|
||||||
size = Py_MIN(size, (DWORD)PY_SSIZE_T_MAX);
|
size = Ty_MIN(size, (DWORD)PY_SSIZE_T_MAX);
|
||||||
#endif
|
#endif
|
||||||
buf = TyBytes_FromStringAndSize(NULL, Py_MAX(size, 1));
|
buf = TyBytes_FromStringAndSize(NULL, Ty_MAX(size, 1));
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -1671,23 +1671,23 @@ Overlapped_traverse(TyObject *op, visitproc visit, void *arg)
|
|||||||
switch (self->type) {
|
switch (self->type) {
|
||||||
case TYPE_READ:
|
case TYPE_READ:
|
||||||
case TYPE_ACCEPT:
|
case TYPE_ACCEPT:
|
||||||
Py_VISIT(self->allocated_buffer);
|
Ty_VISIT(self->allocated_buffer);
|
||||||
break;
|
break;
|
||||||
case TYPE_WRITE:
|
case TYPE_WRITE:
|
||||||
case TYPE_WRITE_TO:
|
case TYPE_WRITE_TO:
|
||||||
case TYPE_READINTO:
|
case TYPE_READINTO:
|
||||||
if (self->user_buffer.obj) {
|
if (self->user_buffer.obj) {
|
||||||
Py_VISIT(&self->user_buffer.obj);
|
Ty_VISIT(&self->user_buffer.obj);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TYPE_READ_FROM:
|
case TYPE_READ_FROM:
|
||||||
Py_VISIT(self->read_from.result);
|
Ty_VISIT(self->read_from.result);
|
||||||
Py_VISIT(self->read_from.allocated_buffer);
|
Ty_VISIT(self->read_from.allocated_buffer);
|
||||||
break;
|
break;
|
||||||
case TYPE_READ_FROM_INTO:
|
case TYPE_READ_FROM_INTO:
|
||||||
Py_VISIT(self->read_from_into.result);
|
Ty_VISIT(self->read_from_into.result);
|
||||||
if (self->read_from_into.user_buffer.obj) {
|
if (self->read_from_into.user_buffer.obj) {
|
||||||
Py_VISIT(&self->read_from_into.user_buffer.obj);
|
Ty_VISIT(&self->read_from_into.user_buffer.obj);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1840,9 +1840,9 @@ _overlapped_Overlapped_WSARecvFrom_impl(OverlappedObject *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if SIZEOF_SIZE_T <= SIZEOF_LONG
|
#if SIZEOF_SIZE_T <= SIZEOF_LONG
|
||||||
size = Py_MIN(size, (DWORD)PY_SSIZE_T_MAX);
|
size = Ty_MIN(size, (DWORD)PY_SSIZE_T_MAX);
|
||||||
#endif
|
#endif
|
||||||
buf = TyBytes_FromStringAndSize(NULL, Py_MAX(size, 1));
|
buf = TyBytes_FromStringAndSize(NULL, Ty_MAX(size, 1));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2557,24 +2557,24 @@ static int
|
|||||||
_posix_traverse(TyObject *module, visitproc visit, void *arg)
|
_posix_traverse(TyObject *module, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
_posixstate *state = get_posix_state(module);
|
_posixstate *state = get_posix_state(module);
|
||||||
Py_VISIT(state->billion);
|
Ty_VISIT(state->billion);
|
||||||
Py_VISIT(state->DirEntryType);
|
Ty_VISIT(state->DirEntryType);
|
||||||
Py_VISIT(state->ScandirIteratorType);
|
Ty_VISIT(state->ScandirIteratorType);
|
||||||
#if defined(HAVE_SCHED_SETPARAM) || defined(HAVE_SCHED_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDPARAM)
|
#if defined(HAVE_SCHED_SETPARAM) || defined(HAVE_SCHED_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDPARAM)
|
||||||
Py_VISIT(state->SchedParamType);
|
Ty_VISIT(state->SchedParamType);
|
||||||
#endif
|
#endif
|
||||||
Py_VISIT(state->StatResultType);
|
Ty_VISIT(state->StatResultType);
|
||||||
Py_VISIT(state->StatVFSResultType);
|
Ty_VISIT(state->StatVFSResultType);
|
||||||
Py_VISIT(state->TerminalSizeType);
|
Ty_VISIT(state->TerminalSizeType);
|
||||||
Py_VISIT(state->TimesResultType);
|
Ty_VISIT(state->TimesResultType);
|
||||||
Py_VISIT(state->UnameResultType);
|
Ty_VISIT(state->UnameResultType);
|
||||||
#if defined(HAVE_WAITID)
|
#if defined(HAVE_WAITID)
|
||||||
Py_VISIT(state->WaitidResultType);
|
Ty_VISIT(state->WaitidResultType);
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_WAIT3) || defined(HAVE_WAIT4)
|
#if defined(HAVE_WAIT3) || defined(HAVE_WAIT4)
|
||||||
Py_VISIT(state->struct_rusage);
|
Ty_VISIT(state->struct_rusage);
|
||||||
#endif
|
#endif
|
||||||
Py_VISIT(state->st_mode);
|
Ty_VISIT(state->st_mode);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5183,7 +5183,7 @@ os__getvolumepathname_impl(TyObject *module, path_t *path)
|
|||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
/* Volume path should be shorter than entire path */
|
/* Volume path should be shorter than entire path */
|
||||||
buflen = Py_MAX(path->length, MAX_PATH);
|
buflen = Ty_MAX(path->length, MAX_PATH);
|
||||||
|
|
||||||
if (buflen > PY_DWORD_MAX) {
|
if (buflen > PY_DWORD_MAX) {
|
||||||
TyErr_SetString(TyExc_OverflowError, "path too long");
|
TyErr_SetString(TyExc_OverflowError, "path too long");
|
||||||
@@ -11467,7 +11467,7 @@ os_read_impl(TyObject *module, int fd, Ty_ssize_t length)
|
|||||||
return posix_error();
|
return posix_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
length = Py_MIN(length, _PY_READ_MAX);
|
length = Ty_MIN(length, _PY_READ_MAX);
|
||||||
|
|
||||||
buffer = TyBytes_FromStringAndSize((char *)NULL, length);
|
buffer = TyBytes_FromStringAndSize((char *)NULL, length);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
|
|||||||
@@ -3862,7 +3862,7 @@ sock_listen(TyObject *self, TyObject *args)
|
|||||||
PySocketSockObject *s = _PySocketSockObject_CAST(self);
|
PySocketSockObject *s = _PySocketSockObject_CAST(self);
|
||||||
/* We try to choose a default backlog high enough to avoid connection drops
|
/* We try to choose a default backlog high enough to avoid connection drops
|
||||||
* for common workloads, yet not too high to limit resource usage. */
|
* for common workloads, yet not too high to limit resource usage. */
|
||||||
int backlog = Py_MIN(SOMAXCONN, 128);
|
int backlog = Ty_MIN(SOMAXCONN, 128);
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (!TyArg_ParseTuple(args, "|i:listen", &backlog))
|
if (!TyArg_ParseTuple(args, "|i:listen", &backlog))
|
||||||
@@ -5519,7 +5519,7 @@ sock_finalize(TyObject *self)
|
|||||||
static int
|
static int
|
||||||
sock_traverse(TyObject *s, visitproc visit, void *arg)
|
sock_traverse(TyObject *s, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
Py_VISIT(Ty_TYPE(s));
|
Ty_VISIT(Ty_TYPE(s));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6782,7 +6782,7 @@ socket_inet_pton(TyObject *self, TyObject *args)
|
|||||||
const char* ip;
|
const char* ip;
|
||||||
int retval;
|
int retval;
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
char packed[Py_MAX(sizeof(struct in_addr), sizeof(struct in6_addr))];
|
char packed[Ty_MAX(sizeof(struct in_addr), sizeof(struct in6_addr))];
|
||||||
#else
|
#else
|
||||||
char packed[sizeof(struct in_addr)];
|
char packed[sizeof(struct in_addr)];
|
||||||
#endif
|
#endif
|
||||||
@@ -6832,7 +6832,7 @@ socket_inet_ntop(TyObject *self, TyObject *args)
|
|||||||
Ty_buffer packed_ip;
|
Ty_buffer packed_ip;
|
||||||
const char* retval;
|
const char* retval;
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
char ip[Py_MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN)];
|
char ip[Ty_MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN)];
|
||||||
#else
|
#else
|
||||||
char ip[INET_ADDRSTRLEN];
|
char ip[INET_ADDRSTRLEN];
|
||||||
#endif
|
#endif
|
||||||
@@ -7519,7 +7519,7 @@ sock_capi_traverse(TyObject *capsule, visitproc visit, void *arg)
|
|||||||
{
|
{
|
||||||
PySocketModule_APIObject *capi = PyCapsule_GetPointer(capsule, PySocket_CAPSULE_NAME);
|
PySocketModule_APIObject *capi = PyCapsule_GetPointer(capsule, PySocket_CAPSULE_NAME);
|
||||||
assert(capi != NULL);
|
assert(capi != NULL);
|
||||||
Py_VISIT(capi->Sock_Type);
|
Ty_VISIT(capi->Sock_Type);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9249,9 +9249,9 @@ static int
|
|||||||
socket_traverse(TyObject *mod, visitproc visit, void *arg)
|
socket_traverse(TyObject *mod, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
socket_state *state = get_module_state(mod);
|
socket_state *state = get_module_state(mod);
|
||||||
Py_VISIT(state->sock_type);
|
Ty_VISIT(state->sock_type);
|
||||||
Py_VISIT(state->socket_herror);
|
Ty_VISIT(state->socket_herror);
|
||||||
Py_VISIT(state->socket_gaierror);
|
Ty_VISIT(state->socket_gaierror);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2541,7 +2541,7 @@ long_from_binary_base(const char *start, const char *end, Ty_ssize_t digits, int
|
|||||||
if (*p == '_') {
|
if (*p == '_') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
k = (int)_TyLong_DigitValue[Py_CHARMASK(*p)];
|
k = (int)_TyLong_DigitValue[Ty_CHARMASK(*p)];
|
||||||
assert(k >= 0 && k < base);
|
assert(k >= 0 && k < base);
|
||||||
accum |= (twodigits)k << bits_in_accum;
|
accum |= (twodigits)k << bits_in_accum;
|
||||||
bits_in_accum += bits_per_char;
|
bits_in_accum += bits_per_char;
|
||||||
@@ -2790,14 +2790,14 @@ long_from_non_binary_base(const char *start, const char *end, Ty_ssize_t digits,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* grab up to convwidth digits from the input string */
|
/* grab up to convwidth digits from the input string */
|
||||||
c = (digit)_TyLong_DigitValue[Py_CHARMASK(*p++)];
|
c = (digit)_TyLong_DigitValue[Ty_CHARMASK(*p++)];
|
||||||
for (i = 1; i < convwidth && p != end; ++p) {
|
for (i = 1; i < convwidth && p != end; ++p) {
|
||||||
if (*p == '_') {
|
if (*p == '_') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
c = (twodigits)(c * base +
|
c = (twodigits)(c * base +
|
||||||
(int)_TyLong_DigitValue[Py_CHARMASK(*p)]);
|
(int)_TyLong_DigitValue[Ty_CHARMASK(*p)]);
|
||||||
assert(c < TyLong_BASE);
|
assert(c < TyLong_BASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2891,7 +2891,7 @@ long_from_string_base(const char **str, int base, PyLongObject **res)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* Verify all characters are digits and underscores. */
|
/* Verify all characters are digits and underscores. */
|
||||||
while (_TyLong_DigitValue[Py_CHARMASK(*p)] < base || *p == '_') {
|
while (_TyLong_DigitValue[Ty_CHARMASK(*p)] < base || *p == '_') {
|
||||||
if (*p == '_') {
|
if (*p == '_') {
|
||||||
/* Double underscore not allowed. */
|
/* Double underscore not allowed. */
|
||||||
if (prev == '_') {
|
if (prev == '_') {
|
||||||
@@ -2915,7 +2915,7 @@ long_from_string_base(const char **str, int base, PyLongObject **res)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* Allow only trailing whitespace after `end` */
|
/* Allow only trailing whitespace after `end` */
|
||||||
while (*p && Py_ISSPACE(*p)) {
|
while (*p && Ty_ISSPACE(*p)) {
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
*str = p;
|
*str = p;
|
||||||
@@ -2977,7 +2977,7 @@ TyLong_FromString(const char *str, char **pend, int base)
|
|||||||
"int() arg 2 must be >= 2 and <= 36");
|
"int() arg 2 must be >= 2 and <= 36");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
while (*str != '\0' && Py_ISSPACE(*str)) {
|
while (*str != '\0' && Ty_ISSPACE(*str)) {
|
||||||
++str;
|
++str;
|
||||||
}
|
}
|
||||||
if (*str == '+') {
|
if (*str == '+') {
|
||||||
@@ -3084,7 +3084,7 @@ _TyLong_FromBytes(const char *s, Ty_ssize_t len, int base)
|
|||||||
if (end == NULL || (result != NULL && end == s + len))
|
if (end == NULL || (result != NULL && end == s + len))
|
||||||
return result;
|
return result;
|
||||||
Ty_XDECREF(result);
|
Ty_XDECREF(result);
|
||||||
strobj = TyBytes_FromStringAndSize(s, Py_MIN(len, 200));
|
strobj = TyBytes_FromStringAndSize(s, Ty_MIN(len, 200));
|
||||||
if (strobj != NULL) {
|
if (strobj != NULL) {
|
||||||
TyErr_Format(TyExc_ValueError,
|
TyErr_Format(TyExc_ValueError,
|
||||||
"invalid literal for int() with base %d: %.200R",
|
"invalid literal for int() with base %d: %.200R",
|
||||||
@@ -3946,7 +3946,7 @@ kmul_split(PyLongObject *n,
|
|||||||
Ty_ssize_t size_lo, size_hi;
|
Ty_ssize_t size_lo, size_hi;
|
||||||
const Ty_ssize_t size_n = _TyLong_DigitCount(n);
|
const Ty_ssize_t size_n = _TyLong_DigitCount(n);
|
||||||
|
|
||||||
size_lo = Py_MIN(size_n, size);
|
size_lo = Ty_MIN(size_n, size);
|
||||||
size_hi = size_n - size_lo;
|
size_hi = size_n - size_lo;
|
||||||
|
|
||||||
if ((hi = long_alloc(size_hi)) == NULL)
|
if ((hi = long_alloc(size_hi)) == NULL)
|
||||||
@@ -4214,7 +4214,7 @@ k_lopsided_mul(PyLongObject *a, PyLongObject *b)
|
|||||||
nbdone = 0;
|
nbdone = 0;
|
||||||
while (bsize > 0) {
|
while (bsize > 0) {
|
||||||
PyLongObject *product;
|
PyLongObject *product;
|
||||||
const Ty_ssize_t nbtouse = Py_MIN(bsize, asize);
|
const Ty_ssize_t nbtouse = Ty_MIN(bsize, asize);
|
||||||
|
|
||||||
/* Multiply the next slice of b by a. */
|
/* Multiply the next slice of b by a. */
|
||||||
memcpy(bslice->long_value.ob_digit, b->long_value.ob_digit + nbdone,
|
memcpy(bslice->long_value.ob_digit, b->long_value.ob_digit + nbdone,
|
||||||
@@ -4656,7 +4656,7 @@ long_true_divide(TyObject *v, TyObject *w)
|
|||||||
goto underflow_or_zero;
|
goto underflow_or_zero;
|
||||||
|
|
||||||
/* Choose value for shift; see comments for step 1 above. */
|
/* Choose value for shift; see comments for step 1 above. */
|
||||||
shift = Py_MAX(diff, DBL_MIN_EXP) - DBL_MANT_DIG - 2;
|
shift = Ty_MAX(diff, DBL_MIN_EXP) - DBL_MANT_DIG - 2;
|
||||||
|
|
||||||
inexact = 0;
|
inexact = 0;
|
||||||
|
|
||||||
@@ -4726,7 +4726,7 @@ long_true_divide(TyObject *v, TyObject *w)
|
|||||||
x_bits = (x_size-1)*TyLong_SHIFT+bit_length_digit(x->long_value.ob_digit[x_size-1]);
|
x_bits = (x_size-1)*TyLong_SHIFT+bit_length_digit(x->long_value.ob_digit[x_size-1]);
|
||||||
|
|
||||||
/* The number of extra bits that have to be rounded away. */
|
/* The number of extra bits that have to be rounded away. */
|
||||||
extra_bits = Py_MAX(x_bits, DBL_MIN_EXP - shift) - DBL_MANT_DIG;
|
extra_bits = Ty_MAX(x_bits, DBL_MIN_EXP - shift) - DBL_MANT_DIG;
|
||||||
assert(extra_bits == 2 || extra_bits == 3);
|
assert(extra_bits == 2 || extra_bits == 3);
|
||||||
|
|
||||||
/* Round by directly modifying the low digit of x. */
|
/* Round by directly modifying the low digit of x. */
|
||||||
@@ -5827,8 +5827,8 @@ simple:
|
|||||||
#else
|
#else
|
||||||
# error "_TyLong_GCD"
|
# error "_TyLong_GCD"
|
||||||
#endif
|
#endif
|
||||||
x = Py_ABS(x);
|
x = Ty_ABS(x);
|
||||||
y = Py_ABS(y);
|
y = Ty_ABS(y);
|
||||||
Ty_DECREF(a);
|
Ty_DECREF(a);
|
||||||
Ty_DECREF(b);
|
Ty_DECREF(b);
|
||||||
|
|
||||||
@@ -6180,9 +6180,9 @@ static Ty_ssize_t
|
|||||||
int___sizeof___impl(TyObject *self)
|
int___sizeof___impl(TyObject *self)
|
||||||
/*[clinic end generated code: output=3303f008eaa6a0a5 input=9b51620c76fc4507]*/
|
/*[clinic end generated code: output=3303f008eaa6a0a5 input=9b51620c76fc4507]*/
|
||||||
{
|
{
|
||||||
/* using Py_MAX(..., 1) because we always allocate space for at least
|
/* using Ty_MAX(..., 1) because we always allocate space for at least
|
||||||
one digit, even though the integer zero has a digit count of 0 */
|
one digit, even though the integer zero has a digit count of 0 */
|
||||||
Ty_ssize_t ndigits = Py_MAX(_TyLong_DigitCount((PyLongObject *)self), 1);
|
Ty_ssize_t ndigits = Ty_MAX(_TyLong_DigitCount((PyLongObject *)self), 1);
|
||||||
return Ty_TYPE(self)->tp_basicsize + Ty_TYPE(self)->tp_itemsize * ndigits;
|
return Ty_TYPE(self)->tp_basicsize + Ty_TYPE(self)->tp_itemsize * ndigits;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6783,7 +6783,7 @@ TyLong_Export(TyObject *obj, PyLongExport *export_long)
|
|||||||
// Windows has 32-bit long, so use 64-bit long long instead
|
// Windows has 32-bit long, so use 64-bit long long instead
|
||||||
long long value = TyLong_AsLongLongAndOverflow(obj, &overflow);
|
long long value = TyLong_AsLongLongAndOverflow(obj, &overflow);
|
||||||
#endif
|
#endif
|
||||||
Py_BUILD_ASSERT(sizeof(value) == sizeof(int64_t));
|
Ty_BUILD_ASSERT(sizeof(value) == sizeof(int64_t));
|
||||||
// the function cannot fail since obj is a PyLongObject
|
// the function cannot fail since obj is a PyLongObject
|
||||||
assert(!(value == -1 && TyErr_Occurred()));
|
assert(!(value == -1 && TyErr_Occurred()));
|
||||||
|
|
||||||
|
|||||||
@@ -513,7 +513,7 @@ static void config_set_argv(TyConfig *config, Ty_ssize_t argc, wchar_t * const *
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
config_set_wide_string_list(TyConfig *config, PyWideStringList *list,
|
config_set_wide_string_list(TyConfig *config, TyWideStringList *list,
|
||||||
Ty_ssize_t length, wchar_t **items)
|
Ty_ssize_t length, wchar_t **items)
|
||||||
{
|
{
|
||||||
TyStatus status = TyConfig_SetWideStringList(config, list, length, items);
|
TyStatus status = TyConfig_SetWideStringList(config, list, length, items);
|
||||||
|
|||||||
@@ -1529,7 +1529,7 @@ _PyCompile_CleanDoc(TyObject *doc)
|
|||||||
const char *s = p;
|
const char *s = p;
|
||||||
while (*p == ' ') p++;
|
while (*p == ' ') p++;
|
||||||
if (p < pend && *p != '\n') {
|
if (p < pend && *p != '\n') {
|
||||||
margin = Py_MIN(margin, p - s);
|
margin = Ty_MIN(margin, p - s);
|
||||||
}
|
}
|
||||||
while (p < pend && *p++ != '\n') {
|
while (p < pend && *p++ != '\n') {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -528,8 +528,8 @@ static int
|
|||||||
context_tp_traverse(TyObject *op, visitproc visit, void *arg)
|
context_tp_traverse(TyObject *op, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
PyContext *self = _TyContext_CAST(op);
|
PyContext *self = _TyContext_CAST(op);
|
||||||
Py_VISIT(self->ctx_prev);
|
Ty_VISIT(self->ctx_prev);
|
||||||
Py_VISIT(self->ctx_vars);
|
Ty_VISIT(self->ctx_vars);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -945,8 +945,8 @@ static int
|
|||||||
contextvar_tp_traverse(TyObject *op, visitproc visit, void *arg)
|
contextvar_tp_traverse(TyObject *op, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
PyContextVar *self = _PyContextVar_CAST(op);
|
PyContextVar *self = _PyContextVar_CAST(op);
|
||||||
Py_VISIT(self->var_name);
|
Ty_VISIT(self->var_name);
|
||||||
Py_VISIT(self->var_default);
|
Ty_VISIT(self->var_default);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1160,9 +1160,9 @@ static int
|
|||||||
token_tp_traverse(TyObject *op, visitproc visit, void *arg)
|
token_tp_traverse(TyObject *op, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
PyContextToken *self = _PyContextToken_CAST(op);
|
PyContextToken *self = _PyContextToken_CAST(op);
|
||||||
Py_VISIT(self->tok_ctx);
|
Ty_VISIT(self->tok_ctx);
|
||||||
Py_VISIT(self->tok_var);
|
Ty_VISIT(self->tok_var);
|
||||||
Py_VISIT(self->tok_oldval);
|
Ty_VISIT(self->tok_oldval);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ vgetargs1_impl(TyObject *compat_args, TyObject *const *stack, Ty_ssize_t nargs,
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (level == 0) {
|
if (level == 0) {
|
||||||
if (Py_ISALPHA(c))
|
if (Ty_ISALPHA(c))
|
||||||
if (c != 'e') /* skip encoded */
|
if (c != 'e') /* skip encoded */
|
||||||
max++;
|
max++;
|
||||||
}
|
}
|
||||||
@@ -359,7 +359,7 @@ vgetargs1_impl(TyObject *compat_args, TyObject *const *stack, Ty_ssize_t nargs,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*format != '\0' && !Py_ISALPHA(*format) &&
|
if (*format != '\0' && !Ty_ISALPHA(*format) &&
|
||||||
*format != '(' &&
|
*format != '(' &&
|
||||||
*format != '|' && *format != ':' && *format != ';') {
|
*format != '|' && *format != ':' && *format != ';') {
|
||||||
TyErr_Format(TyExc_SystemError,
|
TyErr_Format(TyExc_SystemError,
|
||||||
@@ -493,7 +493,7 @@ converttuple(TyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||||||
else if (c == ':' || c == ';' || c == '\0')
|
else if (c == ':' || c == ';' || c == '\0')
|
||||||
break;
|
break;
|
||||||
else {
|
else {
|
||||||
if (level == 0 && Py_ISALPHA(c)) {
|
if (level == 0 && Ty_ISALPHA(c)) {
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
if (c == 'e' && (*format == 's' || *format == 't')) {
|
if (c == 'e' && (*format == 's' || *format == 't')) {
|
||||||
@@ -1853,9 +1853,9 @@ vgetargskeywords(TyObject *args, TyObject *kwargs, const char *format,
|
|||||||
" (%zd given)",
|
" (%zd given)",
|
||||||
(fname == NULL) ? "function" : fname,
|
(fname == NULL) ? "function" : fname,
|
||||||
(fname == NULL) ? "" : "()",
|
(fname == NULL) ? "" : "()",
|
||||||
(Py_MIN(pos, min) < i) ? "at least" : "exactly",
|
(Ty_MIN(pos, min) < i) ? "at least" : "exactly",
|
||||||
Py_MIN(pos, min),
|
Ty_MIN(pos, min),
|
||||||
Py_MIN(pos, min) == 1 ? "" : "s",
|
Ty_MIN(pos, min) == 1 ? "" : "s",
|
||||||
nargs);
|
nargs);
|
||||||
return cleanreturn(0, &freelist);
|
return cleanreturn(0, &freelist);
|
||||||
}
|
}
|
||||||
@@ -2034,8 +2034,8 @@ parse_format(const char *format, int total, int npos,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
min = Py_MIN(min, total);
|
min = Ty_MIN(min, total);
|
||||||
max = Py_MIN(max, total);
|
max = Ty_MIN(max, total);
|
||||||
|
|
||||||
if (!IS_END_OF_FORMAT(*format) && (*format != '|') && (*format != '$')) {
|
if (!IS_END_OF_FORMAT(*format) && (*format != '|') && (*format != '$')) {
|
||||||
TyErr_Format(TyExc_SystemError,
|
TyErr_Format(TyExc_SystemError,
|
||||||
@@ -2348,7 +2348,7 @@ vgetargskeywordsfast_impl(TyObject *const *args, Ty_ssize_t nargs,
|
|||||||
if (i < parser->min) {
|
if (i < parser->min) {
|
||||||
/* Less arguments than required */
|
/* Less arguments than required */
|
||||||
if (i < pos) {
|
if (i < pos) {
|
||||||
Ty_ssize_t min = Py_MIN(pos, parser->min);
|
Ty_ssize_t min = Ty_MIN(pos, parser->min);
|
||||||
TyErr_Format(TyExc_TypeError,
|
TyErr_Format(TyExc_TypeError,
|
||||||
"%.200s%s takes %s %d positional argument%s"
|
"%.200s%s takes %s %d positional argument%s"
|
||||||
" (%zd given)",
|
" (%zd given)",
|
||||||
@@ -2479,7 +2479,7 @@ _TyArg_UnpackKeywords(TyObject *const *args, Ty_ssize_t nargs,
|
|||||||
|
|
||||||
kwtuple = parser->kwtuple;
|
kwtuple = parser->kwtuple;
|
||||||
posonly = parser->pos;
|
posonly = parser->pos;
|
||||||
minposonly = Py_MIN(posonly, minpos);
|
minposonly = Ty_MIN(posonly, minpos);
|
||||||
maxargs = posonly + (int)TyTuple_GET_SIZE(kwtuple);
|
maxargs = posonly + (int)TyTuple_GET_SIZE(kwtuple);
|
||||||
|
|
||||||
if (kwargs != NULL) {
|
if (kwargs != NULL) {
|
||||||
@@ -2542,7 +2542,7 @@ _TyArg_UnpackKeywords(TyObject *const *args, Ty_ssize_t nargs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (varpos) {
|
if (varpos) {
|
||||||
nargs = Py_MIN(maxpos, nargs);
|
nargs = Ty_MIN(maxpos, nargs);
|
||||||
}
|
}
|
||||||
/* copy tuple args */
|
/* copy tuple args */
|
||||||
for (i = 0; i < nargs; i++) {
|
for (i = 0; i < nargs; i++) {
|
||||||
@@ -2550,7 +2550,7 @@ _TyArg_UnpackKeywords(TyObject *const *args, Ty_ssize_t nargs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* copy keyword args using kwtuple to drive process */
|
/* copy keyword args using kwtuple to drive process */
|
||||||
for (i = Py_MAX((int)nargs, posonly); i < maxargs; i++) {
|
for (i = Ty_MAX((int)nargs, posonly); i < maxargs; i++) {
|
||||||
TyObject *current_arg;
|
TyObject *current_arg;
|
||||||
if (nkwargs) {
|
if (nkwargs) {
|
||||||
keyword = TyTuple_GET_ITEM(kwtuple, i - posonly);
|
keyword = TyTuple_GET_ITEM(kwtuple, i - posonly);
|
||||||
|
|||||||
@@ -628,11 +628,11 @@ _TyErr_SetFromPyStatus(TyStatus status)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* --- PyWideStringList ------------------------------------------------ */
|
/* --- TyWideStringList ------------------------------------------------ */
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
int
|
int
|
||||||
_TyWideStringList_CheckConsistency(const PyWideStringList *list)
|
_TyWideStringList_CheckConsistency(const TyWideStringList *list)
|
||||||
{
|
{
|
||||||
assert(list->length >= 0);
|
assert(list->length >= 0);
|
||||||
if (list->length != 0) {
|
if (list->length != 0) {
|
||||||
@@ -647,7 +647,7 @@ _TyWideStringList_CheckConsistency(const PyWideStringList *list)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_TyWideStringList_ClearEx(PyWideStringList *list,
|
_TyWideStringList_ClearEx(TyWideStringList *list,
|
||||||
bool use_default_allocator)
|
bool use_default_allocator)
|
||||||
{
|
{
|
||||||
assert(_TyWideStringList_CheckConsistency(list));
|
assert(_TyWideStringList_CheckConsistency(list));
|
||||||
@@ -670,14 +670,14 @@ _TyWideStringList_ClearEx(PyWideStringList *list,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_TyWideStringList_Clear(PyWideStringList *list)
|
_TyWideStringList_Clear(TyWideStringList *list)
|
||||||
{
|
{
|
||||||
_TyWideStringList_ClearEx(list, false);
|
_TyWideStringList_ClearEx(list, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_TyWideStringList_CopyEx(PyWideStringList *list,
|
_TyWideStringList_CopyEx(TyWideStringList *list,
|
||||||
const PyWideStringList *list2,
|
const TyWideStringList *list2,
|
||||||
bool use_default_allocator)
|
bool use_default_allocator)
|
||||||
{
|
{
|
||||||
assert(_TyWideStringList_CheckConsistency(list));
|
assert(_TyWideStringList_CheckConsistency(list));
|
||||||
@@ -688,7 +688,7 @@ _TyWideStringList_CopyEx(PyWideStringList *list,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyWideStringList copy = _TyWideStringList_INIT;
|
TyWideStringList copy = _TyWideStringList_INIT;
|
||||||
|
|
||||||
size_t size = list2->length * sizeof(list2->items[0]);
|
size_t size = list2->length * sizeof(list2->items[0]);
|
||||||
if (use_default_allocator) {
|
if (use_default_allocator) {
|
||||||
@@ -723,13 +723,13 @@ _TyWideStringList_CopyEx(PyWideStringList *list,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_TyWideStringList_Copy(PyWideStringList *list, const PyWideStringList *list2)
|
_TyWideStringList_Copy(TyWideStringList *list, const TyWideStringList *list2)
|
||||||
{
|
{
|
||||||
return _TyWideStringList_CopyEx(list, list2, false);
|
return _TyWideStringList_CopyEx(list, list2, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
TyStatus
|
TyStatus
|
||||||
PyWideStringList_Insert(PyWideStringList *list,
|
PyWideStringList_Insert(TyWideStringList *list,
|
||||||
Ty_ssize_t index, const wchar_t *item)
|
Ty_ssize_t index, const wchar_t *item)
|
||||||
{
|
{
|
||||||
Ty_ssize_t len = list->length;
|
Ty_ssize_t len = list->length;
|
||||||
@@ -770,14 +770,14 @@ PyWideStringList_Insert(PyWideStringList *list,
|
|||||||
|
|
||||||
|
|
||||||
TyStatus
|
TyStatus
|
||||||
PyWideStringList_Append(PyWideStringList *list, const wchar_t *item)
|
PyWideStringList_Append(TyWideStringList *list, const wchar_t *item)
|
||||||
{
|
{
|
||||||
return PyWideStringList_Insert(list, list->length, item);
|
return PyWideStringList_Insert(list, list->length, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TyStatus
|
TyStatus
|
||||||
_TyWideStringList_Extend(PyWideStringList *list, const PyWideStringList *list2)
|
_TyWideStringList_Extend(TyWideStringList *list, const TyWideStringList *list2)
|
||||||
{
|
{
|
||||||
for (Ty_ssize_t i = 0; i < list2->length; i++) {
|
for (Ty_ssize_t i = 0; i < list2->length; i++) {
|
||||||
TyStatus status = PyWideStringList_Append(list, list2->items[i]);
|
TyStatus status = PyWideStringList_Append(list, list2->items[i]);
|
||||||
@@ -790,7 +790,7 @@ _TyWideStringList_Extend(PyWideStringList *list, const PyWideStringList *list2)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_TyWideStringList_Find(PyWideStringList *list, const wchar_t *item)
|
_TyWideStringList_Find(TyWideStringList *list, const wchar_t *item)
|
||||||
{
|
{
|
||||||
for (Ty_ssize_t i = 0; i < list->length; i++) {
|
for (Ty_ssize_t i = 0; i < list->length; i++) {
|
||||||
if (wcscmp(list->items[i], item) == 0) {
|
if (wcscmp(list->items[i], item) == 0) {
|
||||||
@@ -802,7 +802,7 @@ _TyWideStringList_Find(PyWideStringList *list, const wchar_t *item)
|
|||||||
|
|
||||||
|
|
||||||
TyObject*
|
TyObject*
|
||||||
_TyWideStringList_AsList(const PyWideStringList *list)
|
_TyWideStringList_AsList(const TyWideStringList *list)
|
||||||
{
|
{
|
||||||
assert(_TyWideStringList_CheckConsistency(list));
|
assert(_TyWideStringList_CheckConsistency(list));
|
||||||
|
|
||||||
@@ -824,7 +824,7 @@ _TyWideStringList_AsList(const PyWideStringList *list)
|
|||||||
|
|
||||||
|
|
||||||
static TyObject*
|
static TyObject*
|
||||||
_TyWideStringList_AsTuple(const PyWideStringList *list)
|
_TyWideStringList_AsTuple(const TyWideStringList *list)
|
||||||
{
|
{
|
||||||
assert(_TyWideStringList_CheckConsistency(list));
|
assert(_TyWideStringList_CheckConsistency(list));
|
||||||
|
|
||||||
@@ -857,7 +857,7 @@ _Ty_ClearArgcArgv(void)
|
|||||||
static int
|
static int
|
||||||
_Ty_SetArgcArgv(Ty_ssize_t argc, wchar_t * const *argv)
|
_Ty_SetArgcArgv(Ty_ssize_t argc, wchar_t * const *argv)
|
||||||
{
|
{
|
||||||
const PyWideStringList argv_list = {.length = argc, .items = (wchar_t **)argv};
|
const TyWideStringList argv_list = {.length = argc, .items = (wchar_t **)argv};
|
||||||
|
|
||||||
// XXX _PyRuntime.orig_argv only gets cleared by Ty_Main(),
|
// XXX _PyRuntime.orig_argv only gets cleared by Ty_Main(),
|
||||||
// so it currently leaks for embedders.
|
// so it currently leaks for embedders.
|
||||||
@@ -953,7 +953,7 @@ config_check_consistency(const TyConfig *config)
|
|||||||
|
|
||||||
/* Free memory allocated in config, but don't clear all attributes */
|
/* Free memory allocated in config, but don't clear all attributes */
|
||||||
void
|
void
|
||||||
PyConfig_Clear(TyConfig *config)
|
TyConfig_Clear(TyConfig *config)
|
||||||
{
|
{
|
||||||
#define CLEAR(ATTR) \
|
#define CLEAR(ATTR) \
|
||||||
do { \
|
do { \
|
||||||
@@ -1100,7 +1100,7 @@ config_init_defaults(TyConfig *config)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PyConfig_InitPythonConfig(TyConfig *config)
|
TyConfig_InitTyphonConfig(TyConfig *config)
|
||||||
{
|
{
|
||||||
config_init_defaults(config);
|
config_init_defaults(config);
|
||||||
|
|
||||||
@@ -1111,7 +1111,7 @@ PyConfig_InitPythonConfig(TyConfig *config)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PyConfig_InitIsolatedConfig(TyConfig *config)
|
TyConfig_InitIsolatedConfig(TyConfig *config)
|
||||||
{
|
{
|
||||||
config_init_defaults(config);
|
config_init_defaults(config);
|
||||||
|
|
||||||
@@ -1143,7 +1143,7 @@ PyConfig_InitIsolatedConfig(TyConfig *config)
|
|||||||
|
|
||||||
/* Copy str into *config_str (duplicate the string) */
|
/* Copy str into *config_str (duplicate the string) */
|
||||||
TyStatus
|
TyStatus
|
||||||
PyConfig_SetString(TyConfig *config, wchar_t **config_str, const wchar_t *str)
|
TyConfig_SetString(TyConfig *config, wchar_t **config_str, const wchar_t *str)
|
||||||
{
|
{
|
||||||
TyStatus status = _Ty_PreInitializeFromConfig(config, NULL);
|
TyStatus status = _Ty_PreInitializeFromConfig(config, NULL);
|
||||||
if (_TyStatus_EXCEPTION(status)) {
|
if (_TyStatus_EXCEPTION(status)) {
|
||||||
@@ -1205,7 +1205,7 @@ config_set_bytes_string(TyConfig *config, wchar_t **config_str,
|
|||||||
Pre-initialize Python if needed to ensure that encodings are properly
|
Pre-initialize Python if needed to ensure that encodings are properly
|
||||||
configured. */
|
configured. */
|
||||||
TyStatus
|
TyStatus
|
||||||
PyConfig_SetBytesString(TyConfig *config, wchar_t **config_str,
|
TyConfig_SetBytesString(TyConfig *config, wchar_t **config_str,
|
||||||
const char *str)
|
const char *str)
|
||||||
{
|
{
|
||||||
return CONFIG_SET_BYTES_STR(config, config_str, str, "string");
|
return CONFIG_SET_BYTES_STR(config, config_str, str, "string");
|
||||||
@@ -1261,8 +1261,8 @@ _TyConfig_Copy(TyConfig *config, const TyConfig *config2)
|
|||||||
}
|
}
|
||||||
case PyConfig_MEMBER_WSTR_LIST:
|
case PyConfig_MEMBER_WSTR_LIST:
|
||||||
{
|
{
|
||||||
if (_TyWideStringList_Copy((PyWideStringList*)member,
|
if (_TyWideStringList_Copy((TyWideStringList*)member,
|
||||||
(const PyWideStringList*)member2) < 0) {
|
(const TyWideStringList*)member2) < 0) {
|
||||||
return _TyStatus_NO_MEMORY();
|
return _TyStatus_NO_MEMORY();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1395,7 +1395,7 @@ error:
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
config_dict_get_wstrlist(TyObject *dict, const char *name, TyConfig *config,
|
config_dict_get_wstrlist(TyObject *dict, const char *name, TyConfig *config,
|
||||||
PyWideStringList *result)
|
TyWideStringList *result)
|
||||||
{
|
{
|
||||||
TyObject *list = config_dict_get(dict, name);
|
TyObject *list = config_dict_get(dict, name);
|
||||||
if (list == NULL) {
|
if (list == NULL) {
|
||||||
@@ -1409,7 +1409,7 @@ config_dict_get_wstrlist(TyObject *dict, const char *name, TyConfig *config,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyWideStringList wstrlist = _TyWideStringList_INIT;
|
TyWideStringList wstrlist = _TyWideStringList_INIT;
|
||||||
Ty_ssize_t len = is_list ? TyList_GET_SIZE(list) : TyTuple_GET_SIZE(list);
|
Ty_ssize_t len = is_list ? TyList_GET_SIZE(list) : TyTuple_GET_SIZE(list);
|
||||||
for (Ty_ssize_t i=0; i < len; i++) {
|
for (Ty_ssize_t i=0; i < len; i++) {
|
||||||
TyObject *item = is_list ? TyList_GET_ITEM(list, i) : TyTuple_GET_ITEM(list, i);
|
TyObject *item = is_list ? TyList_GET_ITEM(list, i) : TyTuple_GET_ITEM(list, i);
|
||||||
@@ -1451,7 +1451,7 @@ error:
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
config_dict_get_xoptions(TyObject *dict, const char *name, TyConfig *config,
|
config_dict_get_xoptions(TyObject *dict, const char *name, TyConfig *config,
|
||||||
PyWideStringList *result)
|
TyWideStringList *result)
|
||||||
{
|
{
|
||||||
TyObject *xoptions = config_dict_get(dict, name);
|
TyObject *xoptions = config_dict_get(dict, name);
|
||||||
if (xoptions == NULL) {
|
if (xoptions == NULL) {
|
||||||
@@ -1466,7 +1466,7 @@ config_dict_get_xoptions(TyObject *dict, const char *name, TyConfig *config,
|
|||||||
|
|
||||||
Ty_ssize_t pos = 0;
|
Ty_ssize_t pos = 0;
|
||||||
TyObject *key, *value;
|
TyObject *key, *value;
|
||||||
PyWideStringList wstrlist = _TyWideStringList_INIT;
|
TyWideStringList wstrlist = _TyWideStringList_INIT;
|
||||||
while (TyDict_Next(xoptions, &pos, &key, &value)) {
|
while (TyDict_Next(xoptions, &pos, &key, &value)) {
|
||||||
TyObject *item;
|
TyObject *item;
|
||||||
|
|
||||||
@@ -1572,13 +1572,13 @@ _TyConfig_FromDict(TyConfig *config, TyObject *dict)
|
|||||||
{
|
{
|
||||||
if (strcmp(spec->name, "xoptions") == 0) {
|
if (strcmp(spec->name, "xoptions") == 0) {
|
||||||
if (config_dict_get_xoptions(dict, spec->name, config,
|
if (config_dict_get_xoptions(dict, spec->name, config,
|
||||||
(PyWideStringList*)member) < 0) {
|
(TyWideStringList*)member) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (config_dict_get_wstrlist(dict, spec->name, config,
|
if (config_dict_get_wstrlist(dict, spec->name, config,
|
||||||
(PyWideStringList*)member) < 0) {
|
(TyWideStringList*)member) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2857,11 +2857,11 @@ config_complete_usage(const wchar_t* program)
|
|||||||
|
|
||||||
/* Parse the command line arguments */
|
/* Parse the command line arguments */
|
||||||
static TyStatus
|
static TyStatus
|
||||||
config_parse_cmdline(TyConfig *config, PyWideStringList *warnoptions,
|
config_parse_cmdline(TyConfig *config, TyWideStringList *warnoptions,
|
||||||
Ty_ssize_t *opt_index)
|
Ty_ssize_t *opt_index)
|
||||||
{
|
{
|
||||||
TyStatus status;
|
TyStatus status;
|
||||||
const PyWideStringList *argv = &config->argv;
|
const TyWideStringList *argv = &config->argv;
|
||||||
int print_version = 0;
|
int print_version = 0;
|
||||||
const wchar_t* program = config->program_name;
|
const wchar_t* program = config->program_name;
|
||||||
if (!program && argv->length >= 1) {
|
if (!program && argv->length >= 1) {
|
||||||
@@ -3067,7 +3067,7 @@ config_parse_cmdline(TyConfig *config, PyWideStringList *warnoptions,
|
|||||||
|
|
||||||
/* Get warning options from PYTHONWARNINGS environment variable. */
|
/* Get warning options from PYTHONWARNINGS environment variable. */
|
||||||
static TyStatus
|
static TyStatus
|
||||||
config_init_env_warnoptions(TyConfig *config, PyWideStringList *warnoptions)
|
config_init_env_warnoptions(TyConfig *config, TyWideStringList *warnoptions)
|
||||||
{
|
{
|
||||||
TyStatus status;
|
TyStatus status;
|
||||||
/* CONFIG_GET_ENV_DUP requires dest to be initialized to NULL */
|
/* CONFIG_GET_ENV_DUP requires dest to be initialized to NULL */
|
||||||
@@ -3101,7 +3101,7 @@ config_init_env_warnoptions(TyConfig *config, PyWideStringList *warnoptions)
|
|||||||
|
|
||||||
|
|
||||||
static TyStatus
|
static TyStatus
|
||||||
warnoptions_append(TyConfig *config, PyWideStringList *options,
|
warnoptions_append(TyConfig *config, TyWideStringList *options,
|
||||||
const wchar_t *option)
|
const wchar_t *option)
|
||||||
{
|
{
|
||||||
/* config_init_warnoptions() add existing config warnoptions at the end:
|
/* config_init_warnoptions() add existing config warnoptions at the end:
|
||||||
@@ -3121,8 +3121,8 @@ warnoptions_append(TyConfig *config, PyWideStringList *options,
|
|||||||
|
|
||||||
|
|
||||||
static TyStatus
|
static TyStatus
|
||||||
warnoptions_extend(TyConfig *config, PyWideStringList *options,
|
warnoptions_extend(TyConfig *config, TyWideStringList *options,
|
||||||
const PyWideStringList *options2)
|
const TyWideStringList *options2)
|
||||||
{
|
{
|
||||||
const Ty_ssize_t len = options2->length;
|
const Ty_ssize_t len = options2->length;
|
||||||
wchar_t *const *items = options2->items;
|
wchar_t *const *items = options2->items;
|
||||||
@@ -3139,12 +3139,12 @@ warnoptions_extend(TyConfig *config, PyWideStringList *options,
|
|||||||
|
|
||||||
static TyStatus
|
static TyStatus
|
||||||
config_init_warnoptions(TyConfig *config,
|
config_init_warnoptions(TyConfig *config,
|
||||||
const PyWideStringList *cmdline_warnoptions,
|
const TyWideStringList *cmdline_warnoptions,
|
||||||
const PyWideStringList *env_warnoptions,
|
const TyWideStringList *env_warnoptions,
|
||||||
const PyWideStringList *sys_warnoptions)
|
const TyWideStringList *sys_warnoptions)
|
||||||
{
|
{
|
||||||
TyStatus status;
|
TyStatus status;
|
||||||
PyWideStringList options = _TyWideStringList_INIT;
|
TyWideStringList options = _TyWideStringList_INIT;
|
||||||
|
|
||||||
/* Priority of warnings options, lowest to highest:
|
/* Priority of warnings options, lowest to highest:
|
||||||
*
|
*
|
||||||
@@ -3222,8 +3222,8 @@ error:
|
|||||||
static TyStatus
|
static TyStatus
|
||||||
config_update_argv(TyConfig *config, Ty_ssize_t opt_index)
|
config_update_argv(TyConfig *config, Ty_ssize_t opt_index)
|
||||||
{
|
{
|
||||||
const PyWideStringList *cmdline_argv = &config->argv;
|
const TyWideStringList *cmdline_argv = &config->argv;
|
||||||
PyWideStringList config_argv = _TyWideStringList_INIT;
|
TyWideStringList config_argv = _TyWideStringList_INIT;
|
||||||
|
|
||||||
/* Copy argv to be able to modify it (to force -c/-m) */
|
/* Copy argv to be able to modify it (to force -c/-m) */
|
||||||
if (cmdline_argv->length <= opt_index) {
|
if (cmdline_argv->length <= opt_index) {
|
||||||
@@ -3234,7 +3234,7 @@ config_update_argv(TyConfig *config, Ty_ssize_t opt_index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyWideStringList slice;
|
TyWideStringList slice;
|
||||||
slice.length = cmdline_argv->length - opt_index;
|
slice.length = cmdline_argv->length - opt_index;
|
||||||
slice.items = &cmdline_argv->items[opt_index];
|
slice.items = &cmdline_argv->items[opt_index];
|
||||||
if (_TyWideStringList_Copy(&config_argv, &slice) < 0) {
|
if (_TyWideStringList_Copy(&config_argv, &slice) < 0) {
|
||||||
@@ -3338,9 +3338,9 @@ static TyStatus
|
|||||||
config_read_cmdline(TyConfig *config)
|
config_read_cmdline(TyConfig *config)
|
||||||
{
|
{
|
||||||
TyStatus status;
|
TyStatus status;
|
||||||
PyWideStringList cmdline_warnoptions = _TyWideStringList_INIT;
|
TyWideStringList cmdline_warnoptions = _TyWideStringList_INIT;
|
||||||
PyWideStringList env_warnoptions = _TyWideStringList_INIT;
|
TyWideStringList env_warnoptions = _TyWideStringList_INIT;
|
||||||
PyWideStringList sys_warnoptions = _TyWideStringList_INIT;
|
TyWideStringList sys_warnoptions = _TyWideStringList_INIT;
|
||||||
|
|
||||||
if (config->parse_argv < 0) {
|
if (config->parse_argv < 0) {
|
||||||
config->parse_argv = 1;
|
config->parse_argv = 1;
|
||||||
@@ -3416,7 +3416,7 @@ _TyConfig_SetPyArgv(TyConfig *config, const _PyArgv *args)
|
|||||||
/* Set config.argv: decode argv using Ty_DecodeLocale(). Pre-initialize Python
|
/* Set config.argv: decode argv using Ty_DecodeLocale(). Pre-initialize Python
|
||||||
if needed to ensure that encodings are properly configured. */
|
if needed to ensure that encodings are properly configured. */
|
||||||
TyStatus
|
TyStatus
|
||||||
PyConfig_SetBytesArgv(TyConfig *config, Ty_ssize_t argc, char * const *argv)
|
TyConfig_SetBytesArgv(TyConfig *config, Ty_ssize_t argc, char * const *argv)
|
||||||
{
|
{
|
||||||
_PyArgv args = {
|
_PyArgv args = {
|
||||||
.argc = argc,
|
.argc = argc,
|
||||||
@@ -3428,7 +3428,7 @@ PyConfig_SetBytesArgv(TyConfig *config, Ty_ssize_t argc, char * const *argv)
|
|||||||
|
|
||||||
|
|
||||||
TyStatus
|
TyStatus
|
||||||
PyConfig_SetArgv(TyConfig *config, Ty_ssize_t argc, wchar_t * const *argv)
|
TyConfig_SetArgv(TyConfig *config, Ty_ssize_t argc, wchar_t * const *argv)
|
||||||
{
|
{
|
||||||
_PyArgv args = {
|
_PyArgv args = {
|
||||||
.argc = argc,
|
.argc = argc,
|
||||||
@@ -3440,7 +3440,7 @@ PyConfig_SetArgv(TyConfig *config, Ty_ssize_t argc, wchar_t * const *argv)
|
|||||||
|
|
||||||
|
|
||||||
TyStatus
|
TyStatus
|
||||||
PyConfig_SetWideStringList(TyConfig *config, PyWideStringList *list,
|
TyConfig_SetWideStringList(TyConfig *config, TyWideStringList *list,
|
||||||
Ty_ssize_t length, wchar_t **items)
|
Ty_ssize_t length, wchar_t **items)
|
||||||
{
|
{
|
||||||
TyStatus status = _Ty_PreInitializeFromConfig(config, NULL);
|
TyStatus status = _Ty_PreInitializeFromConfig(config, NULL);
|
||||||
@@ -3448,7 +3448,7 @@ PyConfig_SetWideStringList(TyConfig *config, PyWideStringList *list,
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyWideStringList list2 = {.length = length, .items = items};
|
TyWideStringList list2 = {.length = length, .items = items};
|
||||||
if (_TyWideStringList_Copy(list, &list2) < 0) {
|
if (_TyWideStringList_Copy(list, &list2) < 0) {
|
||||||
return _TyStatus_NO_MEMORY();
|
return _TyStatus_NO_MEMORY();
|
||||||
}
|
}
|
||||||
@@ -3524,7 +3524,7 @@ done:
|
|||||||
|
|
||||||
|
|
||||||
TyStatus
|
TyStatus
|
||||||
PyConfig_Read(TyConfig *config)
|
TyConfig_Read(TyConfig *config)
|
||||||
{
|
{
|
||||||
return _TyConfig_Read(config, 0);
|
return _TyConfig_Read(config, 0);
|
||||||
}
|
}
|
||||||
@@ -3938,7 +3938,7 @@ PyInitConfig_GetStrList(PyInitConfig *config, const char *name, size_t *length,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyWideStringList *list = raw_member;
|
TyWideStringList *list = raw_member;
|
||||||
*length = list->length;
|
*length = list->length;
|
||||||
|
|
||||||
*items = malloc(list->length * sizeof(char*));
|
*items = malloc(list->length * sizeof(char*));
|
||||||
@@ -4094,10 +4094,10 @@ PyInitConfig_SetStr(PyInitConfig *config, const char *name, const char* value)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_TyWideStringList_FromUTF8(PyInitConfig *config, PyWideStringList *list,
|
_TyWideStringList_FromUTF8(PyInitConfig *config, TyWideStringList *list,
|
||||||
Ty_ssize_t length, char * const *items)
|
Ty_ssize_t length, char * const *items)
|
||||||
{
|
{
|
||||||
PyWideStringList wlist = _TyWideStringList_INIT;
|
TyWideStringList wlist = _TyWideStringList_INIT;
|
||||||
size_t size = sizeof(wchar_t*) * length;
|
size_t size = sizeof(wchar_t*) * length;
|
||||||
wlist.items = (wchar_t **)TyMem_RawMalloc(size);
|
wlist.items = (wchar_t **)TyMem_RawMalloc(size);
|
||||||
if (wlist.items == NULL) {
|
if (wlist.items == NULL) {
|
||||||
@@ -4135,7 +4135,7 @@ PyInitConfig_SetStrList(PyInitConfig *config, const char *name,
|
|||||||
initconfig_set_error(config, "config option type is not strings list");
|
initconfig_set_error(config, "config option type is not strings list");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
PyWideStringList *list = raw_member;
|
TyWideStringList *list = raw_member;
|
||||||
if (_TyWideStringList_FromUTF8(config, list, length, items) < 0) {
|
if (_TyWideStringList_FromUTF8(config, list, length, items) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -4371,7 +4371,7 @@ config_get(const TyConfig *config, const PyConfigSpec *spec,
|
|||||||
return _TyConfig_CreateXOptionsDict(config);
|
return _TyConfig_CreateXOptionsDict(config);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const PyWideStringList *list = (const PyWideStringList *)member;
|
const TyWideStringList *list = (const TyWideStringList *)member;
|
||||||
return _TyWideStringList_AsTuple(list);
|
return _TyWideStringList_AsTuple(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4409,7 +4409,7 @@ config_unknown_name_error(const char *name)
|
|||||||
|
|
||||||
|
|
||||||
TyObject*
|
TyObject*
|
||||||
PyConfig_Get(const char *name)
|
TyConfig_Get(const char *name)
|
||||||
{
|
{
|
||||||
const PyConfigSpec *spec = config_find_spec(name);
|
const PyConfigSpec *spec = config_find_spec(name);
|
||||||
if (spec != NULL) {
|
if (spec != NULL) {
|
||||||
@@ -4429,7 +4429,7 @@ PyConfig_Get(const char *name)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
PyConfig_GetInt(const char *name, int *value)
|
TyConfig_GetInt(const char *name, int *value)
|
||||||
{
|
{
|
||||||
assert(!TyErr_Occurred());
|
assert(!TyErr_Occurred());
|
||||||
|
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ Ty_GetProgramName(void)
|
|||||||
Raise an exception and return -1 on error.
|
Raise an exception and return -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
_TyPathConfig_ComputeSysPath0(const PyWideStringList *argv, TyObject **path0_p)
|
_TyPathConfig_ComputeSysPath0(const TyWideStringList *argv, TyObject **path0_p)
|
||||||
{
|
{
|
||||||
assert(_TyWideStringList_CheckConsistency(argv));
|
assert(_TyWideStringList_CheckConsistency(argv));
|
||||||
|
|
||||||
|
|||||||
@@ -76,9 +76,9 @@ _Ty_COMP_DIAG_POP
|
|||||||
|
|
||||||
/* Decode bytes_argv using Ty_DecodeLocale() */
|
/* Decode bytes_argv using Ty_DecodeLocale() */
|
||||||
TyStatus
|
TyStatus
|
||||||
_PyArgv_AsWstrList(const _PyArgv *args, PyWideStringList *list)
|
_PyArgv_AsWstrList(const _PyArgv *args, TyWideStringList *list)
|
||||||
{
|
{
|
||||||
PyWideStringList wargv = _TyWideStringList_INIT;
|
TyWideStringList wargv = _TyWideStringList_INIT;
|
||||||
if (args->use_bytes_argv) {
|
if (args->use_bytes_argv) {
|
||||||
size_t size = sizeof(wchar_t*) * args->argc;
|
size_t size = sizeof(wchar_t*) * args->argc;
|
||||||
wargv.items = (wchar_t **)TyMem_RawMalloc(size);
|
wargv.items = (wchar_t **)TyMem_RawMalloc(size);
|
||||||
@@ -183,7 +183,7 @@ _PyPreCmdline_SetConfig(const _PyPreCmdline *cmdline, TyConfig *config)
|
|||||||
static TyStatus
|
static TyStatus
|
||||||
precmdline_parse_cmdline(_PyPreCmdline *cmdline)
|
precmdline_parse_cmdline(_PyPreCmdline *cmdline)
|
||||||
{
|
{
|
||||||
const PyWideStringList *argv = &cmdline->argv;
|
const TyWideStringList *argv = &cmdline->argv;
|
||||||
|
|
||||||
_TyOS_ResetGetOpt();
|
_TyOS_ResetGetOpt();
|
||||||
/* Don't log parsing errors into stderr here: TyConfig_Read()
|
/* Don't log parsing errors into stderr here: TyConfig_Read()
|
||||||
@@ -579,7 +579,7 @@ _Ty_get_env_flag(int use_environment, int *flag, const char *name)
|
|||||||
|
|
||||||
|
|
||||||
const wchar_t*
|
const wchar_t*
|
||||||
_Ty_get_xoption(const PyWideStringList *xoptions, const wchar_t *name)
|
_Ty_get_xoption(const TyWideStringList *xoptions, const wchar_t *name)
|
||||||
{
|
{
|
||||||
for (Ty_ssize_t i=0; i < xoptions->length; i++) {
|
for (Ty_ssize_t i=0; i < xoptions->length; i++) {
|
||||||
const wchar_t *option = xoptions->items[i];
|
const wchar_t *option = xoptions->items[i];
|
||||||
|
|||||||
@@ -2970,7 +2970,7 @@ _clear_preinit_entries(_Ty_PreInitEntry *optionlist)
|
|||||||
|
|
||||||
|
|
||||||
TyStatus
|
TyStatus
|
||||||
_TySys_ReadPreinitWarnOptions(PyWideStringList *options)
|
_TySys_ReadPreinitWarnOptions(TyWideStringList *options)
|
||||||
{
|
{
|
||||||
TyStatus status;
|
TyStatus status;
|
||||||
_Ty_PreInitEntry entry;
|
_Ty_PreInitEntry entry;
|
||||||
@@ -4259,7 +4259,7 @@ TySys_SetArgvEx(int argc, wchar_t **argv, int updatepath)
|
|||||||
if (updatepath) {
|
if (updatepath) {
|
||||||
/* If argv[0] is not '-c' nor '-m', prepend argv[0] to sys.path.
|
/* If argv[0] is not '-c' nor '-m', prepend argv[0] to sys.path.
|
||||||
If argv[0] is a symlink, use the real path. */
|
If argv[0] is a symlink, use the real path. */
|
||||||
const PyWideStringList argv_list = {.length = argc, .items = argv};
|
const TyWideStringList argv_list = {.length = argc, .items = argv};
|
||||||
TyObject *path0 = NULL;
|
TyObject *path0 = NULL;
|
||||||
if (_TyPathConfig_ComputeSysPath0(&argv_list, &path0)) {
|
if (_TyPathConfig_ComputeSysPath0(&argv_list, &path0)) {
|
||||||
if (path0 == NULL) {
|
if (path0 == NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user