sopel-irc / sopel

:robot::speech_balloon: An easy-to-use and highly extensible IRC Bot framework. Formerly Willie.
https://sopel.chat
Other
948 stars 402 forks source link

irc.utils, test: also remove null (\x00) in safe() #2620

Closed dgw closed 1 month ago

dgw commented 2 months ago

Description

Fixes #2566.

In test_irc_utils suite, rewrote test_safe and test_safe_bytes to generate a bunch more permutations of invalid characters automatically rather than writing them all out. The horse is definitely beaten far past death at this point... but the tests sure are thorough(bred).

Also renamed test_safe_null -> test_safe_none to avoid confusion; test_safe and test_safe_bytes are the cases that check behavior with null characters/bytes. Python's docs technically do refer to None as the "null object" once or twice, but most of the docs (and most of us devs) simply call it None.

Checklist

Notes

This could go into 8.0.1, but I don't really want to mess around with hotfixes unless there's a major bug. I'm open to suggestions for improving the maintenance-branch workflow; since master is de facto for 8.1.0 dev now, the options are to keep the 8.0.x branch unprotected so I can push cherry-picks to it directly, or make @sopel-irc/rockstars review the same PR twice (once to master, once to 8.0.x) for full CI coverage. I don't love either of those.

Exirel commented 1 month ago

Hey, this one could easily go into Sopel 8.0.1 to me. Like a hotfix of something that should be done but isn't.

dgw commented 1 month ago

Like a hotfix of something that should be done but isn't.

Yeah, it is, isn't it? I will tweak the safe() docstring though, as it really should mention NUL in the topline and also explain why the method exists at all.

dgw commented 1 month ago

Netlify still does branch previews of our docs (for now… they are still stuck on Python 3.8 with no apparent plans to upgrade) but including a preview screenshot of the updated docs for this function anyway didn't seem like a bad idea.

image

Note I also fixed the \x00 references in the docstring, which needs to use \\x00 for the text to display as intended.