Flush new pending data before checking if parser didn't finish. - #167
Closed
ianjosephwilson wants to merge 2 commits into
Closed
Flush new pending data before checking if parser didn't finish.#167ianjosephwilson wants to merge 2 commits into
ianjosephwilson wants to merge 2 commits into
Conversation
Contributor
|
Let's merge this now, but it feels like we should go back and do a deeper dive; sounds like we shouldn't be depending on |
davepeck
marked this pull request as ready for review
August 27, 2026 20:26
Contributor
Author
ianjosephwilson
marked this pull request as draft
August 27, 2026 20:39
Contributor
|
@ianjosephwilson Agree; after looking at this a bit more, I think we need to avoid all use of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I think this just gets things "working" for issue #166 but clearly it makes our dependency on the internals worse.
We use
rawdatato check if the parser was able to complete parsing or if its waiting for more data. We also inspect it to see if we can guess why it couldn't finish. A common mistake is when a quote is left open like this:t'<div x="1></div>'.The change in
3.14.7adds a_pendingbuffer,list[str], that lets the parser delay actual parsing until a threshold is met whereas before the parser tried to parse everytimefeed()was called. Onclose()this pending buffer is cleared out and parsing is done but the data is forced to''which I don't quite understand but we cannot detect that it wasn't able to finish.This patch flushes the pending buffer and runs a normal parse,
self.goahead(0)(notself.gohead(1)), before checkingself.rawdataduringclose().