1#-----------------------------------------------------------------------------
2# Copyright (c) 2005-2019, PyInstaller Development Team.
3#
4# Distributed under the terms of the GNU General Public License with exception
5# for distributing bootloader.
6#
7# The full license is in the file COPYING.txt, distributed with this software.
8#-----------------------------------------------------------------------------
9
10from __future__ import print_function
11
12# sys.path  should contain absolute paths.
13# With relative paths frozen application will
14# fail to import modules when currect working
15# directory is changed.
16
17
18import os
19
20import sys
21import tempfile
22
23
24# Python 3 does not have function os.getcwdu() since all strings are unicode.
25getcwd = os.getcwdu if sys.version_info[0] < 3 else os.getcwd
26
27
28print('sys.stderr.encoding:', sys.stderr.encoding)
29print('sys.path', sys.path)
30print('CWD:', repr(getcwd()))
31
32# Change working directory.
33os.chdir(tempfile.gettempdir())
34print('Changing working directory...')
35print('CWD:', repr(getcwd()))
36
37# Try import a module. It should fail
38try:
39    for pth in sys.path:
40        if not os.path.isabs(pth):
41            raise SystemExit('ERROR: sys.path not absolute')
42    import datetime
43except:
44    raise SystemExit('ERROR: sys.path not absolute')
45