Skip to content
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

Fix _buffer_encode() wrong return type. #144

Closed

Conversation

elliotwutingfeng
Copy link
Contributor

Current implementation of _buffer_encode() has the wrong type signature (expected bytes but got str). It also attempts to perform a str.join() on list[bytes].

Fixes #138

@jribbens
Copy link
Collaborator

Hmm it seems rather unimpressive that mypy does not spot that str.join(list[bytes]) will fail.

There is a wider issue here. The codec decoder also doesn't work properly. The existing tests in test_idna_codec.py should be noticing both of these issues, except that, even after import idna.codec, codecs.lookup('idna') is still returning the Python standard library codec instead of the one from this library, so the tests are just testing the Python codec instead of this library's one.

jribbens added a commit to jribbens/idna that referenced this pull request Jun 19, 2023
@sethmlarson
Copy link
Collaborator

I noted here that the codec implementation appears to be untested, broken, and likely unused. #134

@elliotwutingfeng
Copy link
Contributor Author

I see. I think further discussion would be needed before attempting to fix this.

@jribbens
Copy link
Collaborator

@elliotwutingfeng I think your fix was fine, I have incorporated it into my PR #145 which also fixes the other issues.

@elliotwutingfeng
Copy link
Contributor Author

Thanks! Yes, it is better to consolidate all the fixes into one PR.

@elliotwutingfeng elliotwutingfeng deleted the incrementalencoder branch June 19, 2023 17:02
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.

Type error happened when join byte string.
3 participants