2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "py3compat.h"
23 #include "python/modules.h"
24 #include "dynconfig/dynconfig.h"
26 static bool PySys_PathPrepend(PyObject
*list
, const char *path
)
28 PyObject
*py_path
= PyStr_FromString(path
);
32 return (PyList_Insert(list
, 0, py_path
) == 0);
35 bool py_update_path(void)
37 PyObject
*mod_sys
, *py_path
;
39 mod_sys
= PyImport_ImportModule("sys");
40 if (mod_sys
== NULL
) {
44 py_path
= PyObject_GetAttrString(mod_sys
, "path");
45 if (py_path
== NULL
) {
49 if (!PyList_Check(py_path
)) {
53 if (!PySys_PathPrepend(py_path
, dyn_PYTHONDIR
)) {
57 if (strcmp(dyn_PYTHONARCHDIR
, dyn_PYTHONDIR
) != 0) {
58 if (!PySys_PathPrepend(py_path
, dyn_PYTHONARCHDIR
)) {