Python: BufferedRWPair Undefined Behavior#3884
Conversation
tausbn
left a comment
There was a problem hiding this comment.
Thank you for your (many!) recent contributions. I have added a bit of feedback on this query.
Before you submit any further queries, you should be aware that we're currently rewriting large parts of the Python QL libraries. As such, it may be best to hold off on submitting futher PRs, as these will almost certainly have to be rewritten to use the new API. Once the rewrite is completed (in a few months), we'll be happy to revisit your submissions. 🙂
|
Hi @tausbn, that makes sense, I completely understand. I have pivoted to other languages where I will be writing queries in the near future. I just fixed my suggestions as well for this query as well as the other few queries I have already as PRs. Would you mind reviewing/considering these for merging since I already have them here? Thank you! |
The BufferedRWPair class in the io module does not synchronize accesses to its streams. As noted in the official Python 3 documentation, passing in the same object as the reader and writer is a security warning as it generally leads to undefined/undesired behavior. Should a developer want to use an interface for random access streams, it is recommended to use BufferedRandom instead, which creates both a reader and writer for a singular raw stream, and is generally more tailored for this purpose.