Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Include/coreconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ typedef struct {
valid

Set by the --check-hash-based-pycs command line option.
If set to NULL (default), inherit _Py_CheckHashBasedPycsMode value.
The default value is "default".

See PEP 552 "Deterministic pycs" for more details. */
const char *_check_hash_pycs_mode;
Expand Down Expand Up @@ -286,6 +286,7 @@ typedef struct {
.buffered_stdio = -1, \
_PyCoreConfig_WINDOWS_INIT \
._install_importlib = 1, \
._check_hash_pycs_mode = "default", \
._frozen = -1}
/* Note: _PyCoreConfig_INIT sets other fields to 0/NULL */

Expand Down
6 changes: 0 additions & 6 deletions Include/internal/import.h

This file was deleted.

6 changes: 3 additions & 3 deletions Modules/zipimport.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "Python.h"
#include "internal/import.h"
#include "internal/pystate.h"
#include "structmember.h"
#include "osdefs.h"
Expand Down Expand Up @@ -1352,12 +1351,13 @@ unmarshal_code(PyObject *pathname, PyObject *data, time_t mtime)

uint32_t flags = get_uint32(buf + 4);
if (flags != 0) {
_PyCoreConfig *config = &PyThreadState_GET()->interp->core_config;
// Hash-based pyc. We currently refuse to handle checked hash-based
// pycs. We could validate hash-based pycs against the source, but it
// seems likely that most people putting hash-based pycs in a zipfile
// will use unchecked ones.
if (strcmp(_Py_CheckHashBasedPycsMode, "never") &&
(flags != 0x1 || !strcmp(_Py_CheckHashBasedPycsMode, "always")))
if (strcmp(config->_check_hash_pycs_mode, "never") &&
(flags != 0x1 || !strcmp(config->_check_hash_pycs_mode, "always")))
Py_RETURN_NONE;
} else if ((mtime != 0 && !eq_mtime(get_uint32(buf + 8), mtime))) {
if (Py_VerboseFlag) {
Expand Down
2 changes: 0 additions & 2 deletions Programs/_testembed.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,6 @@ static int test_init_global_config(void)
/* FIXME: test Py_LegacyWindowsFSEncodingFlag */
/* FIXME: test Py_LegacyWindowsStdioFlag */

/* _Py_CheckHashBasedPycsMode is not public, and so not tested */

Py_Initialize();
dump_config();
Py_Finalize();
Expand Down
10 changes: 0 additions & 10 deletions Python/coreconfig.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "Python.h"
#include "internal/import.h"
#include "internal/pystate.h"


Expand Down Expand Up @@ -52,7 +51,6 @@ int Py_IsolatedFlag = 0; /* for -I, isolate from user's env */
int Py_LegacyWindowsFSEncodingFlag = 0; /* Uses mbcs instead of utf-8 */
int Py_LegacyWindowsStdioFlag = 0; /* Uses FileIO instead of WindowsConsoleIO */
#endif
const char *_Py_CheckHashBasedPycsMode = "default";


void
Expand Down Expand Up @@ -317,10 +315,6 @@ _PyCoreConfig_GetGlobalConfig(_PyCoreConfig *config)
COPY_NOT_FLAG(write_bytecode, Py_DontWriteBytecodeFlag);
COPY_NOT_FLAG(user_site_directory, Py_NoUserSiteDirectory);

if (config->_check_hash_pycs_mode == NULL) {
config->_check_hash_pycs_mode = _Py_CheckHashBasedPycsMode;
}

#undef COPY_FLAG
#undef COPY_NOT_FLAG
}
Expand Down Expand Up @@ -359,10 +353,6 @@ _PyCoreConfig_SetGlobalConfig(const _PyCoreConfig *config)
COPY_NOT_FLAG(write_bytecode, Py_DontWriteBytecodeFlag);
COPY_NOT_FLAG(user_site_directory, Py_NoUserSiteDirectory);

if (config->_check_hash_pycs_mode != NULL) {
_Py_CheckHashBasedPycsMode = config->_check_hash_pycs_mode;
}

/* Random or non-zero hash seed */
Py_HashRandomizationFlag = (config->use_hash_seed == 0 ||
config->hash_seed != 0);
Expand Down
4 changes: 2 additions & 2 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "Python-ast.h"
#undef Yield /* undefine macro conflicting with winbase.h */
#include "internal/hash.h"
#include "internal/import.h"
#include "internal/pystate.h"
#include "errcode.h"
#include "marshal.h"
Expand Down Expand Up @@ -2290,7 +2289,8 @@ PyInit__imp(void)
d = PyModule_GetDict(m);
if (d == NULL)
goto failure;
PyObject *pyc_mode = PyUnicode_FromString(_Py_CheckHashBasedPycsMode);
_PyCoreConfig *config = &PyThreadState_GET()->interp->core_config;
PyObject *pyc_mode = PyUnicode_FromString(config->_check_hash_pycs_mode);
if (pyc_mode == NULL) {
goto failure;
}
Expand Down