summaryrefslogtreecommitdiff
path: root/error.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2016-11-20 19:29:11 +0100
committerAnthon van der Neut <anthon@mnt.org>2016-11-20 19:29:11 +0100
commit39d3f0eb58e55c84592b07771a5f48503525d6cc (patch)
tree73e90db7810c9e563729b5d1a555ccf83be1f772 /error.py
parent3954b8bf203540dc69fa40c649c0db049d4ad938 (diff)
downloadruamel.yaml-39d3f0eb58e55c84592b07771a5f48503525d6cc.tar.gz
fix #6: non-safe load() now issues warning0.13.0
added method to add before/after comments on specific keys
Diffstat (limited to 'error.py')
-rw-r--r--error.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/error.py b/error.py
index e93c20e..20c7979 100644
--- a/error.py
+++ b/error.py
@@ -2,9 +2,12 @@
from __future__ import absolute_import
+import warnings
+
from ruamel.yaml.compat import utf8
-__all__ = ['Mark', 'YAMLError', 'MarkedYAMLError', 'ReusedAnchorWarning']
+__all__ = ['Mark', 'YAMLError', 'MarkedYAMLError', 'ReusedAnchorWarning',
+ 'UnsafeLoaderWarning']
class Mark(object):
@@ -84,3 +87,18 @@ class MarkedYAMLError(YAMLError):
class ReusedAnchorWarning(Warning):
pass
+
+
+class UnsafeLoaderWarning(Warning):
+ text = """
+The default 'Loader' for 'load(stream)' without further arguments can be unsafe.
+Use 'load(stream, Loader=ruamel.yaml.Loader)' explicitly if that is OK.
+Alternatively include the following in your code:
+
+ import warnings
+ warnings.simplefilter('ignore', ruamel.yaml.error.UnsafeLoaderWarning)
+
+In most other cases you should consider using 'safe_load(stream)'"""
+ pass
+
+warnings.simplefilter('once', UnsafeLoaderWarning)