weixin_39575775
weixin_39575775
2020-12-08 18:24

Drop bleach.encoding module

bleach.encoding is a 63 line file that has a single meaningful function that is used once. The only time force_unicode is used is to ensure that the input to clean is six.text_type instead of bytes. It includes all sorts of weird, unused paths and handles old Django types that aren't even used by Django anymore.

I think the entire module could be replaced by using six.text_type on __init__.py:104 (though linkify() doesn't have that call, so maybe linkify should, or maybe clean doesn't need it?).

该提问来源于开源项目:mozilla/bleach

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • weixin_39971172 weixin_39971172 5月前

    Putting this in the 2.0 milestone for now since we're dropping support for a bunch of things in that milestone and can probably more easily do this.

    点赞 评论 复制链接分享
  • weixin_39971172 weixin_39971172 5月前

    I'm dropping this from the milestone. I think it needs more thinking, but I'm not going to get to it for 2.0.

    点赞 评论 复制链接分享
  • weixin_39971172 weixin_39971172 5月前

    We recently adjusted linkify and clean to throw a TypeError if the argument is not a text type. So, I think we can nix the module now since now it's not doing anything.

    点赞 评论 复制链接分享
  • weixin_39971172 weixin_39971172 5月前

    Oh, wait--actually it is still converting str -> unicode for Python 2 cases. I'll look into this further and probably clean it up for 2.1.

    点赞 评论 复制链接分享

相关推荐