How to use the idna.check_label function in idna

To help you get started, we’ve selected a few idna examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-hyper / hyperlink / src / hyperlink / hypothesis.py View on Github external
label = label[:-1]

        else:
            label = cast(
                Text,
                draw(text(
                    min_size=1, max_size=63,
                    alphabet=Text(ascii_letters + digits + u"-")
                ))
            )

        # Filter invalid labels.
        # It would be better to reliably avoid generation of bogus labels in
        # the first place, but it's hard...
        try:
            check_label(label)
        except UnicodeError:  # pragma: no cover (not always drawn)
            assume(False)

        return label