本文整理汇总了Python中sys._clear_type_cache函数的典型用法代码示例。如果您正苦于以下问题:Python _clear_type_cache函数的具体用法?Python _clear_type_cache怎么用?Python _clear_type_cache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_clear_type_cache函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __setattr__
def __setattr__(self, attr, val, other_arg=2.1**10):
print "__setattr__", attr, val
print other_arg
del C.__setattr__
print other_arg
sys._clear_type_cache()
print other_arg
开发者ID:ChinaQuants,项目名称:pyston,代码行数:7,代码来源:descr_selfdelete.py
示例2: __delattr__
def __delattr__(self, attr, other_arg=2.3**10):
print "__delattr__"
print other_arg
del C.__delattr__
print other_arg
sys._clear_type_cache()
print other_arg
开发者ID:ChinaQuants,项目名称:pyston,代码行数:7,代码来源:descr_selfdelete.py
示例3: enable
def enable(self, sandbox):
# Blacklist all dict methods able to modify a dict, to protect
# ReadOnlyBuiltins
for name in (
'__init__', 'clear', '__delitem__', 'pop', 'popitem',
'setdefault', '__setitem__', 'update'):
del self.dict_dict[name]
if version_info < (3, 0):
del self.function_dict['func_closure']
del self.function_dict['func_globals']
del self.function_dict['func_code']
del self.function_dict['func_defaults']
if version_info >= (2, 6):
del self.function_dict['__closure__']
del self.function_dict['__globals__']
del self.function_dict['__code__']
del self.function_dict['__defaults__']
del self.frame_dict['f_locals']
if ('code' not in sandbox.config.features) \
and ('traceback' not in sandbox.config.features):
del self.frame_dict['f_code']
del self.type_dict['__subclasses__']
del self.builtin_func_dict['__self__']
if version_info >= (2, 6) \
and ('code' not in sandbox.config.features):
del self.generator_dict['gi_code']
_clear_type_cache()
开发者ID:carlio,项目名称:pysandbox,代码行数:27,代码来源:attributes.py
示例4: __set__
def __set__(self, obj, value, other_arg=2.0**10):
print "D.__set__", type(obj), value
print other_arg
del D.__set__
print other_arg
sys._clear_type_cache()
print other_arg
return 1
开发者ID:ChinaQuants,项目名称:pyston,代码行数:8,代码来源:descr_selfdelete.py
示例5: __get__
def __get__(self, obj, type, other_arg=2.4**10):
print "D.__get__"
print other_arg
del C.x
print other_arg
sys._clear_type_cache()
print other_arg
return 1
开发者ID:ChinaQuants,项目名称:pyston,代码行数:8,代码来源:descr_selfdelete.py
示例6: __getattr__
def __getattr__(self, attr, other_arg=2.2**10):
print "__getattr__"
print other_arg
del C.__getattr__
print other_arg
sys._clear_type_cache()
print other_arg
return attr
开发者ID:ChinaQuants,项目名称:pyston,代码行数:8,代码来源:descr_selfdelete.py
示例7: disable
def disable(self, sandbox):
self.dict_dict.restore()
self.function_dict.restore()
self.frame_dict.restore()
self.type_dict.restore()
self.builtin_func_dict.restore()
self.generator_dict.restore()
# Python 2.6+ uses a method cache: clear it to avoid errors
_clear_type_cache()
开发者ID:ailling,项目名称:pysandbox,代码行数:9,代码来源:attributes.py
示例8: dash_R_cleanup
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
# Collect cyclic trash.
gc.collect()
开发者ID:carlosrcjunior,项目名称:BCC-2s13-PI4-WebCrawler,代码行数:52,代码来源:regrtest.py
示例9: dash_R_cleanup
def dash_R_cleanup(fs, ps, pic, 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)
# 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
if _llvm:
code_types = (types.CodeType, types.FunctionType, types.MethodType)
for obj in gc.get_objects():
if isinstance(obj, code_types):
_llvm.clear_feedback(obj)
# Collect cyclic trash.
gc.collect()
开发者ID:ianloic,项目名称:unladen-swallow,代码行数:51,代码来源:regrtest.py
示例10: remove_dangerous_attrs
def remove_dangerous_attrs():
"""
Removes all the methods not mentioned in the good_*_methods.py files.
"""
for i in dangerous:
for j in method_origin[i]:
if not hasattr(j, i):
not_expressed[j].append(i)
saved[(j, i)] = dictionary_of(j)[i]
del dictionary_of(j)[i]
# make sure our modifications is mirrored in the types we modify
# this is a specialised purpose
sys._clear_type_cache()
assert not hasattr(j, i), "{} still has {}".format(j, i)
开发者ID:matsjoyce,项目名称:sandypython,代码行数:14,代码来源:spec.py
示例11: assert_no_dangling_Cclasses
def assert_no_dangling_Cclasses():
global CheckForDanglingClasses
global WorstDanglingCount
sys._clear_type_cache()
gc.collect()
count = proj_class_live_object_count()
# Avoid cluttering the output up with redundant messages...
if count > WorstDanglingCount and CheckForDanglingClasses:
WorstDanglingCount = count
if AssertOnDanglingClasses:
dump_c_objects()
raise AssertionError, "Dangling C-class objects - %d still around" % count
else:
print >> sys.stderr, ("*****ERROR: Dangling C-class objects - %d still around" % count)
开发者ID:JJediny,项目名称:assimilation-official,代码行数:14,代码来源:pcap_test.py
示例12: replace_dangerous_attrs
def replace_dangerous_attrs():
"""
Replaces all the methods removed by :func:`remove_dangerous_attrs`.
"""
for i in dangerous:
for j in method_origin[i]:
dictionary_of(j)[i] = saved[(j, i)]
# make sure our modifications is mirrored in the types we modify
# this is a specialised purpose
sys._clear_type_cache()
if i in not_expressed[j]:
assert i in j.__dict__, "{} still doesn't' have {}" \
.format(j, i)
else:
assert hasattr(j, i), "{} still doesn't' have {}"\
.format(j, i)
开发者ID:matsjoyce,项目名称:sandypython,代码行数:16,代码来源:spec.py
示例13: enable
def enable(self, sandbox):
if not sandbox.config.cpython_restricted:
# Deny access to func.func_code to avoid an attacker to modify a
# trusted function: replace the code of the function
hide_func_code = True
else:
# CPython restricted mode already denies read and write access to
# function attributes
hide_func_code = False
# Blacklist all dict methods able to modify a dict, to protect
# ReadOnlyBuiltins
for name in (
'__init__', 'clear', '__delitem__', 'pop', 'popitem',
'setdefault', '__setitem__', 'update'):
del self.dict_dict[name]
if version_info < (3, 0):
# pysandbox stores trusted objects in closures: deny access to
# closures to not leak these secrets
del self.function_dict['func_closure']
del self.function_dict['func_globals']
if hide_func_code:
del self.function_dict['func_code']
del self.function_dict['func_defaults']
if version_info >= (2, 6):
del self.function_dict['__closure__']
del self.function_dict['__globals__']
if hide_func_code:
del self.function_dict['__code__']
del self.function_dict['__defaults__']
del self.frame_dict['f_locals']
# Hiding type.__bases__ crashs CPython 2.5 because of a infinite loop
# in PyErr_ExceptionMatches(): it calls abstract_get_bases() but
# abstract_get_bases() fails and call PyErr_ExceptionMatches() ...
if version_info >= (2, 6):
# Setting __bases__ crash Python < 3.3a2
# http://bugs.python.org/issue14199
del self.type_dict['__bases__']
# object.__subclasses__ leaks the file type in Python 2
# and (indirectly) the FileIO file in Python 3
del self.type_dict['__subclasses__']
del self.builtin_func_dict['__self__']
_clear_type_cache()
开发者ID:ailling,项目名称:pysandbox,代码行数:45,代码来源:attributes.py
示例14: _refleak_cleanup
def _refleak_cleanup():
# Collect cyclic trash and read memory statistics immediately after.
func1 = sys.getallocatedblocks
try:
func2 = sys.gettotalrefcount
except AttributeError:
func2 = lambda: 42
# Flush standard output, so that buffered data is sent to the OS and
# associated Python objects are reclaimed.
for stream in (sys.stdout, sys.stderr, sys.__stdout__, sys.__stderr__):
if stream is not None:
stream.flush()
sys._clear_type_cache()
# This also clears the various internal CPython freelists.
gc.collect()
return func1(), func2()
开发者ID:kalatestimine,项目名称:numba,代码行数:18,代码来源:testing.py
示例15: dash_R_cleanup
def dash_R_cleanup(fs, ps, pic, zdc, abcs):
import gc, copyreg
import collections.abc
from weakref import WeakSet
# Restore some original values.
warnings.filters[:] = fs
copyreg.dispatch_table.clear()
copyreg.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.
abs_classes = [getattr(collections.abc, a) for a in collections.abc.__all__]
abs_classes = filter(isabstract, abs_classes)
if 'typing' in sys.modules:
t = sys.modules['typing']
# These classes require special treatment because they do not appear
# in direct subclasses of collections.abc classes
abs_classes = list(abs_classes) + [t.ChainMap, t.Counter, t.DefaultDict]
for abc in abs_classes:
for obj in abc.__subclasses__() + [abc]:
obj._abc_registry = abcs.get(obj, WeakSet()).copy()
obj._abc_cache.clear()
obj._abc_negative_cache.clear()
clear_caches()
# Collect cyclic trash and read memory statistics immediately after.
func1 = sys.getallocatedblocks
func2 = sys.gettotalrefcount
gc.collect()
return func1(), func2(), support.fd_count()
开发者ID:1st1,项目名称:cpython,代码行数:43,代码来源:refleak.py
示例16: assert_no_dangling_Cclasses
def assert_no_dangling_Cclasses(doassert=None):
global CheckForDanglingClasses
global WorstDanglingCount
sys._clear_type_cache()
if doassert is None:
doassert = AssertOnDanglingClasses
CMAinit.uninit()
gc.collect() # For good measure...
count = proj_class_live_object_count()
#print >>sys.stderr, "CHECKING FOR DANGLING CLASSES (%d)..." % count
# Avoid cluttering the output up with redundant messages...
if count > WorstDanglingCount and CheckForDanglingClasses:
WorstDanglingCount = count
if doassert:
print >> sys.stderr, 'STARTING OBJECT DUMP'
dump_c_objects()
print >> sys.stderr, 'OBJECT DUMP COMPLETE'
print 'stdout OBJECT DUMP COMPLETE'
raise AssertionError("Dangling C-class objects - %d still around" % count)
else:
print >> sys.stderr, ("*****ERROR: Dangling C-class objects - %d still around" % count)
开发者ID:carrieao,项目名称:assimilation-official,代码行数:21,代码来源:cma_test.py
示例17: dash_R_cleanup
def dash_R_cleanup(fs, ps, pic, zdc, abcs):
import gc, copyreg
import collections.abc
from weakref import WeakSet
# Restore some original values.
warnings.filters[:] = fs
copyreg.dispatch_table.clear()
copyreg.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 in [getattr(collections.abc, a) for a in collections.abc.__all__]:
if not isabstract(abc):
continue
for obj in abc.__subclasses__() + [abc]:
obj._abc_registry = abcs.get(obj, WeakSet()).copy()
obj._abc_cache.clear()
obj._abc_negative_cache.clear()
clear_caches()
# Collect cyclic trash and read memory statistics immediately after.
func1 = sys.getallocatedblocks
func2 = sys.gettotalrefcount
gc.collect()
return func1(), func2(), fd_count()
开发者ID:cpcloud,项目名称:cpython,代码行数:38,代码来源:refleak.py
示例18: reconfig
def reconfig():
''' Set global best configs, eg: gc and recursion limit '''
cfg = {}
cfg['sys.platform'] = sys.platform
cfg['sys.maxsize'] = sys.maxsize
cfg['sys.path'] = sys.path
cfg['sys.excepthook'] = sys.excepthook
cfg['old sys.checkinterval'] = sys.getcheckinterval()
sys.setcheckinterval(BEST_CHECK_INTERVAL)
cfg['new sys.checkinterval'] = sys.getcheckinterval()
cfg['old sys.recursionlimit'] = sys.getrecursionlimit()
sys.setrecursionlimit(BEST_RECURSION_LIMIT)
cfg['new sys.recursionlimit'] = sys.getrecursionlimit()
cfg['old gc.threshold'] = str(gc.get_threshold())
gc.set_threshold(512, 8, 6)
cfg['new gc.threshold'] = str(gc.get_threshold())
sys._clear_type_cache()
cfg['sys._clear_type_cache'] = True
return cfg
开发者ID:cypro666,项目名称:magic3,代码行数:23,代码来源:system.py
示例19: _cleanup
def _cleanup():
sys._clear_type_cache()
gc.collect()
开发者ID:aether-space,项目名称:pakker,代码行数:3,代码来源:test_php.py
示例20: test_clear_type_cache
def test_clear_type_cache(self):
sys._clear_type_cache()
开发者ID:plirof,项目名称:minibloq_v0.83,代码行数:2,代码来源:test_sys.py
注:本文中的sys._clear_type_cache函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论