diff options
author | Leonard Richardson <leonardr@segfault.org> | 2015-06-28 15:39:36 -0400 |
---|---|---|
committer | Leonard Richardson <leonardr@segfault.org> | 2015-06-28 15:39:36 -0400 |
commit | 9428b9d6ed0d279a72414a986290821ca4f0caaf (patch) | |
tree | f792dd2d4e0b4c3913d4766a2717e57e7dd23b12 /bs4/__init__.py | |
parent | 92ad5e0dee9503f507f6277b493dfa96010f3a44 (diff) |
Changed the way soup objects work under copy.copy(). Copying a
NavigableString or a Tag will give you a new NavigableString that's
equal to the old one but not connected to the parse tree. Patch by
Martijn Peters. [bug=1307490]
Diffstat (limited to 'bs4/__init__.py')
-rw-r--r-- | bs4/__init__.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/bs4/__init__.py b/bs4/__init__.py index 68e7512..cb74bd3 100644 --- a/bs4/__init__.py +++ b/bs4/__init__.py @@ -79,6 +79,9 @@ class BeautifulSoup(Tag): NO_PARSER_SPECIFIED_WARNING = "No parser was explicitly specified, so I'm using the best available %(markup_type)s parser for this system (\"%(parser)s\"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.\n\nTo get rid of this warning, change this:\n\n BeautifulSoup([your markup])\n\nto this:\n\n BeautifulSoup([your markup], \"%(parser)s\")\n" + def __copy__(self): + return type(self)(self.encode(), builder=self.builder) + def __init__(self, markup="", features=None, builder=None, parse_only=None, from_encoding=None, exclude_encodings=None, **kwargs): |