diff options
Diffstat (limited to 'bs4')
-rw-r--r-- | bs4/__init__.py | 4 | ||||
-rw-r--r-- | bs4/element.py | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/bs4/__init__.py b/bs4/__init__.py index c78c54e..4b92152 100644 --- a/bs4/__init__.py +++ b/bs4/__init__.py @@ -241,9 +241,7 @@ class BeautifulSoup(Tag): def new_string(self, s, subclass=NavigableString): """Create a new NavigableString associated with this soup.""" - navigable = subclass(s) - navigable.setup() - return navigable + return subclass(s) def insert_before(self, successor): raise NotImplementedError("BeautifulSoup objects don't support insert_before().") diff --git a/bs4/element.py b/bs4/element.py index 2ea68b3..7fdeb08 100644 --- a/bs4/element.py +++ b/bs4/element.py @@ -674,9 +674,11 @@ class NavigableString(unicode, PageElement): how to handle non-ASCII characters. """ if isinstance(value, unicode): - return unicode.__new__(cls, value) - u = unicode.__new__(cls, value, DEFAULT_OUTPUT_ENCODING) + u = unicode.__new__(cls, value) + else: + u = unicode.__new__(cls, value, DEFAULT_OUTPUT_ENCODING) u.setup() + return u def __copy__(self): return self |