bpo-25439: Added additional type checks to urllib.request.Request by CuriousLearner · Pull Request #10616 · python/cpython (original) (raw)

Unfortunately, @vadmium isn't very active any more, and the PR went unreviewed for years. Sorry for that.

I'm OK with the check for common mistake (if isinstance(data, str): raise) in data setter. We can be reasonably sure that this doesn't break existing code.
On the other hand, allowing only bytes and memoryview closes the door for types that might work. How can we be sure that only these two types work?

The extra check for keys adds overhead to the non-error case; that's not ideal.

But overall, I think the issue made much more sense when it was opened, Python 3 was new and mixing up str and bytes was much more common than today. Also, we now have generic tools to detect type errors early -- static type checkers.
I think that today, it's best to close the PR without action. I'll do that in a month if there are no objections.