-
Notifications
You must be signed in to change notification settings - Fork 12
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
Crash on some inputs [Python 3.5.2] #16
Comments
Ha, thanks for pointing this out. I'm going to try looking into this and thinking about it. |
@gergelypolonkai was curious if you had any input here. It seems some unicode characters do not map to cp1252. I'm unsure of the best way to go about this. Do I just catch the exception, but then what? Just ignore the input? Some input here on which bytes will error https://stackoverflow.com/a/26330256 Like, I can convert from utf-8 and if fixes it but I'm unsure if there was a reason, like, for purity sake it was using cp1252? I don't grok encoding probably. :) |
This addresses a UnicodeDecodeError regarding unmapped code points for cp1252. I really don't know if this is the right answer.
No that is bad, I'm not doing the above, heh. |
Well, that is a strange problem and I don’t think there is a good solution to it. The linked SO answer lists the character codes that have no actual characters assigned (like the
|
Fixed with 09e90ff but we'll see if this gets backlash @gergelypolonkai yeah heh re: your rant, I just said screw it and will see if anyone rants back at my choice. I doubt it'll happen |
I was just thinking, maybe I should restore the previous encoding, cp1252, (I still don't know why), and let the user override the encoding when instantiating a TelnetServer instance? |
Despite you restore it or not, I really like the idea of allowing charset selection in the constructor. It makes the whole thing much more flexible. My the way, is there a reason to use cp1252? Or is it because itʼs “legacy”? |
@gergelypolonkai yeah that's exactly what I was thinking, based on a change you did in one of your PR's. That's exactly what I should do. I'll uh, default to utf-8 and let you set it to cp1252 in the constructor. And yes, I believe the idea was in the spirit of some romantic masturbatory Really that's just a guess though 🤷♂️ |
Well I think my change exposed a problem, re: #22 I'm being a bad software maintainer and rushing things. I'll certainly end up reverting, I think. |
Hi, I have started poking at my project again recently, and while doing so it occured to me that I never shared my solution to this that I did a couple weeks after my initial report. I simply added "errors=ignore" to the str() call. :P
This seems to just straight up drop anything it doesn't like, but considering this is user input for a MUD, I am not in the least concerned about that:
Now, I am only like 1% more experienced at Python than I was when I wrote the first message, so I have absolutely zero idea if this has any potential for mayhem, and I am sure there is a more proper solution... but it ain't crashing anymore, so it seems like progress to me. :P |
I'm sorry I haven't really paid attention to this much more. I should. Maybe someone else will, heh |
Ok, I went ahead and took @gergelypolonkai suggestion of specifying the encoding in the You can now Give it a shot if you're still messing with this library, @HallowedPoint |
Hello,
I've been working on a game using miniboa as the base, and have discovered it gets crashy when it encounters inputs that (assumedly?) cp1252 does not know how to deal with:
So far I've discovered this works with ⁒ (u2052) and ⁄ (u2044), but considering the sheer size of unicode I'm just assuming there are more.
I'm actually using this to learn Python and I'm not really sure what the best way to handle this would be, so I figured I'd point it in the direction of the professionals.
And I did test it with the example chat_demo.py to be sure it wasn't something I broke. I was quite surprised to discover that it was not. :)
The text was updated successfully, but these errors were encountered: