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

Handle correct unicodedata method exception #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wesinator
Copy link

@wesinator wesinator commented Mar 30, 2024

unicodedata methods return ValueError, not TypeError. https://docs.python.org/3/library/unicodedata.html
fix #6

@yamatt

@yamatt
Copy link
Owner

yamatt commented Apr 1, 2024

Amazing. Thanks @wesinator this is my first PR since taking over the project. So let me check a few things and I hope to get back to you soon.

@yamatt
Copy link
Owner

yamatt commented Apr 1, 2024

So I've had a look around @wesinator.

So I agree with you that exception type should be ValueError according to the docs and as in your PR.

Although from testing, what happens is that unicode.name does in fact raise a TypeError if you enter an empty unicode string.

Then what happens is the TypeError is caught, but nothing is done with it except that there's a comment about Python 2 -- which is long out of support. Then the code continues on to the section below the error block, that then throws another own TypeError.

Personally I find the flow in this method a bit strange.

I'm not certain of the intention of this bit of code. Possibly one option is to ensure we have a valid char parameter in this function. But I'm also thinking this might mess up some deployments depending on how they defensively they wrote their code.

Could I ask, if you wouldn't mind, providing a bit more detail on the issue you encountered here? Was it just to align it to the docs? Or were you encountering an error?

@wesinator
Copy link
Author

Amazing. Thanks @wesinator this is my first PR since taking over the project. So let me check a few things and I hope to get back to you soon.

#5 was the first?
I think you have to manually follow your own forks to get notified of activity - unfortunately Github doesn't have the fork author automatically follow their own repo yet.

@wesinator
Copy link
Author

That's interesting that it throws a TypeError, the Python docs don't seem complete.

This was to fix someone else's issue, #6

It looks like the purpose of to_ascii is to convert glyphs to ascii representations -

### Converting glyphs to ASCII chars

I'll look at updating the PR. Also I'll probably open a python issue for the undocumented TypeError, since that also seems odd because other non-empty string types work in that method.

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.

Character \x00 in to_ascii() raises an exception
2 participants