From 334c46400c2334b3939c76ab7a7b5d9195b6d131 Mon Sep 17 00:00:00 2001 From: Anthon van der Neut Date: Tue, 4 Apr 2017 10:05:01 +0200 Subject: 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 --- scalarstring.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'scalarstring.py') 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__ = () -- cgit v1.2.1