Python sys._clear_type_cache() Examples

The following are code examples for showing how to use sys._clear_type_cache(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: zippy   Author: securesystemslab   File: test_sys.py    (license) View Source Project 5 votes vote down vote up
def test_clear_type_cache(self):
        sys._clear_type_cache() 
Example 2
Project: oil   Author: oilshell   File: regrtest.py    (license) View Source Project 5 votes vote down vote up
def dash_R_cleanup(fs, ps, pic, zdc, abcs):
    import gc, copy_reg

    # Restore some original values.
    warnings.filters[:] = fs
    copy_reg.dispatch_table.clear()
    copy_reg.dispatch_table.update(ps)
    sys.path_importer_cache.clear()
    sys.path_importer_cache.update(pic)
    try:
        import zipimport
    except ImportError:
        pass # Run unmodified on platforms without zipimport support
    else:
        zipimport._zip_directory_cache.clear()
        zipimport._zip_directory_cache.update(zdc)

    # clear type cache
    sys._clear_type_cache()

    # Clear ABC registries, restoring previously saved ABC registries.
    for abc, registry in abcs.items():
        abc._abc_registry = registry.copy()
        abc._abc_cache.clear()
        abc._abc_negative_cache.clear()

    clear_caches() 
Example 3
Project: oil   Author: oilshell   File: test_sys.py    (license) View Source Project 5 votes vote down vote up
def test_clear_type_cache(self):
        sys._clear_type_cache() 
Example 4
Project: python2-tracer   Author: extremecoders-re   File: regrtest.py    (license) View Source Project 5 votes vote down vote up
def dash_R_cleanup(fs, ps, pic, zdc, abcs):
    import gc, copy_reg

    # Restore some original values.
    warnings.filters[:] = fs
    copy_reg.dispatch_table.clear()
    copy_reg.dispatch_table.update(ps)
    sys.path_importer_cache.clear()
    sys.path_importer_cache.update(pic)
    try:
        import zipimport
    except ImportError:
        pass # Run unmodified on platforms without zipimport support
    else:
        zipimport._zip_directory_cache.clear()
        zipimport._zip_directory_cache.update(zdc)

    # clear type cache
    sys._clear_type_cache()

    # Clear ABC registries, restoring previously saved ABC registries.
    for abc, registry in abcs.items():
        abc._abc_registry = registry.copy()
        abc._abc_cache.clear()
        abc._abc_negative_cache.clear()

    clear_caches() 
Example 5
Project: python2-tracer   Author: extremecoders-re   File: test_sys.py    (license) View Source Project 5 votes vote down vote up
def test_clear_type_cache(self):
        sys._clear_type_cache() 
Example 6
Project: web_ctp   Author: molebot   File: test_sys.py    (license) View Source Project 5 votes vote down vote up
def test_clear_type_cache(self):
        sys._clear_type_cache() 
Example 7
Project: pefile.pypy   Author: cloudtracer   File: test_sys.py    (license) View Source Project 5 votes vote down vote up
def test_clear_type_cache(self):
        sys._clear_type_cache() 
Example 8
Project: ouroboros   Author: pybee   File: test_sys.py    (license) View Source Project 5 votes vote down vote up
def test_clear_type_cache(self):
        sys._clear_type_cache() 
Example 9
Project: ndk-python   Author: gittor   File: test_sys.py    (license) View Source Project 5 votes vote down vote up
def test_clear_type_cache(self):
        sys._clear_type_cache() 
Example 10
Project: kbe_server   Author: xiaohaoppy   File: test_sys.py    (license) View Source Project 5 votes vote down vote up
def test_clear_type_cache(self):
        sys._clear_type_cache() 
Example 11
Project: pefile.pypy   Author: cloudtracer   File: regrtest.py    (license) View Source Project 4 votes vote down vote up
def dash_R_cleanup(fs, ps, pic, zdc, abcs):
    import gc, copy_reg
    import _strptime, linecache
    dircache = test_support.import_module('dircache', deprecated=True)
    import urlparse, urllib, urllib2, mimetypes, doctest
    import struct, filecmp
    from distutils.dir_util import _path_created

    # Clear the warnings registry, so they can be displayed again
    for mod in sys.modules.values():
        if hasattr(mod, '__warningregistry__'):
            del mod.__warningregistry__

    # Restore some original values.
    warnings.filters[:] = fs
    copy_reg.dispatch_table.clear()
    copy_reg.dispatch_table.update(ps)
    sys.path_importer_cache.clear()
    sys.path_importer_cache.update(pic)
    try:
        import zipimport
    except ImportError:
        pass # Run unmodified on platforms without zipimport support
    else:
        zipimport._zip_directory_cache.clear()
        zipimport._zip_directory_cache.update(zdc)

    # clear type cache
    sys._clear_type_cache()

    # Clear ABC registries, restoring previously saved ABC registries.
    for abc, registry in abcs.items():
        abc._abc_registry = registry.copy()
        abc._abc_cache.clear()
        abc._abc_negative_cache.clear()

    # Clear assorted module caches.
    _path_created.clear()
    re.purge()
    _strptime._regex_cache.clear()
    urlparse.clear_cache()
    urllib.urlcleanup()
    urllib2.install_opener(None)
    dircache.reset()
    linecache.clearcache()
    mimetypes._default_mime_types()
    filecmp._cache.clear()
    struct._clearcache()
    doctest.master = None
    try:
        import ctypes
    except ImportError:
        # Don't worry about resetting the cache if ctypes is not supported
        pass
    else:
        ctypes._reset_cache()

    # Collect cyclic trash.
    gc.collect() 
Example 12
Project: ndk-python   Author: gittor   File: regrtest.py    (license) View Source Project 4 votes vote down vote up
def dash_R_cleanup(fs, ps, pic, zdc, abcs):
    import gc, copy_reg
    import _strptime, linecache
    dircache = test_support.import_module('dircache', deprecated=True)
    import urlparse, urllib, urllib2, mimetypes, doctest
    import struct, filecmp
    from distutils.dir_util import _path_created

    # Clear the warnings registry, so they can be displayed again
    for mod in sys.modules.values():
        if hasattr(mod, '__warningregistry__'):
            del mod.__warningregistry__

    # Restore some original values.
    warnings.filters[:] = fs
    copy_reg.dispatch_table.clear()
    copy_reg.dispatch_table.update(ps)
    sys.path_importer_cache.clear()
    sys.path_importer_cache.update(pic)
    try:
        import zipimport
    except ImportError:
        pass # Run unmodified on platforms without zipimport support
    else:
        zipimport._zip_directory_cache.clear()
        zipimport._zip_directory_cache.update(zdc)

    # clear type cache
    sys._clear_type_cache()

    # Clear ABC registries, restoring previously saved ABC registries.
    for abc, registry in abcs.items():
        abc._abc_registry = registry.copy()
        abc._abc_cache.clear()
        abc._abc_negative_cache.clear()

    # Clear assorted module caches.
    _path_created.clear()
    re.purge()
    _strptime._regex_cache.clear()
    urlparse.clear_cache()
    urllib.urlcleanup()
    urllib2.install_opener(None)
    dircache.reset()
    linecache.clearcache()
    mimetypes._default_mime_types()
    filecmp._cache.clear()
    struct._clearcache()
    doctest.master = None
    try:
        import ctypes
    except ImportError:
        # Don't worry about resetting the cache if ctypes is not supported
        pass
    else:
        ctypes._reset_cache()

    # Collect cyclic trash.
    gc.collect()