Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(6)  |  Call(4)  |  Derive(0)  |  Import(2)

        def is_bytes_ascii(data):
    try:
        data.decode("ascii", "strict")
    except UnicodeDecodeError:
        return False
    else:
        return True
        


src/a/s/astoptimizer-0.6/astoptimizer/optimizer.py   astoptimizer(Download)
    clone_node_list, is_empty_body)
from astoptimizer.config import optimize_unicode
from astoptimizer.compatibility import (
    u,
    PYTHON2, PYTHON27, PYTHON3, PYTHON33, PYTHON34,
    def check_format_args(self, format, values):
        if PYTHON2:
            if isinstance(format, BYTES_TYPE):
                if is_bytes_ascii(format):
                    return True
            elif isinstance(format, UNICODE_TYPE):
                return all(
                    (not isinstance(value, BYTES_TYPE)) or is_bytes_ascii(value)
                    for value in values)
        else:
                for constant in constants:
                    if isinstance(constant, BYTES_TYPE):
                        if not is_bytes_ascii(constant):
                            return
                    else:

src/a/s/astoptimizer-0.6/astoptimizer/config_builtin_funcs.py   astoptimizer(Download)
"""
Enable optimizations on the builtins functions, example: len().
"""
from astoptimizer.compatibility import (
    is_bytes_ascii, is_unicode_ascii,
    def check_unicode_args(config, args):
        arg = args[0]
        if isinstance(arg, BYTES_TYPE):
            return is_bytes_ascii(arg)
        else: