summaryrefslogtreecommitdiffhomepage
path: root/libs/subzero/sandbox.py
blob: 888b17a9bac3fedad85a8fdb34f7a5466ddd1c70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# coding=utf-8
from __future__ import absolute_import
import sys


def fix_environment_stuff(module, base):
    # restore builtins
    module.__builtins__ = [x for x in base.__class__.__base__.__subclasses__() if x.__name__ == 'catch_warnings'][0]()._module.__builtins__

    # patch getfilesystemencoding for NVIDIA Shield
    getfilesystemencoding_orig = sys.getfilesystemencoding

    def getfilesystemencoding():
        return getfilesystemencoding_orig() or "utf-8"

    sys.getfilesystemencoding = getfilesystemencoding