Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7701e6e

Browse files
committed
make some freezing related stuff const
1 parent 3279923 commit 7701e6e

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

Include/import.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ PyAPI_FUNC(int) PyImport_AppendInittab(
113113

114114
#ifndef Py_LIMITED_API
115115
struct _frozen {
116-
char *name; /* ASCII encoded string */
117-
unsigned char *code;
116+
const char *name; /* ASCII encoded string */
117+
const unsigned char *code;
118118
int size;
119119
};
120120

121121
/* Embedding apps may change this pointer to point to their favorite
122122
collection of frozen modules: */
123123

124-
PyAPI_DATA(struct _frozen *) PyImport_FrozenModules;
124+
PyAPI_DATA(const struct _frozen *) PyImport_FrozenModules;
125125
#endif
126126

127127
#ifdef __cplusplus

Modules/_freeze_importlib.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
of frozen modules instead, left deliberately blank so as to avoid
1818
unintentional import of a stale version of _frozen_importlib. */
1919

20-
static struct _frozen _PyImport_FrozenModules[] = {
20+
const static struct _frozen _PyImport_FrozenModules[] = {
2121
{0, 0, 0} /* sentinel */
2222
};
2323

2424
#ifndef MS_WINDOWS
2525
/* On Windows, this links with the regular pythonXY.dll, so this variable comes
2626
from frozen.obj. In the Makefile, frozen.o is not linked into this executable,
2727
so we define the variable here. */
28-
struct _frozen *PyImport_FrozenModules;
28+
const struct _frozen *PyImport_FrozenModules;
2929
#endif
3030

3131
const char header[] = "/* Auto-generated by Modules/_freeze_importlib.c */";
@@ -105,7 +105,7 @@ main(int argc, char *argv[])
105105
return 1;
106106
}
107107
fprintf(outfile, "%s\n", header);
108-
fprintf(outfile, "unsigned char _Py_M__importlib[] = {\n");
108+
fprintf(outfile, "const unsigned char _Py_M__importlib[] = {\n");
109109
for (n = 0; n < data_size; n += 16) {
110110
size_t i, end = Py_MIN(n + 16, data_size);
111111
fprintf(outfile, " ");

Python/frozen.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static unsigned char M___hello__[] = {
2828

2929
#define SIZE (int)sizeof(M___hello__)
3030

31-
static struct _frozen _PyImport_FrozenModules[] = {
31+
static const struct _frozen _PyImport_FrozenModules[] = {
3232
/* importlib */
3333
{"_frozen_importlib", _Py_M__importlib, (int)sizeof(_Py_M__importlib)},
3434
/* Test module */
@@ -42,4 +42,4 @@ static struct _frozen _PyImport_FrozenModules[] = {
4242
/* Embedding apps may change this pointer to point to their favorite
4343
collection of frozen modules: */
4444

45-
struct _frozen *PyImport_FrozenModules = _PyImport_FrozenModules;
45+
const struct _frozen *PyImport_FrozenModules = _PyImport_FrozenModules;

Python/importlib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Auto-generated by Modules/_freeze_importlib.c */
2-
unsigned char _Py_M__importlib[] = {
2+
const unsigned char _Py_M__importlib[] = {
33
99,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,
44
0,64,0,0,0,115,229,3,0,0,100,0,0,90,0,0,
55
100,130,0,90,1,0,100,4,0,100,5,0,132,0,0,90,

0 commit comments

Comments
 (0)