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

Skip to content

Commit fadcd31

Browse files
committed
Drop unused macros. Use CACHEDIR consistently.
1 parent 8a0ef78 commit fadcd31

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

Python/import.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ typedef unsigned short mode_t;
108108
/* MAGIC must change whenever the bytecode emitted by the compiler may no
109109
longer be understood by older implementations of the eval loop (usually
110110
due to the addition of new opcodes)
111-
TAG and PYC_TAG_UNICODE must change for each major Python release. The magic
112-
number will take care of any bytecode changes that occur during development.
111+
TAG must change for each major Python release. The magic number will take
112+
care of any bytecode changes that occur during development.
113113
*/
114114
#define QUOTE(arg) #arg
115115
#define STRIFY(name) QUOTE(name)
@@ -118,13 +118,9 @@ typedef unsigned short mode_t;
118118
#define MAGIC (3190 | ((long)'\r'<<16) | ((long)'\n'<<24))
119119
#define TAG "cpython-" MAJOR MINOR;
120120
#define CACHEDIR "__pycache__"
121-
static const Py_UCS4 CACHEDIR_UNICODE[] = {
122-
'_', '_', 'p', 'y', 'c', 'a', 'c', 'h', 'e', '_', '_', '\0'};
123121
/* Current magic word and string tag as globals. */
124122
static long pyc_magic = MAGIC;
125123
static const char *pyc_tag = TAG;
126-
static const Py_UCS4 PYC_TAG_UNICODE[] = {
127-
'c', 'p', 'y', 't', 'h', 'o', 'n', '-', PY_MAJOR_VERSION + 48, PY_MINOR_VERSION + 48, '\0'};
128124
#undef QUOTE
129125
#undef STRIFY
130126
#undef MAJOR
@@ -939,7 +935,7 @@ make_compiled_pathname(PyObject *pathstr, int debug)
939935
{
940936
PyObject *result;
941937
Py_ssize_t fname, ext, len, i, pos, taglen;
942-
Py_ssize_t pycache_len = sizeof("__pycache__/") - 1;
938+
Py_ssize_t pycache_len = sizeof(CACHEDIR) - 1;
943939
int kind;
944940
void *data;
945941

@@ -968,7 +964,7 @@ make_compiled_pathname(PyObject *pathstr, int debug)
968964
PyUnicode_CopyCharacters(result, 0, pathstr, 0, fname);
969965
pos = fname;
970966
for (i = 0; i < pycache_len - 1; i++)
971-
PyUnicode_WRITE(kind, data, pos++, "__pycache__"[i]);
967+
PyUnicode_WRITE(kind, data, pos++, CACHEDIR[i]);
972968
PyUnicode_WRITE(kind, data, pos++, SEP);
973969
PyUnicode_CopyCharacters(result, pos, pathstr,
974970
fname, ext - fname);

0 commit comments

Comments
 (0)