summaryrefslogtreecommitdiff
path: root/scalarstring.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2017-04-04 10:05:01 +0200
committerAnthon van der Neut <anthon@mnt.org>2017-04-04 10:05:01 +0200
commit334c46400c2334b3939c76ab7a7b5d9195b6d131 (patch)
tree1f92afaffb8689b508234157a179f40df3b84856 /scalarstring.py
parent106d8df15be91d294b6a6efd4476fdc87c0a9b5d (diff)
downloadruamel.yaml-334c46400c2334b3939c76ab7a7b5d9195b6d131.tar.gz
fix issue #109 and #110
issue 109: None not represented round-trippable at top level, reported by Andrea Censi issue 110: .replace() on a ScalarString subclass would return a string instead of an instance of that subclass, reported by sandres23
Diffstat (limited to 'scalarstring.py')
-rw-r--r--scalarstring.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/scalarstring.py b/scalarstring.py
index b02ad1d..6689911 100644
--- a/scalarstring.py
+++ b/scalarstring.py
@@ -21,6 +21,9 @@ class ScalarString(text_type):
# type: (Any, Any) -> Any
return text_type.__new__(cls, *args, **kw) # type: ignore
+ def replace(self, old, new, maxreplace=-1):
+ return type(self)((text_type.replace(self, old, new, maxreplace)))
+
class PreservedScalarString(ScalarString):
__slots__ = ()