Exemplo n.º 1
0
 def delegate(*args, **kwargs):
     global __cstruct
     if not __cstruct:
         from build_capi import hint
         with hint("_struct"):
             import _struct as __cstruct
     return getattr(__cstruct, p)(*args, **kwargs)
Exemplo n.º 2
0
def __get_c_unicodedata():
    if c_unicodedata_module is None:
        from build_capi import hint
        with hint("_cpython_unicodedata"):
            import _cpython_unicodedata
        global c_unicodedata_module
        c_unicodedata_module = _cpython_unicodedata
    return c_unicodedata_module
Exemplo n.º 3
0
def __memoryview_init(self, *args, **kwargs):
    from build_capi import hint
    with hint("_memoryview"):
        import _memoryview
    global c_memoryview_module
    c_memoryview_module = _memoryview
    PyTruffle_SetAttr(memoryview, "__init__", __memoryview_init2)
    return __memoryview_init2(self, *args, **kwargs)
Exemplo n.º 4
0
def __register_buffer():
    from build_capi import hint
    with hint("_mmap"):
        import _mmap
    _mmap.init_bufferprotocol(mmap)
Exemplo n.º 5
0
def getlower(char_ord, flags):
    from build_capi import hint
    with hint("_cpython_sre"):
        import _cpython_sre
    return _cpython_sre.getlower(char_ord, flags)
Exemplo n.º 6
0
def compile(pattern, flags, code, groups, groupindex, indexgroup):
    from build_capi import hint
    with hint("_cpython_sre"):
        import _cpython_sre
    return _cpython_sre.compile(pattern, flags, code, groups, groupindex,
                                indexgroup)
Exemplo n.º 7
0
    "BZ2File", "BZ2Compressor", "BZ2Decompressor", "open", "compress",
    "decompress"
]

__author__ = "Nadeem Vawda <*****@*****.**>"

from builtins import open as _builtin_open
import io
import os
import warnings
import _compression
from threading import RLock

# TRUFFLE CHANGE BEGIN
from build_capi import hint
with hint("_bz2"):
    from _bz2 import BZ2Compressor, BZ2Decompressor
# TRUFFLE CHANGE END

_MODE_CLOSED = 0
_MODE_READ = 1
# Value 2 no longer used
_MODE_WRITE = 3


class BZ2File(_compression.BaseStream):
    """A file object providing transparent bzip2 (de)compression.

    A BZ2File can act as a wrapper for an existing file object, or refer
    directly to a named file on disk.