-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python bindings: deprecate nonstandard inputs to bencode #5991
Comments
I only just realized that tuples of ints In the meantime at least |
you don't think it would be reasonable to accept string as well, and encode it as UTF-8 into bytes? |
how does this look? #6125 |
@AllSeeingEyeTolledEweSew that patch, #6125, would you consider that to address this issue? Also, which one of your PRs do you think makes the most sense to land next? |
I think #6188 is definitely my vote for what to do next. |
I still don't understand the rationale for deprecating On the other hand, accepting strings makes the API non-symmetric. The string won't round-trip. What is the reason to deprecate |
I think supporting Python 3 considers that string encodings should be explicit. Typically using a If we were still in the python 2 world, I would want to support |
but bencoding does support strings, and they are supposed to be encoded as utf-8 (by the spec). In a way, one could argue that leaving the string encoding to the user opens up the possibility to generate invalid bencoded structures. In fact this used to be a problem in the early days, where people would encode filenames with arbitrary, local, code pages. I think it's a stretch to say a |
I believe that accidental or ill-considered use of Also, remember that not all Lastly, as you mention, I think it's best to have So I still vote to deprecate |
bencode()
currently accepts any type as input, includingobject
.bdecode()
only outputsdict
,list
,int
orbytes
. This means there are lots of values that aren't stable round-trip, that isv != bdecode(bencode(v))
.It's not clear this support is helpful for any use case, and it can hide mistakes.
bencode()
should only accept combinations ofdict
,list
,int
orbytes
. Any others should fireDeprecationWarning
, and should eventually raiseTypeError
at some later time.The text was updated successfully, but these errors were encountered: