Skip to content

Convert string-like values to plain strings in Entry#1337

Merged
paranoidi merged 2 commits intoFlexget:developfrom
danielkza:entry-coerce-strings
Aug 15, 2016
Merged

Convert string-like values to plain strings in Entry#1337
paranoidi merged 2 commits intoFlexget:developfrom
danielkza:entry-coerce-strings

Conversation

@danielkza
Copy link
Copy Markdown
Contributor

@danielkza danielkza commented Aug 15, 2016

Motivation for changes:

BeautifulSoup, as used in some search plugins, returns strings from HTML
document structures in "enriched" form - instances of unicode/str mixed
in with another class. Those strings carry references to the whole
document tree, which can cause issues when attempting to serialize entry
values for saving to the database.

Detailed changes:

To avoid that, coerce any values whose type is a subtype of text_type,
but not exactly text_type, to text_type, with text_type being unicode
in Py2 and str in Py3. That should ensure we throw away any extra
baggage that might be attached but keep the exact same content.

Supersedes #1302 and fixes #1301.

BeautifulSoup, as used in some search plugins, returns strings from HTML
document structures in "enriched" form - instances of unicode/str mixed
in with another class. Those strings carry references to the whole
document tree, which can cause issues when attempting to serialize entry
values for saving to the database.

To avoid that, coerce any values whose type is a subtype of text_type,
but not *exactly* text_type, to text_type, with text_type being unicode
in Py2 and str in Py3. That should ensure we throw away any extra
baggage that might be attached but keep the exact same content.
@danielkza danielkza force-pushed the entry-coerce-strings branch from 5d08fa3 to fb3dbc9 Compare August 15, 2016 00:48
@paranoidi paranoidi merged commit 39b376b into Flexget:develop Aug 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search plugins storing BeautifulSoup objects in Entry cause excessive recursion in Entry::take_snapshot

2 participants