test_bre.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:backrefs 作者: facelessuser 项目源码 文件源码
def test_binary_unicode_ignore(self):
        r"""Binary patterns should not process `\p` references."""
        import sre_constants

        if PY36_PLUS:
            def no_unicode():
                """Should fail on Unicode back reference."""
                bre.compile_search(br'EX\p{Lu}MPLE')

            # Python 3.6+ fails on invalid back references (which ours are)
            # Since this one is not valid in a bytes string, it shouldn't
            # be used.  It is okay that Python fails on this.
            self.assertRaises(sre_constants.error, no_unicode)
        else:
            pattern = bre.compile_search(br'EX\p{Lu}MPLE')
            m = pattern.match(br'EXp{Lu}MPLE')
            self.assertTrue(m is not None)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号