|
18 | 18 | import io
|
19 | 19 |
|
20 | 20 | #------------------------------------------------------------------------------
|
21 |
| -# Warnings control |
| 21 | +# XXX "Warnings control" is now deprecated. Leaving in the API function to not |
| 22 | +# break code that uses it. |
22 | 23 | #------------------------------------------------------------------------------
|
23 |
| - |
24 |
| -# 'Global' warnings state: |
25 |
| -_warnings_enabled = { |
26 |
| - 'YAMLLoadWarning': True, |
27 |
| -} |
28 |
| - |
29 |
| -# Get or set global warnings' state |
30 | 24 | def warnings(settings=None):
|
31 | 25 | if settings is None:
|
32 |
| - return _warnings_enabled |
33 |
| - |
34 |
| - if type(settings) is dict: |
35 |
| - for key in settings: |
36 |
| - if key in _warnings_enabled: |
37 |
| - _warnings_enabled[key] = settings[key] |
38 |
| - |
39 |
| -# Warn when load() is called without Loader=... |
40 |
| -class YAMLLoadWarning(RuntimeWarning): |
41 |
| - pass |
42 |
| - |
43 |
| -def load_warning(method): |
44 |
| - if _warnings_enabled['YAMLLoadWarning'] is False: |
45 |
| - return |
46 |
| - |
47 |
| - import warnings |
48 |
| - |
49 |
| - message = ( |
50 |
| - "calling yaml.%s() without Loader=... is deprecated, as the " |
51 |
| - "default Loader is unsafe. Please read " |
52 |
| - "https://msg.pyyaml.org/load for full details." |
53 |
| - ) % method |
54 |
| - |
55 |
| - warnings.warn(message, YAMLLoadWarning, stacklevel=3) |
| 26 | + return {} |
56 | 27 |
|
57 | 28 | #------------------------------------------------------------------------------
|
58 | 29 | def scan(stream, Loader=Loader):
|
@@ -100,30 +71,22 @@ def compose_all(stream, Loader=Loader):
|
100 | 71 | finally:
|
101 | 72 | loader.dispose()
|
102 | 73 |
|
103 |
| -def load(stream, Loader=None): |
| 74 | +def load(stream, Loader): |
104 | 75 | """
|
105 | 76 | Parse the first YAML document in a stream
|
106 | 77 | and produce the corresponding Python object.
|
107 | 78 | """
|
108 |
| - if Loader is None: |
109 |
| - load_warning('load') |
110 |
| - Loader = FullLoader |
111 |
| - |
112 | 79 | loader = Loader(stream)
|
113 | 80 | try:
|
114 | 81 | return loader.get_single_data()
|
115 | 82 | finally:
|
116 | 83 | loader.dispose()
|
117 | 84 |
|
118 |
| -def load_all(stream, Loader=None): |
| 85 | +def load_all(stream, Loader): |
119 | 86 | """
|
120 | 87 | Parse all YAML documents in a stream
|
121 | 88 | and produce corresponding Python objects.
|
122 | 89 | """
|
123 |
| - if Loader is None: |
124 |
| - load_warning('load_all') |
125 |
| - Loader = FullLoader |
126 |
| - |
127 | 90 | loader = Loader(stream)
|
128 | 91 | try:
|
129 | 92 | while loader.check_data():
|
|
0 commit comments