codekingpro/portable-devtools
114k
1import sys2 3__all__ = [4 "warn",5 "warn_explicit",6 "showwarning",7 "formatwarning",8 "filterwarnings",9 "simplefilter",10 "resetwarnings",11 "catch_warnings",12 "deprecated",13]14 15from _py_warnings import (16 WarningMessage,17 _DEPRECATED_MSG,18 _OptionError,19 _add_filter,20 _deprecated,21 _filters_mutated,22 _filters_mutated_lock_held,23 _filters_version,24 _formatwarning_orig,25 _formatwarnmsg,26 _formatwarnmsg_impl,27 _get_context,28 _get_filters,29 _getaction,30 _getcategory,31 _is_filename_to_skip,32 _is_internal_filename,33 _is_internal_frame,34 _lock,35 _new_context,36 _next_external_frame,37 _processoptions,38 _set_context,39 _set_module,40 _setoption,41 _setup_defaults,42 _showwarning_orig,43 _showwarnmsg,44 _showwarnmsg_impl,45 _use_context,46 _warn_unawaited_coroutine,47 _warnings_context,48 catch_warnings,49 defaultaction,50 deprecated,51 filters,52 filterwarnings,53 formatwarning,54 onceregistry,55 resetwarnings,56 showwarning,57 simplefilter,58 warn,59 warn_explicit,60)61 62try:63 # Try to use the C extension, this will replace some parts of the64 # _py_warnings implementation imported above.65 from _warnings import (66 _acquire_lock,67 _defaultaction as defaultaction,68 _filters_mutated_lock_held,69 _onceregistry as onceregistry,70 _release_lock,71 _warnings_context,72 filters,73 warn,74 warn_explicit,75 )76 77 _warnings_defaults = True78 79 class _Lock:80 def __enter__(self):81 _acquire_lock()82 return self83 84 def __exit__(self, *args):85 _release_lock()86 87 _lock = _Lock()88except ImportError:89 _warnings_defaults = False90 91 92# Module initialization93_set_module(sys.modules[__name__])94_processoptions(sys.warnoptions)95if not _warnings_defaults:96 _setup_defaults()97 98del _warnings_defaults99del _setup_defaults100 