Skip to content

Commit e060a29

Browse files
committed
general: Clean up hacks to support Python 3.5 from codebase
1 parent e879817 commit e060a29

File tree

2 files changed

+1
-59
lines changed

2 files changed

+1
-59
lines changed

dtool/src/dtoolutil/filename_ext.cxx

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,30 +53,15 @@ __init__(PyObject *path) {
5353
return;
5454
}
5555

56-
PyObject *path_str;
57-
58-
#if PY_VERSION_HEX >= 0x03060000
5956
// It must be an os.PathLike object. Check for an __fspath__ method.
6057
PyObject *fspath = PyObject_GetAttrString((PyObject *)Py_TYPE(path), "__fspath__");
6158
if (fspath == nullptr) {
6259
PyErr_Format(PyExc_TypeError, "expected str, bytes or os.PathLike object, not %s", Py_TYPE(path)->tp_name);
6360
return;
6461
}
6562

66-
path_str = PyObject_CallFunctionObjArgs(fspath, path, nullptr);
63+
PyObject *path_str = PyObject_CallFunctionObjArgs(fspath, path, nullptr);
6764
Py_DECREF(fspath);
68-
#else
69-
// There is no standard path protocol before Python 3.6, but let's try and
70-
// support taking pathlib paths anyway. We don't version check this to
71-
// allow people to use backports of the pathlib module.
72-
if (PyObject_HasAttrString(path, "_format_parsed_parts")) {
73-
path_str = PyObject_Str(path);
74-
} else {
75-
PyErr_Format(PyExc_TypeError, "expected str, bytes, Path or Filename object, not %s", Py_TYPE(path)->tp_name);
76-
return;
77-
}
78-
#endif
79-
8065
if (path_str == nullptr) {
8166
return;
8267
}

pandatool/src/deploy-stub/deploy-stub.c

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -73,36 +73,6 @@ static struct _inittab extensions[] = {
7373
static wchar_t *log_pathw = NULL;
7474
#endif
7575

76-
#if defined(_WIN32) && PY_VERSION_HEX < 0x03060000
77-
static int supports_code_page(UINT cp) {
78-
if (cp == 0) {
79-
cp = GetACP();
80-
}
81-
82-
/* Shortcut, because we know that these encodings are bundled by default--
83-
* see FreezeTool.py and Python's encodings/aliases.py */
84-
if (cp != 0 && cp != 1252 && cp != 367 && cp != 437 && cp != 850 && cp != 819) {
85-
const struct _frozen *moddef;
86-
char codec[100];
87-
88-
/* Check if the codec was frozen into the program. We can't check this
89-
* using _PyCodec_Lookup, since Python hasn't been initialized yet. */
90-
PyOS_snprintf(codec, sizeof(codec), "encodings.cp%u", (unsigned int)cp);
91-
92-
moddef = PyImport_FrozenModules;
93-
while (moddef->name) {
94-
if (strcmp(moddef->name, codec) == 0) {
95-
return 1;
96-
}
97-
++moddef;
98-
}
99-
return 0;
100-
}
101-
102-
return 1;
103-
}
104-
#endif
105-
10676
/**
10777
* Sets the main_dir field of the blobinfo structure, but only if it wasn't
10878
* already set.
@@ -408,19 +378,6 @@ int Py_FrozenMain(int argc, char **argv)
408378
}
409379
#endif
410380

411-
#if defined(MS_WINDOWS) && PY_VERSION_HEX >= 0x03040000 && PY_VERSION_HEX < 0x03060000
412-
if (!supports_code_page(GetConsoleOutputCP()) ||
413-
!supports_code_page(GetConsoleCP())) {
414-
/* Revert to the active codepage, and tell Python to use the 'mbcs'
415-
* encoding (which always uses the active codepage). In 99% of cases,
416-
* this will be the same thing anyway. */
417-
UINT acp = GetACP();
418-
SetConsoleCP(acp);
419-
SetConsoleOutputCP(acp);
420-
Py_SetStandardStreamEncoding("mbcs", NULL);
421-
}
422-
#endif
423-
424381
Py_FrozenFlag = 1; /* Suppress errors from getpath.c */
425382
Py_NoSiteFlag = 0;
426383
Py_NoUserSiteDirectory = 1;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy