summaryrefslogtreecommitdiff
path: root/emitter.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2019-08-15 13:14:08 +0200
committerAnthon van der Neut <anthon@mnt.org>2019-08-15 13:14:08 +0200
commitc3ac95be03b0166b5910675f1d07c4d00db9dff8 (patch)
tree4f176d05d3ae63b68a50b7bbcf027d4fb2088de3 /emitter.py
parentff8e03fe5542a9d7930a5720450c59bb9e9eaaf3 (diff)
downloadruamel.yaml-c3ac95be03b0166b5910675f1d07c4d00db9dff8.tar.gz
allow # in 1.2 URI's0.16.2
fixes issue #305 *When this change indeed resolves your problem, please **Close** this issue*. *(You can do so using the WorkFlow pull-down (close to the top right of this page))*
Diffstat (limited to 'emitter.py')
-rw-r--r--emitter.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/emitter.py b/emitter.py
index 7cdebcd..1b6006f 100644
--- a/emitter.py
+++ b/emitter.py
@@ -410,7 +410,8 @@ class Emitter(object):
and self.sequence_context
):
self.sequence_context = False
- if root and isinstance(self.event, ScalarEvent) and not self.scalar_after_indicator:
+ if root and isinstance(self.event, ScalarEvent) \
+ and not self.scalar_after_indicator:
self.write_indent()
self.process_tag()
if isinstance(self.event, ScalarEvent):
@@ -951,13 +952,18 @@ class Emitter(object):
suffix = tag[len(prefix) :]
chunks = [] # type: List[Any]
start = end = 0
+ ch_set = u"-;/?:@&=+$,_.~*'()[]"
+ if self.dumper:
+ version = getattr(self.dumper, 'version', (1, 2))
+ if version is None or version >= (1, 2):
+ ch_set += u'#'
while end < len(suffix):
ch = suffix[end]
if (
u'0' <= ch <= u'9'
or u'A' <= ch <= u'Z'
or u'a' <= ch <= u'z'
- or ch in u"-;/?:@&=+$,_.~*'()[]"
+ or ch in ch_set
or (ch == u'!' and handle != u'!')
):
end += 1