pax_global_header00006660000000000000000000000064152264544760014531gustar00rootroot0000000000000052 comment=48bada60b888e2dd92f90cab86d585cfacead059 clickhouse-driver-0.2.11/000077500000000000000000000000001522645447600152345ustar00rootroot00000000000000clickhouse-driver-0.2.11/.coveragerc000066400000000000000000000001251522645447600173530ustar00rootroot00000000000000[run] plugins = Cython.Coverage coverage_excludes source = clickhouse_driver clickhouse-driver-0.2.11/.flake8000066400000000000000000000005501522645447600164070ustar00rootroot00000000000000[flake8] filename = *.py, *.pyx exclude = perf per-file-ignores = clickhouse_driver/columns/largeint.pyx: E225, E226, E227, E999 clickhouse_driver/bufferedreader.pyx: E225, E226, E227, E999 clickhouse_driver/bufferedwriter.pyx: E225, E226, E227, E999 clickhouse_driver/varint.pyx: E225, E226, E227, E999 tests/columns/test_newjson.py: E501 clickhouse-driver-0.2.11/.github/000077500000000000000000000000001522645447600165745ustar00rootroot00000000000000clickhouse-driver-0.2.11/.github/FUNDING.yml000066400000000000000000000000241522645447600204050ustar00rootroot00000000000000patreon: xzkostyan clickhouse-driver-0.2.11/.github/ISSUE_TEMPLATE/000077500000000000000000000000001522645447600207575ustar00rootroot00000000000000clickhouse-driver-0.2.11/.github/ISSUE_TEMPLATE/bug_report.md000066400000000000000000000007661522645447600234620ustar00rootroot00000000000000--- name: Bug report about: Create a report to help us improve title: '' labels: '' assignees: '' --- **Describe the bug** A clear and concise description of what the bug is. **To Reproduce** Minimal piece of Python code that reproduces the problem. **Expected behavior** A clear and concise description of what you expected to happen. **Versions** - Version of package with the problem. - ClickHouse server version. Version can be obtained by running `SELECT version()` query. - Python version. clickhouse-driver-0.2.11/.github/dependabot.yml000066400000000000000000000011031522645447600214170ustar00rootroot00000000000000# Keep GitHub Actions up to date with GitHub's Dependabot... # https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot # https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem version: 2 updates: - package-ecosystem: github-actions directory: / groups: github-actions: patterns: - "*" # Group all Actions updates into a single larger pull request schedule: interval: weekly clickhouse-driver-0.2.11/.github/pull_request_template.md000066400000000000000000000013001522645447600235270ustar00rootroot00000000000000 - fixes # Checklist: - [ ] Add tests that demonstrate the correct behavior of the change. Tests should fail without the change. - [ ] Add or update relevant docs, in the docs folder and in code. - [ ] Ensure PR doesn't contain untouched code reformatting: spaces, etc. - [ ] Run `flake8` and fix issues. - [ ] Run `pytest` no tests failed. See https://clickhouse-driver.readthedocs.io/en/latest/development.html. clickhouse-driver-0.2.11/.github/workflows/000077500000000000000000000000001522645447600206315ustar00rootroot00000000000000clickhouse-driver-0.2.11/.github/workflows/actions.yml000066400000000000000000000344541522645447600230260ustar00rootroot00000000000000on: push: branches: [master] tags: ['*'] pull_request: name: build concurrency: # One lane per workflow + PR; non-PR pushes fall back to run_id (never cancel each other) group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: tests: runs-on: ubuntu-22.04 env: CLICKHOUSE_VERSION: ${{ matrix.clickhouse-version }} strategy: matrix: use-numpy: - 0 use-arrow: - 0 python-version: - "3.9" - "3.10" - "3.11" - "3.12" - "3.13" - "3.14" - "pypy-3.9" - "pypy-3.10" clickhouse-version: - 25.5.6.14 - 24.4.1 - 24.1.8.22 - 24.1.7.18 - 24.1.5.6 - 23.9.3.12 - 23.2.6.34 - 22.9.5.25 - 22.2.3.5 - 21.12.3.32 - 21.9.3.30 - 21.4.6.55 - 21.3.10.1 - 21.2.10.48 - 21.1.9.41 - 20.11.2.1 - 20.10.2.20 - 20.9.3.45 - 20.8.4.11 - 20.7.4.11 - 20.6.8.5 - 20.5.5.74 - 20.4.9.110 - 20.3.20.6 - 19.16.17.80 - 19.15.3.6 - 19.9.2.4 # allow_suspicious_low_cardinality_types - 19.8.3.8 # SimpleAggregateFunction include: - clickhouse-version: 20.3.20.6 use-numpy: 1 python-version: 3.9 # Oldest supported server + oldest pyarrow/numpy resolvable # on Python 3.9. - clickhouse-version: 20.3.20.6 use-numpy: 1 use-arrow: 1 python-version: 3.9 - clickhouse-version: 25.5.6.14 use-numpy: 1 use-arrow: 1 python-version: "3.12" # PyArrow without numpy/pandas: plain conversion paths only. - clickhouse-version: 25.5.6.14 use-numpy: 0 use-arrow: 1 python-version: "3.13" name: ${{ matrix.python-version }} CH=${{ matrix.clickhouse-version }} NUMPY=${{ matrix.use-numpy }} ARROW=${{ matrix.use-arrow }} steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} architecture: x64 # - name: Login to Docker Hub # uses: docker/login-action@v1 # with: # username: ${{ secrets.DOCKER_HUB_USERNAME }} # password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - name: Install flake8 run: | pip install --upgrade pip setuptools wheel pip install flake8 flake8-print - name: Run flake8 run: flake8 - name: Start ClickHouse server and client containers run: | if [[ "21.7" = "`echo -e "21.7\n${{ matrix.clickhouse-version }}" | sort -V | head -n1`" ]]; then echo "ORG=clickhouse"; else echo "ORG=yandex" ; fi >> tests/.env if [[ "21.10" = "`echo -e "21.10\n${{ matrix.clickhouse-version }}" | sort -V | head -n1`" ]]; then echo "TOP_LEVEL=clickhouse"; else echo "TOP_LEVEL=yandex" ; fi >> tests/.env docker compose -f tests/docker-compose.yml up -d - name: Setup clickhouse-client proxy for docker run: | # Faking clickhouse-client real communication with container via docker exec. echo -e '#!/bin/bash\n\ndocker exec -e "`env | grep ^TZ=`" test-clickhouse-client clickhouse client "$@"' | sudo tee /usr/local/bin/clickhouse-client > /dev/null sudo chmod +x /usr/local/bin/clickhouse-client # Overriding setup.cfg. Set host=clickhouse-server sed -i 's/^host=localhost$/host=clickhouse-server/' setup.cfg # Make host think that clickhouse-server is localhost echo '127.0.0.1 clickhouse-server' | sudo tee /etc/hosts > /dev/null - name: Build cython extensions with tracing run: CYTHON_TRACE=1 python setup.py build_ext --define CYTHON_TRACE if: ${{ !contains(matrix.python-version, 'pypy') }} - name: Install requirements run: | # Newer coveralls do not work with github actions. pip install 'coveralls<4.0.0' pip install 'cython<3.1.0' pip install -U 'setuptools<72.2' python testsrequire.py python setup.py develop # Limit each test time execution. pip install pytest-timeout env: USE_NUMPY: ${{ matrix.use-numpy }} USE_ARROW: ${{ matrix.use-arrow }} - name: Run tests run: coverage run -m pytest --timeout=10 -v timeout-minutes: 5 env: # Set initial TZ for docker exec -e "`env | grep ^TZ`" TZ: UTC - name: Upload coverage run: coveralls env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COVERALLS_PARALLEL: true COVERALLS_FLAG_NAME: ${{ matrix.python-version }} CH=${{ matrix.clickhouse-version }} NUMPY=${{ matrix.use-numpy }} ARROW=${{ matrix.use-arrow }} coveralls-finished: name: Indicate completion to coveralls.io needs: tests runs-on: ubuntu-latest steps: - name: Finished uses: coverallsapp/github-action@v2.3.4 with: github-token: ${{ secrets.GITHUB_TOKEN }} parallel-finished: true valgrind: name: Valgrind check needs: tests runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: 3.12 architecture: x64 - name: Install valgrind run: sudo apt-get update && sudo apt-get install -y valgrind # - name: Login to Docker Hub # uses: docker/login-action@v1 # with: # username: ${{ secrets.DOCKER_HUB_USERNAME }} # password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - name: Start ClickHouse server and client containers run: | if [[ "21.7" = "`echo -e "21.7\n$CLICKHOUSE_VERSION" | sort -V | head -n1`" ]]; then echo "ORG=clickhouse"; else echo "ORG=yandex" ; fi >> tests/.env if [[ "21.10" = "`echo -e "21.10\n$CLICKHOUSE_VERSION" | sort -V | head -n1`" ]]; then echo "TOP_LEVEL=clickhouse"; else echo "TOP_LEVEL=yandex" ; fi >> tests/.env docker compose -f tests/docker-compose.yml up -d env: CLICKHOUSE_VERSION: 20.3.7.46 - name: Setup clickhouse-client proxy for docker run: | # Faking clickhouse-client real communication with container via docker exec. echo -e '#!/bin/bash\n\ndocker exec -e "`env | grep ^TZ=`" test-clickhouse-client clickhouse-client "$@"' | sudo tee /usr/local/bin/clickhouse-client > /dev/null sudo chmod +x /usr/local/bin/clickhouse-client # Overriding setup.cfg. Set host=clickhouse-server sed -i 's/^host=localhost$/host=clickhouse-server/' setup.cfg # Make host think that clickhouse-server is localhost echo '127.0.0.1 clickhouse-server' | sudo tee /etc/hosts > /dev/null - name: Install requirements run: | pip install --upgrade pip setuptools python testsrequire.py python setup.py develop env: USE_NUMPY: 1 - name: Run tests under valgrind run: valgrind -s --error-exitcode=1 --suppressions=valgrind.supp py.test -v env: # Set initial TZ for docker exec -e "`env | grep ^TZ`" TZ: UTC USE_NUMPY: 1 PYTHONMALLOC: malloc wheels-linux: name: Wheels for Linux needs: valgrind runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: 3.12 architecture: x64 # - name: Login to Docker Hub # uses: docker/login-action@v1 # with: # username: ${{ secrets.DOCKER_HUB_USERNAME }} # password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - name: Install cibuildwheel run: | pip install --upgrade pip setuptools pip install cython cibuildwheel==$VERSION env: VERSION: 3.2.1 - name: Build wheels run: cibuildwheel --output-dir wheelhouse env: CIBW_BUILD: 'cp3{9,10,11,12,13,14}-* pp3{9,10,11}-*' CIBW_ENABLE: 'pypy pypy-eol' CIBW_BEFORE_BUILD: pip install cython - uses: ncipollo/release-action@v1 name: Upload wheels if: ${{ github.ref_type == 'tag' }} with: artifacts: "wheelhouse/*" allowUpdates: true draft: true tag: Linux token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/upload-artifact@v4 name: Store wheels if: ${{ github.ref_type == 'tag' }} with: name: dist-linux path: wheelhouse/*.whl wheels-macos: name: Wheels for OS X needs: valgrind runs-on: macos-latest steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: 3.12 architecture: x64 # - name: Login to Docker Hub # uses: docker/login-action@v1 # with: # username: ${{ secrets.DOCKER_HUB_USERNAME }} # password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - name: Install cibuildwheel run: | pip install --upgrade pip setuptools pip install cython cibuildwheel==$VERSION env: VERSION: 3.2.1 - name: Build wheels run: cibuildwheel --output-dir wheelhouse env: CIBW_BUILD: 'cp3{9,10,11,12,13,14}-* pp3{9,10,11}-*' CIBW_ENABLE: 'pypy pypy-eol' CIBW_BEFORE_BUILD: pip install cython CIBW_ARCHS_MACOS: x86_64 arm64 - uses: ncipollo/release-action@v1 name: Upload wheels if: ${{ github.ref_type == 'tag' }} with: artifacts: "wheelhouse/*" allowUpdates: true draft: true tag: OS X token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/upload-artifact@v4 name: Store wheels if: ${{ github.ref_type == 'tag' }} with: name: dist-macos path: wheelhouse/*.whl wheels-windows: name: Wheels for Windows needs: valgrind runs-on: windows-2022 steps: - name: Set git to use repo line breaks run: | git config --global core.autocrlf false - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: 3.12 architecture: x64 # - name: Login to Docker Hub # uses: docker/login-action@v1 # with: # username: ${{ secrets.DOCKER_HUB_USERNAME }} # password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - name: Install cibuildwheel run: | pip install cibuildwheel==$env:VERSION env: VERSION: 3.2.1 - name: Build wheels run: cibuildwheel --output-dir wheelhouse env: CIBW_BUILD: 'cp3{9,10,11,12,13,14}-* pp3{9,10,11}-*' CIBW_ENABLE: 'pypy pypy-eol' CIBW_BEFORE_BUILD: pip install cython - uses: ncipollo/release-action@v1 name: Upload wheels if: ${{ github.ref_type == 'tag' }} with: artifacts: "wheelhouse/*" allowUpdates: true draft: true tag: Windows token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/upload-artifact@v4 name: Store wheels if: ${{ github.ref_type == 'tag' }} with: name: dist-windows path: wheelhouse/*.whl wheels-linux-non-x86: name: Wheels for Linux non-x86 needs: valgrind runs-on: ubuntu-22.04 strategy: matrix: arch: - aarch64 - ppc64le - s390x steps: - uses: actions/checkout@v4 # - name: Login to Docker Hub # uses: docker/login-action@v1 # with: # username: ${{ secrets.DOCKER_HUB_USERNAME }} # password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - name: Set up Python uses: actions/setup-python@v5 with: python-version: 3.12 architecture: x64 - name: Set up QEMU id: qemu uses: docker/setup-qemu-action@v3.2.0 with: image: tonistiigi/binfmt:latest platforms: all - name: Install cibuildwheel run: | pip install --upgrade pip setuptools pip install cibuildwheel==$VERSION env: VERSION: 3.2.1 - name: Build wheels run: cibuildwheel --output-dir wheelhouse env: CIBW_BUILD: 'cp3{9,10,11,12,13,14}-* pp3{9,10,11}-*' CIBW_ENABLE: 'pypy pypy-eol' CIBW_BEFORE_BUILD: pip install cython CIBW_ARCHS: ${{ matrix.arch }} - uses: ncipollo/release-action@v1 name: Upload wheels if: ${{ github.ref_type == 'tag' }} with: artifacts: "wheelhouse/*" allowUpdates: true draft: true tag: Linux non-x86 token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/upload-artifact@v4 name: Store wheels if: ${{ github.ref_type == 'tag' }} with: name: dist-linux-${{ matrix.arch }} path: wheelhouse/*.whl sdist: name: Source distribution needs: valgrind runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: 3.12 - name: Build sdist run: | pip install --upgrade pip build python -m build --sdist - uses: actions/upload-artifact@v4 name: Store sdist if: ${{ github.ref_type == 'tag' }} with: name: dist-sdist path: dist/*.tar.gz publish-pypi: name: Publish to PyPI if: ${{ github.ref_type == 'tag' }} needs: - sdist - wheels-linux - wheels-macos - wheels-windows - wheels-linux-non-x86 runs-on: ubuntu-22.04 environment: pypi permissions: id-token: write steps: - uses: actions/download-artifact@v4 with: pattern: dist-* merge-multiple: true path: dist - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 clickhouse-driver-0.2.11/.github/workflows/docs.yml000066400000000000000000000014371522645447600223110ustar00rootroot00000000000000on: push: branches: [master] tags: ['*'] pull_request: name: build-docs concurrency: # One lane per workflow + PR; non-PR pushes fall back to run_id (never cancel each other) group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: tests: runs-on: ubuntu-22.04 name: Build docs steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: 3.11 architecture: x64 - name: Update tools run: pip install --upgrade pip setuptools wheel - name: Install sphinx run: pip install sphinx - name: Install package run: pip install -e . - name: Build docs run: cd docs && make html clickhouse-driver-0.2.11/.gitignore000066400000000000000000000020701522645447600172230ustar00rootroot00000000000000# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python env/ build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ *.egg-info/ .installed.cfg *.egg # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *,cover .hypothesis/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # IPython Notebook .ipynb_checkpoints # pyenv .python-version # celery beat schedule file celerybeat-schedule # dotenv .env # virtualenv venv/ ENV/ # Spyder project settings .spyderproject # Rope project settings .ropeproject # PyCharm project settings .idea/ clickhouse-driver-0.2.11/.readthedocs.yaml000066400000000000000000000002351522645447600204630ustar00rootroot00000000000000version: 2 build: os: ubuntu-22.04 tools: python: "3.11" sphinx: configuration: docs/conf.py python: install: - method: pip path: . clickhouse-driver-0.2.11/CHANGELOG.md000066400000000000000000001015251522645447600170510ustar00rootroot00000000000000# Changelog ## [0.2.11] - 2026-07-17 ### Added - PyArrow support. Install with `pip install clickhouse-driver[arrow]`. Solves issue [#375](https://github.com/mymarilyn/clickhouse-driver/issues/375). - Native `JSON` support. Solves issue [#473](https://github.com/mymarilyn/clickhouse-driver/issues/473) and [#460](https://github.com/mymarilyn/clickhouse-driver/issues/460). Pull request [#503](https://github.com/mymarilyn/clickhouse-driver/pull/503/) by [khvn26](https://github.com/khvn26), [gsergey418](https://github.com/gsergey418). - Writing `JSON` columns nested in `Array`, `Tuple` and `Map` columns. Solves issue [#511](https://github.com/mymarilyn/clickhouse-driver/issues/511). ### Fixed - Escaping of `list`/`tuple` parameters with `server_side_params=True`. Solves issue [#497](https://github.com/mymarilyn/clickhouse-driver/issues/497). Pull request [#507](https://github.com/mymarilyn/clickhouse-driver/pull/507) by [khvn26](https://github.com/khvn26). - Sparse deserialization of `IPv6` columns. Solves issue [#480](https://github.com/mymarilyn/clickhouse-driver/issues/480). Pull request [#508](https://github.com/mymarilyn/clickhouse-driver/pull/508) by [khvn26](https://github.com/khvn26). ### Changed - Minimum `clickhouse-cityhash` version raised to 1.0.2.6: first release that builds on Python 3.13+. ## [0.2.10] - 2025-11-10 ### Added - Wheels for Python 3.13 and 3.14. - Tunable parameter `check_hostname` for host checking in SSL. Enabled by default. - Support for encrypted keyfiles. Pull request [#485](https://github.com/mymarilyn/clickhouse-driver/pull/485) by [TheMysteriousX](https://github.com/TheMysteriousX). - Optional automatic reconnect disabling. Solves issue [#452](https://github.com/mymarilyn/clickhouse-driver/issues/452). Pull request [#453](https://github.com/mymarilyn/clickhouse-driver/pull/453) by [crazyproger](https://github.com/crazyproger). ### Fixed - `conneciton.ping()` on not established connection. Pull request [#465](https://github.com/mymarilyn/clickhouse-driver/pull/465) by [azat](https://github.com/azat). - `getuser()` exception in Python 3.13. Pull request [#462](https://github.com/mymarilyn/clickhouse-driver/pull/462) by [darkydash](https://github.com/darkydash). ### Changed - `JSON` renamed to `Object('json')`. Pull request [#490](https://github.com/mymarilyn/clickhouse-driver/pull/490) by [alsugiliazova](https://github.com/alsugiliazova). ### Removed - Python 3.7 and 3.8 support. ## [0.2.9] - 2024-08-16 ### Added - Debug logging on columns read/write. Solves issue [#404](https://github.com/mymarilyn/clickhouse-driver/issues/404). - Separate `parse_url` function for external tools. Solves issue [#438](https://github.com/mymarilyn/clickhouse-driver/issues/438). - [NumPy] Support for pandas StringArray and ArrowStringArray writing. Solves issue [#337](https://github.com/mymarilyn/clickhouse-driver/issues/337). Pull request [#441](https://github.com/mymarilyn/clickhouse-driver/pull/441) by [Simon-Chenzw](https://github.com/Simon-Chenzw). ### Fixed - `ssl.PROTOCOL_TLS` deprecation warning for Python 3.10+. - Trailing spaces in external tables declaration. Solves issue [#385](https://github.com/mymarilyn/clickhouse-driver/issues/385). - [Tests] Skip certificate validation test during run on local machine. Solves issue [#442](https://github.com/mymarilyn/clickhouse-driver/issues/442). - Handle special enum values: ``'mro'`` and ``''``. Solves issue [#333](https://github.com/mymarilyn/clickhouse-driver/issues/333). - [NumPy] Do not localize already localized pandas datetime. Solves issue [#444](https://github.com/mymarilyn/clickhouse-driver/issues/444). - [Tests] Run tests for server 24+. ### Changed - Protocol version bumped to 54468. ## [0.2.8] - 2024-06-12 ### Added - Lazy date LUT initialization for memory reducing. See [docs](https://clickhouse-driver.readthedocs.io/en/0.2.8/types.html#date-date32). Solves issue [#430](https://github.com/mymarilyn/clickhouse-driver/issues/430). Pull request [#431](https://github.com/mymarilyn/clickhouse-driver/pull/431) by [DaniilAnichin](https://github.com/DaniilAnichin). - Dependabot for up-to-date GitHub actions. Pull request [#421](https://github.com/mymarilyn/clickhouse-driver/pull/422) by [cclauss](https://github.com/cclauss). ### Fixed - TCP keepalive idle_time_sec, interval_sec type to integer. Solves issue [#432](https://github.com/mymarilyn/clickhouse-driver/issues/432). - Empty Map type read IndexError. Solves issue [#433](https://github.com/mymarilyn/clickhouse-driver/issues/433). - Test on current versions of PyPy. Pull request [#424](https://github.com/mymarilyn/clickhouse-driver/pull/424) by [cclauss](https://github.com/cclauss). - Connection `verify=False` ignoring. Solves issue [#420](https://github.com/mymarilyn/clickhouse-driver/issues/420). Pull request [#421](https://github.com/mymarilyn/clickhouse-driver/pull/421) by [akurdyukov](https://github.com/akurdyukov). ## [0.2.7] - 2024-02-20 ### Added - Wheels for Python 3.12. - Toggle hostname verification with ``verify`` option. Solves issue [#378](https://github.com/mymarilyn/clickhouse-driver/issues/378). Pull request [#379](https://github.com/mymarilyn/clickhouse-driver/pull/379) by [adamleko](https://github.com/adamleko). ### Fixed - Date32 start interval changed to 1900-01-01. Solves issue [#409](https://github.com/mymarilyn/clickhouse-driver/issues/409). - Memory leak when clickhouse raise exception on ``BufferedSocketWriter.write_into_stream``. Solves issue [#406](https://github.com/mymarilyn/clickhouse-driver/issues/406). Pull request [#407](https://github.com/mymarilyn/clickhouse-driver/pull/407) by [pulina](https://github.com/pulina). - ``input_format_null_as_default`` option for UUID produce ``00000000-0000-0000-0000-000000000000`` if set to true. Solves issue [#401](https://github.com/mymarilyn/clickhouse-driver/issues/401). - [Tests] Remove MemoryTracker asserting on INSERT statements. Solves issue [#403](https://github.com/mymarilyn/clickhouse-driver/issues/403). - Store "progress" and "profile" stats on INSERT statements. Solves issue [#391](https://github.com/mymarilyn/clickhouse-driver/issues/391). Pull request [#392](https://github.com/mymarilyn/clickhouse-driver/pull/392) by [insomnes](https://github.com/insomnes). - Add ``send_logs_level=test`` log level support. Solves issue [#383](https://github.com/mymarilyn/clickhouse-driver/issues/383). Pull request [#395](https://github.com/mymarilyn/clickhouse-driver/pull/395) by [the-horhe](https://github.com/the-horhe). - ``self`` in ``int128_from_quads``, ``int128_to_quads``, ``int256_from_quads``, ``int256_to_quads``. Solves issue [#400](https://github.com/mymarilyn/clickhouse-driver/issues/400). ### Changed - Server-side parameters substitution is turned off by default. You can't mix client-side and server-side formatting in one query. Solves issue [#376](https://github.com/mymarilyn/clickhouse-driver/issues/376) and [#410](https://github.com/mymarilyn/clickhouse-driver/issues/410). - Protocol version bumped to 54462. ## [0.2.6] - 2023-05-02 ### Added - JSON type. Solves issue [#320](https://github.com/mymarilyn/clickhouse-driver/issues/300). - On demand client revision downgrading. - Server-side query templating. - Sparse data type deserialization. - TCP keepalive. - [NumPy] Optional dataframe column names replacing. Pull request [#361](https://github.com/mymarilyn/clickhouse-driver/pull/361) by [notsovitalik](https://github.com/notsovitalik). - Substitution for parameters with time type. Solves issue [#359](https://github.com/mymarilyn/clickhouse-driver/issues/359). Pull request [#360](https://github.com/mymarilyn/clickhouse-driver/pull/360) by [ghazi-git](https://github.com/ghazi-git). ### Fixed - Client construction with round_robin. Solves issue [#373](https://github.com/mymarilyn/clickhouse-driver/issues/373). - Column state prefixes reading and writing. Solves issue [#372](https://github.com/mymarilyn/clickhouse-driver/issues/372). - Inserts to a nullable LowCardinality columns. Solves issue [#363](https://github.com/mymarilyn/clickhouse-driver/issues/363). Pull request [#366](https://github.com/mymarilyn/clickhouse-driver/pull/366) by [Dmitry-k42](https://github.com/Dmitry-k42). - [NumPy] Avoid unnecessary timezone conversion. Solves issue [#354](https://github.com/mymarilyn/clickhouse-driver/issues/354). Pull request [#355](https://github.com/mymarilyn/clickhouse-driver/pull/355) by [edwinwzhe](https://github.com/edwinwzhe). ### Changed - Protocol version bumped to 54459. - [NumPy] Speed-up reading Datetime64. Pull request [#365](https://github.com/mymarilyn/clickhouse-driver/pull/365) by [joelgibson](https://github.com/joelgibson). ### Removed - Python 3.6 support. ## [0.2.5] - 2022-11-27 ### Added - [NumPy] More readable exception for less columns in frame. Solves issue [#320](https://github.com/mymarilyn/clickhouse-driver/issues/320). - Support `server_hostname` via SNI when connecting. Pull request [#325](https://github.com/mymarilyn/clickhouse-driver/pull/325) by [dspangen](https://github.com/dspangen). - [NumPy] Bool support. Pull request [#332](https://github.com/mymarilyn/clickhouse-driver/pull/332) by [DylanModesitt](https://github.com/DylanModesitt). - Multiple connections round-robin. - Wheels for Python 3.11. - Docstring for `substitute_params`. Pull request [#347](https://github.com/mymarilyn/clickhouse-driver/pull/347) by [jasonho-lynx](https://github.com/jasonho-lynx). ### Fixed - Decimal support inside Map type. Pull request [#297](https://github.com/mymarilyn/clickhouse-driver/pull/297) by [zaius](https://github.com/zaius). - Preserve empty dataframe shape. Solves issue [#321](https://github.com/mymarilyn/clickhouse-driver/issues/321). - Preserve nanoseconds on INSERT for DateTime64. Solves issue [#307](https://github.com/mymarilyn/clickhouse-driver/issues/307). - Handle "progress" packets while inserting. Solves issue [#326](https://github.com/mymarilyn/clickhouse-driver/issues/326). Pull request [#327](https://github.com/mymarilyn/clickhouse-driver/pull/327) by [carlosfy](https://github.com/carlosfy). - [NumPy] Don't raise exception on INSERT when dataframe columns are superset of table's. Pull request [#340](https://github.com/mymarilyn/clickhouse-driver/pull/340) by [andrewresnikoff](https://github.com/andrewresnikoff). - Re-cythonize files for Python 3.11. Pull request [#342](https://github.com/mymarilyn/clickhouse-driver/pull/342) by [asottile-sentry](https://github.com/asottile-sentry). - NULL defaults to empty Array instead of one-element array. Solves issue [#339](https://github.com/mymarilyn/clickhouse-driver/issues/339). - Handle "profile event" packets while inserting. ### Removed - Python 3.5 support. ## [0.2.4] - 2022-06-13 ### Added - ``dict`` and ``namedtuple`` cursor factories. Solves issue [#290](https://github.com/mymarilyn/clickhouse-driver/issues/290). - Geo types: Point, Ring, Polygon, MultiPolygon. Solves issue [#228](https://github.com/mymarilyn/clickhouse-driver/issues/228). - [NumPy] Tuple type. - ``input_format_null_as_default`` option for NULL insert into not NULL columns. Solves issue [#312](https://github.com/mymarilyn/clickhouse-driver/issues/312). - Chunk size controlling in ``execute_iter`` by parameter ``chunk_size``. Solves issue [#314](https://github.com/mymarilyn/clickhouse-driver/issues/314). Pull request [#315](https://github.com/mymarilyn/clickhouse-driver/pull/315) by [MIracleyin](https://github.com/MIracleyin). ### Fixed - Decimal precision check on INSERT. Solves issue [#289](https://github.com/mymarilyn/clickhouse-driver/issues/289). Pull request [#295](https://github.com/mymarilyn/clickhouse-driver/pull/295) by [joelynch](https://github.com/joelynch). - Using server's default database instead or ``default``. Solves issue [#309](https://github.com/mymarilyn/clickhouse-driver/issues/309). - ``python_requires`` to valid PEP 440 syntax in ``setup.py``. Pull request [#291](https://github.com/mymarilyn/clickhouse-driver/pull/291) by [LSturtew](https://github.com/LSturtew). ### Changed - Protocol version bumped to 54453. ## [0.2.3] - 2022-02-07 ### Added - `tzlocal`>=4.0 support. Pull request [#263](https://github.com/mymarilyn/clickhouse-driver/pull/263) by [azat](https://github.com/azat). - `quota_key` support. - Wheels for Python 3.10. - Bool type. Pull request [#279](https://github.com/mymarilyn/clickhouse-driver/pull/279) by [adrian17](https://github.com/adrian17). - Nested type with `flatten_nested=0`. Pull request [#285](https://github.com/mymarilyn/clickhouse-driver/pull/285) by [spff](https://github.com/spff). ### Fixed - Handle partially consumed query. Solves issue [#117](https://github.com/mymarilyn/clickhouse-driver/issues/117). - Fallback to generic columns when NumPy support is not implemented for column type. Solves issue [#254](https://github.com/mymarilyn/clickhouse-driver/issues/254). - Broken ZSTD decompression. Solves issue [#269](https://github.com/mymarilyn/clickhouse-driver/issues/269). - External tables passing with NumPy. Solves issue [#267](https://github.com/mymarilyn/clickhouse-driver/issues/267). - Consider tzinfo for datetime parameters substitution. Solves issue [#268](https://github.com/mymarilyn/clickhouse-driver/issues/268). - Do not use NumPy columns inside generic columns. Solves issue [#272](https://github.com/mymarilyn/clickhouse-driver/issues/272). - Decimal128 and Decimal256 types_check. Solves issue [#274](https://github.com/mymarilyn/clickhouse-driver/issues/274). - Insertion using `execute` in DB API. Solves issue [#179](https://github.com/mymarilyn/clickhouse-driver/issues/179). Pull request [#276](https://github.com/mymarilyn/clickhouse-driver/pull/276) by [nnseva](https://github.com/nnseva). - Variables cannot be declared with `cpdef` in Cython 3. Pull request [#281](https://github.com/mymarilyn/clickhouse-driver/pull/281) by [ym](https://github.com/ym). ### Changed - Switch from nose test runner to pytest. - Migrate from Travis CI to GitHub Actions. ## [0.2.2] - 2021-09-24 ### Added - DateTime64 extended range. Pull request [#222](https://github.com/mymarilyn/clickhouse-driver/pull/222) by [0x4ec7](https://github.com/0x4ec7). - Support for using `Client` as context manager closing connection on exit. Solves issue [#237](https://github.com/mymarilyn/clickhouse-driver/issues/237). Pull request [#206](https://github.com/mymarilyn/clickhouse-driver/pull/238) by [wlhjason](https://github.com/wlhjason). - OpenTelemetry support. Solves issue [#230](https://github.com/mymarilyn/clickhouse-driver/issues/230). - `tzlocal`>=3.0 support. - Date32 type. - [NumPy] Nullable(T) support. ### Fixed - Boxing on DataFrames INSERT. - Empty external tables sending. Solves issue [#240](https://github.com/mymarilyn/clickhouse-driver/issues/240). - Create error message before disconnect. Pull request [#247](https://github.com/mymarilyn/clickhouse-driver/pull/247) by [NikiforovG](https://github.com/NikiforovG). - Writing explicit NumPy `NaN` values. Solves issue [#249](https://github.com/mymarilyn/clickhouse-driver/issues/249). - UInt128 INSERTing. Solves issue [#251](https://github.com/mymarilyn/clickhouse-driver/issues/251). - Large DataFrames chunking. Solves issue [#243](https://github.com/mymarilyn/clickhouse-driver/issues/243). - Allow arbitrary DataFrame columns order on INSERT. Solves issue [#245](https://github.com/mymarilyn/clickhouse-driver/issues/245). ### Changed - Protocol version bumped to 54442. - Unpin `lz4` for CPython. Pin `lz4`<=3.0.1 only for PyPy. ### Removed - `transpose` parameter from `insert_dataframe`. ## [0.2.1] - 2021-06-02 ### Added - Linux wheels for AArch64. Pull request [#197](https://github.com/mymarilyn/clickhouse-driver/pull/197) by [odidev](https://github.com/odidev). - [U]Int28/256 types. - Decimal256 type. - Code coverage for cython code. - Map type. - Support for private key/certificate file. Pull request [#219](https://github.com/mymarilyn/clickhouse-driver/pull/219) by [alexole](https://github.com/alexole). ### Fixed - Empty Array(Tuple(T)) writing. Solves issue [#177](https://github.com/mymarilyn/clickhouse-driver/issues/177). - Preserve Decimal precision on INSERT. Solves issue [#192](https://github.com/mymarilyn/clickhouse-driver/issues/192). - Remove closed cursors from connection. Solves issue [#194](https://github.com/mymarilyn/clickhouse-driver/issues/194). - DB API connect with default params. - Fix log blocks handling. Solves issue [#203](https://github.com/mymarilyn/clickhouse-driver/issues/203). - Multidimensional Array decoding. Solves issue [#204](https://github.com/mymarilyn/clickhouse-driver/issues/204). Pull request [#206](https://github.com/mymarilyn/clickhouse-driver/pull/206) by [smagellan](https://github.com/smagellan). - Use last database after reconnect. Solves issue [#205](https://github.com/mymarilyn/clickhouse-driver/issues/205). - Decimal(N, 1) handling. Pull request [#210](https://github.com/mymarilyn/clickhouse-driver/pull/210) by [raw0w](https://github.com/raw0w). ### Changed - Decimal128 performance increased (up to 25% compared to 0.2.0 release). ### Removed - Python 2.7 support. ## [0.2.0] - 2020-12-14 ### Added - NumPy reading/writing for columns: Float32/64, [U]Int8/16/32/64, Date/DateTime(‘timezone’)/DateTime64(‘timezone’), String/FixedString(N), LowCardinality(T). Merge [Arturus's](https://github.com/Arturus/clickhouse-driver) fork. - Pandas DataFrame reading/writing. - Ability to mark all settings as important to fail on unknown settings on sever side. - SSL SNI support. Solves issue [#172](https://github.com/mymarilyn/clickhouse-driver/issues/172). - Wheels for Python 3.9 and PyPy. - Remember last successful host on connection. Solves issue [#168](https://github.com/mymarilyn/clickhouse-driver/issues/168). ### Fixed - Server logs displaying on INSERT. - Make exceptions picklable. Pull request [#169](https://github.com/mymarilyn/clickhouse-driver/pull/169) by [azat](https://github.com/azat). - Enum type deserializing when it wrapped in SimpleAggregateFunction. Pull request [#170](https://github.com/mymarilyn/clickhouse-driver/pull/170) by [flyAwayGG](https://github.com/flyAwayGG). - Pin major `tzlocal` version. Solves issue [#166](https://github.com/mymarilyn/clickhouse-driver/issues/166). ### Changed - String and DateTime columns writing optimization. - Array columns reading/writing optimization. - Chunking optimization for large lists/tuples. - Protocol version bumped to 54441. ## [0.1.5] - 2020-09-19 ### Added - Do not require settings declaration if server support setting-as-string. Pull request [#142](https://github.com/mymarilyn/clickhouse-driver/pull/142) by [azat](https://github.com/azat). - `host_name` in logs. Pull request [#144](https://github.com/mymarilyn/clickhouse-driver/pull/144) by [azat](https://github.com/azat). - Cursor attribute `columns_with_types` to DB API. Issue [#149](https://github.com/mymarilyn/clickhouse-driver/issues/149). - Cursor method `set_query_id` to DB API. Issue [#152](https://github.com/mymarilyn/clickhouse-driver/issues/152). ### Fixed - Connection error messages formatting. - `Client.from_url` credentials unquoting. Issue [#146](https://github.com/mymarilyn/clickhouse-driver/issues/146). - Empty nested array handling. Pull request [#161](https://github.com/mymarilyn/clickhouse-driver/pull/161) by [dourvaris](https://github.com/dourvaris). - `read_varint` overflow. Issue [#163](https://github.com/mymarilyn/clickhouse-driver/issues/163). - Malformed reads/writes in `BufferedReader`. This addresses [CVE-2020-26759](https://nvd.nist.gov/vuln/detail/CVE-2020-26759). ### Changed - Use deque for ~4x speedup when reading Array columns. Pull request [#164](https://github.com/mymarilyn/clickhouse-driver/pull/164) by [dourvaris](https://github.com/dourvaris). ## [0.1.4] - 2020-06-13 ### Added - Tuple type. - Custom String column encoding. - Settings update to v20.4.1.2742 server version. Pull request [#133](https://github.com/mymarilyn/clickhouse-driver/pull/133) by [azat](https://github.com/azat). - Settings update to v20.5.1.3657 server version. Pull request [#141](https://github.com/mymarilyn/clickhouse-driver/pull/141) by [azat](https://github.com/azat). - Unsupported server versions to documentation. - Performance section to documentation. - Python 3.9 in Travis CI build matrix. ### Fixed - Reading/writing Array(Tuple). - 20.x server version support. - Settings mutation in `execute`. - Slow columnar results returning (`columnar=True`). - Segfault on passing not encoded strings during `INSERT` into ByteString column. ### Changed - Miscellaneous read/write optimizations - Protocol version bumped to 54429. ## [0.1.3] - 2020-02-21 ### Added - Python DB API 2.0. - Multiple hosts support on connection errors. - Insert columnar data support. Pull request [#122](https://github.com/mymarilyn/clickhouse-driver/pull/122) by [Anexen](https://github.com/Anexen). - Wheels for Python 3.8. - DateTime64 type. - Settings update to v20.2.1.2201 server version. Pull request [#123](https://github.com/mymarilyn/clickhouse-driver/pull/123) by [azat](https://github.com/azat). ### Fixed - `Client.from_url` settings detection. - Close socket on `KeyboardInterrupt` while running query. - Null handling in LowCardinality columns. ### Changed - Protocol version bumped to 54421. - Increased speed (up to 20-30% compared to 0.1.2 release) on heavy `SELECT` and `INSERT` queries. Pull request [#122](https://github.com/mymarilyn/clickhouse-driver/pull/122) by [Anexen](https://github.com/Anexen). - Memory consumption decreased (up to 20% compared to 0.1.2 release). Pull request [#122](https://github.com/mymarilyn/clickhouse-driver/pull/122) by [Anexen](https://github.com/Anexen). ## [0.1.2] - 2019-10-18 ### Added - Settings update to 19.16.1 server version. Pull request [#111](https://github.com/mymarilyn/clickhouse-driver/pull/111) by [azat](https://github.com/azat). - Python 3.8 in Travis CI build matrix. - Returning inserted rows count on `INSERT` queries with data. Returning rows count from `INSERT FROM SELECT` is not supported. ### Fixed - Exposing `columnar` parameter to `execute_with_progress`. Pull request [#108](https://github.com/mymarilyn/clickhouse-driver/pull/108) by [igorbb](https://github.com/igorbb). - LowCardinality tests. Pull request [#112](https://github.com/mymarilyn/clickhouse-driver/pull/112) by [azat](https://github.com/azat). ### Changed - Increased speed (up to 5 times compared to 0.1.1 release) of `INSERT` queries. - Date/DateTime columns selecting and inserting optimizations. ## [0.1.1] - 2019-09-20 ### Added - `Client.from_url` method that creates client configured from the given URL. ### Fixed - If source column was timezone-aware values from DateTime column are returned with timezone now. - Handling zero bytes in the middle of FixedString column. Issue [#104](https://github.com/mymarilyn/clickhouse-driver/issues/104). ## [0.1.0] - 2019-08-07 ### Added - SimpleAggregateFunction type. Pull request [#95](https://github.com/mymarilyn/clickhouse-driver/pull/95) by [azat](https://github.com/azat). ### Changed - Increased speed (5-6 times compared to 0.0.20 release) of `SELECT` queries with large amount of strings. - Package is distributed in source and binary forms now. Compilation from source is required for platforms without wheels. ### Fixed - Elapsed time calculation on INSERT. - Dependencies environment markers for poetry in `setup.py`. Pull request [#96](https://github.com/mymarilyn/clickhouse-driver/pull/96) by [nitoqq](https://github.com/nitoqq). ## [0.0.20] - 2019-06-02 ### Added - LowCardinality(T) type. - Access for processed rows, bytes and elapsed time of the last executed query. - Allow to insert `datetime` into Date column. Pull request [#75](https://github.com/mymarilyn/clickhouse-driver/pull/75) by [gle4er](https://github.com/gle4er). - 'max_partitions_per_insert_block' setting. Pull request [#85](https://github.com/mymarilyn/clickhouse-driver/pull/85) by [mhsekhavat](https://github.com/mhsekhavat). ### Fixed - Fallback for user name if it's not defined. Pull request [#87](https://github.com/mymarilyn/clickhouse-driver/pull/87) by [wawaka](https://github.com/wawaka). ## [0.0.19] - 2019-03-31 ### Added - IPv4/IPv6 types. Pull request [#73](https://github.com/mymarilyn/clickhouse-driver/pull/73) by [AchilleAsh](https://github.com/AchilleAsh). ### Fixed - String enums escaping. ## [0.0.18] - 2019-02-19 ### Fixed - Strings mishandling read from buffer. Pull request [#72](https://github.com/mymarilyn/clickhouse-driver/pull/72) by [mitsuhiko](https://github.com/mitsuhiko). ## [0.0.17] - 2019-01-09 ### Added - Server logs displaying. - Documentation on Read the Docs: https://clickhouse-driver.readthedocs.io ### Changed - Protocol version bumped to 54406. ### Fixed - INSERT generators support as data parameter. - INSERT null value on ByteString column. Pull request [#65](https://github.com/mymarilyn/clickhouse-driver/pull/65) by [vivienm](https://github.com/vivienm). - Integer types support in FloatColumn. - Handle quotes and equation signs in Enum options. Pull request [#67](https://github.com/mymarilyn/clickhouse-driver/pull/67) by [sochi](https://github.com/sochi). ## [0.0.16] - 2018-10-09 ### Added - Option to access profile info about the last executed query. Pull request [#57](https://github.com/mymarilyn/clickhouse-driver/pull/57) by [vanzi](https://github.com/vanzi). - Decimal type. - Settings update to 18.14.2 server version. ### Changed - String column read/write optimizations. - Protocol version bumped to 54401. ### Fixed - Client settings are not mutable now. ## [0.0.15] - 2018-09-26 ### Fixed - Unpin `clickhouse-cityhash` dependency. ## [0.0.14] - 2018-08-16 ### Added - Block by block results streaming. ## [0.0.13] - 2018-07-26 ### Fixed - Revert pull request [#45](https://github.com/mymarilyn/clickhouse-driver/pull/45) by [shotInLeg](https://github.com/shotInLeg) due to `INSERT FROM SELECT` breaking. ## [0.0.12] - 2018-07-25 ### Added - Allow for access of final progress stats. Pull request [#41](https://github.com/mymarilyn/clickhouse-driver/pull/41) by [alex-hofsteede](https://github.com/alex-hofsteede). - Supplying raw integers in DateTime columns. Pull request [#42](https://github.com/mymarilyn/clickhouse-driver/pull/42) by [wawaka](https://github.com/wawaka). ### Fixed - Pip install in editable mode. ### Changed - Raise ValueError instead of timeout for INSERT queries without params. Pull request [#45](https://github.com/mymarilyn/clickhouse-driver/pull/45) by [shotInLeg](https://github.com/shotInLeg). ## [0.0.11] - 2018-06-03 ### Added - Timezone support in DateTime type. - Python 3.7 and PyPy in Travis CI build matrix. - Direct bytes support in FixedString. Pull request [#26](https://github.com/mymarilyn/clickhouse-driver/pull/26) by [lidalei](https://github.com/lidalei). ### Removed - Python 3.3 support. ## [0.0.10] - 2018-03-14 ### Added - Server version specific tests. - Nothing type. - Travis CI build matrix. ### Fixed - Possible IndexError in packet types string representation. Pull request [#28](https://github.com/mymarilyn/clickhouse-driver/pull/28) by [WouldYouKindly](https://github.com/WouldYouKindly). - Do not use timezone in Date columns. Issue [#29](https://github.com/mymarilyn/clickhouse-driver/issues/29). - Approximate rows to read calculation in `execute_with_progress`. Pull request [#30](https://github.com/mymarilyn/clickhouse-driver/pull/30) by [b1naryth1ef](https://github.com/b1naryth1ef). ### Changed - List and Tuple types rendering in parameters substitution. Pull request [#27](https://github.com/mymarilyn/clickhouse-driver/pull/27) by [silentsokolov](https://github.com/silentsokolov). ## [0.0.9] - 2018-01-17 ### Added - Interval type. Pull request [#16](https://github.com/mymarilyn/clickhouse-driver/pull/16) by [kszucs](https://github.com/kszucs). ### Fixed - Raise EOFError when no data is read in `_read_one` in Python 3. - SSL file descriptors closing in Python 2.7. ### Changed - Log level for normal operations raised to DEBUG. Pull request [#17](https://github.com/mymarilyn/clickhouse-driver/pull/17) by [kmatt](https://github.com/kmatt). ### Removed - Drop Python 3.2 support due to lz4 issues. ## [0.0.8] - 2017-10-23 ### Added - Parameters substitution for SELECT queries. - SSL support. ### Fixed - Columnar result returning from multiple blocks. Columns must be concatenated. - Settings logger was root. - Reading/writing Array(String) NotImplementedError raise. - IPv6 support issue [#12](https://github.com/mymarilyn/clickhouse-driver/issues/12). ## [0.0.7] - 2017-10-12 ### Added - Configurable logging level in tests. - Full error codes list. - Force check clickhouse-cityhash is installed if compression is used. - `Client` can be directly imported from package. - `insert_block_size` parameter - maximum rows in block (default is 1048576). - Columnar result returning (`columnar=True`). Pull request [#11](https://github.com/mymarilyn/clickhouse-driver/pull/11) by [kszucs](https://github.com/kszucs). - Tunable types check (`types_check=True`). Off by default. ### Changed - Handling only socket-related errors on ping. Errors are logged with `WARNING` level. - Client is created per one test. - Sending/receiving data speed significantly increased. ### Fixed - Version detection in setup.py. - Error handling on socket.shutdown. - Install `enum34` only if required. - `clickhouse-cityhash` import issue [#10](https://github.com/mymarilyn/clickhouse-driver/issues/10). ### Removed - QuickLZ support - six dependency ## [0.0.6] - 2017-09-19 ### Added - UUID type. - Query limits settings. - Code coverage. - ClickHouse server and driver version upped to 54276. - Changelog. - Added column name to `TypeMismatchError`. - Query progress information. - Version of package. ### Fixed - socket.timeout error handling on connect. ## [0.0.5] - 2017-07-16 ### Added - Nullable(T) type. - Return data from TOTALS and EXTREMES packets. - Query settings. - query_id execution option. - NULL type. - Raise exception on SELECT queries. ### Changed - Small columns refactoring. - `clickhouse-client` in tests moved to docker. ## [0.0.4] - 2017-06-15 ### Added - FixedString(N) type. - Enum8/16 types. - Array(T) type. - External data for query processing - Raise UnknownTypeError for unsupported columns. ### Changed - Socket connect timeout fix. ## [0.0.3] - 2017-05-24 ### Added - QuickLZ, LZ4/LZ4HC, ZSTD compressions. - Support old servers without BlockInfo. - Travis CI. - flake8 syntax check. ## 0.0.2 - 2017-05-16 ### Added - [U]Int8/16/32/64 types. - Date/DateTime types. - String types. [Unreleased]: https://github.com/mymarilyn/clickhouse-driver/compare/0.2.10...HEAD [0.2.10]: https://github.com/mymarilyn/clickhouse-driver/compare/0.2.9...0.2.10 [0.2.9]: https://github.com/mymarilyn/clickhouse-driver/compare/0.2.8...0.2.9 [0.2.8]: https://github.com/mymarilyn/clickhouse-driver/compare/0.2.7...0.2.8 [0.2.7]: https://github.com/mymarilyn/clickhouse-driver/compare/0.2.6...0.2.7 [0.2.6]: https://github.com/mymarilyn/clickhouse-driver/compare/0.2.5...0.2.6 [0.2.5]: https://github.com/mymarilyn/clickhouse-driver/compare/0.2.4...0.2.5 [0.2.4]: https://github.com/mymarilyn/clickhouse-driver/compare/0.2.3...0.2.4 [0.2.3]: https://github.com/mymarilyn/clickhouse-driver/compare/0.2.2...0.2.3 [0.2.2]: https://github.com/mymarilyn/clickhouse-driver/compare/0.2.1...0.2.2 [0.2.1]: https://github.com/mymarilyn/clickhouse-driver/compare/0.2.0...0.2.1 [0.2.0]: https://github.com/mymarilyn/clickhouse-driver/compare/0.1.5...0.2.0 [0.1.5]: https://github.com/mymarilyn/clickhouse-driver/compare/0.1.4...0.1.5 [0.1.4]: https://github.com/mymarilyn/clickhouse-driver/compare/0.1.3...0.1.4 [0.1.3]: https://github.com/mymarilyn/clickhouse-driver/compare/0.1.2...0.1.3 [0.1.2]: https://github.com/mymarilyn/clickhouse-driver/compare/0.1.1...0.1.2 [0.1.1]: https://github.com/mymarilyn/clickhouse-driver/compare/0.1.0...0.1.1 [0.1.0]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.20...0.1.0 [0.0.20]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.19...0.0.20 [0.0.19]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.18...0.0.19 [0.0.18]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.17...0.0.18 [0.0.17]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.16...0.0.17 [0.0.16]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.15...0.0.16 [0.0.15]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.14...0.0.15 [0.0.14]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.13...0.0.14 [0.0.13]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.12...0.0.13 [0.0.12]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.11...0.0.12 [0.0.11]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.10...0.0.11 [0.0.10]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.9...0.0.10 [0.0.9]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.8...0.0.9 [0.0.8]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.7...0.0.8 [0.0.7]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.6...0.0.7 [0.0.6]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.5...0.0.6 [0.0.5]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.4...0.0.5 [0.0.4]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.3...0.0.4 [0.0.3]: https://github.com/mymarilyn/clickhouse-driver/compare/0.0.2...0.0.3 clickhouse-driver-0.2.11/CONTRIBUTING.rst000066400000000000000000000007301522645447600176750ustar00rootroot00000000000000How to Contribute ================= #. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug. #. Fork `the repository `_ on GitHub to start making your changes to the **master** branch (or branch off of it). #. Write a test which shows that the bug was fixed or that the feature works as expected. #. Send a pull request and bug the maintainer until it gets merged and published. clickhouse-driver-0.2.11/LICENSE000066400000000000000000000021671522645447600162470ustar00rootroot00000000000000This is the MIT license: http://www.opensource.org/licenses/mit-license.php Copyright (c) 2017 by Konstantin Lebedev. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. clickhouse-driver-0.2.11/MANIFEST.in000066400000000000000000000000521522645447600167670ustar00rootroot00000000000000recursive-include clickhouse_driver *.pyx clickhouse-driver-0.2.11/README.rst000066400000000000000000000076671522645447600167430ustar00rootroot00000000000000ClickHouse Python Driver ======================== .. image:: https://img.shields.io/pypi/v/clickhouse-driver.svg :target: https://pypi.org/project/clickhouse-driver .. image:: https://coveralls.io/repos/github/mymarilyn/clickhouse-driver/badge.svg?branch=master :target: https://coveralls.io/github/mymarilyn/clickhouse-driver?branch=master .. image:: https://img.shields.io/pypi/l/clickhouse-driver.svg :target: https://pypi.org/project/clickhouse-driver .. image:: https://img.shields.io/pypi/pyversions/clickhouse-driver.svg :target: https://pypi.org/project/clickhouse-driver .. image:: https://img.shields.io/pypi/dm/clickhouse-driver.svg :target: https://pypi.org/project/clickhouse-driver .. image:: https://github.com/mymarilyn/clickhouse-driver/actions/workflows/actions.yml/badge.svg :target: https://github.com/mymarilyn/clickhouse-driver/actions/workflows/actions.yml ClickHouse Python Driver with native (TCP) interface support. Asynchronous wrapper is available here: https://github.com/mymarilyn/aioch Features ======== - External data for query processing. - Query settings. - Compression support. - TLS support. - Types support: * Float32/64 * [U]Int8/16/32/64/128/256 * Date/Date32/DateTime('timezone')/DateTime64('timezone') * String/FixedString(N) * Enum8/16 * Array(T) * Nullable(T) * Bool * UUID * Decimal * IPv4/IPv6 * LowCardinality(T) * SimpleAggregateFunction(F, T) * Tuple(T1, T2, ...) * Nested * Map(key, value) * JSON - Query progress information. - Block by block results streaming. - Reading query profile info. - Receiving server logs. - Multiple hosts support. - Python DB API 2.0 specification support. - Optional NumPy arrays support. Documentation ============= Documentation is available at https://clickhouse-driver.readthedocs.io. Usage ===== There are two ways to communicate with server: - using pure Client; - using DB API. Pure Client example: .. code-block:: python >>> from clickhouse_driver import Client >>> >>> client = Client('localhost') >>> >>> client.execute('SHOW TABLES') [('test',)] >>> client.execute('DROP TABLE IF EXISTS test') [] >>> client.execute('CREATE TABLE test (x Int32) ENGINE = Memory') [] >>> client.execute( ... 'INSERT INTO test (x) VALUES', ... [{'x': 100}] ... ) 1 >>> client.execute('INSERT INTO test (x) VALUES', [[200]]) 1 >>> client.execute( ... 'INSERT INTO test (x) ' ... 'SELECT * FROM system.numbers LIMIT %(limit)s', ... {'limit': 3} ... ) [] >>> client.execute('SELECT sum(x) FROM test') [(303,)] DB API example: .. code-block:: python >>> from clickhouse_driver import connect >>> >>> conn = connect('clickhouse://localhost') >>> cursor = conn.cursor() >>> >>> cursor.execute('SHOW TABLES') >>> cursor.fetchall() [('test',)] >>> cursor.execute('DROP TABLE IF EXISTS test') >>> cursor.fetchall() [] >>> cursor.execute('CREATE TABLE test (x Int32) ENGINE = Memory') >>> cursor.fetchall() [] >>> cursor.executemany( ... 'INSERT INTO test (x) VALUES', ... [{'x': 100}] ... ) >>> cursor.rowcount 1 >>> cursor.executemany('INSERT INTO test (x) VALUES', [[200]]) >>> cursor.rowcount 1 >>> cursor.execute( ... 'INSERT INTO test (x) ' ... 'SELECT * FROM system.numbers LIMIT %(limit)s', ... {'limit': 3} ... ) >>> cursor.rowcount 0 >>> cursor.execute('SELECT sum(x) FROM test') >>> cursor.fetchall() [(303,)] License ======= ClickHouse Python Driver is distributed under the `MIT license `_. clickhouse-driver-0.2.11/clickhouse_driver/000077500000000000000000000000001522645447600207405ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/__init__.py000066400000000000000000000002371522645447600230530ustar00rootroot00000000000000 from .client import Client from .dbapi import connect VERSION = (0, 2, 11) __version__ = '.'.join(str(x) for x in VERSION) __all__ = ['Client', 'connect'] clickhouse-driver-0.2.11/clickhouse_driver/arrow/000077500000000000000000000000001522645447600220725ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/arrow/__init__.py000066400000000000000000000000001522645447600241710ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/arrow/convert.py000066400000000000000000000240551522645447600241320ustar00rootroot00000000000000import pyarrow as pa try: import numpy as np except ImportError: np = None try: import pandas as pd except ImportError: pd = None try: from ..columns.arrow.stringcolumn import ArrowStringBuffers except ImportError: ArrowStringBuffers = None from .. import errors from ..columns.util import get_inner_columns, get_inner_spec from ..protocol import ServerPacketTypes from .mapping import ( UNSUPPORTED, get_type_and_converter, json_as_object, json_as_text ) class ArrowStreamState(object): """ Tracks whether a streamed query was consumed to the end. ``pyarrow.RecordBatchReader.close`` doesn't reach the underlying generator, so the client uses this state to cancel unfinished streams before the next query. """ __slots__ = ('connection', 'finished', 'cancelled') def __init__(self, connection): self.connection = connection self.finished = False self.cancelled = False def create_record_batch_reader(packet_generator, context, state=None, field_metadata=True, arrow_types=None): """ Creates RecordBatchReader yielding one record batch per ClickHouse block. Schema is built from the header block, so it's available before any data block is received. Unless ``field_metadata`` is disabled, the original ClickHouse type of each column is attached to its Arrow field as ``clickhouse_type`` metadata. ``arrow_types`` maps column names to Arrow types, overriding the default mapping. Columns of types without a default Arrow representation (``JSON``) require an entry. """ strings_as_bytes = context.client_settings.get('strings_as_bytes', False) blocks = _data_blocks(packet_generator) first_block = next(blocks, None) if first_block is None: if state is not None: state.finished = True return pa.RecordBatchReader.from_batches(pa.schema([]), iter([])) columns_with_types = first_block.columns_with_types fields = _resolve_fields( columns_with_types, strings_as_bytes, arrow_types ) # Header block contains no rows. buffered = [first_block] if first_block.num_rows else [] # Types without explicit mapping are inferred from the first non-empty # block. It has to be received before the schema can be built. if any(type_ is None for type_, _ in fields): while not buffered: block = next(blocks, None) if block is None: break if block.num_rows: buffered.append(block) fields = _infer_missing_types(fields, buffered) schema = pa.schema([ pa.field( name, type_, metadata={'clickhouse_type': spec} if field_metadata else None ) for (name, spec), (type_, _) in zip(columns_with_types, fields) ]) def batches(): for block in buffered: yield _block_to_batch(block, schema, fields) while True: # The stream may have been cancelled by a subsequent query # on the same client. Reading further would consume packets # of that query. if state is not None and state.cancelled: raise errors.PartiallyConsumedQueryError() block = next(blocks, None) if block is None: break if block.num_rows: yield _block_to_batch(block, schema, fields) if state is not None: state.finished = True return pa.RecordBatchReader.from_batches(schema, batches()) def _is_json_spec(spec): return spec == 'JSON' or spec.startswith('JSON(') def _json_declared_converter(spec, declared, name): """ Composes JSON converters for a declared Arrow type, following Nullable/Array/Map containers down to JSON positions. Returns ``None`` when the spec contains no JSON at positions matched by the declared type. """ if _is_json_spec(spec): if pa.types.is_string(declared) or \ pa.types.is_large_string(declared): return json_as_text(name) return json_as_object if spec.startswith('Nullable('): return _json_declared_converter( get_inner_spec('Nullable', spec), declared, name ) if spec.startswith('Array(') and ( pa.types.is_list(declared) or pa.types.is_large_list(declared)): inner = _json_declared_converter( get_inner_spec('Array', spec), declared.value_type, name ) if inner is None: return None def converter(value, _converter=inner): return [None if x is None else _converter(x) for x in value] return converter if spec.startswith('Map(') and pa.types.is_map(declared): _, value_spec = get_inner_columns(get_inner_spec('Map', spec)) value_converter = _json_declared_converter( value_spec, declared.item_type, name ) if value_converter is None: return None def converter(value, _vc=value_converter): return [ (k, None if v is None else _vc(v)) for k, v in value.items() ] return converter return None def _resolve_fields(columns_with_types, strings_as_bytes, arrow_types): fields = [] for name, spec in columns_with_types: type_, converter = get_type_and_converter(spec, strings_as_bytes) declared = (arrow_types or {}).get(name) if declared is not None: json_converter = _json_declared_converter(spec, declared, name) if json_converter is not None: converter = json_converter type_ = declared elif type_ is UNSUPPORTED: raise ValueError( "Column '{0}' of type {1} has no default Arrow " "representation. Pass arrow_types={{'{0}': " "pyarrow.string()}} for JSON text, declare a struct " 'type for structured output, or transform the column ' 'in the query (e.g. toJSONString).'.format(name, spec) ) fields.append((type_, converter)) return fields def _data_blocks(packet_generator): for packet in packet_generator: if getattr(packet, 'type', None) == ServerPacketTypes.DATA: block = getattr(packet, 'block', None) if block is not None: yield block def _infer_missing_types(fields, buffered): rv = [] for i, (type_, converter) in enumerate(fields): if type_ is None: if buffered: column = buffered[0].get_columns()[i] type_ = _column_to_array(column, None, converter).type else: type_ = pa.null() rv.append((type_, converter)) return rv def _block_to_batch(block, schema, fields): arrays = [ _column_to_array(column, type_, converter) for column, (type_, converter) in zip(block.get_columns(), fields) ] return pa.RecordBatch.from_arrays(arrays, schema=schema) def _column_to_array(column, type_, converter): if ArrowStringBuffers is not None and \ isinstance(column, ArrowStringBuffers): return _string_buffers_to_array(column, type_) if np is not None and isinstance(column, np.ma.MaskedArray): return _masked_to_array(column, type_, converter) # Numeric and datetime64 NumPy columns are handled by Arrow without # copying. if np is not None and isinstance(column, np.ndarray) and \ column.dtype.kind in 'iufbM': return pa.array(column, type=type_) if pd is not None and isinstance(column, pd.Categorical): if converter is None: # Categorical maps to Arrow dictionary array without # iterating over values. dictionary = pa.array(column) return dictionary.cast(type_) if type_ is not None \ else dictionary column = [None if pd.isna(x) else x for x in column] if converter is not None: column = [None if x is None else converter(x) for x in column] return pa.array(column, type=type_) def _string_buffers_to_array(column, type_): """ Assembles a string/binary array directly from wire-format buffers: concatenated bytes + offsets, no per-string Python objects. The binary -> string cast validates UTF-8 in C. """ n_items = len(column) offsets = np.frombuffer(column.offsets, dtype=np.int64) if offsets[-1] > 2 ** 31 - 1: raise ValueError( 'Block string data exceeds 2GiB. ' 'Lower max_block_size to stream it.' ) validity = None if column.nulls_map is not None: validity = pa.py_buffer( np.packbits(column.nulls_map == 0, bitorder='little') ) binary = pa.Array.from_buffers(pa.binary(), n_items, [ validity, pa.py_buffer(offsets.astype(np.int32)), pa.py_buffer(column.data) ]) if type_ is None or type_ == pa.string(): return binary.cast(pa.string()) return binary def _masked_to_array(column, type_, converter): """ Nullable columns come from the NumPy path as masked arrays: raw values with placeholders in NULL slots plus the nulls map. Arrow stores exactly that, so the values buffer is reused as is and the nulls map is packed into the validity bitmap. """ mask = np.ma.getmaskarray(column) data = column.data if converter is not None: values = [ None if is_null else converter(x) for x, is_null in zip(data, mask) ] return pa.array(values, type=type_, mask=mask) if data.dtype.kind not in 'iufbM': return pa.array(data, type=type_, mask=mask) # pa.array copies values slot by slot when mask is passed. Packing # the validity bitmap manually is ~20x faster. data_array = pa.array(data) if type_ is None else \ pa.array(data, type=type_) validity = pa.py_buffer(np.packbits(~mask, bitorder='little')) return pa.Array.from_buffers( data_array.type, len(data_array), [validity, data_array.buffers()[1]] ) clickhouse-driver-0.2.11/clickhouse_driver/arrow/mapping.py000066400000000000000000000154361522645447600241100ustar00rootroot00000000000000import json import pyarrow as pa from ..columns.util import ( get_inner_columns, get_inner_columns_with_types, get_inner_spec ) SIMPLE_TYPES = { 'Int8': pa.int8(), 'Int16': pa.int16(), 'Int32': pa.int32(), 'Int64': pa.int64(), 'UInt8': pa.uint8(), 'UInt16': pa.uint16(), 'UInt32': pa.uint32(), 'UInt64': pa.uint64(), 'Float32': pa.float32(), 'Float64': pa.float64(), 'Date': pa.date32(), 'Date32': pa.date32(), 'Bool': pa.bool_(), 'Nothing': pa.null() } # Types represented by rich Python objects are stringified. STRINGIFIED_TYPES = {'UUID', 'IPv4', 'IPv6'} DECIMAL_PRECISIONS = { 'Decimal32': 9, 'Decimal64': 18, 'Decimal128': 38, 'Decimal256': 76 } #: Types with no default Arrow representation: an explicit #: ``arrow_types`` entry is required for such columns. UNSUPPORTED = object() def json_as_text(column_name): """ JSON column value to JSON text. Requires output_format_native_write_json_as_string=1: the server sends JSON text which is passed through as is. There is deliberately no client-side serialization fallback to avoid performance bottlenecks. """ def converter(value): if isinstance(value, str): return value or '{}' raise ValueError( "Column '{0}': JSON text output requires server-side " 'serialization. Set ' 'output_format_native_write_json_as_string=1 in query ' 'settings (ClickHouse 24.10+) or transform the column in ' 'the query with toJSONString().'.format(column_name) ) return converter def json_as_object(value): """JSON column value to python objects for structured types.""" if isinstance(value, str): return json.loads(value) if value else {} return value def get_type_and_converter(spec, strings_as_bytes=False): """ Maps ClickHouse type spec into pair (Arrow type, converter). Arrow type is ``None`` for types without explicit mapping. Their Arrow type is inferred from data later. Converter is a callable applied to each non-NULL value before array construction or ``None`` if values can be handled by Arrow as is. """ spec = spec.strip() if spec in SIMPLE_TYPES: return SIMPLE_TYPES[spec], None if spec in STRINGIFIED_TYPES: return pa.string(), str if spec == 'JSON' or spec.startswith('JSON('): # No default representation: dynamic paths make every implicit # choice either lossy or unstable. Requires arrow_types. return UNSUPPORTED, None if spec == 'String' or spec.startswith('FixedString'): if strings_as_bytes: return pa.binary(), None return pa.string(), None if spec.startswith('Enum'): return pa.string(), None if spec.startswith('Nullable('): return get_type_and_converter( get_inner_spec('Nullable', spec), strings_as_bytes ) if spec.startswith('LowCardinality('): return get_type_and_converter( get_inner_spec('LowCardinality', spec), strings_as_bytes ) if spec.startswith('SimpleAggregateFunction('): inner_spec = get_inner_columns( get_inner_spec('SimpleAggregateFunction', spec) )[-1] return get_type_and_converter(inner_spec, strings_as_bytes) if spec.startswith('Array('): inner_type, inner_converter = get_type_and_converter( get_inner_spec('Array', spec), strings_as_bytes ) if inner_type is None or inner_type is UNSUPPORTED: return inner_type, None if inner_converter is None: converter = None else: def converter(value, _converter=inner_converter): return [ None if x is None else _converter(x) for x in value ] return pa.list_(inner_type), converter if spec.startswith('Map('): key_spec, value_spec = get_inner_columns(get_inner_spec('Map', spec)) key_type, key_converter = get_type_and_converter( key_spec, strings_as_bytes ) value_type, value_converter = get_type_and_converter( value_spec, strings_as_bytes ) for t in (key_type, value_type): if t is None or t is UNSUPPORTED: return t, None if key_converter is None and value_converter is None: converter = None else: def converter(value, _kc=key_converter, _vc=value_converter): return [ ( _kc(k) if _kc else k, (None if v is None else _vc(v)) if _vc else v ) for k, v in value.items() ] return pa.map_(key_type, value_type), converter if spec.startswith("Object('json')"): # Legacy JSON type (servers 22.3-24.x): same dynamic nature, # same treatment as JSON. return UNSUPPORTED, None if spec.startswith('Tuple(') or spec.startswith('Nested('): # No explicit mapping (inference applies), but unsupported # element types must not leak into inference. prefix = 'Tuple' if spec.startswith('Tuple(') else 'Nested' inner_columns = get_inner_columns_with_types( get_inner_spec(prefix, spec) ) for _, inner_spec in inner_columns: inner_type, _ = get_type_and_converter( inner_spec, strings_as_bytes ) if inner_type is UNSUPPORTED: return UNSUPPORTED, None return None, None if spec.startswith('Decimal'): if spec.startswith('Decimal('): precision, scale = [ int(x) for x in get_inner_spec('Decimal', spec).split(',') ] else: prefix = spec.split('(')[0] if prefix not in DECIMAL_PRECISIONS: return None, None precision = DECIMAL_PRECISIONS[prefix] scale = int(get_inner_spec(prefix, spec)) if precision <= 38: return pa.decimal128(precision, scale), None return pa.decimal256(precision, scale), None if spec.startswith('DateTime64('): params = get_inner_columns(get_inner_spec('DateTime64', spec)) precision = int(params[0]) tz = params[1].strip("'") if len(params) > 1 else None if precision == 0: unit = 's' elif precision <= 3: unit = 'ms' elif precision <= 6: unit = 'us' else: unit = 'ns' return pa.timestamp(unit, tz=tz), None if spec.startswith('DateTime'): tz = None if spec.startswith('DateTime('): tz = get_inner_spec('DateTime', spec).strip("'") return pa.timestamp('s', tz=tz), None return None, None clickhouse-driver-0.2.11/clickhouse_driver/block.py000066400000000000000000000142471522645447600224140ustar00rootroot00000000000000from .columns.util import get_inner_spec, get_inner_columns_with_types from .reader import read_varint, read_binary_uint8, read_binary_int32 from .varint import write_varint from .writer import write_binary_uint8, write_binary_int32 class BlockInfo(object): is_overflows = False bucket_num = -1 def write(self, buf): # Set of pairs (`FIELD_NUM`, value) in binary form. Then 0. write_varint(1, buf) write_binary_uint8(self.is_overflows, buf) write_varint(2, buf) write_binary_int32(self.bucket_num, buf) write_varint(0, buf) def read(self, buf): while True: field_num = read_varint(buf) if not field_num: break if field_num == 1: self.is_overflows = bool(read_binary_uint8(buf)) elif field_num == 2: self.bucket_num = read_binary_int32(buf) class BaseBlock(object): def __init__(self, columns_with_types=None, data=None, info=None, types_check=False): self.columns_with_types = columns_with_types or [] self.types_check = types_check self.info = info or BlockInfo() self.data = self.normalize(data or []) super(BaseBlock, self).__init__() def normalize(self, data): return data @property def num_columns(self): raise NotImplementedError @property def num_rows(self): raise NotImplementedError def get_columns(self): raise NotImplementedError def get_rows(self): raise NotImplementedError def get_column_by_index(self, index): raise NotImplementedError def transposed(self): return list(zip(*self.data)) class ColumnOrientedBlock(BaseBlock): def normalize(self, data): if not data: return [] self._check_number_of_columns(data) self._check_all_columns_equal_length(data) return data @property def num_columns(self): return len(self.data) @property def num_rows(self): return len(self.data[0]) if self.num_columns else 0 def get_columns(self): return self.data def get_rows(self): return self.transposed() def get_column_by_index(self, index): return self.data[index] def _check_number_of_columns(self, data): expected_row_len = len(self.columns_with_types) got = len(data) if expected_row_len != got: msg = 'Expected {} columns, got {}'.format(expected_row_len, got) raise ValueError(msg) def _check_all_columns_equal_length(self, data): expected = len(data[0]) for column in data: got = len(column) if got != expected: msg = 'Expected {} rows, got {}'.format(expected, got) raise ValueError(msg) class RowOrientedBlock(BaseBlock): dict_row_types = (dict, ) tuple_row_types = (list, tuple) supported_row_types = dict_row_types + tuple_row_types def normalize(self, data): if not data: return [] # Guessing about whole data format by first row. first_row = data[0] if self.types_check: self._check_row_type(first_row) if isinstance(first_row, dict): self._mutate_dicts_to_rows(data) else: self._check_rows(data) return data @property def num_columns(self): if self.columns_with_types is not None: return len(self.columns_with_types) return len(self.data[0]) if self.num_rows else 0 @property def num_rows(self): return len(self.data) def get_columns(self): return self.transposed() def get_rows(self): return self.data def get_column_by_index(self, index): return [row[index] for row in self.data] def _mutate_dicts_to_rows(self, data): check_row_type = False if self.types_check: check_row_type = self._check_dict_row_type return self._pure_mutate_dicts_to_rows( data, self.columns_with_types, check_row_type, ) def _pure_mutate_dicts_to_rows( self, data, columns_with_types, check_row_type, ): columns_with_cwt = [] for name, type_ in columns_with_types: cwt = None if type_.startswith('Nested'): inner_spec = get_inner_spec('Nested', type_) cwt = get_inner_columns_with_types(inner_spec) columns_with_cwt.append((name, cwt)) for i, row in enumerate(data): if check_row_type: check_row_type(row) new_data = [] for name, cwt in columns_with_cwt: if cwt is None: new_data.append(row[name]) else: new_data.append(self._pure_mutate_dicts_to_rows( row[name], cwt, check_row_type )) data[i] = new_data # return for recursion return data def _check_rows(self, data): expected_row_len = len(self.columns_with_types) got = len(data[0]) if expected_row_len != got: msg = 'Expected {} columns, got {}'.format(expected_row_len, got) raise ValueError(msg) if self.types_check: check_row_type = self._check_tuple_row_type for row in data: check_row_type(row) def _check_row_type(self, row): if not isinstance(row, self.supported_row_types): raise TypeError( 'Unsupported row type: {}. dict, list or tuple is expected.' .format(type(row)) ) def _check_tuple_row_type(self, row): if not isinstance(row, self.tuple_row_types): raise TypeError( 'Unsupported row type: {}. list or tuple is expected.' .format(type(row)) ) def _check_dict_row_type(self, row): if not isinstance(row, self.dict_row_types): raise TypeError( 'Unsupported row type: {}. dict is expected.' .format(type(row)) ) clickhouse-driver-0.2.11/clickhouse_driver/blockstreamprofileinfo.py000066400000000000000000000013101522645447600260500ustar00rootroot00000000000000from .reader import read_binary_uint8 from .varint import read_varint class BlockStreamProfileInfo(object): def __init__(self): self.rows = 0 self.blocks = 0 self.bytes = 0 self.applied_limit = False # bool self.rows_before_limit = 0 self.calculated_rows_before_limit = 0 # bool super(BlockStreamProfileInfo, self).__init__() def read(self, fin): self.rows = read_varint(fin) self.blocks = read_varint(fin) self.bytes = read_varint(fin) self.applied_limit = bool(read_binary_uint8(fin)) self.rows_before_limit = read_varint(fin) self.calculated_rows_before_limit = bool(read_binary_uint8(fin)) clickhouse-driver-0.2.11/clickhouse_driver/bufferedreader.c000066400000000000000000027373241522645447600240730ustar00rootroot00000000000000/* Generated by Cython 3.2.0 */ /* BEGIN: Cython Metadata { "distutils": { "depends": [], "name": "clickhouse_driver.bufferedreader", "sources": [ "/Users/kgustyr/dev/clickhouse-driver/clickhouse_driver/bufferedreader.pyx" ] }, "module_name": "clickhouse_driver.bufferedreader" } END: Cython Metadata */ #ifndef PY_SSIZE_T_CLEAN #define PY_SSIZE_T_CLEAN #endif /* PY_SSIZE_T_CLEAN */ /* InitLimitedAPI */ #if defined(Py_LIMITED_API) #if !defined(CYTHON_LIMITED_API) #define CYTHON_LIMITED_API 1 #endif #elif defined(CYTHON_LIMITED_API) #ifdef _MSC_VER #pragma message ("Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead.") #else #warning Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead. #endif #endif #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x03080000 #error Cython requires Python 3.8+. #else #define __PYX_ABI_VERSION "3_2_0" #define CYTHON_HEX_VERSION 0x030200F0 #define CYTHON_FUTURE_DIVISION 1 /* CModulePreamble */ #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(_WIN32) && !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #define __PYX_COMMA , #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #define __PYX_LIMITED_VERSION_HEX PY_VERSION_HEX #if defined(GRAALVM_PYTHON) /* For very preliminary testing purposes. Most variables are set the same as PyPy. The existence of this section does not imply that anything works or is even tested */ #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 1 #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_ASSUME_SAFE_SIZE #define CYTHON_ASSUME_SAFE_SIZE 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #undef CYTHON_USE_SYS_MONITORING #define CYTHON_USE_SYS_MONITORING 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #undef CYTHON_USE_AM_SEND #define CYTHON_USE_AM_SEND 0 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 1 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #undef CYTHON_USE_FREELISTS #define CYTHON_USE_FREELISTS 0 #undef CYTHON_IMMORTAL_CONSTANTS #define CYTHON_IMMORTAL_CONSTANTS 0 #elif defined(PYPY_VERSION) #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #ifndef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #endif #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #ifndef CYTHON_ASSUME_SAFE_SIZE #define CYTHON_ASSUME_SAFE_SIZE 1 #endif #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #if PY_VERSION_HEX < 0x03090000 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT) #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #undef CYTHON_USE_SYS_MONITORING #define CYTHON_USE_SYS_MONITORING 0 #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE (PYPY_VERSION_NUM >= 0x07030C00) #endif #undef CYTHON_USE_AM_SEND #define CYTHON_USE_AM_SEND 0 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_NUM >= 0x07031100) #endif #undef CYTHON_USE_FREELISTS #define CYTHON_USE_FREELISTS 0 #undef CYTHON_IMMORTAL_CONSTANTS #define CYTHON_IMMORTAL_CONSTANTS 0 #elif defined(CYTHON_LIMITED_API) #ifdef Py_LIMITED_API #undef __PYX_LIMITED_VERSION_HEX #define __PYX_LIMITED_VERSION_HEX Py_LIMITED_API #endif #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 1 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 1 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #ifndef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #endif #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0 #endif #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_ASSUME_SAFE_SIZE #define CYTHON_ASSUME_SAFE_SIZE 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL (__PYX_LIMITED_VERSION_HEX >= 0x030C0000) #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #ifndef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #endif #undef CYTHON_USE_SYS_MONITORING #define CYTHON_USE_SYS_MONITORING 0 #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #endif #ifndef CYTHON_USE_AM_SEND #define CYTHON_USE_AM_SEND (__PYX_LIMITED_VERSION_HEX >= 0x030A0000) #endif #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #ifndef CYTHON_USE_FREELISTS #define CYTHON_USE_FREELISTS 1 #endif #undef CYTHON_IMMORTAL_CONSTANTS #define CYTHON_IMMORTAL_CONSTANTS 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 0 #ifdef Py_GIL_DISABLED #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 1 #else #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0 #endif #if PY_VERSION_HEX < 0x030A0000 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #elif !defined(CYTHON_USE_TYPE_SLOTS) #define CYTHON_USE_TYPE_SLOTS 1 #endif #ifndef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #endif #ifndef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 1 #endif #ifndef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #elif !defined(CYTHON_USE_PYLIST_INTERNALS) #define CYTHON_USE_PYLIST_INTERNALS 1 #endif #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING || PY_VERSION_HEX >= 0x030B00A2 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #elif !defined(CYTHON_USE_UNICODE_WRITER) #define CYTHON_USE_UNICODE_WRITER 1 #endif #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1 #elif !defined(CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS) #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_ASSUME_SAFE_SIZE #define CYTHON_ASSUME_SAFE_SIZE 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #ifndef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 1 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #elif !defined(CYTHON_FAST_GIL) #define CYTHON_FAST_GIL (PY_VERSION_HEX < 0x030C00A6) #endif #ifndef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 1 #endif #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #ifndef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #endif #ifndef CYTHON_USE_SYS_MONITORING #define CYTHON_USE_SYS_MONITORING (PY_VERSION_HEX >= 0x030d00B1) #endif #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 1 #endif #ifndef CYTHON_USE_AM_SEND #define CYTHON_USE_AM_SEND 1 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #elif !defined(CYTHON_USE_DICT_VERSIONS) #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX < 0x030C00A5 && !CYTHON_USE_MODULE_STATE) #endif #ifndef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 1 #endif #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 1 #endif #ifndef CYTHON_USE_FREELISTS #define CYTHON_USE_FREELISTS (!CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) #endif #if defined(CYTHON_IMMORTAL_CONSTANTS) && PY_VERSION_HEX < 0x030C0000 #undef CYTHON_IMMORTAL_CONSTANTS #define CYTHON_IMMORTAL_CONSTANTS 0 // definitely won't work #elif !defined(CYTHON_IMMORTAL_CONSTANTS) #define CYTHON_IMMORTAL_CONSTANTS (PY_VERSION_HEX >= 0x030C0000 && !CYTHON_USE_MODULE_STATE && CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) #endif #endif #ifndef CYTHON_COMPRESS_STRINGS #define CYTHON_COMPRESS_STRINGS 1 #endif #ifndef CYTHON_FAST_PYCCALL #define CYTHON_FAST_PYCCALL CYTHON_FAST_PYCALL #endif #ifndef CYTHON_VECTORCALL #if CYTHON_COMPILING_IN_LIMITED_API #define CYTHON_VECTORCALL (__PYX_LIMITED_VERSION_HEX >= 0x030C0000) #else #define CYTHON_VECTORCALL (CYTHON_FAST_PYCCALL) #endif #endif #if CYTHON_USE_PYLONG_INTERNALS #undef SHIFT #undef BASE #undef MASK #ifdef SIZEOF_VOID_P enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; #endif #endif #ifndef __has_attribute #define __has_attribute(x) 0 #endif #ifndef __has_cpp_attribute #define __has_cpp_attribute(x) 0 #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #ifndef CYTHON_UNUSED #if defined(__cplusplus) /* for clang __has_cpp_attribute(maybe_unused) is true even before C++17 * but leads to warnings with -pedantic, since it is a C++17 feature */ #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) #if __has_cpp_attribute(maybe_unused) #define CYTHON_UNUSED [[maybe_unused]] #endif #endif #endif #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_UNUSED_VAR # if defined(__cplusplus) template void CYTHON_UNUSED_VAR( const T& ) { } # else # define CYTHON_UNUSED_VAR(x) (void)(x) # endif #endif #ifndef CYTHON_MAYBE_UNUSED_VAR #define CYTHON_MAYBE_UNUSED_VAR(x) CYTHON_UNUSED_VAR(x) #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif #ifndef CYTHON_USE_CPP_STD_MOVE #if defined(__cplusplus) && (\ __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)) #define CYTHON_USE_CPP_STD_MOVE 1 #else #define CYTHON_USE_CPP_STD_MOVE 0 #endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #include typedef uintptr_t __pyx_uintptr_t; #ifndef CYTHON_FALLTHROUGH #if defined(__cplusplus) /* for clang __has_cpp_attribute(fallthrough) is true even before C++17 * but leads to warnings with -pedantic, since it is a C++17 feature */ #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) #if __has_cpp_attribute(fallthrough) #define CYTHON_FALLTHROUGH [[fallthrough]] #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_cpp_attribute(clang::fallthrough) #define CYTHON_FALLTHROUGH [[clang::fallthrough]] #elif __has_cpp_attribute(gnu::fallthrough) #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] #endif #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_attribute(fallthrough) #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) #else #define CYTHON_FALLTHROUGH #endif #endif #if defined(__clang__) && defined(__apple_build_version__) #if __apple_build_version__ < 7000000 #undef CYTHON_FALLTHROUGH #define CYTHON_FALLTHROUGH #endif #endif #endif #ifndef Py_UNREACHABLE #define Py_UNREACHABLE() assert(0); abort() #endif #ifdef __cplusplus template struct __PYX_IS_UNSIGNED_IMPL {static const bool value = T(0) < T(-1);}; #define __PYX_IS_UNSIGNED(type) (__PYX_IS_UNSIGNED_IMPL::value) #else #define __PYX_IS_UNSIGNED(type) (((type)-1) > 0) #endif #if CYTHON_COMPILING_IN_PYPY == 1 #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX < 0x030A0000) #else #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX < 0x03090000) #endif #define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer)) /* CInitCode */ #ifndef CYTHON_INLINE #if defined(__clang__) #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) #elif defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #endif /* PythonCompatibility */ #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_DefaultClassType PyType_Type #if CYTHON_COMPILING_IN_LIMITED_API #ifndef CO_OPTIMIZED static int CO_OPTIMIZED; #endif #ifndef CO_NEWLOCALS static int CO_NEWLOCALS; #endif #ifndef CO_VARARGS static int CO_VARARGS; #endif #ifndef CO_VARKEYWORDS static int CO_VARKEYWORDS; #endif #ifndef CO_ASYNC_GENERATOR static int CO_ASYNC_GENERATOR; #endif #ifndef CO_GENERATOR static int CO_GENERATOR; #endif #ifndef CO_COROUTINE static int CO_COROUTINE; #endif #else #ifndef CO_COROUTINE #define CO_COROUTINE 0x80 #endif #ifndef CO_ASYNC_GENERATOR #define CO_ASYNC_GENERATOR 0x200 #endif #endif static int __Pyx_init_co_variables(void); #if PY_VERSION_HEX >= 0x030900A4 || defined(Py_IS_TYPE) #define __Pyx_IS_TYPE(ob, type) Py_IS_TYPE(ob, type) #else #define __Pyx_IS_TYPE(ob, type) (((const PyObject*)ob)->ob_type == (type)) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_Is) #define __Pyx_Py_Is(x, y) Py_Is(x, y) #else #define __Pyx_Py_Is(x, y) ((x) == (y)) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsNone) #define __Pyx_Py_IsNone(ob) Py_IsNone(ob) #else #define __Pyx_Py_IsNone(ob) __Pyx_Py_Is((ob), Py_None) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsTrue) #define __Pyx_Py_IsTrue(ob) Py_IsTrue(ob) #else #define __Pyx_Py_IsTrue(ob) __Pyx_Py_Is((ob), Py_True) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsFalse) #define __Pyx_Py_IsFalse(ob) Py_IsFalse(ob) #else #define __Pyx_Py_IsFalse(ob) __Pyx_Py_Is((ob), Py_False) #endif #define __Pyx_NoneAsNull(obj) (__Pyx_Py_IsNone(obj) ? NULL : (obj)) #if PY_VERSION_HEX >= 0x030900F0 && !CYTHON_COMPILING_IN_PYPY #define __Pyx_PyObject_GC_IsFinalized(o) PyObject_GC_IsFinalized(o) #else #define __Pyx_PyObject_GC_IsFinalized(o) _PyGC_FINALIZED(o) #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #ifndef Py_TPFLAGS_SEQUENCE #define Py_TPFLAGS_SEQUENCE 0 #endif #ifndef Py_TPFLAGS_MAPPING #define Py_TPFLAGS_MAPPING 0 #endif #ifndef Py_TPFLAGS_IMMUTABLETYPE #define Py_TPFLAGS_IMMUTABLETYPE (1UL << 8) #endif #ifndef Py_TPFLAGS_DISALLOW_INSTANTIATION #define Py_TPFLAGS_DISALLOW_INSTANTIATION (1UL << 7) #endif #ifndef METH_STACKLESS #define METH_STACKLESS 0 #endif #ifndef METH_FASTCALL #ifndef METH_FASTCALL #define METH_FASTCALL 0x80 #endif typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames); #else #if PY_VERSION_HEX >= 0x030d00A4 # define __Pyx_PyCFunctionFast PyCFunctionFast # define __Pyx_PyCFunctionFastWithKeywords PyCFunctionFastWithKeywords #else # define __Pyx_PyCFunctionFast _PyCFunctionFast # define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords #endif #endif #if CYTHON_METH_FASTCALL #define __Pyx_METH_FASTCALL METH_FASTCALL #define __Pyx_PyCFunction_FastCall __Pyx_PyCFunctionFast #define __Pyx_PyCFunction_FastCallWithKeywords __Pyx_PyCFunctionFastWithKeywords #else #define __Pyx_METH_FASTCALL METH_VARARGS #define __Pyx_PyCFunction_FastCall PyCFunction #define __Pyx_PyCFunction_FastCallWithKeywords PyCFunctionWithKeywords #endif #if CYTHON_VECTORCALL #define __pyx_vectorcallfunc vectorcallfunc #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET PY_VECTORCALL_ARGUMENTS_OFFSET #define __Pyx_PyVectorcall_NARGS(n) PyVectorcall_NARGS((size_t)(n)) #else #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET 0 #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(n)) #endif #if PY_VERSION_HEX >= 0x030900B1 #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_CheckExact(func) #else #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_Check(func) #endif #define __Pyx_CyOrPyCFunction_Check(func) PyCFunction_Check(func) #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) (((PyCFunctionObject*)(func))->m_ml->ml_meth) #elif !CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(func) #endif #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CyOrPyCFunction_GET_FLAGS(func) (((PyCFunctionObject*)(func))->m_ml->ml_flags) static CYTHON_INLINE PyObject* __Pyx_CyOrPyCFunction_GET_SELF(PyObject *func) { return (__Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_STATIC) ? NULL : ((PyCFunctionObject*)func)->m_self; } #endif static CYTHON_INLINE int __Pyx__IsSameCFunction(PyObject *func, void (*cfunc)(void)) { #if CYTHON_COMPILING_IN_LIMITED_API return PyCFunction_Check(func) && PyCFunction_GetFunction(func) == (PyCFunction) cfunc; #else return PyCFunction_Check(func) && PyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; #endif } #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCFunction(func, cfunc) #if PY_VERSION_HEX < 0x03090000 || (CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000) #define __Pyx_PyType_FromModuleAndSpec(m, s, b) ((void)m, PyType_FromSpecWithBases(s, b)) typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *); #else #define __Pyx_PyType_FromModuleAndSpec(m, s, b) PyType_FromModuleAndSpec(m, s, b) #define __Pyx_PyCMethod PyCMethod #endif #ifndef METH_METHOD #define METH_METHOD 0x200 #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) #define PyObject_Malloc(s) PyMem_Malloc(s) #define PyObject_Free(p) PyMem_Free(p) #define PyObject_Realloc(p) PyMem_Realloc(p) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyFrame_SetLineNumber(frame, lineno) #elif CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) GraalPyFrame_SetLineNumber((frame), (lineno)) #elif CYTHON_COMPILING_IN_GRAAL #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) _PyFrame_SetLineNumber((frame), (lineno)) #else #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyThreadState_Current PyThreadState_Get() #elif !CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_Current PyThreadState_GET() #elif PY_VERSION_HEX >= 0x030d00A1 #define __Pyx_PyThreadState_Current PyThreadState_GetUnchecked() #else #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() #endif #if CYTHON_USE_MODULE_STATE static CYTHON_INLINE void *__Pyx__PyModule_GetState(PyObject *op) { void *result; result = PyModule_GetState(op); if (!result) Py_FatalError("Couldn't find the module state"); return result; } #define __Pyx_PyModule_GetState(o) (__pyx_mstatetype *)__Pyx__PyModule_GetState(o) #else #define __Pyx_PyModule_GetState(op) ((void)op,__pyx_mstate_global) #endif #define __Pyx_PyObject_GetSlot(obj, name, func_ctype) __Pyx_PyType_GetSlot(Py_TYPE((PyObject *) obj), name, func_ctype) #define __Pyx_PyObject_TryGetSlot(obj, name, func_ctype) __Pyx_PyType_TryGetSlot(Py_TYPE(obj), name, func_ctype) #define __Pyx_PyObject_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(Py_TYPE(obj), sub, name, func_ctype) #define __Pyx_PyObject_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSubSlot(Py_TYPE(obj), sub, name, func_ctype) #if CYTHON_USE_TYPE_SLOTS #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((type)->name) #define __Pyx_PyType_TryGetSlot(type, name, func_ctype) __Pyx_PyType_GetSlot(type, name, func_ctype) #define __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype) (((type)->sub) ? ((type)->sub->name) : NULL) #define __Pyx_PyType_TryGetSubSlot(type, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype) #else #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((func_ctype) PyType_GetSlot((type), Py_##name)) #define __Pyx_PyType_TryGetSlot(type, name, func_ctype)\ ((__PYX_LIMITED_VERSION_HEX >= 0x030A0000 ||\ (PyType_GetFlags(type) & Py_TPFLAGS_HEAPTYPE) || __Pyx_get_runtime_version() >= 0x030A0000) ?\ __Pyx_PyType_GetSlot(type, name, func_ctype) : NULL) #define __Pyx_PyType_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSlot(obj, name, func_ctype) #define __Pyx_PyType_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSlot(obj, name, func_ctype) #endif #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) #else #define __Pyx_PyDict_NewPresized(n) PyDict_New() #endif #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_UNICODE_INTERNALS #define __Pyx_PyDict_GetItemStrWithError(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) { PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name); if (res == NULL) PyErr_Clear(); return res; } #elif !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000 #define __Pyx_PyDict_GetItemStrWithError PyDict_GetItemWithError #define __Pyx_PyDict_GetItemStr PyDict_GetItem #else static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, PyObject *name) { #if CYTHON_COMPILING_IN_PYPY return PyDict_GetItem(dict, name); #else PyDictEntry *ep; PyDictObject *mp = (PyDictObject*) dict; long hash = ((PyStringObject *) name)->ob_shash; assert(hash != -1); ep = (mp->ma_lookup)(mp, name, hash); if (ep == NULL) { return NULL; } return ep->me_value; #endif } #define __Pyx_PyDict_GetItemStr PyDict_GetItem #endif #if CYTHON_USE_TYPE_SLOTS #define __Pyx_PyType_GetFlags(tp) (((PyTypeObject *)tp)->tp_flags) #define __Pyx_PyType_HasFeature(type, feature) ((__Pyx_PyType_GetFlags(type) & (feature)) != 0) #else #define __Pyx_PyType_GetFlags(tp) (PyType_GetFlags((PyTypeObject *)tp)) #define __Pyx_PyType_HasFeature(type, feature) PyType_HasFeature(type, feature) #endif #define __Pyx_PyObject_GetIterNextFunc(iterator) __Pyx_PyObject_GetSlot(iterator, tp_iternext, iternextfunc) #if CYTHON_USE_TYPE_SPECS #define __Pyx_PyHeapTypeObject_GC_Del(obj) {\ PyTypeObject *type = Py_TYPE((PyObject*)obj);\ assert(__Pyx_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE));\ PyObject_GC_Del(obj);\ Py_DECREF(type);\ } #else #define __Pyx_PyHeapTypeObject_GC_Del(obj) PyObject_GC_Del(obj) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_ReadChar(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((void)u, 1114111U) #define __Pyx_PyUnicode_KIND(u) ((void)u, (0)) #define __Pyx_PyUnicode_DATA(u) ((void*)u) #define __Pyx_PyUnicode_READ(k, d, i) ((void)k, PyUnicode_ReadChar((PyObject*)(d), i)) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GetLength(u)) #else #if PY_VERSION_HEX >= 0x030C0000 #define __Pyx_PyUnicode_READY(op) (0) #else #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #endif #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) #define __Pyx_PyUnicode_KIND(u) ((int)PyUnicode_KIND(u)) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, (Py_UCS4) ch) #if PY_VERSION_HEX >= 0x030C0000 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) #else #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) #else #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) #endif #endif #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY #if !defined(PyUnicode_DecodeUnicodeEscape) #define PyUnicode_DecodeUnicodeEscape(s, size, errors) PyUnicode_Decode(s, size, "unicode_escape", errors) #endif #if !defined(PyUnicode_Contains) #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #if !defined(PyByteArray_Check) #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) #endif #if !defined(PyObject_Format) #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) #endif #endif #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 #define __Pyx_PySequence_ListKeepNew(obj)\ (likely(PyList_CheckExact(obj) && PyUnstable_Object_IsUniquelyReferenced(obj)) ? __Pyx_NewRef(obj) : PySequence_List(obj)) #elif CYTHON_COMPILING_IN_CPYTHON #define __Pyx_PySequence_ListKeepNew(obj)\ (likely(PyList_CheckExact(obj) && Py_REFCNT(obj) == 1) ? __Pyx_NewRef(obj) : PySequence_List(obj)) #else #define __Pyx_PySequence_ListKeepNew(obj) PySequence_List(obj) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) __Pyx_IS_TYPE(obj, &PySet_Type) #endif #if PY_VERSION_HEX >= 0x030900A4 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) #else #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) #endif enum __Pyx_ReferenceSharing { __Pyx_ReferenceSharing_DefinitelyUnique, // We created it so we know it's unshared - no need to check __Pyx_ReferenceSharing_OwnStrongReference, __Pyx_ReferenceSharing_FunctionArgument, __Pyx_ReferenceSharing_SharedReference, // Never trust it to be unshared because it's a global or similar }; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && PY_VERSION_HEX >= 0x030E0000 #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing)\ (sharing == __Pyx_ReferenceSharing_DefinitelyUnique ? 1 :\ (sharing == __Pyx_ReferenceSharing_FunctionArgument ? PyUnstable_Object_IsUniqueReferencedTemporary(o) :\ (sharing == __Pyx_ReferenceSharing_OwnStrongReference ? PyUnstable_Object_IsUniquelyReferenced(o) : 0))) #elif (CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)sharing), Py_REFCNT(o) == 1) #else #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)o), ((void)sharing), 0) #endif #if CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyList_GetItemRef(o, i) PyList_GetItemRef(o, i) #elif CYTHON_COMPILING_IN_LIMITED_API || !CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PyList_GetItemRef(o, i) (likely((i) >= 0) ? PySequence_GetItem(o, i) : (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) #else #define __Pyx_PyList_GetItemRef(o, i) PySequence_ITEM(o, i) #endif #elif CYTHON_COMPILING_IN_LIMITED_API || !CYTHON_ASSUME_SAFE_MACROS #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyList_GetItemRef(o, i) PyList_GetItemRef(o, i) #else #define __Pyx_PyList_GetItemRef(o, i) __Pyx_XNewRef(PyList_GetItem(o, i)) #endif #else #define __Pyx_PyList_GetItemRef(o, i) __Pyx_NewRef(PyList_GET_ITEM(o, i)) #endif #if CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS && !CYTHON_COMPILING_IN_LIMITED_API && CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PyList_GetItemRefFast(o, i, unsafe_shared) (__Pyx_IS_UNIQUELY_REFERENCED(o, unsafe_shared) ?\ __Pyx_NewRef(PyList_GET_ITEM(o, i)) : __Pyx_PyList_GetItemRef(o, i)) #else #define __Pyx_PyList_GetItemRefFast(o, i, unsafe_shared) __Pyx_PyList_GetItemRef(o, i) #endif #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyDict_GetItemRef(dict, key, result) PyDict_GetItemRef(dict, key, result) #elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) { *result = PyObject_GetItem(dict, key); if (*result == NULL) { if (PyErr_ExceptionMatches(PyExc_KeyError)) { PyErr_Clear(); return 0; } return -1; } return 1; } #else static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) { *result = PyDict_GetItemWithError(dict, key); if (*result == NULL) { return PyErr_Occurred() ? -1 : 0; } Py_INCREF(*result); return 1; } #endif #if defined(CYTHON_DEBUG_VISIT_CONST) && CYTHON_DEBUG_VISIT_CONST #define __Pyx_VISIT_CONST(obj) Py_VISIT(obj) #else #define __Pyx_VISIT_CONST(obj) #endif #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PySequence_ITEM(o, i) PySequence_ITEM(o, i) #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) #define __Pyx_PyTuple_SET_ITEM(o, i, v) (PyTuple_SET_ITEM(o, i, v), (0)) #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GET_ITEM(o, i) #define __Pyx_PyList_SET_ITEM(o, i, v) (PyList_SET_ITEM(o, i, v), (0)) #define __Pyx_PyList_GET_ITEM(o, i) PyList_GET_ITEM(o, i) #else #define __Pyx_PySequence_ITEM(o, i) PySequence_GetItem(o, i) #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) #define __Pyx_PyTuple_SET_ITEM(o, i, v) PyTuple_SetItem(o, i, v) #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GetItem(o, i) #define __Pyx_PyList_SET_ITEM(o, i, v) PyList_SetItem(o, i, v) #define __Pyx_PyList_GET_ITEM(o, i) PyList_GetItem(o, i) #endif #if CYTHON_ASSUME_SAFE_SIZE #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_GET_SIZE(o) #define __Pyx_PyList_GET_SIZE(o) PyList_GET_SIZE(o) #define __Pyx_PySet_GET_SIZE(o) PySet_GET_SIZE(o) #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o) #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_GET_SIZE(o) #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GET_LENGTH(o) #else #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_Size(o) #define __Pyx_PyList_GET_SIZE(o) PyList_Size(o) #define __Pyx_PySet_GET_SIZE(o) PySet_Size(o) #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_Size(o) #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_Size(o) #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GetLength(o) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_InternFromString) #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #define __Pyx_PyLong_FromHash_t PyLong_FromSsize_t #define __Pyx_PyLong_AsHash_t __Pyx_PyIndex_AsSsize_t #if __PYX_LIMITED_VERSION_HEX >= 0x030A0000 #define __Pyx_PySendResult PySendResult #else typedef enum { PYGEN_RETURN = 0, PYGEN_ERROR = -1, PYGEN_NEXT = 1, } __Pyx_PySendResult; #endif #if CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX < 0x030A00A3 typedef __Pyx_PySendResult (*__Pyx_pyiter_sendfunc)(PyObject *iter, PyObject *value, PyObject **result); #else #define __Pyx_pyiter_sendfunc sendfunc #endif #if !CYTHON_USE_AM_SEND #define __PYX_HAS_PY_AM_SEND 0 #elif __PYX_LIMITED_VERSION_HEX >= 0x030A0000 #define __PYX_HAS_PY_AM_SEND 1 #else #define __PYX_HAS_PY_AM_SEND 2 // our own backported implementation #endif #if __PYX_HAS_PY_AM_SEND < 2 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #else typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; __Pyx_pyiter_sendfunc am_send; } __Pyx_PyAsyncMethodsStruct; #define __Pyx_SlotTpAsAsync(s) ((PyAsyncMethods*)(s)) #endif #if CYTHON_USE_AM_SEND && PY_VERSION_HEX < 0x030A00F0 #define __Pyx_TPFLAGS_HAVE_AM_SEND (1UL << 21) #else #define __Pyx_TPFLAGS_HAVE_AM_SEND (0) #endif #if PY_VERSION_HEX >= 0x03090000 #define __Pyx_PyInterpreterState_Get() PyInterpreterState_Get() #else #define __Pyx_PyInterpreterState_Get() PyThreadState_Get()->interp #endif #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030A0000 #ifdef __cplusplus extern "C" #endif PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize); #endif #if CYTHON_COMPILING_IN_LIMITED_API static int __Pyx_init_co_variable(PyObject *inspect, const char* name, int *write_to) { int value; PyObject *py_value = PyObject_GetAttrString(inspect, name); if (!py_value) return 0; value = (int) PyLong_AsLong(py_value); Py_DECREF(py_value); *write_to = value; return value != -1 || !PyErr_Occurred(); } static int __Pyx_init_co_variables(void) { PyObject *inspect; int result; inspect = PyImport_ImportModule("inspect"); result = #if !defined(CO_OPTIMIZED) __Pyx_init_co_variable(inspect, "CO_OPTIMIZED", &CO_OPTIMIZED) && #endif #if !defined(CO_NEWLOCALS) __Pyx_init_co_variable(inspect, "CO_NEWLOCALS", &CO_NEWLOCALS) && #endif #if !defined(CO_VARARGS) __Pyx_init_co_variable(inspect, "CO_VARARGS", &CO_VARARGS) && #endif #if !defined(CO_VARKEYWORDS) __Pyx_init_co_variable(inspect, "CO_VARKEYWORDS", &CO_VARKEYWORDS) && #endif #if !defined(CO_ASYNC_GENERATOR) __Pyx_init_co_variable(inspect, "CO_ASYNC_GENERATOR", &CO_ASYNC_GENERATOR) && #endif #if !defined(CO_GENERATOR) __Pyx_init_co_variable(inspect, "CO_GENERATOR", &CO_GENERATOR) && #endif #if !defined(CO_COROUTINE) __Pyx_init_co_variable(inspect, "CO_COROUTINE", &CO_COROUTINE) && #endif 1; Py_DECREF(inspect); return result ? 0 : -1; } #else static int __Pyx_init_co_variables(void) { return 0; // It's a limited API-only feature } #endif /* MathInitCode */ #if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS) #ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES #endif #endif #include #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) #define __Pyx_truncl trunc #else #define __Pyx_truncl truncl #endif #ifndef CYTHON_CLINE_IN_TRACEBACK_RUNTIME #define CYTHON_CLINE_IN_TRACEBACK_RUNTIME 0 #endif #ifndef CYTHON_CLINE_IN_TRACEBACK #define CYTHON_CLINE_IN_TRACEBACK CYTHON_CLINE_IN_TRACEBACK_RUNTIME #endif #if CYTHON_CLINE_IN_TRACEBACK #define __PYX_MARK_ERR_POS(f_index, lineno) { __pyx_filename = __pyx_f[f_index]; (void) __pyx_filename; __pyx_lineno = lineno; (void) __pyx_lineno; __pyx_clineno = __LINE__; (void) __pyx_clineno; } #else #define __PYX_MARK_ERR_POS(f_index, lineno) { __pyx_filename = __pyx_f[f_index]; (void) __pyx_filename; __pyx_lineno = lineno; (void) __pyx_lineno; (void) __pyx_clineno; } #endif #define __PYX_ERR(f_index, lineno, Ln_error) \ { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } #ifdef CYTHON_EXTERN_C #undef __PYX_EXTERN_C #define __PYX_EXTERN_C CYTHON_EXTERN_C #elif defined(__PYX_EXTERN_C) #ifdef _MSC_VER #pragma message ("Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.") #else #warning Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead. #endif #else #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__clickhouse_driver__bufferedreader #define __PYX_HAVE_API__clickhouse_driver__bufferedreader /* Early includes */ #include #include #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyFloat_FromString(obj) PyFloat_FromString(obj) #else #define __Pyx_PyFloat_FromString(obj) PyFloat_FromString(obj, NULL) #endif #include #if PY_MAJOR_VERSION <= 2 #define PyDict_GetItemWithError _PyDict_GetItemWithError #endif #if PY_VERSION_HEX < 0x030d0000 static CYTHON_INLINE int __Pyx_PyWeakref_GetRef(PyObject *ref, PyObject **pobj) { PyObject *obj = PyWeakref_GetObject(ref); if (obj == NULL) { // SystemError if ref is NULL *pobj = NULL; return -1; } if (obj == Py_None) { *pobj = NULL; return 0; } Py_INCREF(obj); *pobj = obj; return 1; } #else #define __Pyx_PyWeakref_GetRef PyWeakref_GetRef #endif #include "pythread.h" #if (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030600) && !defined(PyContextVar_Get) #define PyContextVar_Get(var, d, v) ((d) ? ((void)(var), Py_INCREF(d), (v)[0] = (d), 0) : ((v)[0] = NULL, 0) ) #endif #ifdef _OPENMP #include #endif /* _OPENMP */ #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0 #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { return (size_t) i < (size_t) limit; } #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s); static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char*); #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyByteArray_AsString(s) PyByteArray_AS_STRING(s) #else #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AsString(s)) #define __Pyx_PyByteArray_AsString(s) PyByteArray_AsString(s) #endif #define __Pyx_PyObject_AsWritableString(s) ((char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) #define __Pyx_PyUnicode_FromOrdinal(o) PyUnicode_FromOrdinal((int)o) #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode static CYTHON_INLINE PyObject *__Pyx_NewRef(PyObject *obj) { #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_NewRef) return Py_NewRef(obj); #else Py_INCREF(obj); return obj; #endif } static CYTHON_INLINE PyObject *__Pyx_XNewRef(PyObject *obj) { #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_XNewRef) return Py_XNewRef(obj); #else Py_XINCREF(obj); return obj; #endif } static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b); static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x); #define __Pyx_PySequence_Tuple(obj)\ (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t); static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AS_DOUBLE(x) #else #define __Pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AsDouble(x) #endif #define __Pyx_PyFloat_AsFloat(x) ((float) __Pyx_PyFloat_AsDouble(x)) #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) #if CYTHON_USE_PYLONG_INTERNALS #if PY_VERSION_HEX >= 0x030C00A7 #ifndef _PyLong_SIGN_MASK #define _PyLong_SIGN_MASK 3 #endif #ifndef _PyLong_NON_SIZE_BITS #define _PyLong_NON_SIZE_BITS 3 #endif #define __Pyx_PyLong_Sign(x) (((PyLongObject*)x)->long_value.lv_tag & _PyLong_SIGN_MASK) #define __Pyx_PyLong_IsNeg(x) ((__Pyx_PyLong_Sign(x) & 2) != 0) #define __Pyx_PyLong_IsNonNeg(x) (!__Pyx_PyLong_IsNeg(x)) #define __Pyx_PyLong_IsZero(x) (__Pyx_PyLong_Sign(x) & 1) #define __Pyx_PyLong_IsPos(x) (__Pyx_PyLong_Sign(x) == 0) #define __Pyx_PyLong_CompactValueUnsigned(x) (__Pyx_PyLong_Digits(x)[0]) #define __Pyx_PyLong_DigitCount(x) ((Py_ssize_t) (((PyLongObject*)x)->long_value.lv_tag >> _PyLong_NON_SIZE_BITS)) #define __Pyx_PyLong_SignedDigitCount(x)\ ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * __Pyx_PyLong_DigitCount(x)) #if defined(PyUnstable_Long_IsCompact) && defined(PyUnstable_Long_CompactValue) #define __Pyx_PyLong_IsCompact(x) PyUnstable_Long_IsCompact((PyLongObject*) x) #define __Pyx_PyLong_CompactValue(x) PyUnstable_Long_CompactValue((PyLongObject*) x) #else #define __Pyx_PyLong_IsCompact(x) (((PyLongObject*)x)->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS)) #define __Pyx_PyLong_CompactValue(x) ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_Digits(x)[0]) #endif typedef Py_ssize_t __Pyx_compact_pylong; typedef size_t __Pyx_compact_upylong; #else #define __Pyx_PyLong_IsNeg(x) (Py_SIZE(x) < 0) #define __Pyx_PyLong_IsNonNeg(x) (Py_SIZE(x) >= 0) #define __Pyx_PyLong_IsZero(x) (Py_SIZE(x) == 0) #define __Pyx_PyLong_IsPos(x) (Py_SIZE(x) > 0) #define __Pyx_PyLong_CompactValueUnsigned(x) ((Py_SIZE(x) == 0) ? 0 : __Pyx_PyLong_Digits(x)[0]) #define __Pyx_PyLong_DigitCount(x) __Pyx_sst_abs(Py_SIZE(x)) #define __Pyx_PyLong_SignedDigitCount(x) Py_SIZE(x) #define __Pyx_PyLong_IsCompact(x) (Py_SIZE(x) == 0 || Py_SIZE(x) == 1 || Py_SIZE(x) == -1) #define __Pyx_PyLong_CompactValue(x)\ ((Py_SIZE(x) == 0) ? (sdigit) 0 : ((Py_SIZE(x) < 0) ? -(sdigit)__Pyx_PyLong_Digits(x)[0] : (sdigit)__Pyx_PyLong_Digits(x)[0])) typedef sdigit __Pyx_compact_pylong; typedef digit __Pyx_compact_upylong; #endif #if PY_VERSION_HEX >= 0x030C00A5 #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->long_value.ob_digit) #else #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->ob_digit) #endif #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #elif __PYX_DEFAULT_STRING_ENCODING_IS_ASCII #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeASCII(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ /* PretendToInitialize */ #ifdef __cplusplus #if __cplusplus > 201103L #include #endif template static void __Pyx_pretend_to_initialize(T* ptr) { #if __cplusplus > 201103L if ((std::is_trivially_default_constructible::value)) #endif *ptr = T(); (void)ptr; } #else static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } #endif #if !CYTHON_USE_MODULE_STATE static PyObject *__pyx_m = NULL; #endif static int __pyx_lineno; static int __pyx_clineno = 0; static const char * const __pyx_cfilenm = __FILE__; static const char *__pyx_filename; /* #### Code section: filename_table ### */ static const char* const __pyx_f[] = { "clickhouse_driver/bufferedreader.pyx", ".covenv/lib/python3.11/site-packages/Cython/Includes/cpython/contextvars.pxd", "", ".covenv/lib/python3.11/site-packages/Cython/Includes/cpython/type.pxd", ".covenv/lib/python3.11/site-packages/Cython/Includes/cpython/bool.pxd", ".covenv/lib/python3.11/site-packages/Cython/Includes/cpython/complex.pxd", }; /* #### Code section: utility_code_proto_before_types ### */ /* Atomics.proto */ #include #ifndef CYTHON_ATOMICS #define CYTHON_ATOMICS 1 #endif #define __PYX_CYTHON_ATOMICS_ENABLED() CYTHON_ATOMICS #define __PYX_GET_CYTHON_COMPILING_IN_CPYTHON_FREETHREADING() CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #define __pyx_atomic_int_type int #define __pyx_nonatomic_int_type int #if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\ (__STDC_VERSION__ >= 201112L) &&\ !defined(__STDC_NO_ATOMICS__)) #include #elif CYTHON_ATOMICS && (defined(__cplusplus) && (\ (__cplusplus >= 201103L) ||\ (defined(_MSC_VER) && _MSC_VER >= 1700))) #include #endif #if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\ (__STDC_VERSION__ >= 201112L) &&\ !defined(__STDC_NO_ATOMICS__) &&\ ATOMIC_INT_LOCK_FREE == 2) #undef __pyx_atomic_int_type #define __pyx_atomic_int_type atomic_int #define __pyx_atomic_ptr_type atomic_uintptr_t #define __pyx_nonatomic_ptr_type uintptr_t #define __pyx_atomic_incr_relaxed(value) atomic_fetch_add_explicit(value, 1, memory_order_relaxed) #define __pyx_atomic_incr_acq_rel(value) atomic_fetch_add_explicit(value, 1, memory_order_acq_rel) #define __pyx_atomic_decr_acq_rel(value) atomic_fetch_sub_explicit(value, 1, memory_order_acq_rel) #define __pyx_atomic_sub(value, arg) atomic_fetch_sub(value, arg) #define __pyx_atomic_int_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired) #define __pyx_atomic_load(value) atomic_load(value) #define __pyx_atomic_store(value, new_value) atomic_store(value, new_value) #define __pyx_atomic_pointer_load_relaxed(value) atomic_load_explicit(value, memory_order_relaxed) #define __pyx_atomic_pointer_load_acquire(value) atomic_load_explicit(value, memory_order_acquire) #define __pyx_atomic_pointer_exchange(value, new_value) atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value) #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired) #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER) #pragma message ("Using standard C atomics") #elif defined(__PYX_DEBUG_ATOMICS) #warning "Using standard C atomics" #endif #elif CYTHON_ATOMICS && (defined(__cplusplus) && (\ (__cplusplus >= 201103L) ||\ \ (defined(_MSC_VER) && _MSC_VER >= 1700)) &&\ ATOMIC_INT_LOCK_FREE == 2) #undef __pyx_atomic_int_type #define __pyx_atomic_int_type std::atomic_int #define __pyx_atomic_ptr_type std::atomic_uintptr_t #define __pyx_nonatomic_ptr_type uintptr_t #define __pyx_atomic_incr_relaxed(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_relaxed) #define __pyx_atomic_incr_acq_rel(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_acq_rel) #define __pyx_atomic_decr_acq_rel(value) std::atomic_fetch_sub_explicit(value, 1, std::memory_order_acq_rel) #define __pyx_atomic_sub(value, arg) std::atomic_fetch_sub(value, arg) #define __pyx_atomic_int_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired) #define __pyx_atomic_load(value) std::atomic_load(value) #define __pyx_atomic_store(value, new_value) std::atomic_store(value, new_value) #define __pyx_atomic_pointer_load_relaxed(value) std::atomic_load_explicit(value, std::memory_order_relaxed) #define __pyx_atomic_pointer_load_acquire(value) std::atomic_load_explicit(value, std::memory_order_acquire) #define __pyx_atomic_pointer_exchange(value, new_value) std::atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value) #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired) #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER) #pragma message ("Using standard C++ atomics") #elif defined(__PYX_DEBUG_ATOMICS) #warning "Using standard C++ atomics" #endif #elif CYTHON_ATOMICS && (__GNUC__ >= 5 || (__GNUC__ == 4 &&\ (__GNUC_MINOR__ > 1 ||\ (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ >= 2)))) #define __pyx_atomic_ptr_type void* #define __pyx_nonatomic_ptr_type void* #define __pyx_atomic_incr_relaxed(value) __sync_fetch_and_add(value, 1) #define __pyx_atomic_incr_acq_rel(value) __sync_fetch_and_add(value, 1) #define __pyx_atomic_decr_acq_rel(value) __sync_fetch_and_sub(value, 1) #define __pyx_atomic_sub(value, arg) __sync_fetch_and_sub(value, arg) static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) { __pyx_nonatomic_int_type old = __sync_val_compare_and_swap(value, *expected, desired); int result = old == *expected; *expected = old; return result; } #define __pyx_atomic_load(value) __sync_fetch_and_add(value, 0) #define __pyx_atomic_store(value, new_value) __sync_lock_test_and_set(value, new_value) #define __pyx_atomic_pointer_load_relaxed(value) __sync_fetch_and_add(value, 0) #define __pyx_atomic_pointer_load_acquire(value) __sync_fetch_and_add(value, 0) #define __pyx_atomic_pointer_exchange(value, new_value) __sync_lock_test_and_set(value, (__pyx_atomic_ptr_type)new_value) static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) { __pyx_nonatomic_ptr_type old = __sync_val_compare_and_swap(value, *expected, desired); int result = old == *expected; *expected = old; return result; } #ifdef __PYX_DEBUG_ATOMICS #warning "Using GNU atomics" #endif #elif CYTHON_ATOMICS && defined(_MSC_VER) #include #undef __pyx_atomic_int_type #define __pyx_atomic_int_type long #define __pyx_atomic_ptr_type void* #undef __pyx_nonatomic_int_type #define __pyx_nonatomic_int_type long #define __pyx_nonatomic_ptr_type void* #pragma intrinsic (_InterlockedExchangeAdd, _InterlockedExchange, _InterlockedCompareExchange, _InterlockedCompareExchangePointer, _InterlockedExchangePointer) #define __pyx_atomic_incr_relaxed(value) _InterlockedExchangeAdd(value, 1) #define __pyx_atomic_incr_acq_rel(value) _InterlockedExchangeAdd(value, 1) #define __pyx_atomic_decr_acq_rel(value) _InterlockedExchangeAdd(value, -1) #define __pyx_atomic_sub(value, arg) _InterlockedExchangeAdd(value, -arg) static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) { __pyx_nonatomic_int_type old = _InterlockedCompareExchange(value, desired, *expected); int result = old == *expected; *expected = old; return result; } #define __pyx_atomic_load(value) _InterlockedExchangeAdd(value, 0) #define __pyx_atomic_store(value, new_value) _InterlockedExchange(value, new_value) #define __pyx_atomic_pointer_load_relaxed(value) *(void * volatile *)value #define __pyx_atomic_pointer_load_acquire(value) _InterlockedCompareExchangePointer(value, 0, 0) #define __pyx_atomic_pointer_exchange(value, new_value) _InterlockedExchangePointer(value, (__pyx_atomic_ptr_type)new_value) static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) { __pyx_atomic_ptr_type old = _InterlockedCompareExchangePointer(value, desired, *expected); int result = old == *expected; *expected = old; return result; } #ifdef __PYX_DEBUG_ATOMICS #pragma message ("Using MSVC atomics") #endif #else #undef CYTHON_ATOMICS #define CYTHON_ATOMICS 0 #ifdef __PYX_DEBUG_ATOMICS #warning "Not using atomics" #endif #endif /* CriticalSectionsDefinition.proto */ #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #define __Pyx_PyCriticalSection void* #define __Pyx_PyCriticalSection2 void* #define __Pyx_PyCriticalSection_End(cs) #define __Pyx_PyCriticalSection2_End(cs) #else #define __Pyx_PyCriticalSection PyCriticalSection #define __Pyx_PyCriticalSection2 PyCriticalSection2 #define __Pyx_PyCriticalSection_End PyCriticalSection_End #define __Pyx_PyCriticalSection2_End PyCriticalSection2_End #endif /* CriticalSections.proto */ #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #define __Pyx_PyCriticalSection_Begin(cs, arg) (void)(cs) #define __Pyx_PyCriticalSection2_Begin(cs, arg1, arg2) (void)(cs) #else #define __Pyx_PyCriticalSection_Begin PyCriticalSection_Begin #define __Pyx_PyCriticalSection2_Begin PyCriticalSection2_Begin #endif #if PY_VERSION_HEX < 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_BEGIN_CRITICAL_SECTION(o) { #define __Pyx_END_CRITICAL_SECTION() } #else #define __Pyx_BEGIN_CRITICAL_SECTION Py_BEGIN_CRITICAL_SECTION #define __Pyx_END_CRITICAL_SECTION Py_END_CRITICAL_SECTION #endif /* IncludeStructmemberH.proto */ #include /* #### Code section: numeric_typedefs ### */ /* #### Code section: complex_type_declarations ### */ /* #### Code section: type_declarations ### */ /*--- Type declarations ---*/ struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader; struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader; struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader; struct __pyx_opt_args_7cpython_11contextvars_get_value; struct __pyx_opt_args_7cpython_11contextvars_get_value_no_default; /* "cpython/contextvars.pxd":116 * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline object get_value(var, default_value=None): # <<<<<<<<<<<<<< * """Return a new reference to the value of the context variable, * or the default value of the context variable, */ struct __pyx_opt_args_7cpython_11contextvars_get_value { int __pyx_n; PyObject *default_value; }; /* "cpython/contextvars.pxd":134 * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline object get_value_no_default(var, default_value=None): # <<<<<<<<<<<<<< * """Return a new reference to the value of the context variable, * or the provided default value if no such value was found. */ struct __pyx_opt_args_7cpython_11contextvars_get_value_no_default { int __pyx_n; PyObject *default_value; }; /* "clickhouse_driver/bufferedreader.pyx":10 * * * cdef class BufferedReader(object): # <<<<<<<<<<<<<< * cdef public unsigned long long position, current_buffer_size * cdef public bytearray buffer */ struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader { PyObject_HEAD unsigned PY_LONG_LONG position; unsigned PY_LONG_LONG current_buffer_size; PyObject *buffer; }; /* "clickhouse_driver/bufferedreader.pyx":317 * * * cdef class BufferedSocketReader(BufferedReader): # <<<<<<<<<<<<<< * cdef object sock * */ struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader { struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader __pyx_base; PyObject *sock; }; /* "clickhouse_driver/bufferedreader.pyx":331 * * * cdef class CompressedBufferedReader(BufferedReader): # <<<<<<<<<<<<<< * cdef object read_block * */ struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader { struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader __pyx_base; PyObject *read_block; }; /* #### Code section: utility_code_proto ### */ /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, Py_ssize_t); void (*DECREF)(void*, PyObject*, Py_ssize_t); void (*GOTREF)(void*, PyObject*, Py_ssize_t); void (*GIVEREF)(void*, PyObject*, Py_ssize_t); void* (*SetupContext)(const char*, Py_ssize_t, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\ } #define __Pyx_RefNannyFinishContextNogil() {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __Pyx_RefNannyFinishContext();\ PyGILState_Release(__pyx_gilstate_save);\ } #define __Pyx_RefNannyFinishContextNogil() {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __Pyx_RefNannyFinishContext();\ PyGILState_Release(__pyx_gilstate_save);\ } #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_XINCREF(r) do { if((r) == NULL); else {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) == NULL); else {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) == NULL); else {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) == NULL); else {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContextNogil() #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_Py_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; Py_XDECREF(tmp);\ } while (0) #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) /* PyErrExceptionMatches.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); #else #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) #endif /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; #if PY_VERSION_HEX >= 0x030C00A6 #define __Pyx_PyErr_Occurred() (__pyx_tstate->current_exception != NULL) #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->current_exception ? (PyObject*) Py_TYPE(__pyx_tstate->current_exception) : (PyObject*) NULL) #else #define __Pyx_PyErr_Occurred() (__pyx_tstate->curexc_type != NULL) #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->curexc_type) #endif #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign #define __Pyx_PyErr_Occurred() (PyErr_Occurred() != NULL) #define __Pyx_PyErr_CurrentExceptionType() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A6 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) #else #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #endif #else #define __Pyx_PyErr_Clear() PyErr_Clear() #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) #endif /* PyObjectGetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif /* PyObjectGetAttrStrNoError.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name); /* GetBuiltinName.proto */ static PyObject *__Pyx_GetBuiltinName(PyObject *name); /* TupleAndListFromArray.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n); #endif #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_METH_FASTCALL static CYTHON_INLINE PyObject* __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n); #endif /* IncludeStringH.proto */ #include /* BytesEquals.proto */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /* UnicodeEquals.proto */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /* fastcall.proto */ #if CYTHON_AVOID_BORROWED_REFS #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_PySequence_ITEM(args, i) #elif CYTHON_ASSUME_SAFE_MACROS #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_NewRef(__Pyx_PyTuple_GET_ITEM(args, i)) #else #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_XNewRef(PyTuple_GetItem(args, i)) #endif #define __Pyx_NumKwargs_VARARGS(kwds) PyDict_Size(kwds) #define __Pyx_KwValues_VARARGS(args, nargs) NULL #define __Pyx_GetKwValue_VARARGS(kw, kwvalues, s) __Pyx_PyDict_GetItemStrWithError(kw, s) #define __Pyx_KwargsAsDict_VARARGS(kw, kwvalues) PyDict_Copy(kw) #if CYTHON_METH_FASTCALL #define __Pyx_ArgRef_FASTCALL(args, i) __Pyx_NewRef(args[i]) #define __Pyx_NumKwargs_FASTCALL(kwds) __Pyx_PyTuple_GET_SIZE(kwds) #define __Pyx_KwValues_FASTCALL(args, nargs) ((args) + (nargs)) static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues); #else #define __Pyx_KwargsAsDict_FASTCALL(kw, kwvalues) _PyStack_AsDict(kwvalues, kw) #endif #else #define __Pyx_ArgRef_FASTCALL __Pyx_ArgRef_VARARGS #define __Pyx_NumKwargs_FASTCALL __Pyx_NumKwargs_VARARGS #define __Pyx_KwValues_FASTCALL __Pyx_KwValues_VARARGS #define __Pyx_GetKwValue_FASTCALL __Pyx_GetKwValue_VARARGS #define __Pyx_KwargsAsDict_FASTCALL __Pyx_KwargsAsDict_VARARGS #endif #define __Pyx_ArgsSlice_VARARGS(args, start, stop) PyTuple_GetSlice(args, start, stop) #if CYTHON_METH_FASTCALL || (CYTHON_COMPILING_IN_CPYTHON && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) __Pyx_PyTuple_FromArray(args + start, stop - start) #else #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) PyTuple_GetSlice(args, start, stop) #endif /* py_dict_items.proto */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d); /* CallCFunction.proto */ #define __Pyx_CallCFunction(cfunc, self, args)\ ((PyCFunction)(void(*)(void))(cfunc)->func)(self, args) #define __Pyx_CallCFunctionWithKeywords(cfunc, self, args, kwargs)\ ((PyCFunctionWithKeywords)(void(*)(void))(cfunc)->func)(self, args, kwargs) #define __Pyx_CallCFunctionFast(cfunc, self, args, nargs)\ ((__Pyx_PyCFunctionFast)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs) #define __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, nargs, kwnames)\ ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs, kwnames) /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif /* PyObjectCallMethO.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); #endif /* PyObjectFastCall.proto */ #define __Pyx_PyObject_FastCall(func, args, nargs) __Pyx_PyObject_FastCallDict(func, args, (size_t)(nargs), NULL) static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs); /* PyObjectCallOneArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); /* UnpackUnboundCMethod.proto */ typedef struct { PyObject *type; PyObject **method_name; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && CYTHON_ATOMICS __pyx_atomic_int_type initialized; #endif PyCFunction func; PyObject *method; int flag; } __Pyx_CachedCFunction; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING static CYTHON_INLINE int __Pyx_CachedCFunction_GetAndSetInitializing(__Pyx_CachedCFunction *cfunc) { #if !CYTHON_ATOMICS return 1; #else __pyx_nonatomic_int_type expected = 0; if (__pyx_atomic_int_cmp_exchange(&cfunc->initialized, &expected, 1)) { return 0; } return expected; #endif } static CYTHON_INLINE void __Pyx_CachedCFunction_SetFinishedInitializing(__Pyx_CachedCFunction *cfunc) { #if CYTHON_ATOMICS __pyx_atomic_store(&cfunc->initialized, 2); #endif } #else #define __Pyx_CachedCFunction_GetAndSetInitializing(cfunc) 2 #define __Pyx_CachedCFunction_SetFinishedInitializing(cfunc) #endif /* CallUnboundCMethod0.proto */ CYTHON_UNUSED static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self); #else #define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self) #endif /* py_dict_values.proto */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d); /* OwnedDictNext.proto */ #if CYTHON_AVOID_BORROWED_REFS static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue); #else CYTHON_INLINE static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue); #endif /* RaiseDoubleKeywords.proto */ static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /* ParseKeywordsImpl.export */ static int __Pyx_ParseKeywordsTuple( PyObject *kwds, PyObject * const *kwvalues, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs ); static int __Pyx_ParseKeywordDictToDict( PyObject *kwds, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name ); static int __Pyx_ParseKeywordDict( PyObject *kwds, PyObject ** const argnames[], PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs ); /* CallUnboundCMethod2.proto */ CYTHON_UNUSED static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2); #else #define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2) __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2) #endif /* ParseKeywords.proto */ static CYTHON_INLINE int __Pyx_ParseKeywords( PyObject *kwds, PyObject *const *kwvalues, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs ); /* RaiseArgTupleInvalid.proto */ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /* PyObjectFastCallMethod.proto */ #if CYTHON_VECTORCALL && PY_VERSION_HEX >= 0x03090000 #define __Pyx_PyObject_FastCallMethod(name, args, nargsf) PyObject_VectorcallMethod(name, args, nargsf, NULL) #else static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const *args, size_t nargsf); #endif /* RejectKeywords.export */ static void __Pyx_RejectKeywords(const char* function_name, PyObject *kwds); /* PyNotImplementedError_Check.proto */ #define __Pyx_PyExc_NotImplementedError_Check(obj) __Pyx_TypeCheck(obj, PyExc_NotImplementedError) /* RaiseException.export */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /* SetStringIndexingError.proto */ static void __Pyx_SetStringIndexingError(const char* message, int has_gil); /* GetItemIntByteArray.proto */ #define __Pyx_GetItemInt_ByteArray(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_ByteArray_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, has_gil, unsafe_shared) :\ (__Pyx_SetStringIndexingError("bytearray index out of range", has_gil), -1)) static CYTHON_INLINE int __Pyx_GetItemInt_ByteArray_Fast(PyObject* string, Py_ssize_t i, int wraparound, int boundscheck, int has_gil, int unsafe_shared); /* decode_c_string_utf16.proto */ static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) { int byteorder = 0; return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); } static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) { int byteorder = -1; return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); } static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) { int byteorder = 1; return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); } /* decode_c_string.proto */ static CYTHON_INLINE PyObject* __Pyx_decode_c_string( const char* cstring, Py_ssize_t start, Py_ssize_t stop, const char* encoding, const char* errors, PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)); /* GetTopmostException.proto */ #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); #endif /* SaveResetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); #else #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) #endif /* PyUnicodeDecodeError_Check.proto */ #define __Pyx_PyExc_UnicodeDecodeError_Check(obj) __Pyx_TypeCheck(obj, PyExc_UnicodeDecodeError) /* GetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); #endif /* RaiseUnexpectedTypeError.proto */ static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj); /* GetAttr3.proto */ static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); /* PyDictVersioning.proto */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ (version_var) = __PYX_GET_DICT_VERSION(dict);\ (cache_var) = (value); #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ (VAR) = __Pyx_XNewRef(__pyx_dict_cached_value);\ } else {\ (VAR) = __pyx_dict_cached_value = (LOOKUP);\ __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ }\ } static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); #else #define __PYX_GET_DICT_VERSION(dict) (0) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); #endif /* GetModuleGlobalName.proto */ #if CYTHON_USE_DICT_VERSIONS #define __Pyx_GetModuleGlobalName(var, name) do {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_mstate_global->__pyx_d))) ?\ (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } while(0) #define __Pyx_GetModuleGlobalNameUncached(var, name) do {\ PY_UINT64_T __pyx_dict_version;\ PyObject *__pyx_dict_cached_value;\ (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } while(0) static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); #else #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); #endif /* PyEOFError_Check.proto */ #define __Pyx_PyExc_EOFError_Check(obj) __Pyx_TypeCheck(obj, PyExc_EOFError) /* ArgTypeTestFunc.export */ static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /* ArgTypeTest.proto */ #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ ((likely(__Pyx_IS_TYPE(obj, type) | (none_allowed && (obj == Py_None)))) ? 1 :\ __Pyx__ArgTypeTest(obj, type, name, exact)) /* GetItemInt.proto */ #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck, unsafe_shared) :\ (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ __Pyx_GetItemInt_Generic(o, to_py_func(i)))) #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) :\ (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck, int unsafe_shared); #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) :\ (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck, int unsafe_shared); static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck, int unsafe_shared); /* AllocateExtensionType.proto */ static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final); /* CallNextTpTraverse.proto */ static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse); /* CallTypeTraverse.proto */ #if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000) #define __Pyx_call_type_traverse(o, always_call, visit, arg) 0 #else static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg); #endif /* CallNextTpClear.proto */ static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear); /* LimitedApiGetTypeDict.proto */ #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp); #endif /* SetItemOnTypeDict.proto */ static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v); #define __Pyx_SetItemOnTypeDict(tp, k, v) __Pyx__SetItemOnTypeDict((PyTypeObject*)tp, k, v) /* FixUpExtensionType.proto */ static CYTHON_INLINE int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type); /* PyObjectCallNoArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); /* PyObjectGetMethod.proto */ #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))) static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method); #endif /* PyObjectCallMethod0.proto */ static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name); /* ValidateBasesTuple.proto */ #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases); #endif /* PyType_Ready.proto */ CYTHON_UNUSED static int __Pyx_PyType_Ready(PyTypeObject *t); /* DelItemOnTypeDict.proto */ static int __Pyx__DelItemOnTypeDict(PyTypeObject *tp, PyObject *k); #define __Pyx_DelItemOnTypeDict(tp, k) __Pyx__DelItemOnTypeDict((PyTypeObject*)tp, k) /* SetupReduce.proto */ static int __Pyx_setup_reduce(PyObject* type_obj); /* TypeImport.proto */ #ifndef __PYX_HAVE_RT_ImportType_proto_3_2_0 #define __PYX_HAVE_RT_ImportType_proto_3_2_0 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #include #endif #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || __cplusplus >= 201103L #define __PYX_GET_STRUCT_ALIGNMENT_3_2_0(s) alignof(s) #else #define __PYX_GET_STRUCT_ALIGNMENT_3_2_0(s) sizeof(void*) #endif enum __Pyx_ImportType_CheckSize_3_2_0 { __Pyx_ImportType_CheckSize_Error_3_2_0 = 0, __Pyx_ImportType_CheckSize_Warn_3_2_0 = 1, __Pyx_ImportType_CheckSize_Ignore_3_2_0 = 2 }; static PyTypeObject *__Pyx_ImportType_3_2_0(PyObject* module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_2_0 check_size); #endif /* dict_setdefault.proto */ static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value); /* AddModuleRef.proto */ #if ((CYTHON_COMPILING_IN_CPYTHON_FREETHREADING ) ||\ __PYX_LIMITED_VERSION_HEX < 0x030d0000) static PyObject *__Pyx_PyImport_AddModuleRef(const char *name); #else #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name) #endif /* FetchSharedCythonModule.proto */ static PyObject *__Pyx_FetchSharedCythonABIModule(void); /* FetchCommonType.proto */ static PyTypeObject* __Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases); /* CommonTypesMetaclass.proto */ static int __pyx_CommonTypesMetaclass_init(PyObject *module); #define __Pyx_CommonTypesMetaclass_USED /* PyMethodNew.proto */ static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ); /* PyVectorcallFastCallDict.proto */ #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw); #endif /* CythonFunctionShared.proto */ #define __Pyx_CyFunction_USED #define __Pyx_CYFUNCTION_STATICMETHOD 0x01 #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 #define __Pyx_CYFUNCTION_CCLASS 0x04 #define __Pyx_CYFUNCTION_COROUTINE 0x08 #define __Pyx_CyFunction_GetClosure(f)\ (((__pyx_CyFunctionObject *) (f))->func_closure) #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_GetClassObj(f)\ (((__pyx_CyFunctionObject *) (f))->func_classobj) #else #define __Pyx_CyFunction_GetClassObj(f)\ ((PyObject*) ((PyCMethodObject *) (f))->mm_class) #endif #define __Pyx_CyFunction_SetClassObj(f, classobj)\ __Pyx__CyFunction_SetClassObj((__pyx_CyFunctionObject *) (f), (classobj)) #define __Pyx_CyFunction_Defaults(type, f)\ ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) typedef struct { #if CYTHON_COMPILING_IN_LIMITED_API PyObject_HEAD PyObject *func; #elif PY_VERSION_HEX < 0x030900B1 PyCFunctionObject func; #else PyCMethodObject func; #endif #if CYTHON_COMPILING_IN_LIMITED_API && CYTHON_METH_FASTCALL __pyx_vectorcallfunc func_vectorcall; #endif #if CYTHON_COMPILING_IN_LIMITED_API PyObject *func_weakreflist; #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API PyObject *func_dict; #endif PyObject *func_name; PyObject *func_qualname; PyObject *func_doc; PyObject *func_globals; PyObject *func_code; PyObject *func_closure; #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API PyObject *func_classobj; #endif PyObject *defaults; int flags; PyObject *defaults_tuple; PyObject *defaults_kwdict; PyObject *(*defaults_getter)(PyObject *); PyObject *func_annotations; PyObject *func_is_coroutine; } __pyx_CyFunctionObject; #undef __Pyx_CyOrPyCFunction_Check #define __Pyx_CyFunction_Check(obj) __Pyx_TypeCheck(obj, __pyx_mstate_global->__pyx_CyFunctionType) #define __Pyx_CyOrPyCFunction_Check(obj) __Pyx_TypeCheck2(obj, __pyx_mstate_global->__pyx_CyFunctionType, &PyCFunction_Type) #define __Pyx_CyFunction_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_mstate_global->__pyx_CyFunctionType) static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)); #undef __Pyx_IsSameCFunction #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCyOrCFunction(func, cfunc) static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject *globals, PyObject* code); static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj); static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, PyObject *tuple); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, PyObject *dict); static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, PyObject *dict); static int __pyx_CyFunction_init(PyObject *module); #if CYTHON_METH_FASTCALL static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_func_vectorcall(f) (((__pyx_CyFunctionObject*)f)->func_vectorcall) #else #define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall) #endif #endif /* CythonFunction.proto */ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject *globals, PyObject* code); /* CLineInTraceback.proto */ #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); #else #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) #endif /* CodeObjectCache.proto */ #if CYTHON_COMPILING_IN_LIMITED_API typedef PyObject __Pyx_CachedCodeObjectType; #else typedef PyCodeObject __Pyx_CachedCodeObjectType; #endif typedef struct { __Pyx_CachedCodeObjectType* code_object; int code_line; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_atomic_int_type accessor_count; #endif }; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object); /* AddTraceback.proto */ static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); /* GCCDiagnostics.proto */ #if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #define __Pyx_HAS_GCC_DIAGNOSTIC #endif /* CheckUnpickleChecksum.proto */ static CYTHON_INLINE int __Pyx_CheckUnpickleChecksum(long checksum, long checksum1, long checksum2, long checksum3, const char *members); /* PyObjectVectorCallKwBuilder.proto */ CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n); #if CYTHON_VECTORCALL #if PY_VERSION_HEX >= 0x03090000 #define __Pyx_Object_Vectorcall_CallFromBuilder PyObject_Vectorcall #else #define __Pyx_Object_Vectorcall_CallFromBuilder _PyObject_Vectorcall #endif #define __Pyx_MakeVectorcallBuilderKwds(n) PyTuple_New(n) static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n); static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n); #else #define __Pyx_Object_Vectorcall_CallFromBuilder __Pyx_PyObject_FastCallDict #define __Pyx_MakeVectorcallBuilderKwds(n) __Pyx_PyDict_NewPresized(n) #define __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n) PyDict_SetItem(builder, key, value) #define __Pyx_VectorcallBuilder_AddArgStr(key, value, builder, args, n) PyDict_SetItemString(builder, key, value) #endif /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value); /* CIntFromPy.proto */ static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyLong_As_unsigned_PY_LONG_LONG(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_unsigned_char(unsigned char value); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value); /* PyObjectCall2Args.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); /* PyObjectCallMethod1.proto */ static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); /* UpdateUnpickledDict.proto */ static int __Pyx_UpdateUnpickledDict(PyObject *obj, PyObject *state, Py_ssize_t index); /* FormatTypeName.proto */ #if CYTHON_COMPILING_IN_LIMITED_API typedef PyObject *__Pyx_TypeName; #define __Pyx_FMT_TYPENAME "%U" #define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj) #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyType_GetFullyQualifiedName PyType_GetFullyQualifiedName #else static __Pyx_TypeName __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp); #endif #else // !LIMITED_API typedef const char *__Pyx_TypeName; #define __Pyx_FMT_TYPENAME "%.200s" #define __Pyx_PyType_GetFullyQualifiedName(tp) ((tp)->tp_name) #define __Pyx_DECREF_TypeName(obj) #endif /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *); /* FastTypeChecks.proto */ #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) #define __Pyx_TypeCheck2(obj, type1, type2) __Pyx_IsAnySubtype2(Py_TYPE(obj), (PyTypeObject *)type1, (PyTypeObject *)type2) static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); #else #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_TypeCheck2(obj, type1, type2) (PyObject_TypeCheck(obj, (PyTypeObject *)type1) || PyObject_TypeCheck(obj, (PyTypeObject *)type2)) #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2) { return PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2); } #endif #define __Pyx_PyErr_ExceptionMatches2(err1, err2) __Pyx_PyErr_GivenExceptionMatches2(__Pyx_PyErr_CurrentExceptionType(), err1, err2) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #ifdef PyExceptionInstance_Check #define __Pyx_PyBaseException_Check(obj) PyExceptionInstance_Check(obj) #else #define __Pyx_PyBaseException_Check(obj) __Pyx_TypeCheck(obj, PyExc_BaseException) #endif /* GetRuntimeVersion.proto */ #if __PYX_LIMITED_VERSION_HEX < 0x030b0000 static unsigned long __Pyx_cached_runtime_version = 0; static void __Pyx_init_runtime_version(void); #else #define __Pyx_init_runtime_version() #endif static unsigned long __Pyx_get_runtime_version(void); /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer); /* DecompressString.proto */ static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo); /* MultiPhaseInitModuleState.proto */ #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE static PyObject *__Pyx_State_FindModule(void*); static int __Pyx_State_AddModule(PyObject* module, void*); static int __Pyx_State_RemoveModule(void*); #elif CYTHON_USE_MODULE_STATE #define __Pyx_State_FindModule PyState_FindModule #define __Pyx_State_AddModule PyState_AddModule #define __Pyx_State_RemoveModule PyState_RemoveModule #endif /* #### Code section: module_declarations ### */ /* CythonABIVersion.proto */ #if CYTHON_COMPILING_IN_LIMITED_API #if CYTHON_METH_FASTCALL #define __PYX_FASTCALL_ABI_SUFFIX "_fastcall" #else #define __PYX_FASTCALL_ABI_SUFFIX #endif #define __PYX_LIMITED_ABI_SUFFIX "limited" __PYX_FASTCALL_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX #else #define __PYX_LIMITED_ABI_SUFFIX #endif #if __PYX_HAS_PY_AM_SEND == 1 #define __PYX_AM_SEND_ABI_SUFFIX #elif __PYX_HAS_PY_AM_SEND == 2 #define __PYX_AM_SEND_ABI_SUFFIX "amsendbackport" #else #define __PYX_AM_SEND_ABI_SUFFIX "noamsend" #endif #ifndef __PYX_MONITORING_ABI_SUFFIX #define __PYX_MONITORING_ABI_SUFFIX #endif #if CYTHON_USE_TP_FINALIZE #define __PYX_TP_FINALIZE_ABI_SUFFIX #else #define __PYX_TP_FINALIZE_ABI_SUFFIX "nofinalize" #endif #if CYTHON_USE_FREELISTS || !defined(__Pyx_AsyncGen_USED) #define __PYX_FREELISTS_ABI_SUFFIX #else #define __PYX_FREELISTS_ABI_SUFFIX "nofreelists" #endif #define CYTHON_ABI __PYX_ABI_VERSION __PYX_LIMITED_ABI_SUFFIX __PYX_MONITORING_ABI_SUFFIX __PYX_TP_FINALIZE_ABI_SUFFIX __PYX_FREELISTS_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX #define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI #define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "." #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4real_real(PyComplexObject *__pyx_v_self); /* proto*/ #endif #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4imag_imag(PyComplexObject *__pyx_v_self); /* proto*/ #endif /* Module declarations from "cpython.version" */ /* Module declarations from "__builtin__" */ /* Module declarations from "cpython.type" */ /* Module declarations from "libc.string" */ /* Module declarations from "libc.stdio" */ /* Module declarations from "cpython.object" */ /* Module declarations from "cpython.ref" */ /* Module declarations from "cpython.exc" */ /* Module declarations from "cpython.module" */ /* Module declarations from "cpython.mem" */ /* Module declarations from "cpython.tuple" */ /* Module declarations from "cpython.list" */ /* Module declarations from "cpython.sequence" */ /* Module declarations from "cpython.mapping" */ /* Module declarations from "cpython.iterator" */ /* Module declarations from "cpython.number" */ /* Module declarations from "__builtin__" */ /* Module declarations from "cpython.bool" */ /* Module declarations from "cpython.long" */ /* Module declarations from "cpython.float" */ /* Module declarations from "cython" */ /* Module declarations from "__builtin__" */ /* Module declarations from "cpython.complex" */ /* Module declarations from "libc.stddef" */ /* Module declarations from "cpython.unicode" */ /* Module declarations from "cpython.pyport" */ /* Module declarations from "cpython.dict" */ /* Module declarations from "cpython.instance" */ /* Module declarations from "cpython.function" */ /* Module declarations from "cpython.method" */ /* Module declarations from "cpython.weakref" */ /* Module declarations from "cpython.getargs" */ /* Module declarations from "cpython.pythread" */ /* Module declarations from "cpython.pystate" */ /* Module declarations from "cpython.set" */ /* Module declarations from "cpython.buffer" */ /* Module declarations from "cpython.bytes" */ /* Module declarations from "cpython.pycapsule" */ /* Module declarations from "cpython.contextvars" */ /* Module declarations from "cpython" */ /* Module declarations from "cpython.bytearray" */ /* Module declarations from "clickhouse_driver.bufferedreader" */ static PyObject *__pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedReader__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *, PyObject *); /*proto*/ static PyObject *__pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedSocketReader__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *, PyObject *); /*proto*/ static PyObject *__pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_CompressedBufferedReader__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *, PyObject *); /*proto*/ /* #### Code section: typeinfo ### */ /* #### Code section: before_global_var ### */ #define __Pyx_MODULE_NAME "clickhouse_driver.bufferedreader" extern int __pyx_module_is_main_clickhouse_driver__bufferedreader; int __pyx_module_is_main_clickhouse_driver__bufferedreader = 0; /* Implementation of "clickhouse_driver.bufferedreader" */ /* #### Code section: global_var ### */ static PyObject *__pyx_builtin_super; static PyObject *__pyx_builtin_object; /* #### Code section: string_decls ### */ /* #### Code section: decls ### */ static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader___init__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v_bufsize); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_2read_into_buffer(CYTHON_UNUSED struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_4read(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, unsigned PY_LONG_LONG __pyx_v_unread); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6read_one(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8read_strings(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, unsigned PY_LONG_LONG __pyx_v_n_items, PyObject *__pyx_v_encoding); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_10read_strings_arrow(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, unsigned PY_LONG_LONG __pyx_v_n_items); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_12read_fixed_strings_as_bytes(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, Py_ssize_t __pyx_v_n_items, Py_ssize_t __pyx_v_length); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_14read_fixed_strings(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, Py_ssize_t __pyx_v_n_items, Py_ssize_t __pyx_v_length, PyObject *__pyx_v_encoding); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8position___get__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self); /* proto */ static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_2__set__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size___get__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self); /* proto */ static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_2__set__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer___get__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self); /* proto */ static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_2__set__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_4__del__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_16__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_18__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */ static int __pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader___init__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v_self, PyObject *__pyx_v_sock, PyObject *__pyx_v_bufsize); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_2read_into_buffer(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_4__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_6__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */ static int __pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader___init__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v_self, PyObject *__pyx_v_read_block, PyObject *__pyx_v_bufsize); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_2read_into_buffer(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_4__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_6__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedReader(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_2__pyx_unpickle_BufferedSocketReader(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_4__pyx_unpickle_CompressedBufferedReader(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedReader(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedSocketReader(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedreader_CompressedBufferedReader(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ /* #### Code section: late_includes ### */ /* #### Code section: module_state ### */ /* SmallCodeConfig */ #ifndef CYTHON_SMALL_CODE #if defined(__clang__) #define CYTHON_SMALL_CODE #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) #define CYTHON_SMALL_CODE __attribute__((cold)) #else #define CYTHON_SMALL_CODE #endif #endif typedef struct { PyObject *__pyx_d; PyObject *__pyx_b; PyObject *__pyx_cython_runtime; PyObject *__pyx_empty_tuple; PyObject *__pyx_empty_bytes; PyObject *__pyx_empty_unicode; PyTypeObject *__pyx_ptype_7cpython_4type_type; PyTypeObject *__pyx_ptype_7cpython_4bool_bool; PyTypeObject *__pyx_ptype_7cpython_7complex_complex; PyObject *__pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader; PyObject *__pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader; PyObject *__pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader; PyTypeObject *__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader; PyTypeObject *__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader; PyTypeObject *__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_values; PyObject *__pyx_tuple[4]; PyObject *__pyx_codeobj_tab[18]; PyObject *__pyx_string_tab[127]; PyObject *__pyx_number_tab[3]; /* #### Code section: module_state_contents ### */ /* CommonTypesMetaclass.module_state_decls */ PyTypeObject *__pyx_CommonTypesMetaclassType; /* CachedMethodType.module_state_decls */ #if CYTHON_COMPILING_IN_LIMITED_API PyObject *__Pyx_CachedMethodType; #endif /* CythonFunctionShared.module_state_decls */ PyTypeObject *__pyx_CyFunctionType; /* CodeObjectCache.module_state_decls */ struct __Pyx_CodeObjectCache __pyx_code_cache; /* #### Code section: module_state_end ### */ } __pyx_mstatetype; #if CYTHON_USE_MODULE_STATE #ifdef __cplusplus namespace { extern struct PyModuleDef __pyx_moduledef; } /* anonymous namespace */ #else static struct PyModuleDef __pyx_moduledef; #endif #define __pyx_mstate_global (__Pyx_PyModule_GetState(__Pyx_State_FindModule(&__pyx_moduledef))) #define __pyx_m (__Pyx_State_FindModule(&__pyx_moduledef)) #else static __pyx_mstatetype __pyx_mstate_global_static = #ifdef __cplusplus {}; #else {0}; #endif static __pyx_mstatetype * const __pyx_mstate_global = &__pyx_mstate_global_static; #endif /* #### Code section: constant_name_defines ### */ #define __pyx_kp_u_ __pyx_string_tab[0] #define __pyx_kp_u_Note_that_Cython_is_deliberately __pyx_string_tab[1] #define __pyx_kp_u_Unexpected_EOF_while_reading_byt __pyx_string_tab[2] #define __pyx_kp_u_add_note __pyx_string_tab[3] #define __pyx_kp_u_clickhouse_driver_bufferedreader_2 __pyx_string_tab[4] #define __pyx_kp_u_disable __pyx_string_tab[5] #define __pyx_kp_u_enable __pyx_string_tab[6] #define __pyx_kp_u_gc __pyx_string_tab[7] #define __pyx_kp_u_isenabled __pyx_string_tab[8] #define __pyx_kp_u_self_buffer_is_not_None __pyx_string_tab[9] #define __pyx_kp_u_self_buffer_is_not_None_or_self __pyx_string_tab[10] #define __pyx_kp_u_self_buffer_is_not_None_or_self_2 __pyx_string_tab[11] #define __pyx_kp_u_stringsource __pyx_string_tab[12] #define __pyx_kp_u_utf_8 __pyx_string_tab[13] #define __pyx_n_u_BufferedReader __pyx_string_tab[14] #define __pyx_n_u_BufferedReader___reduce_cython __pyx_string_tab[15] #define __pyx_n_u_BufferedReader___setstate_cython __pyx_string_tab[16] #define __pyx_n_u_BufferedReader_read __pyx_string_tab[17] #define __pyx_n_u_BufferedReader_read_fixed_string __pyx_string_tab[18] #define __pyx_n_u_BufferedReader_read_fixed_string_2 __pyx_string_tab[19] #define __pyx_n_u_BufferedReader_read_into_buffer __pyx_string_tab[20] #define __pyx_n_u_BufferedReader_read_one __pyx_string_tab[21] #define __pyx_n_u_BufferedReader_read_strings __pyx_string_tab[22] #define __pyx_n_u_BufferedReader_read_strings_arro __pyx_string_tab[23] #define __pyx_n_u_BufferedSocketReader __pyx_string_tab[24] #define __pyx_n_u_BufferedSocketReader___reduce_cy __pyx_string_tab[25] #define __pyx_n_u_BufferedSocketReader___setstate __pyx_string_tab[26] #define __pyx_n_u_BufferedSocketReader_read_into_b __pyx_string_tab[27] #define __pyx_n_u_CompressedBufferedReader __pyx_string_tab[28] #define __pyx_n_u_CompressedBufferedReader___reduc __pyx_string_tab[29] #define __pyx_n_u_CompressedBufferedReader___setst __pyx_string_tab[30] #define __pyx_n_u_CompressedBufferedReader_read_in __pyx_string_tab[31] #define __pyx_n_u_Pyx_PyDict_NextRef __pyx_string_tab[32] #define __pyx_n_u_asyncio_coroutines __pyx_string_tab[33] #define __pyx_n_u_b __pyx_string_tab[34] #define __pyx_n_u_buffer_ptr __pyx_string_tab[35] #define __pyx_n_u_bufsize __pyx_string_tab[36] #define __pyx_n_u_bytes_read __pyx_string_tab[37] #define __pyx_n_u_c_encoding __pyx_string_tab[38] #define __pyx_n_u_c_string __pyx_string_tab[39] #define __pyx_n_u_c_string_size __pyx_string_tab[40] #define __pyx_n_u_clickhouse_driver_bufferedreader __pyx_string_tab[41] #define __pyx_n_u_cline_in_traceback __pyx_string_tab[42] #define __pyx_n_u_data __pyx_string_tab[43] #define __pyx_n_u_data_capacity __pyx_string_tab[44] #define __pyx_n_u_data_ptr __pyx_string_tab[45] #define __pyx_n_u_data_size __pyx_string_tab[46] #define __pyx_n_u_dict __pyx_string_tab[47] #define __pyx_n_u_dict_2 __pyx_string_tab[48] #define __pyx_n_u_encode __pyx_string_tab[49] #define __pyx_n_u_encoding __pyx_string_tab[50] #define __pyx_n_u_func __pyx_string_tab[51] #define __pyx_n_u_getstate __pyx_string_tab[52] #define __pyx_n_u_i __pyx_string_tab[53] #define __pyx_n_u_init __pyx_string_tab[54] #define __pyx_n_u_is_coroutine __pyx_string_tab[55] #define __pyx_n_u_item __pyx_string_tab[56] #define __pyx_n_u_items __pyx_string_tab[57] #define __pyx_n_u_j __pyx_string_tab[58] #define __pyx_n_u_length __pyx_string_tab[59] #define __pyx_n_u_main __pyx_string_tab[60] #define __pyx_n_u_module __pyx_string_tab[61] #define __pyx_n_u_n_items __pyx_string_tab[62] #define __pyx_n_u_name __pyx_string_tab[63] #define __pyx_n_u_new __pyx_string_tab[64] #define __pyx_n_u_next_position __pyx_string_tab[65] #define __pyx_n_u_object __pyx_string_tab[66] #define __pyx_n_u_offsets __pyx_string_tab[67] #define __pyx_n_u_offsets_ptr __pyx_string_tab[68] #define __pyx_n_u_pop __pyx_string_tab[69] #define __pyx_n_u_pyx_checksum __pyx_string_tab[70] #define __pyx_n_u_pyx_result __pyx_string_tab[71] #define __pyx_n_u_pyx_state __pyx_string_tab[72] #define __pyx_n_u_pyx_type __pyx_string_tab[73] #define __pyx_n_u_pyx_unpickle_BufferedReader __pyx_string_tab[74] #define __pyx_n_u_pyx_unpickle_BufferedSocketRea __pyx_string_tab[75] #define __pyx_n_u_pyx_unpickle_CompressedBuffere __pyx_string_tab[76] #define __pyx_n_u_qualname __pyx_string_tab[77] #define __pyx_n_u_read __pyx_string_tab[78] #define __pyx_n_u_read_block __pyx_string_tab[79] #define __pyx_n_u_read_bytes __pyx_string_tab[80] #define __pyx_n_u_read_fixed_strings __pyx_string_tab[81] #define __pyx_n_u_read_fixed_strings_as_bytes __pyx_string_tab[82] #define __pyx_n_u_read_into_buffer __pyx_string_tab[83] #define __pyx_n_u_read_one __pyx_string_tab[84] #define __pyx_n_u_read_strings __pyx_string_tab[85] #define __pyx_n_u_read_strings_arrow __pyx_string_tab[86] #define __pyx_n_u_recv_into __pyx_string_tab[87] #define __pyx_n_u_reduce __pyx_string_tab[88] #define __pyx_n_u_reduce_cython __pyx_string_tab[89] #define __pyx_n_u_reduce_ex __pyx_string_tab[90] #define __pyx_n_u_right __pyx_string_tab[91] #define __pyx_n_u_rv __pyx_string_tab[92] #define __pyx_n_u_self __pyx_string_tab[93] #define __pyx_n_u_set_name __pyx_string_tab[94] #define __pyx_n_u_setdefault __pyx_string_tab[95] #define __pyx_n_u_setstate __pyx_string_tab[96] #define __pyx_n_u_setstate_cython __pyx_string_tab[97] #define __pyx_n_u_shift __pyx_string_tab[98] #define __pyx_n_u_size __pyx_string_tab[99] #define __pyx_n_u_sock __pyx_string_tab[100] #define __pyx_n_u_state __pyx_string_tab[101] #define __pyx_n_u_super __pyx_string_tab[102] #define __pyx_n_u_t __pyx_string_tab[103] #define __pyx_n_u_test __pyx_string_tab[104] #define __pyx_n_u_unread __pyx_string_tab[105] #define __pyx_n_u_update __pyx_string_tab[106] #define __pyx_n_u_use_setstate __pyx_string_tab[107] #define __pyx_n_u_values __pyx_string_tab[108] #define __pyx_kp_b_iso88591_1A_4AT_a_0_1_xwaq_q_1_y_QfA_E_a __pyx_string_tab[109] #define __pyx_kp_b_iso88591_2_6 __pyx_string_tab[110] #define __pyx_kp_b_iso88591_6avQ __pyx_string_tab[111] #define __pyx_kp_b_iso88591_AV1 __pyx_string_tab[112] #define __pyx_kp_b_iso88591_A_1_r_Q_4q_A_A_5_WARt1_4AT_U_gRq __pyx_string_tab[113] #define __pyx_kp_b_iso88591_A_4AT_2XRs_A_m3Gq_1E_A_0_Bb_XRq __pyx_string_tab[114] #define __pyx_kp_b_iso88591_A_4uJat1_4_Cq_1 __pyx_string_tab[115] #define __pyx_kp_b_iso88591_A_4z_D_A_T_Q_M_q __pyx_string_tab[116] #define __pyx_kp_b_iso88591_A_9Cq_4_31IQ_87_1_t5_aq_hl_7_A_4 __pyx_string_tab[117] #define __pyx_kp_b_iso88591_A_Jiq_Kq_3at1_4_Cq_1 __pyx_string_tab[118] #define __pyx_kp_b_iso88591_A_a __pyx_string_tab[119] #define __pyx_kp_b_iso88591_A_t5_aq_1A_E_aq_AQhar_9A_Qa_AWCq __pyx_string_tab[120] #define __pyx_kp_b_iso88591_T_4D_4q_G1F_a_vWE_Q_q_q_5T_GST __pyx_string_tab[121] #define __pyx_kp_b_iso88591_T_4D_4q_G1F_a_vWE_Q_q_q_9_Qg_PW __pyx_string_tab[122] #define __pyx_kp_b_iso88591_T_4D_G1F_a_vWE_Q_q_q_t1G_gQ_t1G __pyx_string_tab[123] #define __pyx_kp_b_iso88591_q_0_kQR_7_0_1B_PQ_1 __pyx_string_tab[124] #define __pyx_kp_b_iso88591_q_0_kQR_81A_7_VVdde_1 __pyx_string_tab[125] #define __pyx_kp_b_iso88591_q_0_kQR_xq_7_6a7Nn_1 __pyx_string_tab[126] #define __pyx_int_72267464 __pyx_number_tab[0] #define __pyx_int_98621312 __pyx_number_tab[1] #define __pyx_int_110699518 __pyx_number_tab[2] /* #### Code section: module_state_clear ### */ #if CYTHON_USE_MODULE_STATE static CYTHON_SMALL_CODE int __pyx_m_clear(PyObject *m) { __pyx_mstatetype *clear_module_state = __Pyx_PyModule_GetState(m); if (!clear_module_state) return 0; Py_CLEAR(clear_module_state->__pyx_d); Py_CLEAR(clear_module_state->__pyx_b); Py_CLEAR(clear_module_state->__pyx_cython_runtime); Py_CLEAR(clear_module_state->__pyx_empty_tuple); Py_CLEAR(clear_module_state->__pyx_empty_bytes); Py_CLEAR(clear_module_state->__pyx_empty_unicode); #if CYTHON_PEP489_MULTI_PHASE_INIT __Pyx_State_RemoveModule(NULL); #endif Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_4type_type); Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_4bool_bool); Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_7complex_complex); Py_CLEAR(clear_module_state->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader); Py_CLEAR(clear_module_state->__pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader); Py_CLEAR(clear_module_state->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader); Py_CLEAR(clear_module_state->__pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader); Py_CLEAR(clear_module_state->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader); Py_CLEAR(clear_module_state->__pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader); for (int i=0; i<4; ++i) { Py_CLEAR(clear_module_state->__pyx_tuple[i]); } for (int i=0; i<18; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); } for (int i=0; i<127; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); } for (int i=0; i<3; ++i) { Py_CLEAR(clear_module_state->__pyx_number_tab[i]); } /* #### Code section: module_state_clear_contents ### */ /* CommonTypesMetaclass.module_state_clear */ Py_CLEAR(clear_module_state->__pyx_CommonTypesMetaclassType); /* CythonFunctionShared.module_state_clear */ Py_CLEAR(clear_module_state->__pyx_CyFunctionType); /* #### Code section: module_state_clear_end ### */ return 0; } #endif /* #### Code section: module_state_traverse ### */ #if CYTHON_USE_MODULE_STATE static CYTHON_SMALL_CODE int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) { __pyx_mstatetype *traverse_module_state = __Pyx_PyModule_GetState(m); if (!traverse_module_state) return 0; Py_VISIT(traverse_module_state->__pyx_d); Py_VISIT(traverse_module_state->__pyx_b); Py_VISIT(traverse_module_state->__pyx_cython_runtime); __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_tuple); __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_bytes); __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_unicode); Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_4type_type); Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_4bool_bool); Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_7complex_complex); Py_VISIT(traverse_module_state->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader); Py_VISIT(traverse_module_state->__pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader); Py_VISIT(traverse_module_state->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader); Py_VISIT(traverse_module_state->__pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader); Py_VISIT(traverse_module_state->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader); Py_VISIT(traverse_module_state->__pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader); for (int i=0; i<4; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_tuple[i]); } for (int i=0; i<18; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); } for (int i=0; i<127; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); } for (int i=0; i<3; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_number_tab[i]); } /* #### Code section: module_state_traverse_contents ### */ /* CommonTypesMetaclass.module_state_traverse */ Py_VISIT(traverse_module_state->__pyx_CommonTypesMetaclassType); /* CythonFunctionShared.module_state_traverse */ Py_VISIT(traverse_module_state->__pyx_CyFunctionType); /* #### Code section: module_state_traverse_end ### */ return 0; } #endif /* #### Code section: module_code ### */ /* "cpython/complex.pxd":20 * * # unavailable in limited API * @property # <<<<<<<<<<<<<< * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double real(self) noexcept: */ #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4real_real(PyComplexObject *__pyx_v_self) { double __pyx_r; /* "cpython/complex.pxd":23 * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double real(self) noexcept: * return self.cval.real # <<<<<<<<<<<<<< * * # unavailable in limited API */ __pyx_r = __pyx_v_self->cval.real; goto __pyx_L0; /* "cpython/complex.pxd":20 * * # unavailable in limited API * @property # <<<<<<<<<<<<<< * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double real(self) noexcept: */ /* function exit code */ __pyx_L0:; return __pyx_r; } #endif /*!(#if !CYTHON_COMPILING_IN_LIMITED_API)*/ /* "cpython/complex.pxd":26 * * # unavailable in limited API * @property # <<<<<<<<<<<<<< * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double imag(self) noexcept: */ #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4imag_imag(PyComplexObject *__pyx_v_self) { double __pyx_r; /* "cpython/complex.pxd":29 * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double imag(self) noexcept: * return self.cval.imag # <<<<<<<<<<<<<< * * # PyTypeObject PyComplex_Type */ __pyx_r = __pyx_v_self->cval.imag; goto __pyx_L0; /* "cpython/complex.pxd":26 * * # unavailable in limited API * @property # <<<<<<<<<<<<<< * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double imag(self) noexcept: */ /* function exit code */ __pyx_L0:; return __pyx_r; } #endif /*!(#if !CYTHON_COMPILING_IN_LIMITED_API)*/ /* "cpython/contextvars.pxd":115 * * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") # <<<<<<<<<<<<<< * cdef inline object get_value(var, default_value=None): * """Return a new reference to the value of the context variable, */ #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE PyObject *__pyx_f_7cpython_11contextvars_get_value(PyObject *__pyx_v_var, struct __pyx_opt_args_7cpython_11contextvars_get_value *__pyx_optional_args) { /* "cpython/contextvars.pxd":116 * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline object get_value(var, default_value=None): # <<<<<<<<<<<<<< * """Return a new reference to the value of the context variable, * or the default value of the context variable, */ PyObject *__pyx_v_default_value = ((PyObject *)Py_None); PyObject *__pyx_v_value; PyObject *__pyx_v_pyvalue = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_value", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_default_value = __pyx_optional_args->default_value; } } /* "cpython/contextvars.pxd":121 * or None if no such value or default was found. * """ * cdef PyObject *value = NULL # <<<<<<<<<<<<<< * PyContextVar_Get(var, NULL, &value) * if value is NULL: */ __pyx_v_value = NULL; /* "cpython/contextvars.pxd":122 * """ * cdef PyObject *value = NULL * PyContextVar_Get(var, NULL, &value) # <<<<<<<<<<<<<< * if value is NULL: * # context variable does not have a default */ __pyx_t_1 = PyContextVar_Get(__pyx_v_var, NULL, (&__pyx_v_value)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(1, 122, __pyx_L1_error) /* "cpython/contextvars.pxd":123 * cdef PyObject *value = NULL * PyContextVar_Get(var, NULL, &value) * if value is NULL: # <<<<<<<<<<<<<< * # context variable does not have a default * pyvalue = default_value */ __pyx_t_2 = (__pyx_v_value == NULL); if (__pyx_t_2) { /* "cpython/contextvars.pxd":125 * if value is NULL: * # context variable does not have a default * pyvalue = default_value # <<<<<<<<<<<<<< * else: * # value or default value of context variable */ __Pyx_INCREF(__pyx_v_default_value); __pyx_v_pyvalue = __pyx_v_default_value; /* "cpython/contextvars.pxd":123 * cdef PyObject *value = NULL * PyContextVar_Get(var, NULL, &value) * if value is NULL: # <<<<<<<<<<<<<< * # context variable does not have a default * pyvalue = default_value */ goto __pyx_L3; } /* "cpython/contextvars.pxd":128 * else: * # value or default value of context variable * pyvalue = value # <<<<<<<<<<<<<< * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' * return pyvalue */ /*else*/ { __pyx_t_3 = ((PyObject *)__pyx_v_value); __Pyx_INCREF(__pyx_t_3); __pyx_v_pyvalue = __pyx_t_3; __pyx_t_3 = 0; /* "cpython/contextvars.pxd":129 * # value or default value of context variable * pyvalue = value * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' # <<<<<<<<<<<<<< * return pyvalue * */ Py_XDECREF(__pyx_v_value); } __pyx_L3:; /* "cpython/contextvars.pxd":130 * pyvalue = value * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' * return pyvalue # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_pyvalue); __pyx_r = __pyx_v_pyvalue; goto __pyx_L0; /* "cpython/contextvars.pxd":115 * * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") # <<<<<<<<<<<<<< * cdef inline object get_value(var, default_value=None): * """Return a new reference to the value of the context variable, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("cpython.contextvars.get_value", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_pyvalue); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /*!(#if !CYTHON_COMPILING_IN_LIMITED_API)*/ /* "cpython/contextvars.pxd":133 * * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") # <<<<<<<<<<<<<< * cdef inline object get_value_no_default(var, default_value=None): * """Return a new reference to the value of the context variable, */ #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE PyObject *__pyx_f_7cpython_11contextvars_get_value_no_default(PyObject *__pyx_v_var, struct __pyx_opt_args_7cpython_11contextvars_get_value_no_default *__pyx_optional_args) { /* "cpython/contextvars.pxd":134 * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline object get_value_no_default(var, default_value=None): # <<<<<<<<<<<<<< * """Return a new reference to the value of the context variable, * or the provided default value if no such value was found. */ PyObject *__pyx_v_default_value = ((PyObject *)Py_None); PyObject *__pyx_v_value; PyObject *__pyx_v_pyvalue = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_value_no_default", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_default_value = __pyx_optional_args->default_value; } } /* "cpython/contextvars.pxd":140 * Ignores the default value of the context variable, if any. * """ * cdef PyObject *value = NULL # <<<<<<<<<<<<<< * PyContextVar_Get(var, default_value, &value) * # value of context variable or 'default_value' */ __pyx_v_value = NULL; /* "cpython/contextvars.pxd":141 * """ * cdef PyObject *value = NULL * PyContextVar_Get(var, default_value, &value) # <<<<<<<<<<<<<< * # value of context variable or 'default_value' * pyvalue = value */ __pyx_t_1 = PyContextVar_Get(__pyx_v_var, ((PyObject *)__pyx_v_default_value), (&__pyx_v_value)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(1, 141, __pyx_L1_error) /* "cpython/contextvars.pxd":143 * PyContextVar_Get(var, default_value, &value) * # value of context variable or 'default_value' * pyvalue = value # <<<<<<<<<<<<<< * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' * return pyvalue */ __pyx_t_2 = ((PyObject *)__pyx_v_value); __Pyx_INCREF(__pyx_t_2); __pyx_v_pyvalue = __pyx_t_2; __pyx_t_2 = 0; /* "cpython/contextvars.pxd":144 * # value of context variable or 'default_value' * pyvalue = value * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' # <<<<<<<<<<<<<< * return pyvalue */ Py_XDECREF(__pyx_v_value); /* "cpython/contextvars.pxd":145 * pyvalue = value * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' * return pyvalue # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_pyvalue); __pyx_r = __pyx_v_pyvalue; goto __pyx_L0; /* "cpython/contextvars.pxd":133 * * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") # <<<<<<<<<<<<<< * cdef inline object get_value_no_default(var, default_value=None): * """Return a new reference to the value of the context variable, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("cpython.contextvars.get_value_no_default", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_pyvalue); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /*!(#if !CYTHON_COMPILING_IN_LIMITED_API)*/ /* "clickhouse_driver/bufferedreader.pyx":14 * cdef public bytearray buffer * * def __init__(self, bufsize): # <<<<<<<<<<<<<< * self.buffer = bytearray(bufsize) * */ /* Python wrapper */ static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_bufsize = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_bufsize,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_VARARGS(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 14, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 14, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__init__", 0) < (0)) __PYX_ERR(0, 14, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, i); __PYX_ERR(0, 14, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 14, __pyx_L3_error) } __pyx_v_bufsize = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 14, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader___init__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), __pyx_v_bufsize); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader___init__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v_bufsize) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; size_t __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "clickhouse_driver/bufferedreader.pyx":15 * * def __init__(self, bufsize): * self.buffer = bytearray(bufsize) # <<<<<<<<<<<<<< * * self.position = 0 */ __pyx_t_2 = NULL; __pyx_t_3 = 1; { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_bufsize}; __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(&PyByteArray_Type), __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->buffer); __Pyx_DECREF(__pyx_v_self->buffer); __pyx_v_self->buffer = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":17 * self.buffer = bytearray(bufsize) * * self.position = 0 # <<<<<<<<<<<<<< * self.current_buffer_size = 0 * */ __pyx_v_self->position = 0; /* "clickhouse_driver/bufferedreader.pyx":18 * * self.position = 0 * self.current_buffer_size = 0 # <<<<<<<<<<<<<< * * super(BufferedReader, self).__init__() */ __pyx_v_self->current_buffer_size = 0; /* "clickhouse_driver/bufferedreader.pyx":20 * self.current_buffer_size = 0 * * super(BufferedReader, self).__init__() # <<<<<<<<<<<<<< * * def read_into_buffer(self): */ __pyx_t_5 = NULL; __pyx_t_3 = 1; { PyObject *__pyx_callargs[3] = {__pyx_t_5, ((PyObject *)__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader), ((PyObject *)__pyx_v_self)}; __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_super, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); } __pyx_t_2 = __pyx_t_4; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_init, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":14 * cdef public bytearray buffer * * def __init__(self, bufsize): # <<<<<<<<<<<<<< * self.buffer = bytearray(bufsize) * */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedreader.pyx":22 * super(BufferedReader, self).__init__() * * def read_into_buffer(self): # <<<<<<<<<<<<<< * raise NotImplementedError * */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_3read_into_buffer(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_3read_into_buffer = {"read_into_buffer", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_3read_into_buffer, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_3read_into_buffer(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_into_buffer (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("read_into_buffer", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("read_into_buffer", __pyx_kwds); return NULL;} __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_2read_into_buffer(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_2read_into_buffer(CYTHON_UNUSED struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_into_buffer", 0); /* "clickhouse_driver/bufferedreader.pyx":23 * * def read_into_buffer(self): * raise NotImplementedError # <<<<<<<<<<<<<< * * def read(self, unsigned long long unread): */ __Pyx_Raise(((PyObject *)(((PyTypeObject*)PyExc_NotImplementedError))), 0, 0, 0); __PYX_ERR(0, 23, __pyx_L1_error) /* "clickhouse_driver/bufferedreader.pyx":22 * super(BufferedReader, self).__init__() * * def read_into_buffer(self): # <<<<<<<<<<<<<< * raise NotImplementedError * */ /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_into_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedreader.pyx":25 * raise NotImplementedError * * def read(self, unsigned long long unread): # <<<<<<<<<<<<<< * # When the buffer is large enough bytes read are almost * # always hit the buffer. */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_5read(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_5read = {"read", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_5read, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_5read(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { unsigned PY_LONG_LONG __pyx_v_unread; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_unread,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 25, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 25, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "read", 0) < (0)) __PYX_ERR(0, 25, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("read", 1, 1, 1, i); __PYX_ERR(0, 25, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 25, __pyx_L3_error) } __pyx_v_unread = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(values[0]); if (unlikely((__pyx_v_unread == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 25, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("read", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 25, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_4read(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), __pyx_v_unread); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_4read(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, unsigned PY_LONG_LONG __pyx_v_unread) { unsigned PY_LONG_LONG __pyx_v_next_position; unsigned PY_LONG_LONG __pyx_v_t; char *__pyx_v_buffer_ptr; unsigned PY_LONG_LONG __pyx_v_read_bytes; PyObject *__pyx_v_rv = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; unsigned PY_LONG_LONG __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; size_t __pyx_t_6; unsigned PY_LONG_LONG __pyx_t_7; unsigned PY_LONG_LONG __pyx_t_8; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read", 0); /* "clickhouse_driver/bufferedreader.pyx":28 * # When the buffer is large enough bytes read are almost * # always hit the buffer. * cdef unsigned long long next_position = unread + self.position # <<<<<<<<<<<<<< * if next_position < self.current_buffer_size: * t = self.position */ __pyx_v_next_position = (__pyx_v_unread + __pyx_v_self->position); /* "clickhouse_driver/bufferedreader.pyx":29 * # always hit the buffer. * cdef unsigned long long next_position = unread + self.position * if next_position < self.current_buffer_size: # <<<<<<<<<<<<<< * t = self.position * self.position = next_position */ __pyx_t_1 = (__pyx_v_next_position < __pyx_v_self->current_buffer_size); if (__pyx_t_1) { /* "clickhouse_driver/bufferedreader.pyx":30 * cdef unsigned long long next_position = unread + self.position * if next_position < self.current_buffer_size: * t = self.position # <<<<<<<<<<<<<< * self.position = next_position * return bytes(self.buffer[t:self.position]) */ __pyx_t_2 = __pyx_v_self->position; __pyx_v_t = __pyx_t_2; /* "clickhouse_driver/bufferedreader.pyx":31 * if next_position < self.current_buffer_size: * t = self.position * self.position = next_position # <<<<<<<<<<<<<< * return bytes(self.buffer[t:self.position]) * */ __pyx_v_self->position = __pyx_v_next_position; /* "clickhouse_driver/bufferedreader.pyx":32 * t = self.position * self.position = next_position * return bytes(self.buffer[t:self.position]) # <<<<<<<<<<<<<< * * cdef char* buffer_ptr = PyByteArray_AsString(self.buffer) */ __Pyx_XDECREF(__pyx_r); __pyx_t_4 = NULL; if (unlikely(__pyx_v_self->buffer == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 32, __pyx_L1_error) } __pyx_t_5 = PySequence_GetSlice(__pyx_v_self->buffer, __pyx_v_t, __pyx_v_self->position); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = 1; { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_5}; __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(&PyBytes_Type), __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* "clickhouse_driver/bufferedreader.pyx":29 * # always hit the buffer. * cdef unsigned long long next_position = unread + self.position * if next_position < self.current_buffer_size: # <<<<<<<<<<<<<< * t = self.position * self.position = next_position */ } /* "clickhouse_driver/bufferedreader.pyx":34 * return bytes(self.buffer[t:self.position]) * * cdef char* buffer_ptr = PyByteArray_AsString(self.buffer) # <<<<<<<<<<<<<< * cdef unsigned long long read_bytes * rv = bytes() */ __pyx_t_3 = __pyx_v_self->buffer; __Pyx_INCREF(__pyx_t_3); __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "clickhouse_driver/bufferedreader.pyx":36 * cdef char* buffer_ptr = PyByteArray_AsString(self.buffer) * cdef unsigned long long read_bytes * rv = bytes() # <<<<<<<<<<<<<< * * while unread > 0: */ __pyx_t_5 = NULL; __pyx_t_6 = 1; { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(&PyBytes_Type), __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } __pyx_v_rv = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "clickhouse_driver/bufferedreader.pyx":38 * rv = bytes() * * while unread > 0: # <<<<<<<<<<<<<< * if self.position == self.current_buffer_size: * self.read_into_buffer() */ while (1) { __pyx_t_1 = (__pyx_v_unread > 0); if (!__pyx_t_1) break; /* "clickhouse_driver/bufferedreader.pyx":39 * * while unread > 0: * if self.position == self.current_buffer_size: # <<<<<<<<<<<<<< * self.read_into_buffer() * buffer_ptr = PyByteArray_AsString(self.buffer) */ __pyx_t_1 = (__pyx_v_self->position == __pyx_v_self->current_buffer_size); if (__pyx_t_1) { /* "clickhouse_driver/bufferedreader.pyx":40 * while unread > 0: * if self.position == self.current_buffer_size: * self.read_into_buffer() # <<<<<<<<<<<<<< * buffer_ptr = PyByteArray_AsString(self.buffer) * self.position = 0 */ __pyx_t_5 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_read_into_buffer, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "clickhouse_driver/bufferedreader.pyx":41 * if self.position == self.current_buffer_size: * self.read_into_buffer() * buffer_ptr = PyByteArray_AsString(self.buffer) # <<<<<<<<<<<<<< * self.position = 0 * */ __pyx_t_3 = __pyx_v_self->buffer; __Pyx_INCREF(__pyx_t_3); __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "clickhouse_driver/bufferedreader.pyx":42 * self.read_into_buffer() * buffer_ptr = PyByteArray_AsString(self.buffer) * self.position = 0 # <<<<<<<<<<<<<< * * read_bytes = min(unread, self.current_buffer_size - self.position) */ __pyx_v_self->position = 0; /* "clickhouse_driver/bufferedreader.pyx":39 * * while unread > 0: * if self.position == self.current_buffer_size: # <<<<<<<<<<<<<< * self.read_into_buffer() * buffer_ptr = PyByteArray_AsString(self.buffer) */ } /* "clickhouse_driver/bufferedreader.pyx":44 * self.position = 0 * * read_bytes = min(unread, self.current_buffer_size - self.position) # <<<<<<<<<<<<<< * rv += PyBytes_FromStringAndSize( * &buffer_ptr[self.position], read_bytes */ __pyx_t_2 = (__pyx_v_self->current_buffer_size - __pyx_v_self->position); __pyx_t_7 = __pyx_v_unread; __pyx_t_1 = (__pyx_t_2 < __pyx_t_7); if (__pyx_t_1) { __pyx_t_8 = __pyx_t_2; } else { __pyx_t_8 = __pyx_t_7; } __pyx_v_read_bytes = __pyx_t_8; /* "clickhouse_driver/bufferedreader.pyx":45 * * read_bytes = min(unread, self.current_buffer_size - self.position) * rv += PyBytes_FromStringAndSize( # <<<<<<<<<<<<<< * &buffer_ptr[self.position], read_bytes * ) */ __pyx_t_3 = PyBytes_FromStringAndSize((&(__pyx_v_buffer_ptr[__pyx_v_self->position])), __pyx_v_read_bytes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_rv, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_rv, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0; /* "clickhouse_driver/bufferedreader.pyx":48 * &buffer_ptr[self.position], read_bytes * ) * self.position += read_bytes # <<<<<<<<<<<<<< * unread -= read_bytes * */ __pyx_v_self->position = (__pyx_v_self->position + __pyx_v_read_bytes); /* "clickhouse_driver/bufferedreader.pyx":49 * ) * self.position += read_bytes * unread -= read_bytes # <<<<<<<<<<<<<< * * return rv */ __pyx_v_unread = (__pyx_v_unread - __pyx_v_read_bytes); } /* "clickhouse_driver/bufferedreader.pyx":51 * unread -= read_bytes * * return rv # <<<<<<<<<<<<<< * * def read_one(self): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_rv); __pyx_r = __pyx_v_rv; goto __pyx_L0; /* "clickhouse_driver/bufferedreader.pyx":25 * raise NotImplementedError * * def read(self, unsigned long long unread): # <<<<<<<<<<<<<< * # When the buffer is large enough bytes read are almost * # always hit the buffer. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_rv); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedreader.pyx":53 * return rv * * def read_one(self): # <<<<<<<<<<<<<< * if self.position == self.current_buffer_size: * self.read_into_buffer() */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_7read_one(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_7read_one = {"read_one", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_7read_one, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_7read_one(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_one (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("read_one", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("read_one", __pyx_kwds); return NULL;} __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6read_one(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6read_one(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self) { unsigned char __pyx_v_rv; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; size_t __pyx_t_4; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_one", 0); /* "clickhouse_driver/bufferedreader.pyx":54 * * def read_one(self): * if self.position == self.current_buffer_size: # <<<<<<<<<<<<<< * self.read_into_buffer() * self.position = 0 */ __pyx_t_1 = (__pyx_v_self->position == __pyx_v_self->current_buffer_size); if (__pyx_t_1) { /* "clickhouse_driver/bufferedreader.pyx":55 * def read_one(self): * if self.position == self.current_buffer_size: * self.read_into_buffer() # <<<<<<<<<<<<<< * self.position = 0 * */ __pyx_t_3 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_read_into_buffer, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedreader.pyx":56 * if self.position == self.current_buffer_size: * self.read_into_buffer() * self.position = 0 # <<<<<<<<<<<<<< * * rv = self.buffer[self.position] */ __pyx_v_self->position = 0; /* "clickhouse_driver/bufferedreader.pyx":54 * * def read_one(self): * if self.position == self.current_buffer_size: # <<<<<<<<<<<<<< * self.read_into_buffer() * self.position = 0 */ } /* "clickhouse_driver/bufferedreader.pyx":58 * self.position = 0 * * rv = self.buffer[self.position] # <<<<<<<<<<<<<< * self.position += 1 * return rv */ __pyx_t_5 = __Pyx_GetItemInt_ByteArray(__pyx_v_self->buffer, __pyx_v_self->position, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 58, __pyx_L1_error) __pyx_v_rv = __pyx_t_5; /* "clickhouse_driver/bufferedreader.pyx":59 * * rv = self.buffer[self.position] * self.position += 1 # <<<<<<<<<<<<<< * return rv * */ __pyx_v_self->position = (__pyx_v_self->position + 1); /* "clickhouse_driver/bufferedreader.pyx":60 * rv = self.buffer[self.position] * self.position += 1 * return rv # <<<<<<<<<<<<<< * * def read_strings(self, unsigned long long n_items, encoding=None): */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyLong_From_unsigned_char(__pyx_v_rv); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "clickhouse_driver/bufferedreader.pyx":53 * return rv * * def read_one(self): # <<<<<<<<<<<<<< * if self.position == self.current_buffer_size: * self.read_into_buffer() */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_one", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedreader.pyx":62 * return rv * * def read_strings(self, unsigned long long n_items, encoding=None): # <<<<<<<<<<<<<< * """ * Python has great overhead between function calls. */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_9read_strings(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_17clickhouse_driver_14bufferedreader_14BufferedReader_8read_strings, "\n Python has great overhead between function calls.\n We inline strings reading logic here to avoid this overhead.\n "); static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_9read_strings = {"read_strings", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_9read_strings, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_17clickhouse_driver_14bufferedreader_14BufferedReader_8read_strings}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_9read_strings(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { unsigned PY_LONG_LONG __pyx_v_n_items; PyObject *__pyx_v_encoding = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[2] = {0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_strings (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_n_items,&__pyx_mstate_global->__pyx_n_u_encoding,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 62, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 62, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 62, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "read_strings", 0) < (0)) __PYX_ERR(0, 62, __pyx_L3_error) if (!values[1]) values[1] = __Pyx_NewRef(((PyObject *)Py_None)); for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("read_strings", 0, 1, 2, i); __PYX_ERR(0, 62, __pyx_L3_error) } } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 62, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 62, __pyx_L3_error) break; default: goto __pyx_L5_argtuple_error; } if (!values[1]) values[1] = __Pyx_NewRef(((PyObject *)Py_None)); } __pyx_v_n_items = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(values[0]); if (unlikely((__pyx_v_n_items == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 62, __pyx_L3_error) __pyx_v_encoding = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("read_strings", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 62, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_strings", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8read_strings(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), __pyx_v_n_items, __pyx_v_encoding); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8read_strings(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, unsigned PY_LONG_LONG __pyx_v_n_items, PyObject *__pyx_v_encoding) { PyObject *__pyx_v_items = NULL; unsigned PY_LONG_LONG __pyx_v_i; char *__pyx_v_buffer_ptr; unsigned PY_LONG_LONG __pyx_v_right; unsigned PY_LONG_LONG __pyx_v_size; unsigned PY_LONG_LONG __pyx_v_shift; unsigned PY_LONG_LONG __pyx_v_bytes_read; unsigned PY_LONG_LONG __pyx_v_b; char *__pyx_v_c_string; unsigned PY_LONG_LONG __pyx_v_c_string_size; char *__pyx_v_c_encoding; PyObject *__pyx_v_rv = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; size_t __pyx_t_4; char *__pyx_t_5; unsigned PY_LONG_LONG __pyx_t_6; unsigned PY_LONG_LONG __pyx_t_7; unsigned PY_LONG_LONG __pyx_t_8; unsigned PY_LONG_LONG __pyx_t_9; unsigned PY_LONG_LONG __pyx_t_10; unsigned PY_LONG_LONG __pyx_t_11; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; int __pyx_t_15; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_strings", 0); __Pyx_INCREF(__pyx_v_encoding); /* "clickhouse_driver/bufferedreader.pyx":67 * We inline strings reading logic here to avoid this overhead. * """ * items = PyTuple_New(n_items) # <<<<<<<<<<<<<< * * cdef unsigned long long i */ __pyx_t_1 = PyTuple_New(__pyx_v_n_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_items = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":71 * cdef unsigned long long i * # Buffer vars * cdef char* buffer_ptr = PyByteArray_AsString(self.buffer) # <<<<<<<<<<<<<< * cdef unsigned long long right * # String length vars */ __pyx_t_1 = __pyx_v_self->buffer; __Pyx_INCREF(__pyx_t_1); __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":78 * * # String for decode vars. * cdef char *c_string = NULL # <<<<<<<<<<<<<< * cdef unsigned long long c_string_size = 1024 * cdef char *c_encoding = NULL */ __pyx_v_c_string = NULL; /* "clickhouse_driver/bufferedreader.pyx":79 * # String for decode vars. * cdef char *c_string = NULL * cdef unsigned long long c_string_size = 1024 # <<<<<<<<<<<<<< * cdef char *c_encoding = NULL * if encoding: */ __pyx_v_c_string_size = 0x400; /* "clickhouse_driver/bufferedreader.pyx":80 * cdef char *c_string = NULL * cdef unsigned long long c_string_size = 1024 * cdef char *c_encoding = NULL # <<<<<<<<<<<<<< * if encoding: * encoding = encoding.encode('utf-8') */ __pyx_v_c_encoding = NULL; /* "clickhouse_driver/bufferedreader.pyx":81 * cdef unsigned long long c_string_size = 1024 * cdef char *c_encoding = NULL * if encoding: # <<<<<<<<<<<<<< * encoding = encoding.encode('utf-8') * c_encoding = encoding */ __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_encoding); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 81, __pyx_L1_error) if (__pyx_t_2) { /* "clickhouse_driver/bufferedreader.pyx":82 * cdef char *c_encoding = NULL * if encoding: * encoding = encoding.encode('utf-8') # <<<<<<<<<<<<<< * c_encoding = encoding * */ __pyx_t_3 = __pyx_v_encoding; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_utf_8}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_encode, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_DECREF_SET(__pyx_v_encoding, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":83 * if encoding: * encoding = encoding.encode('utf-8') * c_encoding = encoding # <<<<<<<<<<<<<< * * cdef object rv = object() */ __pyx_t_5 = __Pyx_PyObject_AsWritableString(__pyx_v_encoding); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) __PYX_ERR(0, 83, __pyx_L1_error) __pyx_v_c_encoding = __pyx_t_5; /* "clickhouse_driver/bufferedreader.pyx":81 * cdef unsigned long long c_string_size = 1024 * cdef char *c_encoding = NULL * if encoding: # <<<<<<<<<<<<<< * encoding = encoding.encode('utf-8') * c_encoding = encoding */ } /* "clickhouse_driver/bufferedreader.pyx":85 * c_encoding = encoding * * cdef object rv = object() # <<<<<<<<<<<<<< * # String for decode vars. * if c_encoding: */ __pyx_t_3 = NULL; __pyx_t_4 = 1; { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_object, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_v_rv = __pyx_t_1; __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":87 * cdef object rv = object() * # String for decode vars. * if c_encoding: # <<<<<<<<<<<<<< * c_string = PyMem_Realloc(NULL, c_string_size) * */ __pyx_t_2 = (__pyx_v_c_encoding != 0); if (__pyx_t_2) { /* "clickhouse_driver/bufferedreader.pyx":88 * # String for decode vars. * if c_encoding: * c_string = PyMem_Realloc(NULL, c_string_size) # <<<<<<<<<<<<<< * * for i in range(n_items): */ __pyx_v_c_string = ((char *)PyMem_Realloc(NULL, __pyx_v_c_string_size)); /* "clickhouse_driver/bufferedreader.pyx":87 * cdef object rv = object() * # String for decode vars. * if c_encoding: # <<<<<<<<<<<<<< * c_string = PyMem_Realloc(NULL, c_string_size) * */ } /* "clickhouse_driver/bufferedreader.pyx":90 * c_string = PyMem_Realloc(NULL, c_string_size) * * for i in range(n_items): # <<<<<<<<<<<<<< * shift = size = 0 * */ __pyx_t_6 = __pyx_v_n_items; __pyx_t_7 = __pyx_t_6; for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_v_i = __pyx_t_8; /* "clickhouse_driver/bufferedreader.pyx":91 * * for i in range(n_items): * shift = size = 0 # <<<<<<<<<<<<<< * * # Read string size */ __pyx_v_shift = 0; __pyx_v_size = 0; /* "clickhouse_driver/bufferedreader.pyx":94 * * # Read string size * while True: # <<<<<<<<<<<<<< * if self.position == self.current_buffer_size: * self.read_into_buffer() */ while (1) { /* "clickhouse_driver/bufferedreader.pyx":95 * # Read string size * while True: * if self.position == self.current_buffer_size: # <<<<<<<<<<<<<< * self.read_into_buffer() * # `read_into_buffer` can override buffer */ __pyx_t_2 = (__pyx_v_self->position == __pyx_v_self->current_buffer_size); if (__pyx_t_2) { /* "clickhouse_driver/bufferedreader.pyx":96 * while True: * if self.position == self.current_buffer_size: * self.read_into_buffer() # <<<<<<<<<<<<<< * # `read_into_buffer` can override buffer * buffer_ptr = PyByteArray_AsString(self.buffer) */ __pyx_t_3 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_read_into_buffer, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":98 * self.read_into_buffer() * # `read_into_buffer` can override buffer * buffer_ptr = PyByteArray_AsString(self.buffer) # <<<<<<<<<<<<<< * self.position = 0 * */ __pyx_t_1 = __pyx_v_self->buffer; __Pyx_INCREF(__pyx_t_1); __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":99 * # `read_into_buffer` can override buffer * buffer_ptr = PyByteArray_AsString(self.buffer) * self.position = 0 # <<<<<<<<<<<<<< * * b = buffer_ptr[self.position] */ __pyx_v_self->position = 0; /* "clickhouse_driver/bufferedreader.pyx":95 * # Read string size * while True: * if self.position == self.current_buffer_size: # <<<<<<<<<<<<<< * self.read_into_buffer() * # `read_into_buffer` can override buffer */ } /* "clickhouse_driver/bufferedreader.pyx":101 * self.position = 0 * * b = buffer_ptr[self.position] # <<<<<<<<<<<<<< * self.position += 1 * */ __pyx_v_b = (__pyx_v_buffer_ptr[__pyx_v_self->position]); /* "clickhouse_driver/bufferedreader.pyx":102 * * b = buffer_ptr[self.position] * self.position += 1 # <<<<<<<<<<<<<< * * size |= (b & 0x7f) << shift */ __pyx_v_self->position = (__pyx_v_self->position + 1); /* "clickhouse_driver/bufferedreader.pyx":104 * self.position += 1 * * size |= (b & 0x7f) << shift # <<<<<<<<<<<<<< * if b < 0x80: * break */ __pyx_v_size = (__pyx_v_size | ((__pyx_v_b & 0x7f) << __pyx_v_shift)); /* "clickhouse_driver/bufferedreader.pyx":105 * * size |= (b & 0x7f) << shift * if b < 0x80: # <<<<<<<<<<<<<< * break * */ __pyx_t_2 = (__pyx_v_b < 0x80); if (__pyx_t_2) { /* "clickhouse_driver/bufferedreader.pyx":106 * size |= (b & 0x7f) << shift * if b < 0x80: * break # <<<<<<<<<<<<<< * * shift += 7 */ goto __pyx_L8_break; /* "clickhouse_driver/bufferedreader.pyx":105 * * size |= (b & 0x7f) << shift * if b < 0x80: # <<<<<<<<<<<<<< * break * */ } /* "clickhouse_driver/bufferedreader.pyx":108 * break * * shift += 7 # <<<<<<<<<<<<<< * * right = self.position + size */ __pyx_v_shift = (__pyx_v_shift + 7); } __pyx_L8_break:; /* "clickhouse_driver/bufferedreader.pyx":110 * shift += 7 * * right = self.position + size # <<<<<<<<<<<<<< * * if c_encoding: */ __pyx_v_right = (__pyx_v_self->position + __pyx_v_size); /* "clickhouse_driver/bufferedreader.pyx":112 * right = self.position + size * * if c_encoding: # <<<<<<<<<<<<<< * if size + 1 > c_string_size: * c_string_size = size + 1 */ __pyx_t_2 = (__pyx_v_c_encoding != 0); if (__pyx_t_2) { /* "clickhouse_driver/bufferedreader.pyx":113 * * if c_encoding: * if size + 1 > c_string_size: # <<<<<<<<<<<<<< * c_string_size = size + 1 * c_string = PyMem_Realloc(c_string, c_string_size) */ __pyx_t_2 = ((__pyx_v_size + 1) > __pyx_v_c_string_size); if (__pyx_t_2) { /* "clickhouse_driver/bufferedreader.pyx":114 * if c_encoding: * if size + 1 > c_string_size: * c_string_size = size + 1 # <<<<<<<<<<<<<< * c_string = PyMem_Realloc(c_string, c_string_size) * if c_string is NULL: */ __pyx_v_c_string_size = (__pyx_v_size + 1); /* "clickhouse_driver/bufferedreader.pyx":115 * if size + 1 > c_string_size: * c_string_size = size + 1 * c_string = PyMem_Realloc(c_string, c_string_size) # <<<<<<<<<<<<<< * if c_string is NULL: * raise MemoryError() */ __pyx_v_c_string = ((char *)PyMem_Realloc(__pyx_v_c_string, __pyx_v_c_string_size)); /* "clickhouse_driver/bufferedreader.pyx":116 * c_string_size = size + 1 * c_string = PyMem_Realloc(c_string, c_string_size) * if c_string is NULL: # <<<<<<<<<<<<<< * raise MemoryError() * c_string[size] = 0 */ __pyx_t_2 = (__pyx_v_c_string == NULL); if (unlikely(__pyx_t_2)) { /* "clickhouse_driver/bufferedreader.pyx":117 * c_string = PyMem_Realloc(c_string, c_string_size) * if c_string is NULL: * raise MemoryError() # <<<<<<<<<<<<<< * c_string[size] = 0 * bytes_read = 0 */ PyErr_NoMemory(); __PYX_ERR(0, 117, __pyx_L1_error) /* "clickhouse_driver/bufferedreader.pyx":116 * c_string_size = size + 1 * c_string = PyMem_Realloc(c_string, c_string_size) * if c_string is NULL: # <<<<<<<<<<<<<< * raise MemoryError() * c_string[size] = 0 */ } /* "clickhouse_driver/bufferedreader.pyx":113 * * if c_encoding: * if size + 1 > c_string_size: # <<<<<<<<<<<<<< * c_string_size = size + 1 * c_string = PyMem_Realloc(c_string, c_string_size) */ } /* "clickhouse_driver/bufferedreader.pyx":118 * if c_string is NULL: * raise MemoryError() * c_string[size] = 0 # <<<<<<<<<<<<<< * bytes_read = 0 * */ (__pyx_v_c_string[__pyx_v_size]) = 0; /* "clickhouse_driver/bufferedreader.pyx":119 * raise MemoryError() * c_string[size] = 0 * bytes_read = 0 # <<<<<<<<<<<<<< * * # Decoding pure c strings in Cython is faster than in pure Python. */ __pyx_v_bytes_read = 0; /* "clickhouse_driver/bufferedreader.pyx":112 * right = self.position + size * * if c_encoding: # <<<<<<<<<<<<<< * if size + 1 > c_string_size: * c_string_size = size + 1 */ } /* "clickhouse_driver/bufferedreader.pyx":124 * # We need to copy it into buffer for adding null symbol at the end. * # In ClickHouse block there is no null * if right > self.current_buffer_size: # <<<<<<<<<<<<<< * if c_encoding: * memcpy(&c_string[bytes_read], &buffer_ptr[self.position], */ __pyx_t_2 = (__pyx_v_right > __pyx_v_self->current_buffer_size); if (__pyx_t_2) { /* "clickhouse_driver/bufferedreader.pyx":125 * # In ClickHouse block there is no null * if right > self.current_buffer_size: * if c_encoding: # <<<<<<<<<<<<<< * memcpy(&c_string[bytes_read], &buffer_ptr[self.position], * self.current_buffer_size - self.position) */ __pyx_t_2 = (__pyx_v_c_encoding != 0); if (__pyx_t_2) { /* "clickhouse_driver/bufferedreader.pyx":126 * if right > self.current_buffer_size: * if c_encoding: * memcpy(&c_string[bytes_read], &buffer_ptr[self.position], # <<<<<<<<<<<<<< * self.current_buffer_size - self.position) * else: */ (void)(memcpy((&(__pyx_v_c_string[__pyx_v_bytes_read])), (&(__pyx_v_buffer_ptr[__pyx_v_self->position])), (__pyx_v_self->current_buffer_size - __pyx_v_self->position))); /* "clickhouse_driver/bufferedreader.pyx":125 * # In ClickHouse block there is no null * if right > self.current_buffer_size: * if c_encoding: # <<<<<<<<<<<<<< * memcpy(&c_string[bytes_read], &buffer_ptr[self.position], * self.current_buffer_size - self.position) */ goto __pyx_L15; } /* "clickhouse_driver/bufferedreader.pyx":129 * self.current_buffer_size - self.position) * else: * rv = PyBytes_FromStringAndSize( # <<<<<<<<<<<<<< * &buffer_ptr[self.position], * self.current_buffer_size - self.position */ /*else*/ { /* "clickhouse_driver/bufferedreader.pyx":131 * rv = PyBytes_FromStringAndSize( * &buffer_ptr[self.position], * self.current_buffer_size - self.position # <<<<<<<<<<<<<< * ) * */ __pyx_t_1 = PyBytes_FromStringAndSize((&(__pyx_v_buffer_ptr[__pyx_v_self->position])), (__pyx_v_self->current_buffer_size - __pyx_v_self->position)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_rv, __pyx_t_1); __pyx_t_1 = 0; } __pyx_L15:; /* "clickhouse_driver/bufferedreader.pyx":134 * ) * * bytes_read = self.current_buffer_size - self.position # <<<<<<<<<<<<<< * # Read the rest of the string. * while bytes_read != size: */ __pyx_v_bytes_read = (__pyx_v_self->current_buffer_size - __pyx_v_self->position); /* "clickhouse_driver/bufferedreader.pyx":136 * bytes_read = self.current_buffer_size - self.position * # Read the rest of the string. * while bytes_read != size: # <<<<<<<<<<<<<< * self.position = size - bytes_read * */ while (1) { __pyx_t_2 = (__pyx_v_bytes_read != __pyx_v_size); if (!__pyx_t_2) break; /* "clickhouse_driver/bufferedreader.pyx":137 * # Read the rest of the string. * while bytes_read != size: * self.position = size - bytes_read # <<<<<<<<<<<<<< * * self.read_into_buffer() */ __pyx_v_self->position = (__pyx_v_size - __pyx_v_bytes_read); /* "clickhouse_driver/bufferedreader.pyx":139 * self.position = size - bytes_read * * self.read_into_buffer() # <<<<<<<<<<<<<< * # `read_into_buffer` can override buffer * buffer_ptr = PyByteArray_AsString(self.buffer) */ __pyx_t_3 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_read_into_buffer, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":141 * self.read_into_buffer() * # `read_into_buffer` can override buffer * buffer_ptr = PyByteArray_AsString(self.buffer) # <<<<<<<<<<<<<< * # There can be not enough data in buffer. * self.position = min( */ __pyx_t_1 = __pyx_v_self->buffer; __Pyx_INCREF(__pyx_t_1); __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":144 * # There can be not enough data in buffer. * self.position = min( * self.position, self.current_buffer_size # <<<<<<<<<<<<<< * ) * if c_encoding: */ __pyx_t_9 = __pyx_v_self->current_buffer_size; __pyx_t_10 = __pyx_v_self->position; __pyx_t_2 = (__pyx_t_9 < __pyx_t_10); if (__pyx_t_2) { __pyx_t_11 = __pyx_t_9; } else { __pyx_t_11 = __pyx_t_10; } /* "clickhouse_driver/bufferedreader.pyx":143 * buffer_ptr = PyByteArray_AsString(self.buffer) * # There can be not enough data in buffer. * self.position = min( # <<<<<<<<<<<<<< * self.position, self.current_buffer_size * ) */ __pyx_v_self->position = __pyx_t_11; /* "clickhouse_driver/bufferedreader.pyx":146 * self.position, self.current_buffer_size * ) * if c_encoding: # <<<<<<<<<<<<<< * memcpy( * &c_string[bytes_read], buffer_ptr, self.position */ __pyx_t_2 = (__pyx_v_c_encoding != 0); if (__pyx_t_2) { /* "clickhouse_driver/bufferedreader.pyx":147 * ) * if c_encoding: * memcpy( # <<<<<<<<<<<<<< * &c_string[bytes_read], buffer_ptr, self.position * ) */ (void)(memcpy((&(__pyx_v_c_string[__pyx_v_bytes_read])), __pyx_v_buffer_ptr, __pyx_v_self->position)); /* "clickhouse_driver/bufferedreader.pyx":146 * self.position, self.current_buffer_size * ) * if c_encoding: # <<<<<<<<<<<<<< * memcpy( * &c_string[bytes_read], buffer_ptr, self.position */ goto __pyx_L18; } /* "clickhouse_driver/bufferedreader.pyx":151 * ) * else: * rv += PyBytes_FromStringAndSize( # <<<<<<<<<<<<<< * buffer_ptr, self.position * ) */ /*else*/ { /* "clickhouse_driver/bufferedreader.pyx":152 * else: * rv += PyBytes_FromStringAndSize( * buffer_ptr, self.position # <<<<<<<<<<<<<< * ) * bytes_read += self.position */ __pyx_t_1 = PyBytes_FromStringAndSize(__pyx_v_buffer_ptr, __pyx_v_self->position); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); /* "clickhouse_driver/bufferedreader.pyx":151 * ) * else: * rv += PyBytes_FromStringAndSize( # <<<<<<<<<<<<<< * buffer_ptr, self.position * ) */ __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_rv, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_rv, __pyx_t_3); __pyx_t_3 = 0; } __pyx_L18:; /* "clickhouse_driver/bufferedreader.pyx":154 * buffer_ptr, self.position * ) * bytes_read += self.position # <<<<<<<<<<<<<< * * else: */ __pyx_v_bytes_read = (__pyx_v_bytes_read + __pyx_v_self->position); } /* "clickhouse_driver/bufferedreader.pyx":124 * # We need to copy it into buffer for adding null symbol at the end. * # In ClickHouse block there is no null * if right > self.current_buffer_size: # <<<<<<<<<<<<<< * if c_encoding: * memcpy(&c_string[bytes_read], &buffer_ptr[self.position], */ goto __pyx_L14; } /* "clickhouse_driver/bufferedreader.pyx":157 * * else: * if c_encoding: # <<<<<<<<<<<<<< * memcpy(c_string, &buffer_ptr[self.position], size) * else: */ /*else*/ { __pyx_t_2 = (__pyx_v_c_encoding != 0); if (__pyx_t_2) { /* "clickhouse_driver/bufferedreader.pyx":158 * else: * if c_encoding: * memcpy(c_string, &buffer_ptr[self.position], size) # <<<<<<<<<<<<<< * else: * rv = PyBytes_FromStringAndSize( */ (void)(memcpy(__pyx_v_c_string, (&(__pyx_v_buffer_ptr[__pyx_v_self->position])), __pyx_v_size)); /* "clickhouse_driver/bufferedreader.pyx":157 * * else: * if c_encoding: # <<<<<<<<<<<<<< * memcpy(c_string, &buffer_ptr[self.position], size) * else: */ goto __pyx_L19; } /* "clickhouse_driver/bufferedreader.pyx":160 * memcpy(c_string, &buffer_ptr[self.position], size) * else: * rv = PyBytes_FromStringAndSize( # <<<<<<<<<<<<<< * &buffer_ptr[self.position], size * ) */ /*else*/ { /* "clickhouse_driver/bufferedreader.pyx":161 * else: * rv = PyBytes_FromStringAndSize( * &buffer_ptr[self.position], size # <<<<<<<<<<<<<< * ) * self.position = right */ __pyx_t_3 = PyBytes_FromStringAndSize((&(__pyx_v_buffer_ptr[__pyx_v_self->position])), __pyx_v_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_rv, __pyx_t_3); __pyx_t_3 = 0; } __pyx_L19:; /* "clickhouse_driver/bufferedreader.pyx":163 * &buffer_ptr[self.position], size * ) * self.position = right # <<<<<<<<<<<<<< * * if c_encoding: */ __pyx_v_self->position = __pyx_v_right; } __pyx_L14:; /* "clickhouse_driver/bufferedreader.pyx":165 * self.position = right * * if c_encoding: # <<<<<<<<<<<<<< * try: * rv = c_string[:size].decode(c_encoding) */ __pyx_t_2 = (__pyx_v_c_encoding != 0); if (__pyx_t_2) { /* "clickhouse_driver/bufferedreader.pyx":166 * * if c_encoding: * try: # <<<<<<<<<<<<<< * rv = c_string[:size].decode(c_encoding) * except UnicodeDecodeError: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); /*try:*/ { /* "clickhouse_driver/bufferedreader.pyx":167 * if c_encoding: * try: * rv = c_string[:size].decode(c_encoding) # <<<<<<<<<<<<<< * except UnicodeDecodeError: * rv = PyBytes_FromStringAndSize(c_string, size) */ __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_c_string, 0, __pyx_v_size, __pyx_v_c_encoding, NULL, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L21_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_rv, __pyx_t_3); __pyx_t_3 = 0; /* "clickhouse_driver/bufferedreader.pyx":166 * * if c_encoding: * try: # <<<<<<<<<<<<<< * rv = c_string[:size].decode(c_encoding) * except UnicodeDecodeError: */ } __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; goto __pyx_L28_try_end; __pyx_L21_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; /* "clickhouse_driver/bufferedreader.pyx":168 * try: * rv = c_string[:size].decode(c_encoding) * except UnicodeDecodeError: # <<<<<<<<<<<<<< * rv = PyBytes_FromStringAndSize(c_string, size) * */ __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_UnicodeDecodeError)))); if (__pyx_t_15) { __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_strings", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_16) < 0) __PYX_ERR(0, 168, __pyx_L23_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_16); /* "clickhouse_driver/bufferedreader.pyx":169 * rv = c_string[:size].decode(c_encoding) * except UnicodeDecodeError: * rv = PyBytes_FromStringAndSize(c_string, size) # <<<<<<<<<<<<<< * * Py_INCREF(rv) */ __pyx_t_17 = PyBytes_FromStringAndSize(__pyx_v_c_string, __pyx_v_size); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 169, __pyx_L23_except_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF_SET(__pyx_v_rv, __pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; goto __pyx_L22_exception_handled; } goto __pyx_L23_except_error; /* "clickhouse_driver/bufferedreader.pyx":166 * * if c_encoding: * try: # <<<<<<<<<<<<<< * rv = c_string[:size].decode(c_encoding) * except UnicodeDecodeError: */ __pyx_L23_except_error:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); goto __pyx_L1_error; __pyx_L22_exception_handled:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); __pyx_L28_try_end:; } /* "clickhouse_driver/bufferedreader.pyx":165 * self.position = right * * if c_encoding: # <<<<<<<<<<<<<< * try: * rv = c_string[:size].decode(c_encoding) */ } /* "clickhouse_driver/bufferedreader.pyx":171 * rv = PyBytes_FromStringAndSize(c_string, size) * * Py_INCREF(rv) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(items, i, rv) * */ Py_INCREF(__pyx_v_rv); /* "clickhouse_driver/bufferedreader.pyx":172 * * Py_INCREF(rv) * PyTuple_SET_ITEM(items, i, rv) # <<<<<<<<<<<<<< * * if c_string: */ PyTuple_SET_ITEM(__pyx_v_items, __pyx_v_i, __pyx_v_rv); } /* "clickhouse_driver/bufferedreader.pyx":174 * PyTuple_SET_ITEM(items, i, rv) * * if c_string: # <<<<<<<<<<<<<< * PyMem_Free(c_string) * */ __pyx_t_2 = (__pyx_v_c_string != 0); if (__pyx_t_2) { /* "clickhouse_driver/bufferedreader.pyx":175 * * if c_string: * PyMem_Free(c_string) # <<<<<<<<<<<<<< * * return items */ PyMem_Free(__pyx_v_c_string); /* "clickhouse_driver/bufferedreader.pyx":174 * PyTuple_SET_ITEM(items, i, rv) * * if c_string: # <<<<<<<<<<<<<< * PyMem_Free(c_string) * */ } /* "clickhouse_driver/bufferedreader.pyx":177 * PyMem_Free(c_string) * * return items # <<<<<<<<<<<<<< * * def read_strings_arrow(self, unsigned long long n_items): */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_items); __pyx_r = __pyx_v_items; goto __pyx_L0; /* "clickhouse_driver/bufferedreader.pyx":62 * return rv * * def read_strings(self, unsigned long long n_items, encoding=None): # <<<<<<<<<<<<<< * """ * Python has great overhead between function calls. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_16); __Pyx_XDECREF(__pyx_t_17); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_strings", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_items); __Pyx_XDECREF(__pyx_v_rv); __Pyx_XDECREF(__pyx_v_encoding); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedreader.pyx":179 * return items * * def read_strings_arrow(self, unsigned long long n_items): # <<<<<<<<<<<<<< * """ * Reads ``n_items`` varint-prefixed strings into Arrow-style */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_11read_strings_arrow(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_17clickhouse_driver_14bufferedreader_14BufferedReader_10read_strings_arrow, "\n Reads ``n_items`` varint-prefixed strings into Arrow-style\n buffers without creating per-string Python objects.\n\n Returns (offsets, data) pair of bytearrays: ``offsets`` holds\n ``n_items + 1`` little-endian int64 values, ``data`` holds\n concatenated string bytes.\n "); static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_11read_strings_arrow = {"read_strings_arrow", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_11read_strings_arrow, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_17clickhouse_driver_14bufferedreader_14BufferedReader_10read_strings_arrow}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_11read_strings_arrow(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { unsigned PY_LONG_LONG __pyx_v_n_items; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_strings_arrow (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_n_items,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 179, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 179, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "read_strings_arrow", 0) < (0)) __PYX_ERR(0, 179, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("read_strings_arrow", 1, 1, 1, i); __PYX_ERR(0, 179, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 179, __pyx_L3_error) } __pyx_v_n_items = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(values[0]); if (unlikely((__pyx_v_n_items == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 179, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("read_strings_arrow", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 179, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_strings_arrow", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_10read_strings_arrow(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), __pyx_v_n_items); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_10read_strings_arrow(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, unsigned PY_LONG_LONG __pyx_v_n_items) { unsigned PY_LONG_LONG __pyx_v_i; char *__pyx_v_buffer_ptr; unsigned PY_LONG_LONG __pyx_v_right; unsigned PY_LONG_LONG __pyx_v_size; unsigned PY_LONG_LONG __pyx_v_shift; unsigned PY_LONG_LONG __pyx_v_bytes_read; unsigned PY_LONG_LONG __pyx_v_b; PyObject *__pyx_v_offsets = NULL; PY_LONG_LONG *__pyx_v_offsets_ptr; unsigned PY_LONG_LONG __pyx_v_data_size; unsigned PY_LONG_LONG __pyx_v_data_capacity; PyObject *__pyx_v_data = NULL; char *__pyx_v_data_ptr; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; size_t __pyx_t_4; unsigned PY_LONG_LONG __pyx_t_5; int __pyx_t_6; unsigned PY_LONG_LONG __pyx_t_7; unsigned PY_LONG_LONG __pyx_t_8; int __pyx_t_9; unsigned PY_LONG_LONG __pyx_t_10; unsigned PY_LONG_LONG __pyx_t_11; unsigned PY_LONG_LONG __pyx_t_12; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_strings_arrow", 0); /* "clickhouse_driver/bufferedreader.pyx":190 * cdef unsigned long long i * # Buffer vars * cdef char* buffer_ptr = PyByteArray_AsString(self.buffer) # <<<<<<<<<<<<<< * cdef unsigned long long right * # String length vars */ __pyx_t_1 = __pyx_v_self->buffer; __Pyx_INCREF(__pyx_t_1); __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":196 * cdef unsigned long long b * * offsets = bytearray((n_items + 1) * 8) # <<<<<<<<<<<<<< * cdef long long* offsets_ptr = PyByteArray_AsString( * offsets */ __pyx_t_2 = NULL; __pyx_t_3 = __Pyx_PyLong_From_unsigned_PY_LONG_LONG(((__pyx_v_n_items + 1) * 8)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = 1; { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3}; __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(&PyByteArray_Type), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_v_offsets = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":197 * * offsets = bytearray((n_items + 1) * 8) * cdef long long* offsets_ptr = PyByteArray_AsString( # <<<<<<<<<<<<<< * offsets * ) */ __pyx_v_offsets_ptr = ((PY_LONG_LONG *)PyByteArray_AsString(__pyx_v_offsets)); /* "clickhouse_driver/bufferedreader.pyx":200 * offsets * ) * offsets_ptr[0] = 0 # <<<<<<<<<<<<<< * * cdef unsigned long long data_size = 0 */ (__pyx_v_offsets_ptr[0]) = 0; /* "clickhouse_driver/bufferedreader.pyx":202 * offsets_ptr[0] = 0 * * cdef unsigned long long data_size = 0 # <<<<<<<<<<<<<< * cdef unsigned long long data_capacity = 65536 if \ * n_items * 8 < 65536 else n_items * 8 */ __pyx_v_data_size = 0; /* "clickhouse_driver/bufferedreader.pyx":204 * cdef unsigned long long data_size = 0 * cdef unsigned long long data_capacity = 65536 if \ * n_items * 8 < 65536 else n_items * 8 # <<<<<<<<<<<<<< * data = bytearray(data_capacity) * cdef char* data_ptr = PyByteArray_AsString(data) */ __pyx_t_6 = ((__pyx_v_n_items * 8) < 0x10000); if (__pyx_t_6) { __pyx_t_5 = 0x10000; } else { __pyx_t_5 = (__pyx_v_n_items * 8); } __pyx_v_data_capacity = __pyx_t_5; /* "clickhouse_driver/bufferedreader.pyx":205 * cdef unsigned long long data_capacity = 65536 if \ * n_items * 8 < 65536 else n_items * 8 * data = bytearray(data_capacity) # <<<<<<<<<<<<<< * cdef char* data_ptr = PyByteArray_AsString(data) * */ __pyx_t_3 = NULL; __pyx_t_2 = __Pyx_PyLong_From_unsigned_PY_LONG_LONG(__pyx_v_data_capacity); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = 1; { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_2}; __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(&PyByteArray_Type), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_v_data = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":206 * n_items * 8 < 65536 else n_items * 8 * data = bytearray(data_capacity) * cdef char* data_ptr = PyByteArray_AsString(data) # <<<<<<<<<<<<<< * * for i in range(n_items): */ __pyx_v_data_ptr = PyByteArray_AsString(__pyx_v_data); /* "clickhouse_driver/bufferedreader.pyx":208 * cdef char* data_ptr = PyByteArray_AsString(data) * * for i in range(n_items): # <<<<<<<<<<<<<< * shift = size = 0 * */ __pyx_t_5 = __pyx_v_n_items; __pyx_t_7 = __pyx_t_5; for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_v_i = __pyx_t_8; /* "clickhouse_driver/bufferedreader.pyx":209 * * for i in range(n_items): * shift = size = 0 # <<<<<<<<<<<<<< * * # Read string size */ __pyx_v_shift = 0; __pyx_v_size = 0; /* "clickhouse_driver/bufferedreader.pyx":212 * * # Read string size * while True: # <<<<<<<<<<<<<< * if self.position == self.current_buffer_size: * self.read_into_buffer() */ while (1) { /* "clickhouse_driver/bufferedreader.pyx":213 * # Read string size * while True: * if self.position == self.current_buffer_size: # <<<<<<<<<<<<<< * self.read_into_buffer() * # `read_into_buffer` can override buffer */ __pyx_t_6 = (__pyx_v_self->position == __pyx_v_self->current_buffer_size); if (__pyx_t_6) { /* "clickhouse_driver/bufferedreader.pyx":214 * while True: * if self.position == self.current_buffer_size: * self.read_into_buffer() # <<<<<<<<<<<<<< * # `read_into_buffer` can override buffer * buffer_ptr = PyByteArray_AsString(self.buffer) */ __pyx_t_2 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_read_into_buffer, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 214, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":216 * self.read_into_buffer() * # `read_into_buffer` can override buffer * buffer_ptr = PyByteArray_AsString(self.buffer) # <<<<<<<<<<<<<< * self.position = 0 * */ __pyx_t_1 = __pyx_v_self->buffer; __Pyx_INCREF(__pyx_t_1); __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":217 * # `read_into_buffer` can override buffer * buffer_ptr = PyByteArray_AsString(self.buffer) * self.position = 0 # <<<<<<<<<<<<<< * * b = buffer_ptr[self.position] */ __pyx_v_self->position = 0; /* "clickhouse_driver/bufferedreader.pyx":213 * # Read string size * while True: * if self.position == self.current_buffer_size: # <<<<<<<<<<<<<< * self.read_into_buffer() * # `read_into_buffer` can override buffer */ } /* "clickhouse_driver/bufferedreader.pyx":219 * self.position = 0 * * b = buffer_ptr[self.position] # <<<<<<<<<<<<<< * self.position += 1 * */ __pyx_v_b = (__pyx_v_buffer_ptr[__pyx_v_self->position]); /* "clickhouse_driver/bufferedreader.pyx":220 * * b = buffer_ptr[self.position] * self.position += 1 # <<<<<<<<<<<<<< * * size |= (b & 0x7f) << shift */ __pyx_v_self->position = (__pyx_v_self->position + 1); /* "clickhouse_driver/bufferedreader.pyx":222 * self.position += 1 * * size |= (b & 0x7f) << shift # <<<<<<<<<<<<<< * if b < 0x80: * break */ __pyx_v_size = (__pyx_v_size | ((__pyx_v_b & 0x7f) << __pyx_v_shift)); /* "clickhouse_driver/bufferedreader.pyx":223 * * size |= (b & 0x7f) << shift * if b < 0x80: # <<<<<<<<<<<<<< * break * */ __pyx_t_6 = (__pyx_v_b < 0x80); if (__pyx_t_6) { /* "clickhouse_driver/bufferedreader.pyx":224 * size |= (b & 0x7f) << shift * if b < 0x80: * break # <<<<<<<<<<<<<< * * shift += 7 */ goto __pyx_L6_break; /* "clickhouse_driver/bufferedreader.pyx":223 * * size |= (b & 0x7f) << shift * if b < 0x80: # <<<<<<<<<<<<<< * break * */ } /* "clickhouse_driver/bufferedreader.pyx":226 * break * * shift += 7 # <<<<<<<<<<<<<< * * if data_size + size > data_capacity: */ __pyx_v_shift = (__pyx_v_shift + 7); } __pyx_L6_break:; /* "clickhouse_driver/bufferedreader.pyx":228 * shift += 7 * * if data_size + size > data_capacity: # <<<<<<<<<<<<<< * while data_capacity < data_size + size: * data_capacity *= 2 */ __pyx_t_6 = ((__pyx_v_data_size + __pyx_v_size) > __pyx_v_data_capacity); if (__pyx_t_6) { /* "clickhouse_driver/bufferedreader.pyx":229 * * if data_size + size > data_capacity: * while data_capacity < data_size + size: # <<<<<<<<<<<<<< * data_capacity *= 2 * PyByteArray_Resize(data, data_capacity) */ while (1) { __pyx_t_6 = (__pyx_v_data_capacity < (__pyx_v_data_size + __pyx_v_size)); if (!__pyx_t_6) break; /* "clickhouse_driver/bufferedreader.pyx":230 * if data_size + size > data_capacity: * while data_capacity < data_size + size: * data_capacity *= 2 # <<<<<<<<<<<<<< * PyByteArray_Resize(data, data_capacity) * data_ptr = PyByteArray_AsString(data) */ __pyx_v_data_capacity = (__pyx_v_data_capacity * 2); } /* "clickhouse_driver/bufferedreader.pyx":231 * while data_capacity < data_size + size: * data_capacity *= 2 * PyByteArray_Resize(data, data_capacity) # <<<<<<<<<<<<<< * data_ptr = PyByteArray_AsString(data) * */ __pyx_t_9 = PyByteArray_Resize(__pyx_v_data, __pyx_v_data_capacity); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 231, __pyx_L1_error) /* "clickhouse_driver/bufferedreader.pyx":232 * data_capacity *= 2 * PyByteArray_Resize(data, data_capacity) * data_ptr = PyByteArray_AsString(data) # <<<<<<<<<<<<<< * * right = self.position + size */ __pyx_v_data_ptr = PyByteArray_AsString(__pyx_v_data); /* "clickhouse_driver/bufferedreader.pyx":228 * shift += 7 * * if data_size + size > data_capacity: # <<<<<<<<<<<<<< * while data_capacity < data_size + size: * data_capacity *= 2 */ } /* "clickhouse_driver/bufferedreader.pyx":234 * data_ptr = PyByteArray_AsString(data) * * right = self.position + size # <<<<<<<<<<<<<< * * if right > self.current_buffer_size: */ __pyx_v_right = (__pyx_v_self->position + __pyx_v_size); /* "clickhouse_driver/bufferedreader.pyx":236 * right = self.position + size * * if right > self.current_buffer_size: # <<<<<<<<<<<<<< * # String spans multiple reader buffers. * bytes_read = self.current_buffer_size - self.position */ __pyx_t_6 = (__pyx_v_right > __pyx_v_self->current_buffer_size); if (__pyx_t_6) { /* "clickhouse_driver/bufferedreader.pyx":238 * if right > self.current_buffer_size: * # String spans multiple reader buffers. * bytes_read = self.current_buffer_size - self.position # <<<<<<<<<<<<<< * memcpy(&data_ptr[data_size], &buffer_ptr[self.position], * bytes_read) */ __pyx_v_bytes_read = (__pyx_v_self->current_buffer_size - __pyx_v_self->position); /* "clickhouse_driver/bufferedreader.pyx":239 * # String spans multiple reader buffers. * bytes_read = self.current_buffer_size - self.position * memcpy(&data_ptr[data_size], &buffer_ptr[self.position], # <<<<<<<<<<<<<< * bytes_read) * */ (void)(memcpy((&(__pyx_v_data_ptr[__pyx_v_data_size])), (&(__pyx_v_buffer_ptr[__pyx_v_self->position])), __pyx_v_bytes_read)); /* "clickhouse_driver/bufferedreader.pyx":242 * bytes_read) * * while bytes_read != size: # <<<<<<<<<<<<<< * self.position = size - bytes_read * */ while (1) { __pyx_t_6 = (__pyx_v_bytes_read != __pyx_v_size); if (!__pyx_t_6) break; /* "clickhouse_driver/bufferedreader.pyx":243 * * while bytes_read != size: * self.position = size - bytes_read # <<<<<<<<<<<<<< * * self.read_into_buffer() */ __pyx_v_self->position = (__pyx_v_size - __pyx_v_bytes_read); /* "clickhouse_driver/bufferedreader.pyx":245 * self.position = size - bytes_read * * self.read_into_buffer() # <<<<<<<<<<<<<< * # `read_into_buffer` can override buffer * buffer_ptr = PyByteArray_AsString(self.buffer) */ __pyx_t_2 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_read_into_buffer, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":247 * self.read_into_buffer() * # `read_into_buffer` can override buffer * buffer_ptr = PyByteArray_AsString(self.buffer) # <<<<<<<<<<<<<< * # There can be not enough data in buffer. * self.position = min( */ __pyx_t_1 = __pyx_v_self->buffer; __Pyx_INCREF(__pyx_t_1); __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":250 * # There can be not enough data in buffer. * self.position = min( * self.position, self.current_buffer_size # <<<<<<<<<<<<<< * ) * memcpy(&data_ptr[data_size + bytes_read], buffer_ptr, */ __pyx_t_10 = __pyx_v_self->current_buffer_size; __pyx_t_11 = __pyx_v_self->position; __pyx_t_6 = (__pyx_t_10 < __pyx_t_11); if (__pyx_t_6) { __pyx_t_12 = __pyx_t_10; } else { __pyx_t_12 = __pyx_t_11; } /* "clickhouse_driver/bufferedreader.pyx":249 * buffer_ptr = PyByteArray_AsString(self.buffer) * # There can be not enough data in buffer. * self.position = min( # <<<<<<<<<<<<<< * self.position, self.current_buffer_size * ) */ __pyx_v_self->position = __pyx_t_12; /* "clickhouse_driver/bufferedreader.pyx":252 * self.position, self.current_buffer_size * ) * memcpy(&data_ptr[data_size + bytes_read], buffer_ptr, # <<<<<<<<<<<<<< * self.position) * bytes_read += self.position */ (void)(memcpy((&(__pyx_v_data_ptr[(__pyx_v_data_size + __pyx_v_bytes_read)])), __pyx_v_buffer_ptr, __pyx_v_self->position)); /* "clickhouse_driver/bufferedreader.pyx":254 * memcpy(&data_ptr[data_size + bytes_read], buffer_ptr, * self.position) * bytes_read += self.position # <<<<<<<<<<<<<< * * else: */ __pyx_v_bytes_read = (__pyx_v_bytes_read + __pyx_v_self->position); } /* "clickhouse_driver/bufferedreader.pyx":236 * right = self.position + size * * if right > self.current_buffer_size: # <<<<<<<<<<<<<< * # String spans multiple reader buffers. * bytes_read = self.current_buffer_size - self.position */ goto __pyx_L12; } /* "clickhouse_driver/bufferedreader.pyx":257 * * else: * memcpy(&data_ptr[data_size], &buffer_ptr[self.position], # <<<<<<<<<<<<<< * size) * self.position = right */ /*else*/ { /* "clickhouse_driver/bufferedreader.pyx":258 * else: * memcpy(&data_ptr[data_size], &buffer_ptr[self.position], * size) # <<<<<<<<<<<<<< * self.position = right * */ (void)(memcpy((&(__pyx_v_data_ptr[__pyx_v_data_size])), (&(__pyx_v_buffer_ptr[__pyx_v_self->position])), __pyx_v_size)); /* "clickhouse_driver/bufferedreader.pyx":259 * memcpy(&data_ptr[data_size], &buffer_ptr[self.position], * size) * self.position = right # <<<<<<<<<<<<<< * * data_size += size */ __pyx_v_self->position = __pyx_v_right; } __pyx_L12:; /* "clickhouse_driver/bufferedreader.pyx":261 * self.position = right * * data_size += size # <<<<<<<<<<<<<< * offsets_ptr[i + 1] = data_size * */ __pyx_v_data_size = (__pyx_v_data_size + __pyx_v_size); /* "clickhouse_driver/bufferedreader.pyx":262 * * data_size += size * offsets_ptr[i + 1] = data_size # <<<<<<<<<<<<<< * * PyByteArray_Resize(data, data_size) */ (__pyx_v_offsets_ptr[(__pyx_v_i + 1)]) = ((PY_LONG_LONG)__pyx_v_data_size); } /* "clickhouse_driver/bufferedreader.pyx":264 * offsets_ptr[i + 1] = data_size * * PyByteArray_Resize(data, data_size) # <<<<<<<<<<<<<< * return offsets, data * */ __pyx_t_9 = PyByteArray_Resize(__pyx_v_data, __pyx_v_data_size); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 264, __pyx_L1_error) /* "clickhouse_driver/bufferedreader.pyx":265 * * PyByteArray_Resize(data, data_size) * return offsets, data # <<<<<<<<<<<<<< * * def read_fixed_strings_as_bytes(self, Py_ssize_t n_items, */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_offsets); __Pyx_GIVEREF(__pyx_v_offsets); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_offsets) != (0)) __PYX_ERR(0, 265, __pyx_L1_error); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_data) != (0)) __PYX_ERR(0, 265, __pyx_L1_error); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "clickhouse_driver/bufferedreader.pyx":179 * return items * * def read_strings_arrow(self, unsigned long long n_items): # <<<<<<<<<<<<<< * """ * Reads ``n_items`` varint-prefixed strings into Arrow-style */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_strings_arrow", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_offsets); __Pyx_XDECREF(__pyx_v_data); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedreader.pyx":267 * return offsets, data * * def read_fixed_strings_as_bytes(self, Py_ssize_t n_items, # <<<<<<<<<<<<<< * Py_ssize_t length): * cdef Py_ssize_t i */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_13read_fixed_strings_as_bytes(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_13read_fixed_strings_as_bytes = {"read_fixed_strings_as_bytes", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_13read_fixed_strings_as_bytes, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_13read_fixed_strings_as_bytes(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { Py_ssize_t __pyx_v_n_items; Py_ssize_t __pyx_v_length; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[2] = {0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_fixed_strings_as_bytes (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_n_items,&__pyx_mstate_global->__pyx_n_u_length,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 267, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 267, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 267, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "read_fixed_strings_as_bytes", 0) < (0)) __PYX_ERR(0, 267, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 2; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("read_fixed_strings_as_bytes", 1, 2, 2, i); __PYX_ERR(0, 267, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 267, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 267, __pyx_L3_error) } __pyx_v_n_items = __Pyx_PyIndex_AsSsize_t(values[0]); if (unlikely((__pyx_v_n_items == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 267, __pyx_L3_error) __pyx_v_length = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_length == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 268, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("read_fixed_strings_as_bytes", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 267, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_fixed_strings_as_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_12read_fixed_strings_as_bytes(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), __pyx_v_n_items, __pyx_v_length); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_12read_fixed_strings_as_bytes(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, Py_ssize_t __pyx_v_n_items, Py_ssize_t __pyx_v_length) { Py_ssize_t __pyx_v_i; PyObject *__pyx_v_data = NULL; char *__pyx_v_data_ptr; PyObject *__pyx_v_items = NULL; PyObject *__pyx_v_item = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; size_t __pyx_t_4; char *__pyx_t_5; Py_ssize_t __pyx_t_6; Py_ssize_t __pyx_t_7; Py_ssize_t __pyx_t_8; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_fixed_strings_as_bytes", 0); /* "clickhouse_driver/bufferedreader.pyx":270 * Py_ssize_t length): * cdef Py_ssize_t i * data = self.read(length * n_items) # <<<<<<<<<<<<<< * cdef char* data_ptr = PyBytes_AsString(data) * */ __pyx_t_2 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = PyLong_FromSsize_t((__pyx_v_length * __pyx_v_n_items)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_read, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_v_data = __pyx_t_1; __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":271 * cdef Py_ssize_t i * data = self.read(length * n_items) * cdef char* data_ptr = PyBytes_AsString(data) # <<<<<<<<<<<<<< * * items = PyTuple_New(n_items) */ __pyx_t_5 = PyBytes_AsString(__pyx_v_data); if (unlikely(__pyx_t_5 == ((void *)NULL))) __PYX_ERR(0, 271, __pyx_L1_error) __pyx_v_data_ptr = __pyx_t_5; /* "clickhouse_driver/bufferedreader.pyx":273 * cdef char* data_ptr = PyBytes_AsString(data) * * items = PyTuple_New(n_items) # <<<<<<<<<<<<<< * for i in range(n_items): * item = PyBytes_FromStringAndSize(&data_ptr[i * length], length) */ __pyx_t_1 = PyTuple_New(__pyx_v_n_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 273, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_items = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":274 * * items = PyTuple_New(n_items) * for i in range(n_items): # <<<<<<<<<<<<<< * item = PyBytes_FromStringAndSize(&data_ptr[i * length], length) * Py_INCREF(item) */ __pyx_t_6 = __pyx_v_n_items; __pyx_t_7 = __pyx_t_6; for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_v_i = __pyx_t_8; /* "clickhouse_driver/bufferedreader.pyx":275 * items = PyTuple_New(n_items) * for i in range(n_items): * item = PyBytes_FromStringAndSize(&data_ptr[i * length], length) # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(items, i, item) */ __pyx_t_1 = PyBytes_FromStringAndSize((&(__pyx_v_data_ptr[(__pyx_v_i * __pyx_v_length)])), __pyx_v_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_item, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":276 * for i in range(n_items): * item = PyBytes_FromStringAndSize(&data_ptr[i * length], length) * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(items, i, item) * return items */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/bufferedreader.pyx":277 * item = PyBytes_FromStringAndSize(&data_ptr[i * length], length) * Py_INCREF(item) * PyTuple_SET_ITEM(items, i, item) # <<<<<<<<<<<<<< * return items * */ PyTuple_SET_ITEM(__pyx_v_items, __pyx_v_i, __pyx_v_item); } /* "clickhouse_driver/bufferedreader.pyx":278 * Py_INCREF(item) * PyTuple_SET_ITEM(items, i, item) * return items # <<<<<<<<<<<<<< * * def read_fixed_strings(self, Py_ssize_t n_items, Py_ssize_t length, */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_items); __pyx_r = __pyx_v_items; goto __pyx_L0; /* "clickhouse_driver/bufferedreader.pyx":267 * return offsets, data * * def read_fixed_strings_as_bytes(self, Py_ssize_t n_items, # <<<<<<<<<<<<<< * Py_ssize_t length): * cdef Py_ssize_t i */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_fixed_strings_as_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_data); __Pyx_XDECREF(__pyx_v_items); __Pyx_XDECREF(__pyx_v_item); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedreader.pyx":280 * return items * * def read_fixed_strings(self, Py_ssize_t n_items, Py_ssize_t length, # <<<<<<<<<<<<<< * encoding=None): * if encoding is None: */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_15read_fixed_strings(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_15read_fixed_strings = {"read_fixed_strings", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_15read_fixed_strings, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_15read_fixed_strings(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { Py_ssize_t __pyx_v_n_items; Py_ssize_t __pyx_v_length; PyObject *__pyx_v_encoding = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_fixed_strings (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_n_items,&__pyx_mstate_global->__pyx_n_u_length,&__pyx_mstate_global->__pyx_n_u_encoding,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 280, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 280, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 280, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 280, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "read_fixed_strings", 0) < (0)) __PYX_ERR(0, 280, __pyx_L3_error) /* "clickhouse_driver/bufferedreader.pyx":281 * * def read_fixed_strings(self, Py_ssize_t n_items, Py_ssize_t length, * encoding=None): # <<<<<<<<<<<<<< * if encoding is None: * return self.read_fixed_strings_as_bytes(n_items, length) */ if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)Py_None)); for (Py_ssize_t i = __pyx_nargs; i < 2; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("read_fixed_strings", 0, 2, 3, i); __PYX_ERR(0, 280, __pyx_L3_error) } } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 280, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 280, __pyx_L3_error) values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 280, __pyx_L3_error) break; default: goto __pyx_L5_argtuple_error; } if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)Py_None)); } __pyx_v_n_items = __Pyx_PyIndex_AsSsize_t(values[0]); if (unlikely((__pyx_v_n_items == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 280, __pyx_L3_error) __pyx_v_length = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_length == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 280, __pyx_L3_error) __pyx_v_encoding = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("read_fixed_strings", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 280, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_fixed_strings", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_14read_fixed_strings(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), __pyx_v_n_items, __pyx_v_length, __pyx_v_encoding); /* "clickhouse_driver/bufferedreader.pyx":280 * return items * * def read_fixed_strings(self, Py_ssize_t n_items, Py_ssize_t length, # <<<<<<<<<<<<<< * encoding=None): * if encoding is None: */ /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_14read_fixed_strings(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, Py_ssize_t __pyx_v_n_items, Py_ssize_t __pyx_v_length, PyObject *__pyx_v_encoding) { Py_ssize_t __pyx_v_i; Py_ssize_t __pyx_v_j; char *__pyx_v_c_encoding; PyObject *__pyx_v_data = NULL; char *__pyx_v_data_ptr; char *__pyx_v_c_string; PyObject *__pyx_v_items = NULL; PyObject *__pyx_v_item = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; size_t __pyx_t_6; char *__pyx_t_7; Py_ssize_t __pyx_t_8; Py_ssize_t __pyx_t_9; Py_ssize_t __pyx_t_10; int __pyx_t_11; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; int __pyx_t_15; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_fixed_strings", 0); __Pyx_INCREF(__pyx_v_encoding); /* "clickhouse_driver/bufferedreader.pyx":282 * def read_fixed_strings(self, Py_ssize_t n_items, Py_ssize_t length, * encoding=None): * if encoding is None: # <<<<<<<<<<<<<< * return self.read_fixed_strings_as_bytes(n_items, length) * */ __pyx_t_1 = (__pyx_v_encoding == Py_None); if (__pyx_t_1) { /* "clickhouse_driver/bufferedreader.pyx":283 * encoding=None): * if encoding is None: * return self.read_fixed_strings_as_bytes(n_items, length) # <<<<<<<<<<<<<< * * cdef Py_ssize_t i, j */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = PyLong_FromSsize_t(__pyx_v_n_items); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyLong_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = 0; { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_t_4, __pyx_t_5}; __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_read_fixed_strings_as_bytes, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "clickhouse_driver/bufferedreader.pyx":282 * def read_fixed_strings(self, Py_ssize_t n_items, Py_ssize_t length, * encoding=None): * if encoding is None: # <<<<<<<<<<<<<< * return self.read_fixed_strings_as_bytes(n_items, length) * */ } /* "clickhouse_driver/bufferedreader.pyx":286 * * cdef Py_ssize_t i, j * encoding = encoding.encode('utf-8') # <<<<<<<<<<<<<< * cdef char* c_encoding = encoding * data = self.read(length * n_items) */ __pyx_t_5 = __pyx_v_encoding; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_utf_8}; __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_encode, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __Pyx_DECREF_SET(__pyx_v_encoding, __pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedreader.pyx":287 * cdef Py_ssize_t i, j * encoding = encoding.encode('utf-8') * cdef char* c_encoding = encoding # <<<<<<<<<<<<<< * data = self.read(length * n_items) * cdef char* data_ptr = PyBytes_AsString(data) */ __pyx_t_7 = __Pyx_PyObject_AsWritableString(__pyx_v_encoding); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(0, 287, __pyx_L1_error) __pyx_v_c_encoding = __pyx_t_7; /* "clickhouse_driver/bufferedreader.pyx":288 * encoding = encoding.encode('utf-8') * cdef char* c_encoding = encoding * data = self.read(length * n_items) # <<<<<<<<<<<<<< * cdef char* data_ptr = PyBytes_AsString(data) * */ __pyx_t_5 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_5); __pyx_t_4 = PyLong_FromSsize_t((__pyx_v_length * __pyx_v_n_items)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_4}; __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_read, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __pyx_v_data = __pyx_t_2; __pyx_t_2 = 0; /* "clickhouse_driver/bufferedreader.pyx":289 * cdef char* c_encoding = encoding * data = self.read(length * n_items) * cdef char* data_ptr = PyBytes_AsString(data) # <<<<<<<<<<<<<< * * cdef char* c_string = PyMem_Malloc(length + 1) */ __pyx_t_7 = PyBytes_AsString(__pyx_v_data); if (unlikely(__pyx_t_7 == ((void *)NULL))) __PYX_ERR(0, 289, __pyx_L1_error) __pyx_v_data_ptr = __pyx_t_7; /* "clickhouse_driver/bufferedreader.pyx":291 * cdef char* data_ptr = PyBytes_AsString(data) * * cdef char* c_string = PyMem_Malloc(length + 1) # <<<<<<<<<<<<<< * if not c_string: * raise MemoryError() */ __pyx_v_c_string = ((char *)PyMem_Malloc((__pyx_v_length + 1))); /* "clickhouse_driver/bufferedreader.pyx":292 * * cdef char* c_string = PyMem_Malloc(length + 1) * if not c_string: # <<<<<<<<<<<<<< * raise MemoryError() * c_string[length] = 0 */ __pyx_t_1 = (!(__pyx_v_c_string != 0)); if (unlikely(__pyx_t_1)) { /* "clickhouse_driver/bufferedreader.pyx":293 * cdef char* c_string = PyMem_Malloc(length + 1) * if not c_string: * raise MemoryError() # <<<<<<<<<<<<<< * c_string[length] = 0 * */ PyErr_NoMemory(); __PYX_ERR(0, 293, __pyx_L1_error) /* "clickhouse_driver/bufferedreader.pyx":292 * * cdef char* c_string = PyMem_Malloc(length + 1) * if not c_string: # <<<<<<<<<<<<<< * raise MemoryError() * c_string[length] = 0 */ } /* "clickhouse_driver/bufferedreader.pyx":294 * if not c_string: * raise MemoryError() * c_string[length] = 0 # <<<<<<<<<<<<<< * * items = PyTuple_New(n_items) */ (__pyx_v_c_string[__pyx_v_length]) = 0; /* "clickhouse_driver/bufferedreader.pyx":296 * c_string[length] = 0 * * items = PyTuple_New(n_items) # <<<<<<<<<<<<<< * for i in range(n_items): * memcpy(c_string, &data_ptr[i * length], length) */ __pyx_t_2 = PyTuple_New(__pyx_v_n_items); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_items = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedreader.pyx":297 * * items = PyTuple_New(n_items) * for i in range(n_items): # <<<<<<<<<<<<<< * memcpy(c_string, &data_ptr[i * length], length) * */ __pyx_t_8 = __pyx_v_n_items; __pyx_t_9 = __pyx_t_8; for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { __pyx_v_i = __pyx_t_10; /* "clickhouse_driver/bufferedreader.pyx":298 * items = PyTuple_New(n_items) * for i in range(n_items): * memcpy(c_string, &data_ptr[i * length], length) # <<<<<<<<<<<<<< * * # Get last non zero byte of string from the end. */ (void)(memcpy(__pyx_v_c_string, (&(__pyx_v_data_ptr[(__pyx_v_i * __pyx_v_length)])), __pyx_v_length)); /* "clickhouse_driver/bufferedreader.pyx":301 * * # Get last non zero byte of string from the end. * j = length - 1 # <<<<<<<<<<<<<< * while j >= 0 and not c_string[j]: * j -= 1 */ __pyx_v_j = (__pyx_v_length - 1); /* "clickhouse_driver/bufferedreader.pyx":302 * # Get last non zero byte of string from the end. * j = length - 1 * while j >= 0 and not c_string[j]: # <<<<<<<<<<<<<< * j -= 1 * */ while (1) { __pyx_t_11 = (__pyx_v_j >= 0); if (__pyx_t_11) { } else { __pyx_t_1 = __pyx_t_11; goto __pyx_L9_bool_binop_done; } __pyx_t_11 = (!((__pyx_v_c_string[__pyx_v_j]) != 0)); __pyx_t_1 = __pyx_t_11; __pyx_L9_bool_binop_done:; if (!__pyx_t_1) break; /* "clickhouse_driver/bufferedreader.pyx":303 * j = length - 1 * while j >= 0 and not c_string[j]: * j -= 1 # <<<<<<<<<<<<<< * * try: */ __pyx_v_j = (__pyx_v_j - 1); } /* "clickhouse_driver/bufferedreader.pyx":305 * j -= 1 * * try: # <<<<<<<<<<<<<< * item = c_string[:j + 1].decode(c_encoding) * except UnicodeDecodeError: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); /*try:*/ { /* "clickhouse_driver/bufferedreader.pyx":306 * * try: * item = c_string[:j + 1].decode(c_encoding) # <<<<<<<<<<<<<< * except UnicodeDecodeError: * item = PyBytes_FromStringAndSize(c_string, length) */ __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_c_string, 0, (__pyx_v_j + 1), __pyx_v_c_encoding, NULL, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 306, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedreader.pyx":305 * j -= 1 * * try: # <<<<<<<<<<<<<< * item = c_string[:j + 1].decode(c_encoding) * except UnicodeDecodeError: */ } __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; goto __pyx_L18_try_end; __pyx_L11_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* "clickhouse_driver/bufferedreader.pyx":307 * try: * item = c_string[:j + 1].decode(c_encoding) * except UnicodeDecodeError: # <<<<<<<<<<<<<< * item = PyBytes_FromStringAndSize(c_string, length) * Py_INCREF(item) */ __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_UnicodeDecodeError)))); if (__pyx_t_15) { __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_fixed_strings", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_4, &__pyx_t_5) < 0) __PYX_ERR(0, 307, __pyx_L13_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_5); /* "clickhouse_driver/bufferedreader.pyx":308 * item = c_string[:j + 1].decode(c_encoding) * except UnicodeDecodeError: * item = PyBytes_FromStringAndSize(c_string, length) # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(items, i, item) */ __pyx_t_3 = PyBytes_FromStringAndSize(__pyx_v_c_string, __pyx_v_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 308, __pyx_L13_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L12_exception_handled; } goto __pyx_L13_except_error; /* "clickhouse_driver/bufferedreader.pyx":305 * j -= 1 * * try: # <<<<<<<<<<<<<< * item = c_string[:j + 1].decode(c_encoding) * except UnicodeDecodeError: */ __pyx_L13_except_error:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); goto __pyx_L1_error; __pyx_L12_exception_handled:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); __pyx_L18_try_end:; } /* "clickhouse_driver/bufferedreader.pyx":309 * except UnicodeDecodeError: * item = PyBytes_FromStringAndSize(c_string, length) * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(items, i, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/bufferedreader.pyx":310 * item = PyBytes_FromStringAndSize(c_string, length) * Py_INCREF(item) * PyTuple_SET_ITEM(items, i, item) # <<<<<<<<<<<<<< * * PyMem_Free(c_string) */ PyTuple_SET_ITEM(__pyx_v_items, __pyx_v_i, __pyx_v_item); } /* "clickhouse_driver/bufferedreader.pyx":312 * PyTuple_SET_ITEM(items, i, item) * * PyMem_Free(c_string) # <<<<<<<<<<<<<< * * return items */ PyMem_Free(__pyx_v_c_string); /* "clickhouse_driver/bufferedreader.pyx":314 * PyMem_Free(c_string) * * return items # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_items); __pyx_r = __pyx_v_items; goto __pyx_L0; /* "clickhouse_driver/bufferedreader.pyx":280 * return items * * def read_fixed_strings(self, Py_ssize_t n_items, Py_ssize_t length, # <<<<<<<<<<<<<< * encoding=None): * if encoding is None: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_fixed_strings", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_data); __Pyx_XDECREF(__pyx_v_items); __Pyx_XDECREF(__pyx_v_item); __Pyx_XDECREF(__pyx_v_encoding); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedreader.pyx":11 * * cdef class BufferedReader(object): * cdef public unsigned long long position, current_buffer_size # <<<<<<<<<<<<<< * cdef public bytearray buffer * */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8position___get__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8position___get__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyLong_From_unsigned_PY_LONG_LONG(__pyx_v_self->position); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.position.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_2__set__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_2__set__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; unsigned PY_LONG_LONG __pyx_t_1; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __pyx_t_1 = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(__pyx_v_value); if (unlikely((__pyx_t_1 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 11, __pyx_L1_error) __pyx_v_self->position = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.position.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size___get__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size___get__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyLong_From_unsigned_PY_LONG_LONG(__pyx_v_self->current_buffer_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.current_buffer_size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_2__set__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_2__set__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; unsigned PY_LONG_LONG __pyx_t_1; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __pyx_t_1 = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(__pyx_v_value); if (unlikely((__pyx_t_1 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 11, __pyx_L1_error) __pyx_v_self->current_buffer_size = __pyx_t_1; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.current_buffer_size.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; return __pyx_r; } /* "clickhouse_driver/bufferedreader.pyx":12 * cdef class BufferedReader(object): * cdef public unsigned long long position, current_buffer_size * cdef public bytearray buffer # <<<<<<<<<<<<<< * * def __init__(self, bufsize): */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer___get__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer___get__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->buffer); __pyx_r = __pyx_v_self->buffer; goto __pyx_L0; /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_2__set__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_2__set__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); if (!(likely(PyByteArray_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytearray", __pyx_t_1))) __PYX_ERR(0, 12, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->buffer); __Pyx_DECREF(__pyx_v_self->buffer); __pyx_v_self->buffer = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.buffer.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_5__del__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_4__del__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_4__del__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__", 0); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->buffer); __Pyx_DECREF(__pyx_v_self->buffer); __pyx_v_self->buffer = ((PyObject*)Py_None); /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_17__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_17__reduce_cython__ = {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_17__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_17__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__reduce_cython__", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("__reduce_cython__", __pyx_kwds); return NULL;} __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_16__reduce_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_16__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self) { PyObject *__pyx_v_state = 0; PyObject *__pyx_v__dict = 0; int __pyx_v_use_setstate; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":5 * cdef object _dict * cdef bint use_setstate * state = (self.buffer, self.current_buffer_size, self.position) # <<<<<<<<<<<<<< * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: */ __pyx_t_1 = __Pyx_PyLong_From_unsigned_PY_LONG_LONG(__pyx_v_self->current_buffer_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyLong_From_unsigned_PY_LONG_LONG(__pyx_v_self->position); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_self->buffer); __Pyx_GIVEREF(__pyx_v_self->buffer); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->buffer) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_v_state = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "(tree fragment)":6 * cdef bint use_setstate * state = (self.buffer, self.current_buffer_size, self.position) * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<< * if _dict is not None and _dict: * state += (_dict,) */ __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v__dict = __pyx_t_3; __pyx_t_3 = 0; /* "(tree fragment)":7 * state = (self.buffer, self.current_buffer_size, self.position) * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ __pyx_t_5 = (__pyx_v__dict != Py_None); if (__pyx_t_5) { } else { __pyx_t_4 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v__dict); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(2, 7, __pyx_L1_error) __pyx_t_4 = __pyx_t_5; __pyx_L4_bool_binop_done:; if (__pyx_t_4) { /* "(tree fragment)":8 * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: * state += (_dict,) # <<<<<<<<<<<<<< * use_setstate = True * else: */ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v__dict); __Pyx_GIVEREF(__pyx_v__dict); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict) != (0)) __PYX_ERR(2, 8, __pyx_L1_error); __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0; /* "(tree fragment)":9 * if _dict is not None and _dict: * state += (_dict,) * use_setstate = True # <<<<<<<<<<<<<< * else: * use_setstate = ('self.buffer is not None',) */ __pyx_v_use_setstate = 1; /* "(tree fragment)":7 * state = (self.buffer, self.current_buffer_size, self.position) * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ goto __pyx_L3; } /* "(tree fragment)":11 * use_setstate = True * else: * use_setstate = ('self.buffer is not None',) # <<<<<<<<<<<<<< * if use_setstate: * return __pyx_unpickle_BufferedReader, (type(self), 0x5e0d780, None), state */ /*else*/ { __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_mstate_global->__pyx_tuple[0]); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 11, __pyx_L1_error) __pyx_v_use_setstate = __pyx_t_4; } __pyx_L3:; /* "(tree fragment)":12 * else: * use_setstate = ('self.buffer is not None',) * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle_BufferedReader, (type(self), 0x5e0d780, None), state * else: */ if (__pyx_v_use_setstate) { /* "(tree fragment)":13 * use_setstate = ('self.buffer is not None',) * if use_setstate: * return __pyx_unpickle_BufferedReader, (type(self), 0x5e0d780, None), state # <<<<<<<<<<<<<< * else: * return __pyx_unpickle_BufferedReader, (type(self), 0x5e0d780, state) */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_BufferedReader); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(__pyx_mstate_global->__pyx_int_98621312); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_98621312); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_mstate_global->__pyx_int_98621312) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "(tree fragment)":12 * else: * use_setstate = ('self.buffer is not None',) * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle_BufferedReader, (type(self), 0x5e0d780, None), state * else: */ } /* "(tree fragment)":15 * return __pyx_unpickle_BufferedReader, (type(self), 0x5e0d780, None), state * else: * return __pyx_unpickle_BufferedReader, (type(self), 0x5e0d780, state) # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle_BufferedReader__set_state(self, __pyx_state) */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_BufferedReader); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_INCREF(__pyx_mstate_global->__pyx_int_98621312); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_98621312); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_mstate_global->__pyx_int_98621312) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_state); __Pyx_XDECREF(__pyx_v__dict); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":16 * else: * return __pyx_unpickle_BufferedReader, (type(self), 0x5e0d780, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedReader__set_state(self, __pyx_state) */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_19__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_19__setstate_cython__ = {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_19__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_19__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v___pyx_state = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pyx_state,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(2, 16, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 16, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__setstate_cython__", 0) < (0)) __PYX_ERR(2, 16, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__setstate_cython__", 1, 1, 1, i); __PYX_ERR(2, 16, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 16, __pyx_L3_error) } __pyx_v___pyx_state = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__setstate_cython__", 1, 1, 1, __pyx_nargs); __PYX_ERR(2, 16, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_18__setstate_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), __pyx_v___pyx_state); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_18__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":17 * return __pyx_unpickle_BufferedReader, (type(self), 0x5e0d780, state) * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle_BufferedReader__set_state(self, __pyx_state) # <<<<<<<<<<<<<< */ __pyx_t_1 = __pyx_v___pyx_state; __Pyx_INCREF(__pyx_t_1); if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_t_1))) __PYX_ERR(2, 17, __pyx_L1_error) if (unlikely(__pyx_t_1 == Py_None)) { PyErr_SetString(PyExc_TypeError, "cannot pass None into a C function argument that is declared 'not None'"); __PYX_ERR(2, 17, __pyx_L1_error) } __pyx_t_2 = __pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedReader__set_state(__pyx_v_self, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":16 * else: * return __pyx_unpickle_BufferedReader, (type(self), 0x5e0d780, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedReader__set_state(self, __pyx_state) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedreader.pyx":320 * cdef object sock * * def __init__(self, sock, bufsize): # <<<<<<<<<<<<<< * self.sock = sock * super(BufferedSocketReader, self).__init__(bufsize) */ /* Python wrapper */ static int __pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_sock = 0; PyObject *__pyx_v_bufsize = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[2] = {0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_sock,&__pyx_mstate_global->__pyx_n_u_bufsize,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_VARARGS(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 320, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 2: values[1] = __Pyx_ArgRef_VARARGS(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 320, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 320, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__init__", 0) < (0)) __PYX_ERR(0, 320, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 2; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, i); __PYX_ERR(0, 320, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 320, __pyx_L3_error) values[1] = __Pyx_ArgRef_VARARGS(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 320, __pyx_L3_error) } __pyx_v_sock = values[0]; __pyx_v_bufsize = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 320, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedSocketReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader___init__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)__pyx_v_self), __pyx_v_sock, __pyx_v_bufsize); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader___init__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v_self, PyObject *__pyx_v_sock, PyObject *__pyx_v_bufsize) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; size_t __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "clickhouse_driver/bufferedreader.pyx":321 * * def __init__(self, sock, bufsize): * self.sock = sock # <<<<<<<<<<<<<< * super(BufferedSocketReader, self).__init__(bufsize) * */ __Pyx_INCREF(__pyx_v_sock); __Pyx_GIVEREF(__pyx_v_sock); __Pyx_GOTREF(__pyx_v_self->sock); __Pyx_DECREF(__pyx_v_self->sock); __pyx_v_self->sock = __pyx_v_sock; /* "clickhouse_driver/bufferedreader.pyx":322 * def __init__(self, sock, bufsize): * self.sock = sock * super(BufferedSocketReader, self).__init__(bufsize) # <<<<<<<<<<<<<< * * def read_into_buffer(self): */ __pyx_t_4 = NULL; __pyx_t_5 = 1; { PyObject *__pyx_callargs[3] = {__pyx_t_4, ((PyObject *)__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader), ((PyObject *)__pyx_v_self)}; __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_super, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_bufsize}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_init, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":320 * cdef object sock * * def __init__(self, sock, bufsize): # <<<<<<<<<<<<<< * self.sock = sock * super(BufferedSocketReader, self).__init__(bufsize) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedSocketReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedreader.pyx":324 * super(BufferedSocketReader, self).__init__(bufsize) * * def read_into_buffer(self): # <<<<<<<<<<<<<< * self.current_buffer_size = self.sock.recv_into(self.buffer) * */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_3read_into_buffer(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_3read_into_buffer = {"read_into_buffer", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_3read_into_buffer, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_3read_into_buffer(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_into_buffer (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("read_into_buffer", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("read_into_buffer", __pyx_kwds); return NULL;} __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_2read_into_buffer(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_2read_into_buffer(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; size_t __pyx_t_3; unsigned PY_LONG_LONG __pyx_t_4; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_into_buffer", 0); /* "clickhouse_driver/bufferedreader.pyx":325 * * def read_into_buffer(self): * self.current_buffer_size = self.sock.recv_into(self.buffer) # <<<<<<<<<<<<<< * * if self.current_buffer_size == 0: */ __pyx_t_2 = __pyx_v_self->sock; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_self->__pyx_base.buffer}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_recv_into, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_t_4 = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_4 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 325, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_self->__pyx_base.current_buffer_size = __pyx_t_4; /* "clickhouse_driver/bufferedreader.pyx":327 * self.current_buffer_size = self.sock.recv_into(self.buffer) * * if self.current_buffer_size == 0: # <<<<<<<<<<<<<< * raise EOFError('Unexpected EOF while reading bytes') * */ __pyx_t_5 = (__pyx_v_self->__pyx_base.current_buffer_size == 0); if (unlikely(__pyx_t_5)) { /* "clickhouse_driver/bufferedreader.pyx":328 * * if self.current_buffer_size == 0: * raise EOFError('Unexpected EOF while reading bytes') # <<<<<<<<<<<<<< * * */ __pyx_t_2 = NULL; __pyx_t_3 = 1; { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Unexpected_EOF_while_reading_byt}; __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_EOFError)), __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 328, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 328, __pyx_L1_error) /* "clickhouse_driver/bufferedreader.pyx":327 * self.current_buffer_size = self.sock.recv_into(self.buffer) * * if self.current_buffer_size == 0: # <<<<<<<<<<<<<< * raise EOFError('Unexpected EOF while reading bytes') * */ } /* "clickhouse_driver/bufferedreader.pyx":324 * super(BufferedSocketReader, self).__init__(bufsize) * * def read_into_buffer(self): # <<<<<<<<<<<<<< * self.current_buffer_size = self.sock.recv_into(self.buffer) * */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedSocketReader.read_into_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_5__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_5__reduce_cython__ = {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_5__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_5__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__reduce_cython__", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("__reduce_cython__", __pyx_kwds); return NULL;} __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_4__reduce_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_4__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v_self) { PyObject *__pyx_v_state = 0; PyObject *__pyx_v__dict = 0; int __pyx_v_use_setstate; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":5 * cdef object _dict * cdef bint use_setstate * state = (self.buffer, self.current_buffer_size, self.position, self.sock) # <<<<<<<<<<<<<< * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: */ __pyx_t_1 = __Pyx_PyLong_From_unsigned_PY_LONG_LONG(__pyx_v_self->__pyx_base.current_buffer_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyLong_From_unsigned_PY_LONG_LONG(__pyx_v_self->__pyx_base.position); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_self->__pyx_base.buffer); __Pyx_GIVEREF(__pyx_v_self->__pyx_base.buffer); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->__pyx_base.buffer) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __Pyx_INCREF(__pyx_v_self->sock); __Pyx_GIVEREF(__pyx_v_self->sock); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_self->sock) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_v_state = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "(tree fragment)":6 * cdef bint use_setstate * state = (self.buffer, self.current_buffer_size, self.position, self.sock) * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<< * if _dict is not None and _dict: * state += (_dict,) */ __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v__dict = __pyx_t_3; __pyx_t_3 = 0; /* "(tree fragment)":7 * state = (self.buffer, self.current_buffer_size, self.position, self.sock) * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ __pyx_t_5 = (__pyx_v__dict != Py_None); if (__pyx_t_5) { } else { __pyx_t_4 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v__dict); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(2, 7, __pyx_L1_error) __pyx_t_4 = __pyx_t_5; __pyx_L4_bool_binop_done:; if (__pyx_t_4) { /* "(tree fragment)":8 * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: * state += (_dict,) # <<<<<<<<<<<<<< * use_setstate = True * else: */ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v__dict); __Pyx_GIVEREF(__pyx_v__dict); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict) != (0)) __PYX_ERR(2, 8, __pyx_L1_error); __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0; /* "(tree fragment)":9 * if _dict is not None and _dict: * state += (_dict,) * use_setstate = True # <<<<<<<<<<<<<< * else: * use_setstate = ('self.buffer is not None or self.sock is not None',) */ __pyx_v_use_setstate = 1; /* "(tree fragment)":7 * state = (self.buffer, self.current_buffer_size, self.position, self.sock) * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ goto __pyx_L3; } /* "(tree fragment)":11 * use_setstate = True * else: * use_setstate = ('self.buffer is not None or self.sock is not None',) # <<<<<<<<<<<<<< * if use_setstate: * return __pyx_unpickle_BufferedSocketReader, (type(self), 0x44eb6c8, None), state */ /*else*/ { __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_mstate_global->__pyx_tuple[1]); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 11, __pyx_L1_error) __pyx_v_use_setstate = __pyx_t_4; } __pyx_L3:; /* "(tree fragment)":12 * else: * use_setstate = ('self.buffer is not None or self.sock is not None',) * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle_BufferedSocketReader, (type(self), 0x44eb6c8, None), state * else: */ if (__pyx_v_use_setstate) { /* "(tree fragment)":13 * use_setstate = ('self.buffer is not None or self.sock is not None',) * if use_setstate: * return __pyx_unpickle_BufferedSocketReader, (type(self), 0x44eb6c8, None), state # <<<<<<<<<<<<<< * else: * return __pyx_unpickle_BufferedSocketReader, (type(self), 0x44eb6c8, state) */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_BufferedSocketRea); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(__pyx_mstate_global->__pyx_int_72267464); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_72267464); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_mstate_global->__pyx_int_72267464) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "(tree fragment)":12 * else: * use_setstate = ('self.buffer is not None or self.sock is not None',) * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle_BufferedSocketReader, (type(self), 0x44eb6c8, None), state * else: */ } /* "(tree fragment)":15 * return __pyx_unpickle_BufferedSocketReader, (type(self), 0x44eb6c8, None), state * else: * return __pyx_unpickle_BufferedSocketReader, (type(self), 0x44eb6c8, state) # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle_BufferedSocketReader__set_state(self, __pyx_state) */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_BufferedSocketRea); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_INCREF(__pyx_mstate_global->__pyx_int_72267464); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_72267464); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_mstate_global->__pyx_int_72267464) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedSocketReader.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_state); __Pyx_XDECREF(__pyx_v__dict); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":16 * else: * return __pyx_unpickle_BufferedSocketReader, (type(self), 0x44eb6c8, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedSocketReader__set_state(self, __pyx_state) */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_7__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_7__setstate_cython__ = {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_7__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_7__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v___pyx_state = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pyx_state,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(2, 16, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 16, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__setstate_cython__", 0) < (0)) __PYX_ERR(2, 16, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__setstate_cython__", 1, 1, 1, i); __PYX_ERR(2, 16, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 16, __pyx_L3_error) } __pyx_v___pyx_state = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__setstate_cython__", 1, 1, 1, __pyx_nargs); __PYX_ERR(2, 16, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedSocketReader.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_6__setstate_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)__pyx_v_self), __pyx_v___pyx_state); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_6__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":17 * return __pyx_unpickle_BufferedSocketReader, (type(self), 0x44eb6c8, state) * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle_BufferedSocketReader__set_state(self, __pyx_state) # <<<<<<<<<<<<<< */ __pyx_t_1 = __pyx_v___pyx_state; __Pyx_INCREF(__pyx_t_1); if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_t_1))) __PYX_ERR(2, 17, __pyx_L1_error) if (unlikely(__pyx_t_1 == Py_None)) { PyErr_SetString(PyExc_TypeError, "cannot pass None into a C function argument that is declared 'not None'"); __PYX_ERR(2, 17, __pyx_L1_error) } __pyx_t_2 = __pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedSocketReader__set_state(__pyx_v_self, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":16 * else: * return __pyx_unpickle_BufferedSocketReader, (type(self), 0x44eb6c8, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedSocketReader__set_state(self, __pyx_state) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedSocketReader.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedreader.pyx":334 * cdef object read_block * * def __init__(self, read_block, bufsize): # <<<<<<<<<<<<<< * self.read_block = read_block * super(CompressedBufferedReader, self).__init__(bufsize) */ /* Python wrapper */ static int __pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_read_block = 0; PyObject *__pyx_v_bufsize = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[2] = {0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_read_block,&__pyx_mstate_global->__pyx_n_u_bufsize,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_VARARGS(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 334, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 2: values[1] = __Pyx_ArgRef_VARARGS(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 334, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 334, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__init__", 0) < (0)) __PYX_ERR(0, 334, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 2; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, i); __PYX_ERR(0, 334, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 334, __pyx_L3_error) values[1] = __Pyx_ArgRef_VARARGS(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 334, __pyx_L3_error) } __pyx_v_read_block = values[0]; __pyx_v_bufsize = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 334, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedreader.CompressedBufferedReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader___init__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)__pyx_v_self), __pyx_v_read_block, __pyx_v_bufsize); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader___init__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v_self, PyObject *__pyx_v_read_block, PyObject *__pyx_v_bufsize) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; size_t __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "clickhouse_driver/bufferedreader.pyx":335 * * def __init__(self, read_block, bufsize): * self.read_block = read_block # <<<<<<<<<<<<<< * super(CompressedBufferedReader, self).__init__(bufsize) * */ __Pyx_INCREF(__pyx_v_read_block); __Pyx_GIVEREF(__pyx_v_read_block); __Pyx_GOTREF(__pyx_v_self->read_block); __Pyx_DECREF(__pyx_v_self->read_block); __pyx_v_self->read_block = __pyx_v_read_block; /* "clickhouse_driver/bufferedreader.pyx":336 * def __init__(self, read_block, bufsize): * self.read_block = read_block * super(CompressedBufferedReader, self).__init__(bufsize) # <<<<<<<<<<<<<< * * def read_into_buffer(self): */ __pyx_t_4 = NULL; __pyx_t_5 = 1; { PyObject *__pyx_callargs[3] = {__pyx_t_4, ((PyObject *)__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader), ((PyObject *)__pyx_v_self)}; __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_super, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 336, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_bufsize}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_init, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":334 * cdef object read_block * * def __init__(self, read_block, bufsize): # <<<<<<<<<<<<<< * self.read_block = read_block * super(CompressedBufferedReader, self).__init__(bufsize) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.CompressedBufferedReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedreader.pyx":338 * super(CompressedBufferedReader, self).__init__(bufsize) * * def read_into_buffer(self): # <<<<<<<<<<<<<< * self.buffer = bytearray(self.read_block()) * self.current_buffer_size = len(self.buffer) */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_3read_into_buffer(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_3read_into_buffer = {"read_into_buffer", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_3read_into_buffer, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_3read_into_buffer(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_into_buffer (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("read_into_buffer", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("read_into_buffer", __pyx_kwds); return NULL;} __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_2read_into_buffer(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_2read_into_buffer(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; size_t __pyx_t_6; Py_ssize_t __pyx_t_7; int __pyx_t_8; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_into_buffer", 0); /* "clickhouse_driver/bufferedreader.pyx":339 * * def read_into_buffer(self): * self.buffer = bytearray(self.read_block()) # <<<<<<<<<<<<<< * self.current_buffer_size = len(self.buffer) * */ __pyx_t_2 = NULL; __pyx_t_4 = NULL; __Pyx_INCREF(__pyx_v_self->read_block); __pyx_t_5 = __pyx_v_self->read_block; __pyx_t_6 = 1; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); assert(__pyx_t_4); PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(__pyx__function); __Pyx_DECREF_SET(__pyx_t_5, __pyx__function); __pyx_t_6 = 0; } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 339, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } __pyx_t_6 = 1; { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3}; __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(&PyByteArray_Type), __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 339, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->__pyx_base.buffer); __Pyx_DECREF(__pyx_v_self->__pyx_base.buffer); __pyx_v_self->__pyx_base.buffer = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedreader.pyx":340 * def read_into_buffer(self): * self.buffer = bytearray(self.read_block()) * self.current_buffer_size = len(self.buffer) # <<<<<<<<<<<<<< * * if self.current_buffer_size == 0: */ __pyx_t_1 = __pyx_v_self->__pyx_base.buffer; __Pyx_INCREF(__pyx_t_1); if (unlikely(__pyx_t_1 == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 340, __pyx_L1_error) } __pyx_t_7 = __Pyx_PyByteArray_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 340, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_self->__pyx_base.current_buffer_size = __pyx_t_7; /* "clickhouse_driver/bufferedreader.pyx":342 * self.current_buffer_size = len(self.buffer) * * if self.current_buffer_size == 0: # <<<<<<<<<<<<<< * raise EOFError('Unexpected EOF while reading bytes') */ __pyx_t_8 = (__pyx_v_self->__pyx_base.current_buffer_size == 0); if (unlikely(__pyx_t_8)) { /* "clickhouse_driver/bufferedreader.pyx":343 * * if self.current_buffer_size == 0: * raise EOFError('Unexpected EOF while reading bytes') # <<<<<<<<<<<<<< */ __pyx_t_3 = NULL; __pyx_t_6 = 1; { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Unexpected_EOF_while_reading_byt}; __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_EOFError)), __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 343, __pyx_L1_error) /* "clickhouse_driver/bufferedreader.pyx":342 * self.current_buffer_size = len(self.buffer) * * if self.current_buffer_size == 0: # <<<<<<<<<<<<<< * raise EOFError('Unexpected EOF while reading bytes') */ } /* "clickhouse_driver/bufferedreader.pyx":338 * super(CompressedBufferedReader, self).__init__(bufsize) * * def read_into_buffer(self): # <<<<<<<<<<<<<< * self.buffer = bytearray(self.read_block()) * self.current_buffer_size = len(self.buffer) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.CompressedBufferedReader.read_into_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_5__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_5__reduce_cython__ = {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_5__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_5__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__reduce_cython__", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("__reduce_cython__", __pyx_kwds); return NULL;} __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_4__reduce_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_4__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v_self) { PyObject *__pyx_v_state = 0; PyObject *__pyx_v__dict = 0; int __pyx_v_use_setstate; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":5 * cdef object _dict * cdef bint use_setstate * state = (self.buffer, self.current_buffer_size, self.position, self.read_block) # <<<<<<<<<<<<<< * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: */ __pyx_t_1 = __Pyx_PyLong_From_unsigned_PY_LONG_LONG(__pyx_v_self->__pyx_base.current_buffer_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyLong_From_unsigned_PY_LONG_LONG(__pyx_v_self->__pyx_base.position); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_self->__pyx_base.buffer); __Pyx_GIVEREF(__pyx_v_self->__pyx_base.buffer); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->__pyx_base.buffer) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __Pyx_INCREF(__pyx_v_self->read_block); __Pyx_GIVEREF(__pyx_v_self->read_block); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_self->read_block) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_v_state = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "(tree fragment)":6 * cdef bint use_setstate * state = (self.buffer, self.current_buffer_size, self.position, self.read_block) * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<< * if _dict is not None and _dict: * state += (_dict,) */ __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v__dict = __pyx_t_3; __pyx_t_3 = 0; /* "(tree fragment)":7 * state = (self.buffer, self.current_buffer_size, self.position, self.read_block) * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ __pyx_t_5 = (__pyx_v__dict != Py_None); if (__pyx_t_5) { } else { __pyx_t_4 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v__dict); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(2, 7, __pyx_L1_error) __pyx_t_4 = __pyx_t_5; __pyx_L4_bool_binop_done:; if (__pyx_t_4) { /* "(tree fragment)":8 * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: * state += (_dict,) # <<<<<<<<<<<<<< * use_setstate = True * else: */ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v__dict); __Pyx_GIVEREF(__pyx_v__dict); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict) != (0)) __PYX_ERR(2, 8, __pyx_L1_error); __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0; /* "(tree fragment)":9 * if _dict is not None and _dict: * state += (_dict,) * use_setstate = True # <<<<<<<<<<<<<< * else: * use_setstate = ('self.buffer is not None or self.read_block is not None',) */ __pyx_v_use_setstate = 1; /* "(tree fragment)":7 * state = (self.buffer, self.current_buffer_size, self.position, self.read_block) * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ goto __pyx_L3; } /* "(tree fragment)":11 * use_setstate = True * else: * use_setstate = ('self.buffer is not None or self.read_block is not None',) # <<<<<<<<<<<<<< * if use_setstate: * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x69923fe, None), state */ /*else*/ { __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_mstate_global->__pyx_tuple[2]); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 11, __pyx_L1_error) __pyx_v_use_setstate = __pyx_t_4; } __pyx_L3:; /* "(tree fragment)":12 * else: * use_setstate = ('self.buffer is not None or self.read_block is not None',) * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x69923fe, None), state * else: */ if (__pyx_v_use_setstate) { /* "(tree fragment)":13 * use_setstate = ('self.buffer is not None or self.read_block is not None',) * if use_setstate: * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x69923fe, None), state # <<<<<<<<<<<<<< * else: * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x69923fe, state) */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_CompressedBuffere); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(__pyx_mstate_global->__pyx_int_110699518); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_110699518); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_mstate_global->__pyx_int_110699518) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "(tree fragment)":12 * else: * use_setstate = ('self.buffer is not None or self.read_block is not None',) * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x69923fe, None), state * else: */ } /* "(tree fragment)":15 * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x69923fe, None), state * else: * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x69923fe, state) # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle_CompressedBufferedReader__set_state(self, __pyx_state) */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_CompressedBuffere); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_INCREF(__pyx_mstate_global->__pyx_int_110699518); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_110699518); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_mstate_global->__pyx_int_110699518) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.CompressedBufferedReader.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_state); __Pyx_XDECREF(__pyx_v__dict); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":16 * else: * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x69923fe, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_CompressedBufferedReader__set_state(self, __pyx_state) */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_7__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_7__setstate_cython__ = {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_7__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_7__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v___pyx_state = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pyx_state,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(2, 16, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 16, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__setstate_cython__", 0) < (0)) __PYX_ERR(2, 16, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__setstate_cython__", 1, 1, 1, i); __PYX_ERR(2, 16, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 16, __pyx_L3_error) } __pyx_v___pyx_state = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__setstate_cython__", 1, 1, 1, __pyx_nargs); __PYX_ERR(2, 16, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedreader.CompressedBufferedReader.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_6__setstate_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)__pyx_v_self), __pyx_v___pyx_state); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_6__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":17 * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x69923fe, state) * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle_CompressedBufferedReader__set_state(self, __pyx_state) # <<<<<<<<<<<<<< */ __pyx_t_1 = __pyx_v___pyx_state; __Pyx_INCREF(__pyx_t_1); if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_t_1))) __PYX_ERR(2, 17, __pyx_L1_error) if (unlikely(__pyx_t_1 == Py_None)) { PyErr_SetString(PyExc_TypeError, "cannot pass None into a C function argument that is declared 'not None'"); __PYX_ERR(2, 17, __pyx_L1_error) } __pyx_t_2 = __pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_CompressedBufferedReader__set_state(__pyx_v_self, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":16 * else: * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x69923fe, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_CompressedBufferedReader__set_state(self, __pyx_state) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.CompressedBufferedReader.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":4 * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 * def __pyx_unpickle_BufferedReader(__pyx_type, long __pyx_checksum, tuple __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x5e0d780, 0x07c78bc, 0x2a8a945, b'buffer, current_buffer_size, position') */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_1__pyx_unpickle_BufferedReader(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_1__pyx_unpickle_BufferedReader = {"__pyx_unpickle_BufferedReader", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_1__pyx_unpickle_BufferedReader, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_1__pyx_unpickle_BufferedReader(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v___pyx_type = 0; long __pyx_v___pyx_checksum; PyObject *__pyx_v___pyx_state = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedReader (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pyx_type,&__pyx_mstate_global->__pyx_n_u_pyx_checksum,&__pyx_mstate_global->__pyx_n_u_pyx_state,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(2, 4, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__pyx_unpickle_BufferedReader", 0) < (0)) __PYX_ERR(2, 4, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 3; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BufferedReader", 1, 3, 3, i); __PYX_ERR(2, 4, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 4, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(2, 4, __pyx_L3_error) values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(2, 4, __pyx_L3_error) } __pyx_v___pyx_type = values[0]; __pyx_v___pyx_checksum = __Pyx_PyLong_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 4, __pyx_L3_error) __pyx_v___pyx_state = ((PyObject*)values[2]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BufferedReader", 1, 3, 3, __pyx_nargs); __PYX_ERR(2, 4, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_BufferedReader", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v___pyx_state), (&PyTuple_Type), 1, "__pyx_state", 1))) __PYX_ERR(2, 4, __pyx_L1_error) __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedReader(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } goto __pyx_L7_cleaned_up; __pyx_L0:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __pyx_L7_cleaned_up:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedReader(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_v___pyx_result = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; size_t __pyx_t_4; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedReader", 0); /* "(tree fragment)":6 * def __pyx_unpickle_BufferedReader(__pyx_type, long __pyx_checksum, tuple __pyx_state): * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x5e0d780, 0x07c78bc, 0x2a8a945, b'buffer, current_buffer_size, position') # <<<<<<<<<<<<<< * __pyx_result = BufferedReader.__new__(__pyx_type) * if __pyx_state is not None: */ __pyx_t_1 = __Pyx_CheckUnpickleChecksum(__pyx_v___pyx_checksum, 0x5e0d780, 0x07c78bc, 0x2a8a945, ((char const *)"buffer, current_buffer_size, position")); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(2, 6, __pyx_L1_error) /* "(tree fragment)":7 * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x5e0d780, 0x07c78bc, 0x2a8a945, b'buffer, current_buffer_size, position') * __pyx_result = BufferedReader.__new__(__pyx_type) # <<<<<<<<<<<<<< * if __pyx_state is not None: * __pyx_unpickle_BufferedReader__set_state( __pyx_result, __pyx_state) */ __pyx_t_3 = ((PyObject *)__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v___pyx_type}; __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_new, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __pyx_v___pyx_result = __pyx_t_2; __pyx_t_2 = 0; /* "(tree fragment)":8 * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x5e0d780, 0x07c78bc, 0x2a8a945, b'buffer, current_buffer_size, position') * __pyx_result = BufferedReader.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedReader__set_state( __pyx_result, __pyx_state) * return __pyx_result */ __pyx_t_5 = (__pyx_v___pyx_state != ((PyObject*)Py_None)); if (__pyx_t_5) { /* "(tree fragment)":9 * __pyx_result = BufferedReader.__new__(__pyx_type) * if __pyx_state is not None: * __pyx_unpickle_BufferedReader__set_state( __pyx_result, __pyx_state) # <<<<<<<<<<<<<< * return __pyx_result * cdef __pyx_unpickle_BufferedReader__set_state(BufferedReader __pyx_result, __pyx_state: tuple): */ if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "cannot pass None into a C function argument that is declared 'not None'"); __PYX_ERR(2, 9, __pyx_L1_error) } __pyx_t_2 = __pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedReader__set_state(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v___pyx_result), __pyx_v___pyx_state); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":8 * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x5e0d780, 0x07c78bc, 0x2a8a945, b'buffer, current_buffer_size, position') * __pyx_result = BufferedReader.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedReader__set_state( __pyx_result, __pyx_state) * return __pyx_result */ } /* "(tree fragment)":10 * if __pyx_state is not None: * __pyx_unpickle_BufferedReader__set_state( __pyx_result, __pyx_state) * return __pyx_result # <<<<<<<<<<<<<< * cdef __pyx_unpickle_BufferedReader__set_state(BufferedReader __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2] */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v___pyx_result); __pyx_r = __pyx_v___pyx_result; goto __pyx_L0; /* "(tree fragment)":4 * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 * def __pyx_unpickle_BufferedReader(__pyx_type, long __pyx_checksum, tuple __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x5e0d780, 0x07c78bc, 0x2a8a945, b'buffer, current_buffer_size, position') */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_BufferedReader", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v___pyx_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":11 * __pyx_unpickle_BufferedReader__set_state( __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle_BufferedReader__set_state(BufferedReader __pyx_result, __pyx_state: tuple): # <<<<<<<<<<<<<< * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 3) */ static PyObject *__pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedReader__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; unsigned PY_LONG_LONG __pyx_t_2; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedReader__set_state", 0); /* "(tree fragment)":12 * return __pyx_result * cdef __pyx_unpickle_BufferedReader__set_state(BufferedReader __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2] # <<<<<<<<<<<<<< * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 3) */ __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyByteArray_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytearray", __pyx_t_1))) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->buffer); __Pyx_DECREF(__pyx_v___pyx_result->buffer); __pyx_v___pyx_result->buffer = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_2 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->current_buffer_size = __pyx_t_2; __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_2 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->position = __pyx_t_2; /* "(tree fragment)":13 * cdef __pyx_unpickle_BufferedReader__set_state(BufferedReader __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 3) # <<<<<<<<<<<<<< */ __pyx_t_3 = __Pyx_UpdateUnpickledDict(((PyObject *)__pyx_v___pyx_result), __pyx_v___pyx_state, 3); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(2, 13, __pyx_L1_error) /* "(tree fragment)":11 * __pyx_unpickle_BufferedReader__set_state( __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle_BufferedReader__set_state(BufferedReader __pyx_result, __pyx_state: tuple): # <<<<<<<<<<<<<< * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 3) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_BufferedReader__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":4 * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 * def __pyx_unpickle_BufferedSocketReader(__pyx_type, long __pyx_checksum, tuple __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x44eb6c8, 0xb4ff772, 0xef9caf0, b'buffer, current_buffer_size, position, sock') */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_3__pyx_unpickle_BufferedSocketReader(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_3__pyx_unpickle_BufferedSocketReader = {"__pyx_unpickle_BufferedSocketReader", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_3__pyx_unpickle_BufferedSocketReader, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_3__pyx_unpickle_BufferedSocketReader(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v___pyx_type = 0; long __pyx_v___pyx_checksum; PyObject *__pyx_v___pyx_state = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedSocketReader (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pyx_type,&__pyx_mstate_global->__pyx_n_u_pyx_checksum,&__pyx_mstate_global->__pyx_n_u_pyx_state,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(2, 4, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__pyx_unpickle_BufferedSocketReader", 0) < (0)) __PYX_ERR(2, 4, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 3; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BufferedSocketReader", 1, 3, 3, i); __PYX_ERR(2, 4, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 4, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(2, 4, __pyx_L3_error) values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(2, 4, __pyx_L3_error) } __pyx_v___pyx_type = values[0]; __pyx_v___pyx_checksum = __Pyx_PyLong_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 4, __pyx_L3_error) __pyx_v___pyx_state = ((PyObject*)values[2]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BufferedSocketReader", 1, 3, 3, __pyx_nargs); __PYX_ERR(2, 4, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_BufferedSocketReader", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v___pyx_state), (&PyTuple_Type), 1, "__pyx_state", 1))) __PYX_ERR(2, 4, __pyx_L1_error) __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_2__pyx_unpickle_BufferedSocketReader(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } goto __pyx_L7_cleaned_up; __pyx_L0:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __pyx_L7_cleaned_up:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_2__pyx_unpickle_BufferedSocketReader(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_v___pyx_result = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; size_t __pyx_t_4; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedSocketReader", 0); /* "(tree fragment)":6 * def __pyx_unpickle_BufferedSocketReader(__pyx_type, long __pyx_checksum, tuple __pyx_state): * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x44eb6c8, 0xb4ff772, 0xef9caf0, b'buffer, current_buffer_size, position, sock') # <<<<<<<<<<<<<< * __pyx_result = BufferedSocketReader.__new__(__pyx_type) * if __pyx_state is not None: */ __pyx_t_1 = __Pyx_CheckUnpickleChecksum(__pyx_v___pyx_checksum, 0x44eb6c8, 0xb4ff772, 0xef9caf0, ((char const *)"buffer, current_buffer_size, position, sock")); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(2, 6, __pyx_L1_error) /* "(tree fragment)":7 * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x44eb6c8, 0xb4ff772, 0xef9caf0, b'buffer, current_buffer_size, position, sock') * __pyx_result = BufferedSocketReader.__new__(__pyx_type) # <<<<<<<<<<<<<< * if __pyx_state is not None: * __pyx_unpickle_BufferedSocketReader__set_state( __pyx_result, __pyx_state) */ __pyx_t_3 = ((PyObject *)__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v___pyx_type}; __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_new, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __pyx_v___pyx_result = __pyx_t_2; __pyx_t_2 = 0; /* "(tree fragment)":8 * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x44eb6c8, 0xb4ff772, 0xef9caf0, b'buffer, current_buffer_size, position, sock') * __pyx_result = BufferedSocketReader.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedSocketReader__set_state( __pyx_result, __pyx_state) * return __pyx_result */ __pyx_t_5 = (__pyx_v___pyx_state != ((PyObject*)Py_None)); if (__pyx_t_5) { /* "(tree fragment)":9 * __pyx_result = BufferedSocketReader.__new__(__pyx_type) * if __pyx_state is not None: * __pyx_unpickle_BufferedSocketReader__set_state( __pyx_result, __pyx_state) # <<<<<<<<<<<<<< * return __pyx_result * cdef __pyx_unpickle_BufferedSocketReader__set_state(BufferedSocketReader __pyx_result, __pyx_state: tuple): */ if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "cannot pass None into a C function argument that is declared 'not None'"); __PYX_ERR(2, 9, __pyx_L1_error) } __pyx_t_2 = __pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedSocketReader__set_state(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)__pyx_v___pyx_result), __pyx_v___pyx_state); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":8 * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x44eb6c8, 0xb4ff772, 0xef9caf0, b'buffer, current_buffer_size, position, sock') * __pyx_result = BufferedSocketReader.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedSocketReader__set_state( __pyx_result, __pyx_state) * return __pyx_result */ } /* "(tree fragment)":10 * if __pyx_state is not None: * __pyx_unpickle_BufferedSocketReader__set_state( __pyx_result, __pyx_state) * return __pyx_result # <<<<<<<<<<<<<< * cdef __pyx_unpickle_BufferedSocketReader__set_state(BufferedSocketReader __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3] */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v___pyx_result); __pyx_r = __pyx_v___pyx_result; goto __pyx_L0; /* "(tree fragment)":4 * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 * def __pyx_unpickle_BufferedSocketReader(__pyx_type, long __pyx_checksum, tuple __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x44eb6c8, 0xb4ff772, 0xef9caf0, b'buffer, current_buffer_size, position, sock') */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_BufferedSocketReader", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v___pyx_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":11 * __pyx_unpickle_BufferedSocketReader__set_state( __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle_BufferedSocketReader__set_state(BufferedSocketReader __pyx_result, __pyx_state: tuple): # <<<<<<<<<<<<<< * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 4) */ static PyObject *__pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedSocketReader__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; unsigned PY_LONG_LONG __pyx_t_2; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedSocketReader__set_state", 0); /* "(tree fragment)":12 * return __pyx_result * cdef __pyx_unpickle_BufferedSocketReader__set_state(BufferedSocketReader __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3] # <<<<<<<<<<<<<< * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 4) */ __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyByteArray_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytearray", __pyx_t_1))) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.buffer); __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.buffer); __pyx_v___pyx_result->__pyx_base.buffer = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_2 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->__pyx_base.current_buffer_size = __pyx_t_2; __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_2 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->__pyx_base.position = __pyx_t_2; __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->sock); __Pyx_DECREF(__pyx_v___pyx_result->sock); __pyx_v___pyx_result->sock = __pyx_t_1; __pyx_t_1 = 0; /* "(tree fragment)":13 * cdef __pyx_unpickle_BufferedSocketReader__set_state(BufferedSocketReader __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 4) # <<<<<<<<<<<<<< */ __pyx_t_3 = __Pyx_UpdateUnpickledDict(((PyObject *)__pyx_v___pyx_result), __pyx_v___pyx_state, 4); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(2, 13, __pyx_L1_error) /* "(tree fragment)":11 * __pyx_unpickle_BufferedSocketReader__set_state( __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle_BufferedSocketReader__set_state(BufferedSocketReader __pyx_result, __pyx_state: tuple): # <<<<<<<<<<<<<< * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 4) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_BufferedSocketReader__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":4 * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 * def __pyx_unpickle_CompressedBufferedReader(__pyx_type, long __pyx_checksum, tuple __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x69923fe, 0xfd1be99, 0x183c0eb, b'buffer, current_buffer_size, position, read_block') */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_5__pyx_unpickle_CompressedBufferedReader(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_5__pyx_unpickle_CompressedBufferedReader = {"__pyx_unpickle_CompressedBufferedReader", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_5__pyx_unpickle_CompressedBufferedReader, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_5__pyx_unpickle_CompressedBufferedReader(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v___pyx_type = 0; long __pyx_v___pyx_checksum; PyObject *__pyx_v___pyx_state = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__pyx_unpickle_CompressedBufferedReader (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pyx_type,&__pyx_mstate_global->__pyx_n_u_pyx_checksum,&__pyx_mstate_global->__pyx_n_u_pyx_state,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(2, 4, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__pyx_unpickle_CompressedBufferedReader", 0) < (0)) __PYX_ERR(2, 4, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 3; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_CompressedBufferedReader", 1, 3, 3, i); __PYX_ERR(2, 4, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 4, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(2, 4, __pyx_L3_error) values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(2, 4, __pyx_L3_error) } __pyx_v___pyx_type = values[0]; __pyx_v___pyx_checksum = __Pyx_PyLong_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 4, __pyx_L3_error) __pyx_v___pyx_state = ((PyObject*)values[2]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_CompressedBufferedReader", 1, 3, 3, __pyx_nargs); __PYX_ERR(2, 4, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_CompressedBufferedReader", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v___pyx_state), (&PyTuple_Type), 1, "__pyx_state", 1))) __PYX_ERR(2, 4, __pyx_L1_error) __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_4__pyx_unpickle_CompressedBufferedReader(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } goto __pyx_L7_cleaned_up; __pyx_L0:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __pyx_L7_cleaned_up:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_4__pyx_unpickle_CompressedBufferedReader(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_v___pyx_result = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; size_t __pyx_t_4; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle_CompressedBufferedReader", 0); /* "(tree fragment)":6 * def __pyx_unpickle_CompressedBufferedReader(__pyx_type, long __pyx_checksum, tuple __pyx_state): * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x69923fe, 0xfd1be99, 0x183c0eb, b'buffer, current_buffer_size, position, read_block') # <<<<<<<<<<<<<< * __pyx_result = CompressedBufferedReader.__new__(__pyx_type) * if __pyx_state is not None: */ __pyx_t_1 = __Pyx_CheckUnpickleChecksum(__pyx_v___pyx_checksum, 0x69923fe, 0xfd1be99, 0x183c0eb, ((char const *)"buffer, current_buffer_size, position, read_block")); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(2, 6, __pyx_L1_error) /* "(tree fragment)":7 * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x69923fe, 0xfd1be99, 0x183c0eb, b'buffer, current_buffer_size, position, read_block') * __pyx_result = CompressedBufferedReader.__new__(__pyx_type) # <<<<<<<<<<<<<< * if __pyx_state is not None: * __pyx_unpickle_CompressedBufferedReader__set_state( __pyx_result, __pyx_state) */ __pyx_t_3 = ((PyObject *)__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v___pyx_type}; __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_new, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __pyx_v___pyx_result = __pyx_t_2; __pyx_t_2 = 0; /* "(tree fragment)":8 * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x69923fe, 0xfd1be99, 0x183c0eb, b'buffer, current_buffer_size, position, read_block') * __pyx_result = CompressedBufferedReader.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle_CompressedBufferedReader__set_state( __pyx_result, __pyx_state) * return __pyx_result */ __pyx_t_5 = (__pyx_v___pyx_state != ((PyObject*)Py_None)); if (__pyx_t_5) { /* "(tree fragment)":9 * __pyx_result = CompressedBufferedReader.__new__(__pyx_type) * if __pyx_state is not None: * __pyx_unpickle_CompressedBufferedReader__set_state( __pyx_result, __pyx_state) # <<<<<<<<<<<<<< * return __pyx_result * cdef __pyx_unpickle_CompressedBufferedReader__set_state(CompressedBufferedReader __pyx_result, __pyx_state: tuple): */ if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "cannot pass None into a C function argument that is declared 'not None'"); __PYX_ERR(2, 9, __pyx_L1_error) } __pyx_t_2 = __pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_CompressedBufferedReader__set_state(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)__pyx_v___pyx_result), __pyx_v___pyx_state); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":8 * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x69923fe, 0xfd1be99, 0x183c0eb, b'buffer, current_buffer_size, position, read_block') * __pyx_result = CompressedBufferedReader.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle_CompressedBufferedReader__set_state( __pyx_result, __pyx_state) * return __pyx_result */ } /* "(tree fragment)":10 * if __pyx_state is not None: * __pyx_unpickle_CompressedBufferedReader__set_state( __pyx_result, __pyx_state) * return __pyx_result # <<<<<<<<<<<<<< * cdef __pyx_unpickle_CompressedBufferedReader__set_state(CompressedBufferedReader __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.read_block = __pyx_state[3] */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v___pyx_result); __pyx_r = __pyx_v___pyx_result; goto __pyx_L0; /* "(tree fragment)":4 * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 * def __pyx_unpickle_CompressedBufferedReader(__pyx_type, long __pyx_checksum, tuple __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x69923fe, 0xfd1be99, 0x183c0eb, b'buffer, current_buffer_size, position, read_block') */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_CompressedBufferedReader", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v___pyx_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":11 * __pyx_unpickle_CompressedBufferedReader__set_state( __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle_CompressedBufferedReader__set_state(CompressedBufferedReader __pyx_result, __pyx_state: tuple): # <<<<<<<<<<<<<< * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.read_block = __pyx_state[3] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 4) */ static PyObject *__pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_CompressedBufferedReader__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; unsigned PY_LONG_LONG __pyx_t_2; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle_CompressedBufferedReader__set_state", 0); /* "(tree fragment)":12 * return __pyx_result * cdef __pyx_unpickle_CompressedBufferedReader__set_state(CompressedBufferedReader __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.read_block = __pyx_state[3] # <<<<<<<<<<<<<< * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 4) */ __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyByteArray_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytearray", __pyx_t_1))) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.buffer); __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.buffer); __pyx_v___pyx_result->__pyx_base.buffer = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_2 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->__pyx_base.current_buffer_size = __pyx_t_2; __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_2 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->__pyx_base.position = __pyx_t_2; __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->read_block); __Pyx_DECREF(__pyx_v___pyx_result->read_block); __pyx_v___pyx_result->read_block = __pyx_t_1; __pyx_t_1 = 0; /* "(tree fragment)":13 * cdef __pyx_unpickle_CompressedBufferedReader__set_state(CompressedBufferedReader __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.read_block = __pyx_state[3] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 4) # <<<<<<<<<<<<<< */ __pyx_t_3 = __Pyx_UpdateUnpickledDict(((PyObject *)__pyx_v___pyx_result), __pyx_v___pyx_state, 4); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(2, 13, __pyx_L1_error) /* "(tree fragment)":11 * __pyx_unpickle_CompressedBufferedReader__set_state( __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle_CompressedBufferedReader__set_state(CompressedBufferedReader __pyx_result, __pyx_state: tuple): # <<<<<<<<<<<<<< * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.read_block = __pyx_state[3] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 4) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_CompressedBufferedReader__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* #### Code section: module_exttypes ### */ static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedReader(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *p; PyObject *o; o = __Pyx_AllocateExtensionType(t, 0); if (unlikely(!o)) return 0; p = ((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)o); p->buffer = ((PyObject*)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_BufferedReader(PyObject *o) { struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *p = (struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)o; #if CYTHON_USE_TP_FINALIZE if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && (!PyType_IS_GC(Py_TYPE(o)) || !__Pyx_PyObject_GC_IsFinalized(o))) { if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_BufferedReader) { if (PyObject_CallFinalizerFromDealloc(o)) return; } } #endif Py_CLEAR(p->buffer); PyTypeObject *tp = Py_TYPE(o); #if CYTHON_USE_TYPE_SLOTS (*tp->tp_free)(o); #else { freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free); if (tp_free) tp_free(o); } #endif #if CYTHON_USE_TYPE_SPECS Py_DECREF(tp); #endif } static PyObject *__pyx_getprop_17clickhouse_driver_14bufferedreader_14BufferedReader_position(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_1__get__(o); } static int __pyx_setprop_17clickhouse_driver_14bufferedreader_14BufferedReader_position(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_17clickhouse_driver_14bufferedreader_14BufferedReader_current_buffer_size(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_1__get__(o); } static int __pyx_setprop_17clickhouse_driver_14bufferedreader_14BufferedReader_current_buffer_size(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_3__set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); return -1; } } static PyObject *__pyx_getprop_17clickhouse_driver_14bufferedreader_14BufferedReader_buffer(PyObject *o, CYTHON_UNUSED void *x) { return __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_1__get__(o); } static int __pyx_setprop_17clickhouse_driver_14bufferedreader_14BufferedReader_buffer(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { if (v) { return __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_3__set__(o, v); } else { return __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_5__del__(o); } } static PyMethodDef __pyx_methods_17clickhouse_driver_14bufferedreader_BufferedReader[] = { {"read_into_buffer", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_3read_into_buffer, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"read", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_5read, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"read_one", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_7read_one, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"read_strings", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_9read_strings, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_17clickhouse_driver_14bufferedreader_14BufferedReader_8read_strings}, {"read_strings_arrow", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_11read_strings_arrow, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_17clickhouse_driver_14bufferedreader_14BufferedReader_10read_strings_arrow}, {"read_fixed_strings_as_bytes", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_13read_fixed_strings_as_bytes, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"read_fixed_strings", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_15read_fixed_strings, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_17__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_19__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_17clickhouse_driver_14bufferedreader_BufferedReader[] = { {"position", __pyx_getprop_17clickhouse_driver_14bufferedreader_14BufferedReader_position, __pyx_setprop_17clickhouse_driver_14bufferedreader_14BufferedReader_position, 0, 0}, {"current_buffer_size", __pyx_getprop_17clickhouse_driver_14bufferedreader_14BufferedReader_current_buffer_size, __pyx_setprop_17clickhouse_driver_14bufferedreader_14BufferedReader_current_buffer_size, 0, 0}, {"buffer", __pyx_getprop_17clickhouse_driver_14bufferedreader_14BufferedReader_buffer, __pyx_setprop_17clickhouse_driver_14bufferedreader_14BufferedReader_buffer, 0, 0}, {0, 0, 0, 0, 0} }; #if CYTHON_USE_TYPE_SPECS static PyType_Slot __pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader_slots[] = { {Py_tp_dealloc, (void *)__pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_BufferedReader}, {Py_tp_methods, (void *)__pyx_methods_17clickhouse_driver_14bufferedreader_BufferedReader}, {Py_tp_getset, (void *)__pyx_getsets_17clickhouse_driver_14bufferedreader_BufferedReader}, {Py_tp_init, (void *)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_1__init__}, {Py_tp_new, (void *)__pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedReader}, {0, 0}, }; static PyType_Spec __pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader_spec = { "clickhouse_driver.bufferedreader.BufferedReader", sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader), 0, Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, __pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader_slots, }; #else static PyTypeObject __pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader = { PyVarObject_HEAD_INIT(0, 0) "clickhouse_driver.bufferedreader.""BufferedReader", /*tp_name*/ sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_BufferedReader, /*tp_dealloc*/ 0, /*tp_vectorcall_offset*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_as_async*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ 0, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_17clickhouse_driver_14bufferedreader_BufferedReader, /*tp_methods*/ 0, /*tp_members*/ __pyx_getsets_17clickhouse_driver_14bufferedreader_BufferedReader, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ #if !CYTHON_USE_TYPE_SPECS 0, /*tp_dictoffset*/ #endif __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedReader, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if CYTHON_USE_TP_FINALIZE 0, /*tp_finalize*/ #else NULL, /*tp_finalize*/ #endif #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800 0, /*tp_vectorcall*/ #endif #if __PYX_NEED_TP_PRINT_SLOT == 1 0, /*tp_print*/ #endif #if PY_VERSION_HEX >= 0x030C0000 0, /*tp_watched*/ #endif #if PY_VERSION_HEX >= 0x030d00A4 0, /*tp_versions_used*/ #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000 0, /*tp_pypy_flags*/ #endif }; #endif static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedSocketReader(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *p; PyObject *o = __pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedReader(t, a, k); if (unlikely(!o)) return 0; p = ((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)o); p->sock = Py_None; Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_BufferedSocketReader(PyObject *o) { struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *p = (struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)o; #if CYTHON_USE_TP_FINALIZE if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) { if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_BufferedSocketReader) { if (PyObject_CallFinalizerFromDealloc(o)) return; } } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->sock); __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_BufferedReader(o); } static int __pyx_tp_traverse_17clickhouse_driver_14bufferedreader_BufferedSocketReader(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *p = (struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)o; #if !CYTHON_USE_MODULE_STATE e = 0; if (likely(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader)) { traverseproc traverse = __Pyx_PyType_GetSlot(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader, tp_traverse, traverseproc); if (traverse) { e = traverse(o, v, a); } } else #endif { e = __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_17clickhouse_driver_14bufferedreader_BufferedSocketReader); } if (e) return e; { e = __Pyx_call_type_traverse(o, 0, v, a); if (e) return e; } if (p->sock) { e = (*v)(p->sock, a); if (e) return e; } return 0; } static int __pyx_tp_clear_17clickhouse_driver_14bufferedreader_BufferedSocketReader(PyObject *o) { PyObject* tmp; struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *p = (struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)o; #if !CYTHON_USE_MODULE_STATE if (likely(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader)) { inquiry clear = __Pyx_PyType_GetSlot(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader, tp_clear, inquiry); if (clear) clear(o); } else #endif { __Pyx_call_next_tp_clear(o, __pyx_tp_clear_17clickhouse_driver_14bufferedreader_BufferedSocketReader); } tmp = ((PyObject*)p->sock); p->sock = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyMethodDef __pyx_methods_17clickhouse_driver_14bufferedreader_BufferedSocketReader[] = { {"read_into_buffer", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_3read_into_buffer, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_5__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_7__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; #if CYTHON_USE_TYPE_SPECS static PyType_Slot __pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader_slots[] = { {Py_tp_dealloc, (void *)__pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_BufferedSocketReader}, {Py_tp_traverse, (void *)__pyx_tp_traverse_17clickhouse_driver_14bufferedreader_BufferedSocketReader}, {Py_tp_clear, (void *)__pyx_tp_clear_17clickhouse_driver_14bufferedreader_BufferedSocketReader}, {Py_tp_methods, (void *)__pyx_methods_17clickhouse_driver_14bufferedreader_BufferedSocketReader}, {Py_tp_init, (void *)__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_1__init__}, {Py_tp_new, (void *)__pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedSocketReader}, {0, 0}, }; static PyType_Spec __pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader_spec = { "clickhouse_driver.bufferedreader.BufferedSocketReader", sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader), 0, Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, __pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader_slots, }; #else static PyTypeObject __pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader = { PyVarObject_HEAD_INIT(0, 0) "clickhouse_driver.bufferedreader.""BufferedSocketReader", /*tp_name*/ sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_BufferedSocketReader, /*tp_dealloc*/ 0, /*tp_vectorcall_offset*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_as_async*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_17clickhouse_driver_14bufferedreader_BufferedSocketReader, /*tp_traverse*/ __pyx_tp_clear_17clickhouse_driver_14bufferedreader_BufferedSocketReader, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_17clickhouse_driver_14bufferedreader_BufferedSocketReader, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ #if !CYTHON_USE_TYPE_SPECS 0, /*tp_dictoffset*/ #endif __pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedSocketReader, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if CYTHON_USE_TP_FINALIZE 0, /*tp_finalize*/ #else NULL, /*tp_finalize*/ #endif #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800 0, /*tp_vectorcall*/ #endif #if __PYX_NEED_TP_PRINT_SLOT == 1 0, /*tp_print*/ #endif #if PY_VERSION_HEX >= 0x030C0000 0, /*tp_watched*/ #endif #if PY_VERSION_HEX >= 0x030d00A4 0, /*tp_versions_used*/ #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000 0, /*tp_pypy_flags*/ #endif }; #endif static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedreader_CompressedBufferedReader(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *p; PyObject *o = __pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedReader(t, a, k); if (unlikely(!o)) return 0; p = ((struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)o); p->read_block = Py_None; Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_CompressedBufferedReader(PyObject *o) { struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *p = (struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)o; #if CYTHON_USE_TP_FINALIZE if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) { if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_CompressedBufferedReader) { if (PyObject_CallFinalizerFromDealloc(o)) return; } } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->read_block); __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_BufferedReader(o); } static int __pyx_tp_traverse_17clickhouse_driver_14bufferedreader_CompressedBufferedReader(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *p = (struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)o; #if !CYTHON_USE_MODULE_STATE e = 0; if (likely(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader)) { traverseproc traverse = __Pyx_PyType_GetSlot(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader, tp_traverse, traverseproc); if (traverse) { e = traverse(o, v, a); } } else #endif { e = __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_17clickhouse_driver_14bufferedreader_CompressedBufferedReader); } if (e) return e; { e = __Pyx_call_type_traverse(o, 0, v, a); if (e) return e; } if (p->read_block) { e = (*v)(p->read_block, a); if (e) return e; } return 0; } static int __pyx_tp_clear_17clickhouse_driver_14bufferedreader_CompressedBufferedReader(PyObject *o) { PyObject* tmp; struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *p = (struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)o; #if !CYTHON_USE_MODULE_STATE if (likely(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader)) { inquiry clear = __Pyx_PyType_GetSlot(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader, tp_clear, inquiry); if (clear) clear(o); } else #endif { __Pyx_call_next_tp_clear(o, __pyx_tp_clear_17clickhouse_driver_14bufferedreader_CompressedBufferedReader); } tmp = ((PyObject*)p->read_block); p->read_block = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyMethodDef __pyx_methods_17clickhouse_driver_14bufferedreader_CompressedBufferedReader[] = { {"read_into_buffer", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_3read_into_buffer, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_5__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_7__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; #if CYTHON_USE_TYPE_SPECS static PyType_Slot __pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader_slots[] = { {Py_tp_dealloc, (void *)__pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_CompressedBufferedReader}, {Py_tp_traverse, (void *)__pyx_tp_traverse_17clickhouse_driver_14bufferedreader_CompressedBufferedReader}, {Py_tp_clear, (void *)__pyx_tp_clear_17clickhouse_driver_14bufferedreader_CompressedBufferedReader}, {Py_tp_methods, (void *)__pyx_methods_17clickhouse_driver_14bufferedreader_CompressedBufferedReader}, {Py_tp_init, (void *)__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_1__init__}, {Py_tp_new, (void *)__pyx_tp_new_17clickhouse_driver_14bufferedreader_CompressedBufferedReader}, {0, 0}, }; static PyType_Spec __pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader_spec = { "clickhouse_driver.bufferedreader.CompressedBufferedReader", sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader), 0, Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, __pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader_slots, }; #else static PyTypeObject __pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader = { PyVarObject_HEAD_INIT(0, 0) "clickhouse_driver.bufferedreader.""CompressedBufferedReader", /*tp_name*/ sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_CompressedBufferedReader, /*tp_dealloc*/ 0, /*tp_vectorcall_offset*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_as_async*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_17clickhouse_driver_14bufferedreader_CompressedBufferedReader, /*tp_traverse*/ __pyx_tp_clear_17clickhouse_driver_14bufferedreader_CompressedBufferedReader, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_17clickhouse_driver_14bufferedreader_CompressedBufferedReader, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ #if !CYTHON_USE_TYPE_SPECS 0, /*tp_dictoffset*/ #endif __pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_17clickhouse_driver_14bufferedreader_CompressedBufferedReader, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if CYTHON_USE_TP_FINALIZE 0, /*tp_finalize*/ #else NULL, /*tp_finalize*/ #endif #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800 0, /*tp_vectorcall*/ #endif #if __PYX_NEED_TP_PRINT_SLOT == 1 0, /*tp_print*/ #endif #if PY_VERSION_HEX >= 0x030C0000 0, /*tp_watched*/ #endif #if PY_VERSION_HEX >= 0x030d00A4 0, /*tp_versions_used*/ #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000 0, /*tp_pypy_flags*/ #endif }; #endif static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; /* #### Code section: initfunc_declarations ### */ static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate); /*proto*/ /* #### Code section: init_module ### */ static int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); /*--- Global init code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); /*--- Variable export code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); /*--- Function export code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); /*--- Type init code ---*/ #if CYTHON_USE_TYPE_SPECS __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader)) __PYX_ERR(0, 10, __pyx_L1_error) if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader_spec, __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader) < (0)) __PYX_ERR(0, 10, __pyx_L1_error) #else __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader = &__pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader; #endif #if !CYTHON_COMPILING_IN_LIMITED_API #endif #if !CYTHON_USE_TYPE_SPECS if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader) < (0)) __PYX_ERR(0, 10, __pyx_L1_error) #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader); #endif #if !CYTHON_COMPILING_IN_LIMITED_API if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader->tp_dictoffset && __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader->tp_getattro == PyObject_GenericGetAttr)) { __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader->tp_getattro = PyObject_GenericGetAttr; } #endif if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_BufferedReader, (PyObject *) __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader) < (0)) __PYX_ERR(0, 10, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject *) __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader) < (0)) __PYX_ERR(0, 10, __pyx_L1_error) #if CYTHON_USE_TYPE_SPECS __pyx_t_1 = PyTuple_Pack(1, (PyObject *)__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader_spec, __pyx_t_1); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader)) __PYX_ERR(0, 317, __pyx_L1_error) if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader_spec, __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader) < (0)) __PYX_ERR(0, 317, __pyx_L1_error) #else __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader = &__pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader; #endif #if !CYTHON_COMPILING_IN_LIMITED_API __pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader->tp_base = __pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader; #endif #if !CYTHON_USE_TYPE_SPECS if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader) < (0)) __PYX_ERR(0, 317, __pyx_L1_error) #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader); #endif #if !CYTHON_COMPILING_IN_LIMITED_API if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader->tp_dictoffset && __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader->tp_getattro == PyObject_GenericGetAttr)) { __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader->tp_getattro = PyObject_GenericGetAttr; } #endif if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_BufferedSocketReader, (PyObject *) __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader) < (0)) __PYX_ERR(0, 317, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject *) __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader) < (0)) __PYX_ERR(0, 317, __pyx_L1_error) #if CYTHON_USE_TYPE_SPECS __pyx_t_1 = PyTuple_Pack(1, (PyObject *)__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader_spec, __pyx_t_1); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader)) __PYX_ERR(0, 331, __pyx_L1_error) if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader_spec, __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader) < (0)) __PYX_ERR(0, 331, __pyx_L1_error) #else __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader = &__pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader; #endif #if !CYTHON_COMPILING_IN_LIMITED_API __pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader->tp_base = __pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader; #endif #if !CYTHON_USE_TYPE_SPECS if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader) < (0)) __PYX_ERR(0, 331, __pyx_L1_error) #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader); #endif #if !CYTHON_COMPILING_IN_LIMITED_API if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader->tp_dictoffset && __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader->tp_getattro == PyObject_GenericGetAttr)) { __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader->tp_getattro = PyObject_GenericGetAttr; } #endif if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_CompressedBufferedReader, (PyObject *) __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader) < (0)) __PYX_ERR(0, 331, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject *) __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader) < (0)) __PYX_ERR(0, 331, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); /*--- Type import code ---*/ __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_mstate->__pyx_ptype_7cpython_4type_type = __Pyx_ImportType_3_2_0(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 sizeof(PyTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyTypeObject), #elif CYTHON_COMPILING_IN_LIMITED_API 0, 0, #else sizeof(PyHeapTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyHeapTypeObject), #endif __Pyx_ImportType_CheckSize_Warn_3_2_0); if (!__pyx_mstate->__pyx_ptype_7cpython_4type_type) __PYX_ERR(3, 9, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_mstate->__pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType_3_2_0(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "bool", #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 sizeof(PyLongObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyLongObject), #elif CYTHON_COMPILING_IN_LIMITED_API 0, 0, #else sizeof(PyLongObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyLongObject), #endif __Pyx_ImportType_CheckSize_Warn_3_2_0); if (!__pyx_mstate->__pyx_ptype_7cpython_4bool_bool) __PYX_ERR(4, 8, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_mstate->__pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType_3_2_0(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "complex", #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 sizeof(PyComplexObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyComplexObject), #elif CYTHON_COMPILING_IN_LIMITED_API 0, 0, #else sizeof(PyComplexObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyComplexObject), #endif __Pyx_ImportType_CheckSize_Warn_3_2_0); if (!__pyx_mstate->__pyx_ptype_7cpython_7complex_complex) __PYX_ERR(5, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); /*--- Variable import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); /*--- Function import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } #if CYTHON_PEP489_MULTI_PHASE_INIT static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ static int __pyx_pymod_exec_bufferedreader(PyObject* module); /*proto*/ static PyModuleDef_Slot __pyx_moduledef_slots[] = { {Py_mod_create, (void*)__pyx_pymod_create}, {Py_mod_exec, (void*)__pyx_pymod_exec_bufferedreader}, #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING {Py_mod_gil, Py_MOD_GIL_USED}, #endif #if PY_VERSION_HEX >= 0x030C0000 && CYTHON_USE_MODULE_STATE {Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED}, #endif {0, NULL} }; #endif #ifdef __cplusplus namespace { struct PyModuleDef __pyx_moduledef = #else static struct PyModuleDef __pyx_moduledef = #endif { PyModuleDef_HEAD_INIT, "bufferedreader", 0, /* m_doc */ #if CYTHON_USE_MODULE_STATE sizeof(__pyx_mstatetype), /* m_size */ #else (CYTHON_PEP489_MULTI_PHASE_INIT) ? 0 : -1, /* m_size */ #endif __pyx_methods /* m_methods */, #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_moduledef_slots, /* m_slots */ #else NULL, /* m_reload */ #endif #if CYTHON_USE_MODULE_STATE __pyx_m_traverse, /* m_traverse */ __pyx_m_clear, /* m_clear */ NULL /* m_free */ #else NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ #endif }; #ifdef __cplusplus } /* anonymous namespace */ #endif /* PyModInitFuncType */ #ifndef CYTHON_NO_PYINIT_EXPORT #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC #else #ifdef __cplusplus #define __Pyx_PyMODINIT_FUNC extern "C" PyObject * #else #define __Pyx_PyMODINIT_FUNC PyObject * #endif #endif __Pyx_PyMODINIT_FUNC PyInit_bufferedreader(void) CYTHON_SMALL_CODE; /*proto*/ __Pyx_PyMODINIT_FUNC PyInit_bufferedreader(void) #if CYTHON_PEP489_MULTI_PHASE_INIT { return PyModuleDef_Init(&__pyx_moduledef); } /* ModuleCreationPEP489 */ #if CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\ || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000)) static PY_INT64_T __Pyx_GetCurrentInterpreterId(void) { { PyObject *module = PyImport_ImportModule("_interpreters"); // 3.13+ I think if (!module) { PyErr_Clear(); // just try the 3.8-3.12 version module = PyImport_ImportModule("_xxsubinterpreters"); if (!module) goto bad; } PyObject *current = PyObject_CallMethod(module, "get_current", NULL); Py_DECREF(module); if (!current) goto bad; if (PyTuple_Check(current)) { PyObject *new_current = PySequence_GetItem(current, 0); Py_DECREF(current); current = new_current; if (!new_current) goto bad; } long long as_c_int = PyLong_AsLongLong(current); Py_DECREF(current); return as_c_int; } bad: PySys_WriteStderr("__Pyx_GetCurrentInterpreterId failed. Try setting the C define CYTHON_PEP489_MULTI_PHASE_INIT=0\n"); return -1; } #endif #if !CYTHON_USE_MODULE_STATE static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { static PY_INT64_T main_interpreter_id = -1; #if CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000 PY_INT64_T current_id = GraalPyInterpreterState_GetIDFromThreadState(PyThreadState_Get()); #elif CYTHON_COMPILING_IN_GRAAL PY_INT64_T current_id = PyInterpreterState_GetIDFromThreadState(PyThreadState_Get()); #elif CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\ || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000)) PY_INT64_T current_id = __Pyx_GetCurrentInterpreterId(); #elif CYTHON_COMPILING_IN_LIMITED_API PY_INT64_T current_id = PyInterpreterState_GetID(PyInterpreterState_Get()); #else PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); #endif if (unlikely(current_id == -1)) { return -1; } if (main_interpreter_id == -1) { main_interpreter_id = current_id; return 0; } else if (unlikely(main_interpreter_id != current_id)) { PyErr_SetString( PyExc_ImportError, "Interpreter change detected - this module can only be loaded into one interpreter per process."); return -1; } return 0; } #endif static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { PyObject *value = PyObject_GetAttrString(spec, from_name); int result = 0; if (likely(value)) { if (allow_none || value != Py_None) { result = PyDict_SetItemString(moddict, to_name, value); } Py_DECREF(value); } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Clear(); } else { result = -1; } return result; } static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def) { PyObject *module = NULL, *moddict, *modname; CYTHON_UNUSED_VAR(def); #if !CYTHON_USE_MODULE_STATE if (__Pyx_check_single_interpreter()) return NULL; #endif if (__pyx_m) return __Pyx_NewRef(__pyx_m); modname = PyObject_GetAttrString(spec, "name"); if (unlikely(!modname)) goto bad; module = PyModule_NewObject(modname); Py_DECREF(modname); if (unlikely(!module)) goto bad; moddict = PyModule_GetDict(module); if (unlikely(!moddict)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; return module; bad: Py_XDECREF(module); return NULL; } static CYTHON_SMALL_CODE int __pyx_pymod_exec_bufferedreader(PyObject *__pyx_pyinit_module) #endif { int stringtab_initialized = 0; #if CYTHON_USE_MODULE_STATE int pystate_addmodule_run = 0; #endif __pyx_mstatetype *__pyx_mstate = NULL; PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #if CYTHON_PEP489_MULTI_PHASE_INIT if (__pyx_m) { if (__pyx_m == __pyx_pyinit_module) return 0; PyErr_SetString(PyExc_RuntimeError, "Module 'bufferedreader' has already been imported. Re-initialisation is not supported."); return -1; } #else if (__pyx_m) return __Pyx_NewRef(__pyx_m); #endif /*--- Module creation code ---*/ #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_t_1 = __pyx_pyinit_module; Py_INCREF(__pyx_t_1); #else __pyx_t_1 = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) #endif #if CYTHON_USE_MODULE_STATE { int add_module_result = __Pyx_State_AddModule(__pyx_t_1, &__pyx_moduledef); __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to "bufferedreader" pseudovariable */ if (unlikely((add_module_result < 0))) __PYX_ERR(0, 1, __pyx_L1_error) pystate_addmodule_run = 1; } #else __pyx_m = __pyx_t_1; #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING PyUnstable_Module_SetGIL(__pyx_m, Py_MOD_GIL_USED); #endif __pyx_mstate = __pyx_mstate_global; CYTHON_UNUSED_VAR(__pyx_t_1); __pyx_mstate->__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_mstate->__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_mstate->__pyx_d); __pyx_mstate->__pyx_b = __Pyx_PyImport_AddModuleRef(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_mstate->__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_mstate->__pyx_cython_runtime = __Pyx_PyImport_AddModuleRef("cython_runtime"); if (unlikely(!__pyx_mstate->__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_mstate->__pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error) /* ImportRefnannyAPI */ #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("PyInit_bufferedreader", 0); __Pyx_init_runtime_version(); if (__Pyx_check_binary_version(__PYX_LIMITED_VERSION_HEX, __Pyx_get_runtime_version(), CYTHON_COMPILING_IN_LIMITED_API) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_mstate->__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_mstate->__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_mstate->__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_mstate->__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Library function declarations ---*/ /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) stringtab_initialized = 1; if (__Pyx_InitGlobals() < (0)) __PYX_ERR(0, 1, __pyx_L1_error) if (__pyx_module_is_main_clickhouse_driver__bufferedreader) { if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_name, __pyx_mstate_global->__pyx_n_u_main) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) } { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) if (!PyDict_GetItemString(modules, "clickhouse_driver.bufferedreader")) { if (unlikely((PyDict_SetItemString(modules, "clickhouse_driver.bufferedreader", __pyx_m) < 0))) __PYX_ERR(0, 1, __pyx_L1_error) } } /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_CreateCodeObjects(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Global type/function init code ---*/ (void)__Pyx_modinit_global_init_code(__pyx_mstate); (void)__Pyx_modinit_variable_export_code(__pyx_mstate); (void)__Pyx_modinit_function_export_code(__pyx_mstate); if (unlikely((__Pyx_modinit_type_init_code(__pyx_mstate) < 0))) __PYX_ERR(0, 1, __pyx_L1_error) if (unlikely((__Pyx_modinit_type_import_code(__pyx_mstate) < 0))) __PYX_ERR(0, 1, __pyx_L1_error) (void)__Pyx_modinit_variable_import_code(__pyx_mstate); (void)__Pyx_modinit_function_import_code(__pyx_mstate); /*--- Execution code ---*/ /* "clickhouse_driver/bufferedreader.pyx":22 * super(BufferedReader, self).__init__() * * def read_into_buffer(self): # <<<<<<<<<<<<<< * raise NotImplementedError * */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_3read_into_buffer, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedReader_read_into_buffer, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader, __pyx_mstate_global->__pyx_n_u_read_into_buffer, __pyx_t_2) < (0)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedreader.pyx":25 * raise NotImplementedError * * def read(self, unsigned long long unread): # <<<<<<<<<<<<<< * # When the buffer is large enough bytes read are almost * # always hit the buffer. */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_5read, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedReader_read, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader, __pyx_mstate_global->__pyx_n_u_read, __pyx_t_2) < (0)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedreader.pyx":53 * return rv * * def read_one(self): # <<<<<<<<<<<<<< * if self.position == self.current_buffer_size: * self.read_into_buffer() */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_7read_one, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedReader_read_one, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[2])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader, __pyx_mstate_global->__pyx_n_u_read_one, __pyx_t_2) < (0)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedreader.pyx":62 * return rv * * def read_strings(self, unsigned long long n_items, encoding=None): # <<<<<<<<<<<<<< * """ * Python has great overhead between function calls. */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_9read_strings, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedReader_read_strings, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[3])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_mstate_global->__pyx_tuple[3]); if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader, __pyx_mstate_global->__pyx_n_u_read_strings, __pyx_t_2) < (0)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedreader.pyx":179 * return items * * def read_strings_arrow(self, unsigned long long n_items): # <<<<<<<<<<<<<< * """ * Reads ``n_items`` varint-prefixed strings into Arrow-style */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_11read_strings_arrow, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedReader_read_strings_arro, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[4])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader, __pyx_mstate_global->__pyx_n_u_read_strings_arrow, __pyx_t_2) < (0)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedreader.pyx":267 * return offsets, data * * def read_fixed_strings_as_bytes(self, Py_ssize_t n_items, # <<<<<<<<<<<<<< * Py_ssize_t length): * cdef Py_ssize_t i */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_13read_fixed_strings_as_bytes, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedReader_read_fixed_string, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[5])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 267, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader, __pyx_mstate_global->__pyx_n_u_read_fixed_strings_as_bytes, __pyx_t_2) < (0)) __PYX_ERR(0, 267, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedreader.pyx":280 * return items * * def read_fixed_strings(self, Py_ssize_t n_items, Py_ssize_t length, # <<<<<<<<<<<<<< * encoding=None): * if encoding is None: */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_15read_fixed_strings, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedReader_read_fixed_string_2, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[6])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_mstate_global->__pyx_tuple[3]); if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader, __pyx_mstate_global->__pyx_n_u_read_fixed_strings, __pyx_t_2) < (0)) __PYX_ERR(0, 280, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_17__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedReader___reduce_cython, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[7])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader, __pyx_mstate_global->__pyx_n_u_reduce_cython, __pyx_t_2) < (0)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":16 * else: * return __pyx_unpickle_BufferedReader, (type(self), 0x5e0d780, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedReader__set_state(self, __pyx_state) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_19__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedReader___setstate_cython, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[8])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader, __pyx_mstate_global->__pyx_n_u_setstate_cython, __pyx_t_2) < (0)) __PYX_ERR(2, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedreader.pyx":324 * super(BufferedSocketReader, self).__init__(bufsize) * * def read_into_buffer(self): # <<<<<<<<<<<<<< * self.current_buffer_size = self.sock.recv_into(self.buffer) * */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_3read_into_buffer, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedSocketReader_read_into_b, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[9])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 324, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader, __pyx_mstate_global->__pyx_n_u_read_into_buffer, __pyx_t_2) < (0)) __PYX_ERR(0, 324, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_5__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedSocketReader___reduce_cy, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[10])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader, __pyx_mstate_global->__pyx_n_u_reduce_cython, __pyx_t_2) < (0)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":16 * else: * return __pyx_unpickle_BufferedSocketReader, (type(self), 0x44eb6c8, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedSocketReader__set_state(self, __pyx_state) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_7__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedSocketReader___setstate, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[11])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader, __pyx_mstate_global->__pyx_n_u_setstate_cython, __pyx_t_2) < (0)) __PYX_ERR(2, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedreader.pyx":338 * super(CompressedBufferedReader, self).__init__(bufsize) * * def read_into_buffer(self): # <<<<<<<<<<<<<< * self.buffer = bytearray(self.read_block()) * self.current_buffer_size = len(self.buffer) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_3read_into_buffer, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_CompressedBufferedReader_read_in, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[12])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 338, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader, __pyx_mstate_global->__pyx_n_u_read_into_buffer, __pyx_t_2) < (0)) __PYX_ERR(0, 338, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_5__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_CompressedBufferedReader___reduc, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[13])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader, __pyx_mstate_global->__pyx_n_u_reduce_cython, __pyx_t_2) < (0)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":16 * else: * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x69923fe, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_CompressedBufferedReader__set_state(self, __pyx_state) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_7__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_CompressedBufferedReader___setst, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[14])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader, __pyx_mstate_global->__pyx_n_u_setstate_cython, __pyx_t_2) < (0)) __PYX_ERR(2, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":4 * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 * def __pyx_unpickle_BufferedReader(__pyx_type, long __pyx_checksum, tuple __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x5e0d780, 0x07c78bc, 0x2a8a945, b'buffer, current_buffer_size, position') */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_1__pyx_unpickle_BufferedReader, 0, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_BufferedReader, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[15])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_BufferedReader, __pyx_t_2) < (0)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":1 * cdef extern from *: # <<<<<<<<<<<<<< * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_3__pyx_unpickle_BufferedSocketReader, 0, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_BufferedSocketRea, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[16])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_BufferedSocketRea, __pyx_t_2) < (0)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":4 * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 * def __pyx_unpickle_CompressedBufferedReader(__pyx_type, long __pyx_checksum, tuple __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x69923fe, 0xfd1be99, 0x183c0eb, b'buffer, current_buffer_size, position, read_block') */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedreader_5__pyx_unpickle_CompressedBufferedReader, 0, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_CompressedBuffere, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedreader, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[17])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_CompressedBuffere, __pyx_t_2) < (0)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedreader.pyx":1 * from cpython cimport Py_INCREF, PyBytes_FromStringAndSize, PyBytes_AsString # <<<<<<<<<<<<<< * from cpython.bytearray cimport PyByteArray_AsString, PyByteArray_Resize * # Using python's versions of pure c memory management functions for */ __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_test, __pyx_t_2) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); if (__pyx_m) { if (__pyx_mstate->__pyx_d && stringtab_initialized) { __Pyx_AddTraceback("init clickhouse_driver.bufferedreader", __pyx_clineno, __pyx_lineno, __pyx_filename); } #if !CYTHON_USE_MODULE_STATE Py_CLEAR(__pyx_m); #else Py_DECREF(__pyx_m); if (pystate_addmodule_run) { PyObject *tp, *value, *tb; PyErr_Fetch(&tp, &value, &tb); PyState_RemoveModule(&__pyx_moduledef); PyErr_Restore(tp, value, tb); } #endif } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init clickhouse_driver.bufferedreader"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if CYTHON_PEP489_MULTI_PHASE_INIT return (__pyx_m != NULL) ? 0 : -1; #else return __pyx_m; #endif } /* #### Code section: pystring_table ### */ /* #### Code section: cached_builtins ### */ static int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate) { CYTHON_UNUSED_VAR(__pyx_mstate); __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_super); if (!__pyx_builtin_super) __PYX_ERR(0, 20, __pyx_L1_error) __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_object); if (!__pyx_builtin_object) __PYX_ERR(0, 85, __pyx_L1_error) /* Cached unbound methods */ __pyx_mstate->__pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type; __pyx_mstate->__pyx_umethod_PyDict_Type_items.method_name = &__pyx_mstate->__pyx_n_u_items; __pyx_mstate->__pyx_umethod_PyDict_Type_pop.type = (PyObject*)&PyDict_Type; __pyx_mstate->__pyx_umethod_PyDict_Type_pop.method_name = &__pyx_mstate->__pyx_n_u_pop; __pyx_mstate->__pyx_umethod_PyDict_Type_values.type = (PyObject*)&PyDict_Type; __pyx_mstate->__pyx_umethod_PyDict_Type_values.method_name = &__pyx_mstate->__pyx_n_u_values; return 0; __pyx_L1_error:; return -1; } /* #### Code section: cached_constants ### */ static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "(tree fragment)":11 * use_setstate = True * else: * use_setstate = ('self.buffer is not None',) # <<<<<<<<<<<<<< * if use_setstate: * return __pyx_unpickle_BufferedReader, (type(self), 0x5e0d780, None), state */ __pyx_mstate_global->__pyx_tuple[0] = PyTuple_Pack(1, __pyx_mstate_global->__pyx_kp_u_self_buffer_is_not_None); if (unlikely(!__pyx_mstate_global->__pyx_tuple[0])) __PYX_ERR(2, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[0]); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[0]); __pyx_mstate_global->__pyx_tuple[1] = PyTuple_Pack(1, __pyx_mstate_global->__pyx_kp_u_self_buffer_is_not_None_or_self); if (unlikely(!__pyx_mstate_global->__pyx_tuple[1])) __PYX_ERR(2, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[1]); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[1]); __pyx_mstate_global->__pyx_tuple[2] = PyTuple_Pack(1, __pyx_mstate_global->__pyx_kp_u_self_buffer_is_not_None_or_self_2); if (unlikely(!__pyx_mstate_global->__pyx_tuple[2])) __PYX_ERR(2, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[2]); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[2]); /* "clickhouse_driver/bufferedreader.pyx":62 * return rv * * def read_strings(self, unsigned long long n_items, encoding=None): # <<<<<<<<<<<<<< * """ * Python has great overhead between function calls. */ __pyx_mstate_global->__pyx_tuple[3] = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_mstate_global->__pyx_tuple[3])) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[3]); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[3]); #if CYTHON_IMMORTAL_CONSTANTS { PyObject **table = __pyx_mstate->__pyx_tuple; for (Py_ssize_t i=0; i<4; ++i) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL); #else Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT); #endif } } #endif __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } /* #### Code section: init_constants ### */ static int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate) { CYTHON_UNUSED_VAR(__pyx_mstate); { const struct { const unsigned int length: 10; } index[] = {{1},{179},{34},{8},{36},{7},{6},{2},{9},{23},{48},{54},{14},{5},{14},{32},{34},{19},{42},{33},{31},{23},{27},{33},{20},{38},{40},{37},{24},{42},{44},{41},{20},{18},{1},{10},{7},{10},{10},{8},{13},{32},{18},{4},{13},{8},{9},{8},{5},{6},{8},{8},{12},{1},{8},{13},{4},{5},{1},{6},{8},{10},{7},{8},{7},{13},{6},{7},{11},{3},{14},{12},{11},{10},{29},{35},{39},{12},{4},{10},{10},{18},{27},{16},{8},{12},{18},{9},{10},{17},{13},{5},{2},{4},{12},{10},{12},{19},{5},{4},{4},{5},{5},{1},{8},{6},{6},{12},{6},{613},{11},{11},{11},{183},{484},{41},{55},{248},{52},{7},{94},{105},{107},{100},{57},{59},{58}}; #if (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (2098 bytes) */ const char* const cstring = "BZh91AY&SY\376)\327\341\000\001\375\177\377\377\377\377\377\377\357\377\375\377\377\377\336\277\377\377\364@@@@@@@@@@@@@\000@\000`\007\375\360\006\272\223\323\313\220)\333+\254o\000>\267\276\302P\246\222F4@\003M=0\243e0\332\032\247\222m\t\204\315&\201\223!\221\264M\0322a\032m#\324\323\021\221\240\224\202\230\324\323\010\324\362$\364\364\320\220\364\236\246\200\003@\032\r\000\000\000\000\000\001\246\200\0004S\032)\250\000\017P\000\000\000\000\000\000\000\000\000\000\000\000\000\tM\020\240j\217\324\232\001\240\000\000\000\036\243@\000\000\000\000\006\200\000\036\247\244\364\232\004R\021\204\323\t\246\t\350&\230\001\032b\014\001\0310\000\000\004\301\r\030LC\000\t\220$P\010\024be\006\324a4\312z\201\240\000\000\000\000\000\000\000\000\000\000\321e\254[\251\362\271\251\303M1\334\032\365\3447\350\307?b\206O}\244BX0\016\244\322\206AJ\212*O\375\020tS]\033\344]yv\205\377\010\344\240\2550\220a\203c\0301\203\033\033m\246\333li\246\323\023Cm\243\022\300H\201e\235\005\312\313\002\226\271\261\261\246\3041\246\304\330<\212\205\223,\\\031c#\020d\345-+\016R\241\3140\002\010\230\330\307y\001d\006I\244\306\014\030\334\336\272\316\254a\222\331\224\36723\314\307e\266J\023\224\202&\211\204\214\261\305\246\252\025(\027VyYav\010\230\364a\200@\225\215\226\2061\214i\246\206\\\367o\232.J\341c\212#\2775\r!\3165FCV\301bc:\346U\214]\326%d\254\020\252\250\246f \034\365\252\252\362\301jp\230((2.%\346lK\265\027D\215\341y\222q\231\322\332\021J\325\370\240\367G\246\2239\322\333j \234\033u\360\236B\276>\347\333\203\t\376\002\270\274/\211hY\254W\313\0168\204g\224aJ{\031r\026qo\233\342\327\270sQ\254\333\016.;*\026Q\204\212\256\nE7\207@>@\366\023/j<\361\013\221\206\376Jw\230\354\022\030\246^\244!\316}h\254P\370\356SMB\212{\354\203\001\367'2<|\263\250\301j]\035,\316m\352\010\013Y\275\335r\350\022\333\262_\201\243\206.\262\336mf)@\242\313\005\243\326\256f\244mK<\376\302I\031\001\002\020A\300\n\0062Z+\016\226\004~\026\353\244\2554J\210\310h\353\016!\254\206S\024\347\374O'7\375\200h[\005\341""\207k1\251\027\351\223\255\031J\316%Y\031\306dg\r\316\207l\337\004\033\216x\353\224\334\340\177\217b\354\260\317Z\r\363*Q\035l\013\021\013)\361r\002\200D.DY0\2144f\310\270\"\321\004{\004%\022\314C\264\206\266\216\340T\2610\031A\026\345\206\006!\222(\250\346\211\2206)X\223\325\3311\2646\206\306\334\221UO\231aDW8\243oj\224\260E\005\244\342\223\264,\240o\243).N}\220\232\014\244N\326\241y\005\272\222 Ealv\324\003\237r\257\245ED\341QV\256\217\355\223\000\224cD\322A\005 \306\333T\322\203X\344\233Ed\223\266t\247\022PM\003\326\327E|\252\312\002\270-.\r\237;\r\230V\224!\216\320\017R\005\222\022H\301\203\013I\271\273\326\273\2365\272L_\201o7\177C\00607y\203\305\347e\264g9\354tQ\341B@\356V\204\233\222\030\001\353Z\250`\252U?H\272\231\354$\201yQ\316s\275.\337\372\261\327\314EF@\372\006\005s\254i\355\276\013!\026\377\211\221\371&Z\336\2520\363*Js\207\2021\336\033}5\301e\317S,p\234r0>%\312\206\026p\373\221\366}QR\271\274\032IXr-T\226B\221\030\230\313t]\232\252?\252\2770\230R\026\356k2\2168o\002\373e\347\233bh\3654s\315vl\336\330M\\7%\322\301\2358W\266\n\205\327\032@A;NtG\270\243O\236Mm\002yC\022\201\r\013\231\351\370\030\234ZN+\301\371\326\025\237\303\376\030\324\013\"\022\254M\341G\312#\317\226\020\362p\013B\026\342x\326\367\326\375\242\226e+\347\333\367\222\224}\003\r\342U\344)\265i\351\225E\241\234C\220\027\251\016iV\332e\342(\254\326\304\265\225+^\244\214\224\224\322\266\010\341\215\227Z\3424t\376\270\335\3441TQ\240y\024\301-\346\232\274\255\204\244zy\222\010i\311P\334\201-v\345h\270\034\220\004\245$&u,\330\013\365;a~\270\366r{\212G(\350\nsj!#\244,\223\301\264\204X\345K\210\336\263=)Q4l\273(\0031Q\212xL<\333\305\312\364\r\2422`9\005\256\031\204\004`sXpey\324\003\302\030\ti\014q\020R\037\014\rT\213\223\033\340\223SP\305Ou1&\245\355:\016\345\312]$\267\304\317\320\271\262K\024\261l\034\215\331\316\350\036D`\241\333\233\262\233\212\354\323\207\022mm\211O\213bU;\226A\351HtBJ\021\n\025\234\tUB\016\007\312Gz2+sw\360o\336`^\261\251b\004\360\275S\n\271\246\360c\002\315\2137\234\262x0\224\034\213Z6S1l\021\006NG\226\245>\370Q\233\320\210\013\230\304\312\025\010N\350&XP*\213Qi\244\247B?\342\356H\247\n\022\037\305:\374 "; PyObject *data = __Pyx_DecompressString(cstring, 2098, 2); if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error) const char* const bytes = __Pyx_PyBytes_AsString(data); #if !CYTHON_ASSUME_SAFE_MACROS if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } #endif #elif (CYTHON_COMPRESS_STRINGS) != 0 /* compression: zlib (1978 bytes) */ const char* const cstring = "x\332\275U\317S\333X\022\306Y\357\306L\014\330\340\304&! \263\314fR\311\220qb \311Le\327\004\302Nf&\033\023&\241vg\352\225,=c\201\221l\375\000\234\332\003G\037u|\307w\324QG\035}\314QG\035\365'\360'l\267l\363\303\340l\315\324\326R\330z~\257\273_\367\327\337\327\372\353\033\315\244\202Y\023M\341e\313\254i\252\240\030\202L\353J\205\352\242I\353-\3010uE2\251\216F\252\360v\375\355\327\305\247EATeA\247\273T2\r\301\260*R]4\014j\010ZU\250XJ\335TT\301l5\250\261(|_\025Z\232%\250\224\312\202\251\t\r\260;\357`\326\250*\030\324\304\205pOTU\315\024MES\t\270+\352\316=AVt\270D9\240\350\375J\254\033t\361g\225\0365`\023\"\256\377\343\225pXS\352\024\222\021ep\020*-\223\032\242,\023\210D\245\272\"\355\3254\313\240D\326!\206\376\250bU\253T\2472\232S}\261\321:\222\025C\254\324)U\361{GR\214\356J6h\275\272\3305GL \234\360FS\351\220mA\323\205\350\310\320\244\275\337b\217\211\220J}\300\353;D]\33514K\227\350\013\313\254~\375t\265\227\371f\224\371\305_\213\204\300\332\222(\221\242&\022r\351\03406\000\332\241\026\230\307\025[\244\252\034Q\231\364\322!\242A\"\200\377\253\345U\006\212jj\244\013\305U\307P\366U\333\237\tx\232\225\256k\207}\203w\000%5/\242t~o8V\003VC\021\273`7X\331Km\277\241S\340\366\000\232\303\366/\247\363\031\313K)\r\265\035L\213\220\267\255#\370\254\201\226\311\033z\004\351WE\243\245J\212\266(i\272f\201d\251Q\351\0317L\035V\206\362\221F\335&\030M\"T\2254\324\230\324\003\276\377$hxIj\213\027\245\006\347*\205\214\210\251\213\022\255\210\322\236,\232\"~\210$6DI1[\321\017\270:zbLBdL\267\373\210n\247\375\034\010\251Z\252\004Gd\247\217\tQ\340_U\320^1\310iQ\212I\367\361c\354\326\251\272c\326\010\331\027!\r\370\333\327d\253\016~*\211\316a!\356S\031\037\031\235cb\220\370\306\215\005\t\201\303\327\215v!Hf\355#v\310E\336\014\222\323,\035&\246\331-\326\014\373g->\346\224\235\252[\n\023\311\366\272}\323\026m0\314\330\033\254p\362\247\221\261\361 5e\027\355\217|\212\2579\261 \223\363s\367\235t\230\311\373\371%\267\354\312^\036\366X\222\227\302T\306~\315Df\362B\000\313\237x:LM\263I\366\230\275\347O\270\210a\036\333\233\020;s\023\017\322!\334\261\306\276\340\363\340\232\234h7\321`\211]c\363l\025j\310,\360ug\322)\004\2319\326r\306\340\246\335\016\334\216\351\376\001.\310M\007\251\034\213\261\034O\007\251\273\254\014\230\214\245\332\007\020\337d\005\214\004\216\267Y\0360\372;/\361_\335\274\373\334+{r'\037\334\231\363\347\212\356*&\036f\246\375\351\307n\036\242\261\333\274\020\325\227\233\361g\n\356\244[t\233P}z\226m\371\371e\267\342\305=(\360\226\275\0070\224\272\005G\351\205W\340\001{l\002\300\316\315\260\037\270\2116Y\250:7\013U\315\334e\333\274\314\367\335\357<\263\203\360N\317\371\263+n3\230\371\312\211;\24503\317\027\270\210\027g\372\025<\007\373]7\346f\334_:\351\313\031'\335\010\370\037y\254\007b:\310L\003,\223|\311\271\3564\201\010\331\\\320\363B\014\302\344M\273l\213Ar\206\225\330\007\376\222\367\211p\013\373\036& \306q,\210\243\365\262\227\306\345\262+\272\007^\031\227\017\235\222\363\336-\034\227 \303\321\202{\335\325\275\214WF\226\275\200F\027\031\360&e\307\355\022>\222\014\036\330\321\030\313\300E%\276\031a\221\020N\351\032&\306\332?\333\37101\336\336\211\210\001\005\230\366s\366\216\307\001\343T\306\317|\311\313\320]\377n\301M\273\013\256\030\364\013\305\334\267\371\226\177\377\205W\351\304;p\321\244?\371\000\310\222J\333\267\241\347k<\t`B\022c\254\034U\326\255\253tr\353\202\\\222#\243S\366} \3506$g8\363N)H\374\205\357\373O6:\220\314X\230\000\032\331\353\250\230\207x\204\252\002\316\256\332\025`\351""\003\276\355l:\315\000\002\267\240\304t\220\230\365g\021\265\302\377]F\023\355\217p\276\304\257\361|\000\024U\371*\020\346\032\220\244\213\337<\317\363e\007dr\307\277\363\010\0311 \274\236hB\220\321\031\3271\020\024\300\022<\306g`<\354z\261\250\325\331\334\357W\301\231\036\377\351\350\356]O\004-\002e\3168\237\035r\345i\337\241\\\234X\315hJ\254\243U\230\300\250\3130\005\272\2158\206>%\375\344\237y\221[\316k`\256\351\025\220\340E\177b\001\311\016L\261\277\302<\320\020\266\001\272)\240\01346\345\247\362\020\246\313\\\244\346\226\235\215\270\013\374N\266\177b\321\r\300\241`\341K\364|f\277\304\376BO\375\354\023\267\340~\357\225Q\024\031\373)[\001\300\013\275\371\213\214F\td\243\356 G\026\035\321\001\235\315\262\032\257\003]V\274y\257\227\nr.H\244\354\030r8\204E4\342\203\363t\232\264\363 \2202\370\212\\\007\344\237\271(\305\261\264}\335\326\021\233I{\036\362\322!\353-\236s\322\016\020\002\344\036B\334\024\276\004t\030\013\217\201\353\207\230C0\225\201]?\013\264vo{0\001.\017\006\274\256\320\323\016\346\361\332VX\023\324\371\003\022?\202\031\030\331\225\365\020\210\307\333bwZ\244\206\001qU\231S\376\024\216\232\262S\203\016\352\336\244\367\0145>\230_\267!1x\007\376q\034\2725\315\026\374\331\242\273\346\335\350\024A\277\361d{\003\344\373\212=\004\321\304\257\037\037\264?\200\226\243vBYA\"\213\323\016^!x\206\241\374\211%\034\n\336\275\316\235O\033\376\273\255\360\342V\351\177x\3213\344\265\267\323\371\227\377\366\203\377a;\034\330+_qU\354w\\\363\3101\201\230\033\336\267\235\235O\345\360\342\216x\034\013\343\240>_\370\306\275\001\277\367\374\362f\020\237\262_\364h\003A\376m\257\260|4\365\374\302jg\021\362\n\342\360\246\270\332\321\237z\340<\205\330\245s\236\317\275\274\377\355{\377\275\354\313\364\263\256\367\370Q\364\246:s\205w\216\277\362\346\223\352\377\362k\344\371\037R\367K("; PyObject *data = __Pyx_DecompressString(cstring, 1978, 1); if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error) const char* const bytes = __Pyx_PyBytes_AsString(data); #if !CYTHON_ASSUME_SAFE_MACROS if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } #endif #else /* compression: none (4102 bytes) */ const char* const bytes = "?Note that Cython is deliberately stricter than PEP-484 and rejects subclasses of builtin types. If you need to pass subclasses then set the 'annotation_typing' directive to False.Unexpected EOF while reading bytesadd_noteclickhouse_driver/bufferedreader.pyxdisableenablegcisenabledself.buffer is not Noneself.buffer is not None or self.sock is not Noneself.buffer is not None or self.read_block is not Noneutf-8BufferedReaderBufferedReader.__reduce_cython__BufferedReader.__setstate_cython__BufferedReader.readBufferedReader.read_fixed_strings_as_bytesBufferedReader.read_fixed_stringsBufferedReader.read_into_bufferBufferedReader.read_oneBufferedReader.read_stringsBufferedReader.read_strings_arrowBufferedSocketReaderBufferedSocketReader.__reduce_cython__BufferedSocketReader.__setstate_cython__BufferedSocketReader.read_into_bufferCompressedBufferedReaderCompressedBufferedReader.__reduce_cython__CompressedBufferedReader.__setstate_cython__CompressedBufferedReader.read_into_buffer__Pyx_PyDict_NextRefasyncio.coroutinesbbuffer_ptrbufsizebytes_readc_encodingc_stringc_string_sizeclickhouse_driver.bufferedreadercline_in_tracebackdatadata_capacitydata_ptrdata_size__dict___dictencodeencoding__func____getstate__i__init___is_coroutineitemitemsjlength__main____module__n_items__name____new__next_positionobjectoffsetsoffsets_ptrpop__pyx_checksum__pyx_result__pyx_state__pyx_type__pyx_unpickle_BufferedReader__pyx_unpickle_BufferedSocketReader__pyx_unpickle_CompressedBufferedReader__qualname__readread_blockread_bytesread_fixed_stringsread_fixed_strings_as_bytesread_into_bufferread_oneread_stringsread_strings_arrowrecv_into__reduce____reduce_cython____reduce_ex__rightrvself__set_name__setdefault__setstate____setstate_cython__shiftsizesockstatesupert__test__unreadupdateuse_setstatevalues\320\004@\300\001\360\n\000\t\021\220\013\2301\230A\360\010\000\t!\320 4\260A\260T\270\021\360\016\000\t\037\230a\330\0100\260\001\330\010 \240\001\330\010\013\2101\330\014\027\220x\230w\240a""\240q\330\014\031\230\021\340\010\031\230\026\230q\340\010\013\2101\330\014\027\220y\240\r\250Q\250f\260A\340\010\014\210E\220\025\220a\220q\330\014\024\220G\2301\360\006\000\r\016\330\020\023\2204\220z\240\023\240D\250\001\330\024\030\320\030)\250\021\340\024!\320!5\260Q\260d\270!\330\024\030\230\014\240A\340\020\024\220J\230a\230t\2401\330\020\024\220M\240\021\340\020\031\230\022\2302\230V\2403\240a\330\020\023\2202\220R\220q\330\024\025\340\020\031\230\021\340\014\024\220D\230\n\240\"\240A\340\014\017\210q\330\020\023\2205\230\002\230\"\230B\230a\330\024$\240E\250\022\2501\330\024\037\230y\250\r\260Q\260j\300\001\330\024\027\220y\240\003\2401\330\030\031\330\020\030\230\001\230\030\240\021\330\020\035\230Q\360\n\000\r\020\210v\220R\220t\2301\330\020\023\2201\330\024\032\230!\2301\230H\240A\240]\260!\260:\270Q\270d\300!\330\033\037\320\0374\260B\260d\270!\340\024\031\320\0312\260!\330\030\031\230\032\2401\240D\250\001\330\030\034\320\0341\260\022\2604\260q\360\006\000\021\036\230T\320!6\260b\270\004\270A\340\020\026\220k\240\023\240A\330\024\030\230\014\240E\250\022\2501\340\024\030\320\030)\250\021\340\024!\320!5\260Q\260d\270!\340\024\030\230\017\240q\330\030\034\230K\240t\2501\340\024\027\220q\330\030\036\230a\330\034\035\230X\240Q\240m\260<\270t\3001\360\006\000\031\037\320\0367\260q\330\034(\250\004\250A\340\024\"\240$\240a\360\006\000\021\024\2201\330\024\032\230!\230:\240Q\240j\260\001\260\024\260\\\300\021\340\024\031\320\0312\260!\330\030\031\230\032\2401\240D\250\014\260A\340\020\024\220L\240\001\340\014\017\210q\330\020\021\330\024\031\230\030\240\022\2405\250\007\250q\260\001\330\027\030\330\024\031\320\0312\260!\260:\270Q\340\014\025\220Q\220a\330\014\034\230A\230W\240C\240q\340\010\013\2101\330\014\026\220a\220q\340\010\017\210q\200\001\330\0042\260!\2606\270\021\200\001\330\0046\260a\260v\270Q\200\001\330\004,\250A\250V\2601\200A\360\006\000\t1\260\007\260r\270\024\270Q\330\010\013\210>\230\022\2304\230q\330\014\020\220\004\220A\330\014\020\220\014""\230A\330\014\023\2205\230\001\230\024\230W\240A\240R\240t\2501\340\010 \320 4\260A\260T\270\021\340\010\r\210U\220!\340\010\016\210g\220R\220q\330\014\017\210t\220:\230S\240\004\240A\330\020\024\320\024%\240Q\330\020\035\320\0351\260\021\260$\260a\330\020\024\220L\240\001\340\014\034\230A\230X\240T\320)>\270b\300\004\300A\330\014\022\320\022+\2501\330\020\021\220\032\2301\230D\240\014\250A\340\014\020\220\r\230Q\330\014\026\220a\340\010\017\210q\200A\360\026\000\t!\320 4\260A\260T\270\021\360\014\000\t\023\220)\2302\230X\240R\240s\250\"\250A\330\010&\240m\3203G\300q\330\014\r\340\010\023\2201\220E\230\021\340\010,\250A\330\0100\260\001\330\014\024\220B\220b\230\002\230+\240X\250R\250q\330\010\017\210y\230\001\230\021\330\010\036\320\0362\260!\2601\340\010\014\210E\220\025\220a\220q\330\014\024\220G\2301\360\006\000\r\016\330\020\023\2204\220z\240\023\240D\250\001\330\024\030\320\030)\250\021\340\024!\320!5\260Q\260d\270!\330\024\030\230\014\240A\340\020\024\220J\230a\230t\2401\330\020\024\220M\240\021\340\020\031\230\022\2302\230V\2403\240a\330\020\023\2202\220R\220q\330\024\025\340\020\031\230\021\340\014\017\210z\230\022\2305\240\002\240!\330\020\026\220n\240B\240j\260\002\260!\330\024%\240Q\330\020\"\240!\2406\250\021\330\020\033\320\033/\250q\260\001\340\014\024\220D\230\n\240\"\240A\340\014\017\210v\220R\220t\2301\340\020\035\230T\320!6\260b\270\004\270A\330\020\026\220a\220q\230\010\240\001\240\034\250Q\250j\270\001\270\024\270Q\330\027\030\340\020\026\220k\240\023\240A\330\024\030\230\014\240E\250\022\2501\340\024\030\320\030)\250\021\340\024!\320!5\260Q\260d\270!\340\024\030\230\017\240q\330\030\034\230K\240t\2501\340\024\032\230!\2301\230H\240A\240Z\250r\260\035\270a\330\033\037\230q\330\024\"\240$\240a\360\006\000\021\027\220a\220q\230\010\240\001\240\034\250Q\250j\270\001\270\024\270Q\330\027\030\330\020\024\220L\240\001\340\014\031\230\021\330\014\027\220q\230\002\230\"\230E\240\034\250Q\340\010\032\230!\2306\240\021\330\010\017\210y\230\001\200A\330""\010\014\320\014#\2404\240u\250J\260a\260t\2701\340\010\013\2104\320\017$\240C\240q\330\014\022\220(\230!\2301\200A\330\010\013\2104\210z\230\023\230D\240\001\330\014\020\320\020!\240\021\330\014\020\220\014\230A\340\010\r\210T\220\027\230\001\230\024\230Q\330\010\014\210M\230\021\330\010\017\210q\200A\330$%\330\010\013\2109\220C\220q\330\014\023\2204\320\0273\2601\260I\270Q\360\006\000\t\024\2208\2307\240!\2401\330\010 \240\001\330\010\017\210t\2205\230\001\230\027\240\002\240!\330\010\036\320\036.\250a\250q\340\010\036\230h\240l\260!\2607\270\"\270A\330\010\013\2104\210q\330\014\r\330\010\020\220\001\220\032\2301\340\010\020\220\013\2301\230A\330\010\014\210E\220\025\220a\220q\330\014\022\220!\220:\230Q\230h\240a\240r\250\022\2509\260A\360\006\000\r\021\220\007\220r\230\021\330\014\022\220\"\220C\220r\230\024\230T\240\030\250\021\250!\330\020\025\220Q\340\014\r\330\020\027\220x\230r\240\022\2402\240R\240w\250a\250q\330\023\024\330\020\027\320\0270\260\001\260\032\2701\330\014\025\220Q\220a\330\014\034\230A\230W\240C\240q\340\010\022\220!\2201\340\010\017\210q\200A\330\010\014\210J\220i\230q\240\004\240K\250q\330\010\014\320\014#\2403\240a\240t\2501\340\010\013\2104\320\017$\240C\240q\330\014\022\220(\230!\2301\200A\330\010\016\210a\200A\360\006\000\t\020\210t\2205\230\001\230\027\240\002\240!\330\010\036\320\036.\250a\250q\340\010\020\220\013\2301\230A\330\010\014\210E\220\025\220a\220q\330\014\023\320\023,\250A\250Q\250h\260a\260r\270\022\2709\300A\330\014\025\220Q\220a\330\014\034\230A\230W\240C\240q\330\010\017\210q\200\001\360\010\000\005\016\210T\220\031\230$\320\0364\260D\270\013\3004\300q\330\004\014\210G\2201\220F\230,\240a\330\004\007\200v\210W\220E\230\024\230Q\330\010\022\220!\330\010\027\220q\340\010\030\230\001\330\004\007\200q\330\010\017\320\0175\260T\270\021\270'\300\033\310G\320ST\340\010\017\320\0175\260T\270\021\270'\300\033\310A\200\001\360\010\000\005\016\210T\220\031\230$\320\0364\260D\270\013\3004\300q\330\004\014\210G\2201\220F\230,\240a""\330\004\007\200v\210W\220E\230\024\230Q\330\010\022\220!\330\010\027\220q\340\010\030\230\001\330\004\007\200q\330\010\017\320\0179\270\024\270Q\270g\300[\320PW\320WX\340\010\017\320\0179\270\024\270Q\270g\300[\320PQ\200\001\360\010\000\005\016\210T\220\031\230$\320\0364\260D\270\001\330\004\014\210G\2201\220F\230,\240a\330\004\007\200v\210W\220E\230\024\230Q\330\010\022\220!\330\010\027\220q\340\010\030\230\001\330\004\007\200q\330\010\017\320\017/\250t\2601\260G\270;\300g\310Q\340\010\017\320\017/\250t\2601\260G\270;\300a\200\001\340\004\037\230q\320 0\260\013\270;\300k\320QR\330\004\023\220>\240\030\250\021\250!\330\004\007\200|\2207\230!\330\0100\260\001\3201B\300.\320PQ\330\004\013\2101\200\001\340\004\037\230q\320 0\260\013\270;\300k\320QR\330\004\023\320\023+\2508\2601\260A\330\004\007\200|\2207\230!\330\010:\270!\320;V\320Vd\320de\330\004\013\2101\200\001\340\004\037\230q\320 0\260\013\270;\300k\320QR\330\004\023\320\023'\240x\250q\260\001\330\004\007\200|\2207\230!\330\0106\260a\3207N\310n\320\\]\330\004\013\2101"; PyObject *data = NULL; CYTHON_UNUSED_VAR(__Pyx_DecompressString); #endif PyObject **stringtab = __pyx_mstate->__pyx_string_tab; Py_ssize_t pos = 0; for (int i = 0; i < 109; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyUnicode_DecodeUTF8(bytes + pos, bytes_length, NULL); if (likely(string) && i >= 14) PyUnicode_InternInPlace(&string); if (unlikely(!string)) { Py_XDECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } stringtab[i] = string; pos += bytes_length; } for (int i = 109; i < 127; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyBytes_FromStringAndSize(bytes + pos, bytes_length); stringtab[i] = string; pos += bytes_length; if (unlikely(!string)) { Py_XDECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } } Py_XDECREF(data); for (Py_ssize_t i = 0; i < 127; i++) { if (unlikely(PyObject_Hash(stringtab[i]) == -1)) { __PYX_ERR(0, 1, __pyx_L1_error) } } #if CYTHON_IMMORTAL_CONSTANTS { PyObject **table = stringtab + 109; for (Py_ssize_t i=0; i<18; ++i) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL); #else Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT); #endif } } #endif } { PyObject **numbertab = __pyx_mstate->__pyx_number_tab + 0; int32_t const cint_constants_4[] = {72267464L,98621312L,110699518L}; for (int i = 0; i < 3; i++) { numbertab[i] = PyLong_FromLong(cint_constants_4[i - 0]); if (unlikely(!numbertab[i])) __PYX_ERR(0, 1, __pyx_L1_error) } } #if CYTHON_IMMORTAL_CONSTANTS { PyObject **table = __pyx_mstate->__pyx_number_tab; for (Py_ssize_t i=0; i<3; ++i) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL); #else Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT); #endif } } #endif return 0; __pyx_L1_error:; return -1; } /* #### Code section: init_codeobjects ### */ typedef struct { unsigned int argcount : 3; unsigned int num_posonly_args : 1; unsigned int num_kwonly_args : 1; unsigned int nlocals : 4; unsigned int flags : 10; unsigned int first_line : 9; } __Pyx_PyCode_New_function_description; /* NewCodeObj.proto */ static PyObject* __Pyx_PyCode_New( const __Pyx_PyCode_New_function_description descr, PyObject * const *varnames, PyObject *filename, PyObject *funcname, PyObject *line_table, PyObject *tuple_dedup_map ); static int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate) { PyObject* tuple_dedup_map = PyDict_New(); if (unlikely(!tuple_dedup_map)) return -1; { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 22}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; __pyx_mstate_global->__pyx_codeobj_tab[0] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedreader_2, __pyx_mstate->__pyx_n_u_read_into_buffer, __pyx_mstate->__pyx_kp_b_iso88591_A_a, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[0])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 7, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 25}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_unread, __pyx_mstate->__pyx_n_u_next_position, __pyx_mstate->__pyx_n_u_t, __pyx_mstate->__pyx_n_u_buffer_ptr, __pyx_mstate->__pyx_n_u_read_bytes, __pyx_mstate->__pyx_n_u_rv}; __pyx_mstate_global->__pyx_codeobj_tab[1] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedreader_2, __pyx_mstate->__pyx_n_u_read, __pyx_mstate->__pyx_kp_b_iso88591_A_1_r_Q_4q_A_A_5_WARt1_4AT_U_gRq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[1])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 53}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_rv}; __pyx_mstate_global->__pyx_codeobj_tab[2] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedreader_2, __pyx_mstate->__pyx_n_u_read_one, __pyx_mstate->__pyx_kp_b_iso88591_A_4z_D_A_T_Q_M_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[2])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 15, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 62}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_n_items, __pyx_mstate->__pyx_n_u_encoding, __pyx_mstate->__pyx_n_u_items, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_buffer_ptr, __pyx_mstate->__pyx_n_u_right, __pyx_mstate->__pyx_n_u_size, __pyx_mstate->__pyx_n_u_shift, __pyx_mstate->__pyx_n_u_bytes_read, __pyx_mstate->__pyx_n_u_b, __pyx_mstate->__pyx_n_u_c_string, __pyx_mstate->__pyx_n_u_c_string_size, __pyx_mstate->__pyx_n_u_c_encoding, __pyx_mstate->__pyx_n_u_rv}; __pyx_mstate_global->__pyx_codeobj_tab[3] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedreader_2, __pyx_mstate->__pyx_n_u_read_strings, __pyx_mstate->__pyx_kp_b_iso88591_1A_4AT_a_0_1_xwaq_q_1_y_QfA_E_a, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[3])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 15, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 179}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_n_items, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_buffer_ptr, __pyx_mstate->__pyx_n_u_right, __pyx_mstate->__pyx_n_u_size, __pyx_mstate->__pyx_n_u_shift, __pyx_mstate->__pyx_n_u_bytes_read, __pyx_mstate->__pyx_n_u_b, __pyx_mstate->__pyx_n_u_offsets, __pyx_mstate->__pyx_n_u_offsets_ptr, __pyx_mstate->__pyx_n_u_data_size, __pyx_mstate->__pyx_n_u_data_capacity, __pyx_mstate->__pyx_n_u_data, __pyx_mstate->__pyx_n_u_data_ptr}; __pyx_mstate_global->__pyx_codeobj_tab[4] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedreader_2, __pyx_mstate->__pyx_n_u_read_strings_arrow, __pyx_mstate->__pyx_kp_b_iso88591_A_4AT_2XRs_A_m3Gq_1E_A_0_Bb_XRq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[4])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 8, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 267}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_n_items, __pyx_mstate->__pyx_n_u_length, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_data, __pyx_mstate->__pyx_n_u_data_ptr, __pyx_mstate->__pyx_n_u_items, __pyx_mstate->__pyx_n_u_item}; __pyx_mstate_global->__pyx_codeobj_tab[5] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedreader_2, __pyx_mstate->__pyx_n_u_read_fixed_strings_as_bytes, __pyx_mstate->__pyx_kp_b_iso88591_A_t5_aq_1A_E_aq_AQhar_9A_Qa_AWCq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[5])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {4, 0, 0, 12, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 280}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_n_items, __pyx_mstate->__pyx_n_u_length, __pyx_mstate->__pyx_n_u_encoding, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_j, __pyx_mstate->__pyx_n_u_c_encoding, __pyx_mstate->__pyx_n_u_data, __pyx_mstate->__pyx_n_u_data_ptr, __pyx_mstate->__pyx_n_u_c_string, __pyx_mstate->__pyx_n_u_items, __pyx_mstate->__pyx_n_u_item}; __pyx_mstate_global->__pyx_codeobj_tab[6] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedreader_2, __pyx_mstate->__pyx_n_u_read_fixed_strings, __pyx_mstate->__pyx_kp_b_iso88591_A_9Cq_4_31IQ_87_1_t5_aq_hl_7_A_4, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[6])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 1}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_state, __pyx_mstate->__pyx_n_u_dict_2, __pyx_mstate->__pyx_n_u_use_setstate}; __pyx_mstate_global->__pyx_codeobj_tab[7] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_reduce_cython, __pyx_mstate->__pyx_kp_b_iso88591_T_4D_G1F_a_vWE_Q_q_q_t1G_gQ_t1G, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[7])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 16}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_pyx_state}; __pyx_mstate_global->__pyx_codeobj_tab[8] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_setstate_cython, __pyx_mstate->__pyx_kp_b_iso88591_AV1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[8])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 324}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; __pyx_mstate_global->__pyx_codeobj_tab[9] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedreader_2, __pyx_mstate->__pyx_n_u_read_into_buffer, __pyx_mstate->__pyx_kp_b_iso88591_A_4uJat1_4_Cq_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[9])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 1}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_state, __pyx_mstate->__pyx_n_u_dict_2, __pyx_mstate->__pyx_n_u_use_setstate}; __pyx_mstate_global->__pyx_codeobj_tab[10] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_reduce_cython, __pyx_mstate->__pyx_kp_b_iso88591_T_4D_4q_G1F_a_vWE_Q_q_q_5T_GST, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[10])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 16}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_pyx_state}; __pyx_mstate_global->__pyx_codeobj_tab[11] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_setstate_cython, __pyx_mstate->__pyx_kp_b_iso88591_2_6, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[11])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 338}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; __pyx_mstate_global->__pyx_codeobj_tab[12] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedreader_2, __pyx_mstate->__pyx_n_u_read_into_buffer, __pyx_mstate->__pyx_kp_b_iso88591_A_Jiq_Kq_3at1_4_Cq_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[12])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 1}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_state, __pyx_mstate->__pyx_n_u_dict_2, __pyx_mstate->__pyx_n_u_use_setstate}; __pyx_mstate_global->__pyx_codeobj_tab[13] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_reduce_cython, __pyx_mstate->__pyx_kp_b_iso88591_T_4D_4q_G1F_a_vWE_Q_q_q_9_Qg_PW, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[13])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 16}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_pyx_state}; __pyx_mstate_global->__pyx_codeobj_tab[14] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_setstate_cython, __pyx_mstate->__pyx_kp_b_iso88591_6avQ, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[14])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 4}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_pyx_type, __pyx_mstate->__pyx_n_u_pyx_checksum, __pyx_mstate->__pyx_n_u_pyx_state, __pyx_mstate->__pyx_n_u_pyx_result}; __pyx_mstate_global->__pyx_codeobj_tab[15] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_pyx_unpickle_BufferedReader, __pyx_mstate->__pyx_kp_b_iso88591_q_0_kQR_7_0_1B_PQ_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[15])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 4}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_pyx_type, __pyx_mstate->__pyx_n_u_pyx_checksum, __pyx_mstate->__pyx_n_u_pyx_state, __pyx_mstate->__pyx_n_u_pyx_result}; __pyx_mstate_global->__pyx_codeobj_tab[16] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_pyx_unpickle_BufferedSocketRea, __pyx_mstate->__pyx_kp_b_iso88591_q_0_kQR_xq_7_6a7Nn_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[16])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 4}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_pyx_type, __pyx_mstate->__pyx_n_u_pyx_checksum, __pyx_mstate->__pyx_n_u_pyx_state, __pyx_mstate->__pyx_n_u_pyx_result}; __pyx_mstate_global->__pyx_codeobj_tab[17] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_pyx_unpickle_CompressedBuffere, __pyx_mstate->__pyx_kp_b_iso88591_q_0_kQR_81A_7_VVdde_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[17])) goto bad; } Py_DECREF(tuple_dedup_map); return 0; bad: Py_DECREF(tuple_dedup_map); return -1; } /* #### Code section: init_globals ### */ static int __Pyx_InitGlobals(void) { /* PythonCompatibility.init */ if (likely(__Pyx_init_co_variables() == 0)); else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) /* CommonTypesMetaclass.init */ if (likely(__pyx_CommonTypesMetaclass_init(__pyx_m) == 0)); else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) /* CachedMethodType.init */ #if CYTHON_COMPILING_IN_LIMITED_API { PyObject *typesModule=NULL; typesModule = PyImport_ImportModule("types"); if (typesModule) { __pyx_mstate_global->__Pyx_CachedMethodType = PyObject_GetAttrString(typesModule, "MethodType"); Py_DECREF(typesModule); } } // error handling follows #endif if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) /* CythonFunctionShared.init */ if (likely(__pyx_CyFunction_init(__pyx_m) == 0)); else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } /* #### Code section: cleanup_globals ### */ /* #### Code section: cleanup_module ### */ /* #### Code section: main_method ### */ /* #### Code section: utility_code_pragmas ### */ #ifdef _MSC_VER #pragma warning( push ) /* Warning 4127: conditional expression is constant * Cython uses constant conditional expressions to allow in inline functions to be optimized at * compile-time, so this warning is not useful */ #pragma warning( disable : 4127 ) #endif /* #### Code section: utility_code_def ### */ /* --- Runtime support code --- */ /* Refnanny */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule(modname); if (!m) goto end; p = PyObject_GetAttrString(m, "RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif /* PyErrExceptionMatches */ #if CYTHON_FAST_THREAD_STATE static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(tuple); for (i=0; i= 0x030C00A6 PyObject *current_exception = tstate->current_exception; if (unlikely(!current_exception)) return 0; exc_type = (PyObject*) Py_TYPE(current_exception); if (exc_type == err) return 1; #else exc_type = tstate->curexc_type; if (exc_type == err) return 1; if (unlikely(!exc_type)) return 0; #endif #if CYTHON_AVOID_BORROWED_REFS Py_INCREF(exc_type); #endif if (unlikely(PyTuple_Check(err))) { result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); } else { result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err); } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(exc_type); #endif return result; } #endif /* PyErrFetchRestore */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyObject *tmp_value; assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value))); if (value) { #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb)) #endif PyException_SetTraceback(value, tb); } tmp_value = tstate->current_exception; tstate->current_exception = value; Py_XDECREF(tmp_value); Py_XDECREF(type); Py_XDECREF(tb); #else PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #endif } static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyObject* exc_value; exc_value = tstate->current_exception; tstate->current_exception = 0; *value = exc_value; *type = NULL; *tb = NULL; if (exc_value) { *type = (PyObject*) Py_TYPE(exc_value); Py_INCREF(*type); #if CYTHON_COMPILING_IN_CPYTHON *tb = ((PyBaseExceptionObject*) exc_value)->traceback; Py_XINCREF(*tb); #else *tb = PyException_GetTraceback(exc_value); #endif } #else *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #endif } #endif /* PyObjectGetAttrStr */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); return PyObject_GetAttr(obj, attr_name); } #endif /* PyObjectGetAttrStrNoError */ #if __PYX_LIMITED_VERSION_HEX < 0x030d0000 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) __Pyx_PyErr_Clear(); } #endif static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { PyObject *result; #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 (void) PyObject_GetOptionalAttr(obj, attr_name, &result); return result; #else #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); } #endif result = __Pyx_PyObject_GetAttrStr(obj, attr_name); if (unlikely(!result)) { __Pyx_PyObject_GetAttrStr_ClearAttributeError(); } return result; #endif } /* GetBuiltinName */ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStrNoError(__pyx_mstate_global->__pyx_b, name); if (unlikely(!result) && !PyErr_Occurred()) { PyErr_Format(PyExc_NameError, "name '%U' is not defined", name); } return result; } /* TupleAndListFromArray */ #if !CYTHON_COMPILING_IN_CPYTHON && CYTHON_METH_FASTCALL static CYTHON_INLINE PyObject * __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n) { PyObject *res; Py_ssize_t i; if (n <= 0) { return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple); } res = PyTuple_New(n); if (unlikely(res == NULL)) return NULL; for (i = 0; i < n; i++) { if (unlikely(__Pyx_PyTuple_SET_ITEM(res, i, src[i]) < (0))) { Py_DECREF(res); return NULL; } Py_INCREF(src[i]); } return res; } #elif CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE void __Pyx_copy_object_array(PyObject *const *CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) { PyObject *v; Py_ssize_t i; for (i = 0; i < length; i++) { v = dest[i] = src[i]; Py_INCREF(v); } } static CYTHON_INLINE PyObject * __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n) { PyObject *res; if (n <= 0) { return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple); } res = PyTuple_New(n); if (unlikely(res == NULL)) return NULL; __Pyx_copy_object_array(src, ((PyTupleObject*)res)->ob_item, n); return res; } static CYTHON_INLINE PyObject * __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n) { PyObject *res; if (n <= 0) { return PyList_New(0); } res = PyList_New(n); if (unlikely(res == NULL)) return NULL; __Pyx_copy_object_array(src, ((PyListObject*)res)->ob_item, n); return res; } #endif /* BytesEquals */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL ||\ !(CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS) return PyObject_RichCompareBool(s1, s2, equals); #else if (s1 == s2) { return (equals == Py_EQ); } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { const char *ps1, *ps2; Py_ssize_t length = PyBytes_GET_SIZE(s1); if (length != PyBytes_GET_SIZE(s2)) return (equals == Py_NE); ps1 = PyBytes_AS_STRING(s1); ps2 = PyBytes_AS_STRING(s2); if (ps1[0] != ps2[0]) { return (equals == Py_NE); } else if (length == 1) { return (equals == Py_EQ); } else { int result; #if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000) Py_hash_t hash1, hash2; hash1 = ((PyBytesObject*)s1)->ob_shash; hash2 = ((PyBytesObject*)s2)->ob_shash; if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { return (equals == Py_NE); } #endif result = memcmp(ps1, ps2, (size_t)length); return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { return (equals == Py_NE); } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { return (equals == Py_NE); } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } #endif } /* UnicodeEquals */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL return PyObject_RichCompareBool(s1, s2, equals); #else int s1_is_unicode, s2_is_unicode; if (s1 == s2) { goto return_eq; } s1_is_unicode = PyUnicode_CheckExact(s1); s2_is_unicode = PyUnicode_CheckExact(s2); if (s1_is_unicode & s2_is_unicode) { Py_ssize_t length, length2; int kind; void *data1, *data2; #if !CYTHON_COMPILING_IN_LIMITED_API if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0)) return -1; #endif length = __Pyx_PyUnicode_GET_LENGTH(s1); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(length < 0)) return -1; #endif length2 = __Pyx_PyUnicode_GET_LENGTH(s2); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(length2 < 0)) return -1; #endif if (length != length2) { goto return_ne; } #if CYTHON_USE_UNICODE_INTERNALS { Py_hash_t hash1, hash2; hash1 = ((PyASCIIObject*)s1)->hash; hash2 = ((PyASCIIObject*)s2)->hash; if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { goto return_ne; } } #endif kind = __Pyx_PyUnicode_KIND(s1); if (kind != __Pyx_PyUnicode_KIND(s2)) { goto return_ne; } data1 = __Pyx_PyUnicode_DATA(s1); data2 = __Pyx_PyUnicode_DATA(s2); if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) { goto return_ne; } else if (length == 1) { goto return_eq; } else { int result = memcmp(data1, data2, (size_t)(length * kind)); return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & s2_is_unicode) { goto return_ne; } else if ((s2 == Py_None) & s1_is_unicode) { goto return_ne; } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } return_eq: return (equals == Py_EQ); return_ne: return (equals == Py_NE); #endif } /* fastcall */ #if CYTHON_METH_FASTCALL static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s) { Py_ssize_t i, n = __Pyx_PyTuple_GET_SIZE(kwnames); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(n == -1)) return NULL; #endif for (i = 0; i < n; i++) { PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely(!namei)) return NULL; #endif if (s == namei) return kwvalues[i]; } for (i = 0; i < n; i++) { PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely(!namei)) return NULL; #endif int eq = __Pyx_PyUnicode_Equals(s, namei, Py_EQ); if (unlikely(eq != 0)) { if (unlikely(eq < 0)) return NULL; return kwvalues[i]; } } return NULL; } #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues) { Py_ssize_t i, nkwargs; PyObject *dict; #if !CYTHON_ASSUME_SAFE_SIZE nkwargs = PyTuple_Size(kwnames); if (unlikely(nkwargs < 0)) return NULL; #else nkwargs = PyTuple_GET_SIZE(kwnames); #endif dict = PyDict_New(); if (unlikely(!dict)) return NULL; for (i=0; itp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) return NULL; result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectCallMethO */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { PyObject *self, *result; PyCFunction cfunc; cfunc = __Pyx_CyOrPyCFunction_GET_FUNCTION(func); self = __Pyx_CyOrPyCFunction_GET_SELF(func); if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) return NULL; result = cfunc(self, arg); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectFastCall */ #if PY_VERSION_HEX < 0x03090000 || CYTHON_COMPILING_IN_LIMITED_API static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs) { PyObject *argstuple; PyObject *result = 0; size_t i; argstuple = PyTuple_New((Py_ssize_t)nargs); if (unlikely(!argstuple)) return NULL; for (i = 0; i < nargs; i++) { Py_INCREF(args[i]); if (__Pyx_PyTuple_SET_ITEM(argstuple, (Py_ssize_t)i, args[i]) != (0)) goto bad; } result = __Pyx_PyObject_Call(func, argstuple, kwargs); bad: Py_DECREF(argstuple); return result; } #endif #if CYTHON_VECTORCALL && !CYTHON_COMPILING_IN_LIMITED_API #if PY_VERSION_HEX < 0x03090000 #define __Pyx_PyVectorcall_Function(callable) _PyVectorcall_Function(callable) #elif CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE vectorcallfunc __Pyx_PyVectorcall_Function(PyObject *callable) { PyTypeObject *tp = Py_TYPE(callable); #if defined(__Pyx_CyFunction_USED) if (__Pyx_CyFunction_CheckExact(callable)) { return __Pyx_CyFunction_func_vectorcall(callable); } #endif if (!PyType_HasFeature(tp, Py_TPFLAGS_HAVE_VECTORCALL)) { return NULL; } assert(PyCallable_Check(callable)); Py_ssize_t offset = tp->tp_vectorcall_offset; assert(offset > 0); vectorcallfunc ptr; memcpy(&ptr, (char *) callable + offset, sizeof(ptr)); return ptr; } #else #define __Pyx_PyVectorcall_Function(callable) PyVectorcall_Function(callable) #endif #endif static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject *const *args, size_t _nargs, PyObject *kwargs) { Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs); #if CYTHON_COMPILING_IN_CPYTHON if (nargs == 0 && kwargs == NULL) { if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_NOARGS)) return __Pyx_PyObject_CallMethO(func, NULL); } else if (nargs == 1 && kwargs == NULL) { if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_O)) return __Pyx_PyObject_CallMethO(func, args[0]); } #endif if (kwargs == NULL) { #if CYTHON_VECTORCALL #if CYTHON_COMPILING_IN_LIMITED_API return PyObject_Vectorcall(func, args, _nargs, NULL); #else vectorcallfunc f = __Pyx_PyVectorcall_Function(func); if (f) { return f(func, args, _nargs, NULL); } #endif #endif } if (nargs == 0) { return __Pyx_PyObject_Call(func, __pyx_mstate_global->__pyx_empty_tuple, kwargs); } #if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API return PyObject_VectorcallDict(func, args, (size_t)nargs, kwargs); #else return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs); #endif } /* PyObjectCallOneArg */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *args[2] = {NULL, arg}; return __Pyx_PyObject_FastCall(func, args+1, 1 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } /* UnpackUnboundCMethod */ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000 static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *args, PyObject *kwargs) { PyObject *result; PyObject *selfless_args = PyTuple_GetSlice(args, 1, PyTuple_Size(args)); if (unlikely(!selfless_args)) return NULL; result = PyObject_Call(method, selfless_args, kwargs); Py_DECREF(selfless_args); return result; } #elif CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03090000 static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { return _PyObject_Vectorcall (method, args ? args+1 : NULL, nargs ? nargs-1 : 0, kwnames); } #else static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { return #if PY_VERSION_HEX < 0x03090000 _PyObject_Vectorcall #else PyObject_Vectorcall #endif (method, args ? args+1 : NULL, nargs ? (size_t) nargs-1 : 0, kwnames); } #endif static PyMethodDef __Pyx_UnboundCMethod_Def = { "CythonUnboundCMethod", __PYX_REINTERPRET_FUNCION(PyCFunction, __Pyx_SelflessCall), #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000 METH_VARARGS | METH_KEYWORDS, #else METH_FASTCALL | METH_KEYWORDS, #endif NULL }; static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) { PyObject *method, *result=NULL; method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name); if (unlikely(!method)) return -1; result = method; #if CYTHON_COMPILING_IN_CPYTHON if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type))) { PyMethodDescrObject *descr = (PyMethodDescrObject*) method; target->func = descr->d_method->ml_meth; target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS); } else #endif #if CYTHON_COMPILING_IN_PYPY #else if (PyCFunction_Check(method)) #endif { PyObject *self; int self_found; #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY self = PyObject_GetAttrString(method, "__self__"); if (!self) { PyErr_Clear(); } #else self = PyCFunction_GET_SELF(method); #endif self_found = (self && self != Py_None); #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY Py_XDECREF(self); #endif if (self_found) { PyObject *unbound_method = PyCFunction_New(&__Pyx_UnboundCMethod_Def, method); if (unlikely(!unbound_method)) return -1; Py_DECREF(method); result = unbound_method; } } #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING if (unlikely(target->method)) { Py_DECREF(result); } else #endif target->method = result; return 0; } /* CallUnboundCMethod0 */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) { int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc); if (likely(was_initialized == 2 && cfunc->func)) { if (likely(cfunc->flag == METH_NOARGS)) return __Pyx_CallCFunction(cfunc, self, NULL); if (likely(cfunc->flag == METH_FASTCALL)) return __Pyx_CallCFunctionFast(cfunc, self, NULL, 0); if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS)) return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, NULL, 0, NULL); if (likely(cfunc->flag == (METH_VARARGS | METH_KEYWORDS))) return __Pyx_CallCFunctionWithKeywords(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple, NULL); if (cfunc->flag == METH_VARARGS) return __Pyx_CallCFunction(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple); return __Pyx__CallUnboundCMethod0(cfunc, self); } #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING else if (unlikely(was_initialized == 1)) { __Pyx_CachedCFunction tmp_cfunc = { #ifndef __cplusplus 0 #endif }; tmp_cfunc.type = cfunc->type; tmp_cfunc.method_name = cfunc->method_name; return __Pyx__CallUnboundCMethod0(&tmp_cfunc, self); } #endif PyObject *result = __Pyx__CallUnboundCMethod0(cfunc, self); __Pyx_CachedCFunction_SetFinishedInitializing(cfunc); return result; } #endif static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) { PyObject *result; if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; result = __Pyx_PyObject_CallOneArg(cfunc->method, self); return result; } /* py_dict_items */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) { return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_items, d); } /* py_dict_values */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d) { return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_values, d); } /* OwnedDictNext */ #if CYTHON_AVOID_BORROWED_REFS static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue) { PyObject *next = NULL; if (!*ppos) { if (pvalue) { PyObject *dictview = pkey ? __Pyx_PyDict_Items(p) : __Pyx_PyDict_Values(p); if (unlikely(!dictview)) goto bad; *ppos = PyObject_GetIter(dictview); Py_DECREF(dictview); } else { *ppos = PyObject_GetIter(p); } if (unlikely(!*ppos)) goto bad; } next = PyIter_Next(*ppos); if (!next) { if (PyErr_Occurred()) goto bad; return 0; } if (pkey && pvalue) { *pkey = __Pyx_PySequence_ITEM(next, 0); if (unlikely(*pkey)) goto bad; *pvalue = __Pyx_PySequence_ITEM(next, 1); if (unlikely(*pvalue)) goto bad; Py_DECREF(next); } else if (pkey) { *pkey = next; } else { assert(pvalue); *pvalue = next; } return 1; bad: Py_XDECREF(next); #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000 PyErr_FormatUnraisable("Exception ignored in __Pyx_PyDict_NextRef"); #else PyErr_WriteUnraisable(__pyx_mstate_global->__pyx_n_u_Pyx_PyDict_NextRef); #endif if (pkey) *pkey = NULL; if (pvalue) *pvalue = NULL; return 0; } #else // !CYTHON_AVOID_BORROWED_REFS static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue) { int result = PyDict_Next(p, ppos, pkey, pvalue); if (likely(result == 1)) { if (pkey) Py_INCREF(*pkey); if (pvalue) Py_INCREF(*pvalue); } return result; } #endif /* RaiseDoubleKeywords */ static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { PyErr_Format(PyExc_TypeError, "%s() got multiple values for keyword argument '%U'", func_name, kw_name); } /* CallUnboundCMethod2 */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) { int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc); if (likely(was_initialized == 2 && cfunc->func)) { PyObject *args[2] = {arg1, arg2}; if (cfunc->flag == METH_FASTCALL) { return __Pyx_CallCFunctionFast(cfunc, self, args, 2); } if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS)) return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, 2, NULL); } #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING else if (unlikely(was_initialized == 1)) { __Pyx_CachedCFunction tmp_cfunc = { #ifndef __cplusplus 0 #endif }; tmp_cfunc.type = cfunc->type; tmp_cfunc.method_name = cfunc->method_name; return __Pyx__CallUnboundCMethod2(&tmp_cfunc, self, arg1, arg2); } #endif PyObject *result = __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2); __Pyx_CachedCFunction_SetFinishedInitializing(cfunc); return result; } #endif static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){ if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; #if CYTHON_COMPILING_IN_CPYTHON if (cfunc->func && (cfunc->flag & METH_VARARGS)) { PyObject *result = NULL; PyObject *args = PyTuple_New(2); if (unlikely(!args)) return NULL; Py_INCREF(arg1); PyTuple_SET_ITEM(args, 0, arg1); Py_INCREF(arg2); PyTuple_SET_ITEM(args, 1, arg2); if (cfunc->flag & METH_KEYWORDS) result = __Pyx_CallCFunctionWithKeywords(cfunc, self, args, NULL); else result = __Pyx_CallCFunction(cfunc, self, args); Py_DECREF(args); return result; } #endif { PyObject *args[4] = {NULL, self, arg1, arg2}; return __Pyx_PyObject_FastCall(cfunc->method, args+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } } /* ParseKeywordsImpl */ static int __Pyx_ValidateDuplicatePosArgs( PyObject *kwds, PyObject ** const argnames[], PyObject ** const *first_kw_arg, const char* function_name) { PyObject ** const *name = argnames; while (name != first_kw_arg) { PyObject *key = **name; int found = PyDict_Contains(kwds, key); if (unlikely(found)) { if (found == 1) __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; } name++; } return 0; bad: return -1; } #if CYTHON_USE_UNICODE_INTERNALS static CYTHON_INLINE int __Pyx_UnicodeKeywordsEqual(PyObject *s1, PyObject *s2) { int kind; Py_ssize_t len = PyUnicode_GET_LENGTH(s1); if (len != PyUnicode_GET_LENGTH(s2)) return 0; kind = PyUnicode_KIND(s1); if (kind != PyUnicode_KIND(s2)) return 0; const void *data1 = PyUnicode_DATA(s1); const void *data2 = PyUnicode_DATA(s2); return (memcmp(data1, data2, (size_t) len * (size_t) kind) == 0); } #endif static int __Pyx_MatchKeywordArg_str( PyObject *key, PyObject ** const argnames[], PyObject ** const *first_kw_arg, size_t *index_found, const char *function_name) { PyObject ** const *name; #if CYTHON_USE_UNICODE_INTERNALS Py_hash_t key_hash = ((PyASCIIObject*)key)->hash; if (unlikely(key_hash == -1)) { key_hash = PyObject_Hash(key); if (unlikely(key_hash == -1)) goto bad; } #endif name = first_kw_arg; while (*name) { PyObject *name_str = **name; #if CYTHON_USE_UNICODE_INTERNALS if (key_hash == ((PyASCIIObject*)name_str)->hash && __Pyx_UnicodeKeywordsEqual(name_str, key)) { *index_found = (size_t) (name - argnames); return 1; } #else #if CYTHON_ASSUME_SAFE_SIZE if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key)) #endif { int cmp = PyUnicode_Compare(name_str, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { *index_found = (size_t) (name - argnames); return 1; } } #endif name++; } name = argnames; while (name != first_kw_arg) { PyObject *name_str = **name; #if CYTHON_USE_UNICODE_INTERNALS if (unlikely(key_hash == ((PyASCIIObject*)name_str)->hash)) { if (__Pyx_UnicodeKeywordsEqual(name_str, key)) goto arg_passed_twice; } #else #if CYTHON_ASSUME_SAFE_SIZE if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key)) #endif { if (unlikely(name_str == key)) goto arg_passed_twice; int cmp = PyUnicode_Compare(name_str, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) goto arg_passed_twice; } #endif name++; } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; bad: return -1; } static int __Pyx_MatchKeywordArg_nostr( PyObject *key, PyObject ** const argnames[], PyObject ** const *first_kw_arg, size_t *index_found, const char *function_name) { PyObject ** const *name; if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type; name = first_kw_arg; while (*name) { int cmp = PyObject_RichCompareBool(**name, key, Py_EQ); if (cmp == 1) { *index_found = (size_t) (name - argnames); return 1; } if (unlikely(cmp == -1)) goto bad; name++; } name = argnames; while (name != first_kw_arg) { int cmp = PyObject_RichCompareBool(**name, key, Py_EQ); if (unlikely(cmp != 0)) { if (cmp == 1) goto arg_passed_twice; else goto bad; } name++; } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); goto bad; bad: return -1; } static CYTHON_INLINE int __Pyx_MatchKeywordArg( PyObject *key, PyObject ** const argnames[], PyObject ** const *first_kw_arg, size_t *index_found, const char *function_name) { return likely(PyUnicode_CheckExact(key)) ? __Pyx_MatchKeywordArg_str(key, argnames, first_kw_arg, index_found, function_name) : __Pyx_MatchKeywordArg_nostr(key, argnames, first_kw_arg, index_found, function_name); } static void __Pyx_RejectUnknownKeyword( PyObject *kwds, PyObject ** const argnames[], PyObject ** const *first_kw_arg, const char *function_name) { #if CYTHON_AVOID_BORROWED_REFS PyObject *pos = NULL; #else Py_ssize_t pos = 0; #endif PyObject *key = NULL; __Pyx_BEGIN_CRITICAL_SECTION(kwds); while ( #if CYTHON_AVOID_BORROWED_REFS __Pyx_PyDict_NextRef(kwds, &pos, &key, NULL) #else PyDict_Next(kwds, &pos, &key, NULL) #endif ) { PyObject** const *name = first_kw_arg; while (*name && (**name != key)) name++; if (!*name) { size_t index_found = 0; int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name); if (cmp != 1) { if (cmp == 0) { PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%U'", function_name, key); } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(key); #endif break; } } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(key); #endif } __Pyx_END_CRITICAL_SECTION(); #if CYTHON_AVOID_BORROWED_REFS Py_XDECREF(pos); #endif assert(PyErr_Occurred()); } static int __Pyx_ParseKeywordDict( PyObject *kwds, PyObject ** const argnames[], PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs) { PyObject** const *name; PyObject** const *first_kw_arg = argnames + num_pos_args; Py_ssize_t extracted = 0; #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments) if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1; #endif name = first_kw_arg; while (*name && num_kwargs > extracted) { PyObject * key = **name; PyObject *value; int found = 0; #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 found = PyDict_GetItemRef(kwds, key, &value); #else value = PyDict_GetItemWithError(kwds, key); if (value) { Py_INCREF(value); found = 1; } else { if (unlikely(PyErr_Occurred())) goto bad; } #endif if (found) { if (unlikely(found < 0)) goto bad; values[name-argnames] = value; extracted++; } name++; } if (num_kwargs > extracted) { if (ignore_unknown_kwargs) { if (unlikely(__Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name) == -1)) goto bad; } else { __Pyx_RejectUnknownKeyword(kwds, argnames, first_kw_arg, function_name); goto bad; } } return 0; bad: return -1; } static int __Pyx_ParseKeywordDictToDict( PyObject *kwds, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject** const *name; PyObject** const *first_kw_arg = argnames + num_pos_args; Py_ssize_t len; #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments) if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1; #endif if (PyDict_Update(kwds2, kwds) < 0) goto bad; name = first_kw_arg; while (*name) { PyObject *key = **name; PyObject *value; #if !CYTHON_COMPILING_IN_LIMITED_API && (PY_VERSION_HEX >= 0x030d00A2 || defined(PyDict_Pop)) int found = PyDict_Pop(kwds2, key, &value); if (found) { if (unlikely(found < 0)) goto bad; values[name-argnames] = value; } #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000 int found = PyDict_GetItemRef(kwds2, key, &value); if (found) { if (unlikely(found < 0)) goto bad; values[name-argnames] = value; if (unlikely(PyDict_DelItem(kwds2, key) < 0)) goto bad; } #else #if CYTHON_COMPILING_IN_CPYTHON value = _PyDict_Pop(kwds2, key, kwds2); #else value = __Pyx_CallUnboundCMethod2(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_pop, kwds2, key, kwds2); #endif if (value == kwds2) { Py_DECREF(value); } else { if (unlikely(!value)) goto bad; values[name-argnames] = value; } #endif name++; } len = PyDict_Size(kwds2); if (len > 0) { return __Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name); } else if (unlikely(len == -1)) { goto bad; } return 0; bad: return -1; } static int __Pyx_ParseKeywordsTuple( PyObject *kwds, PyObject * const *kwvalues, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs) { PyObject *key = NULL; PyObject** const * name; PyObject** const *first_kw_arg = argnames + num_pos_args; for (Py_ssize_t pos = 0; pos < num_kwargs; pos++) { #if CYTHON_AVOID_BORROWED_REFS key = __Pyx_PySequence_ITEM(kwds, pos); #else key = __Pyx_PyTuple_GET_ITEM(kwds, pos); #endif #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely(!key)) goto bad; #endif name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { PyObject *value = kwvalues[pos]; values[name-argnames] = __Pyx_NewRef(value); } else { size_t index_found = 0; int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name); if (cmp == 1) { PyObject *value = kwvalues[pos]; values[index_found] = __Pyx_NewRef(value); } else { if (unlikely(cmp == -1)) goto bad; if (kwds2) { PyObject *value = kwvalues[pos]; if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else if (!ignore_unknown_kwargs) { goto invalid_keyword; } } } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(key); key = NULL; #endif } return 0; invalid_keyword: PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%U'", function_name, key); goto bad; bad: #if CYTHON_AVOID_BORROWED_REFS Py_XDECREF(key); #endif return -1; } /* ParseKeywords */ static int __Pyx_ParseKeywords( PyObject *kwds, PyObject * const *kwvalues, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs) { if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds))) return __Pyx_ParseKeywordsTuple(kwds, kwvalues, argnames, kwds2, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs); else if (kwds2) return __Pyx_ParseKeywordDictToDict(kwds, argnames, kwds2, values, num_pos_args, function_name); else return __Pyx_ParseKeywordDict(kwds, argnames, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs); } /* RaiseArgTupleInvalid */ static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found) { Py_ssize_t num_expected; const char *more_or_less; if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; } else { num_expected = num_max; more_or_less = "at most"; } if (exact) { more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } /* PyObjectFastCallMethod */ #if !CYTHON_VECTORCALL || PY_VERSION_HEX < 0x03090000 static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const *args, size_t nargsf) { PyObject *result; PyObject *attr = PyObject_GetAttr(args[0], name); if (unlikely(!attr)) return NULL; result = __Pyx_PyObject_FastCall(attr, args+1, nargsf - 1); Py_DECREF(attr); return result; } #endif /* RejectKeywords */ static void __Pyx_RejectKeywords(const char* function_name, PyObject *kwds) { PyObject *key = NULL; if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds))) { key = __Pyx_PySequence_ITEM(kwds, 0); } else { #if CYTHON_AVOID_BORROWED_REFS PyObject *pos = NULL; #else Py_ssize_t pos = 0; #endif #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments) if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return; #endif __Pyx_PyDict_NextRef(kwds, &pos, &key, NULL); #if CYTHON_AVOID_BORROWED_REFS Py_XDECREF(pos); #endif } if (likely(key)) { PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%U'", function_name, key); Py_DECREF(key); } } /* RaiseException */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto bad; } if (value == Py_None) value = 0; if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto bad; } value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { PyObject *instance_class = NULL; if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { int is_subclass = PyObject_IsSubclass(instance_class, type); if (!is_subclass) { instance_class = NULL; } else if (unlikely(is_subclass == -1)) { goto bad; } else { type = instance_class; } } } if (!instance_class) { PyObject *args; if (!value) args = PyTuple_New(0); else if (PyTuple_Check(value)) { Py_INCREF(value); args = value; } else args = PyTuple_Pack(1, value); if (!args) goto bad; owned_instance = PyObject_Call(type, args, NULL); Py_DECREF(args); if (!owned_instance) goto bad; value = owned_instance; if (!PyExceptionInstance_Check(value)) { PyErr_Format(PyExc_TypeError, "calling %R should have returned an instance of " "BaseException, not %R", type, Py_TYPE(value)); goto bad; } } } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } if (cause) { PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyException_SetTraceback(value, tb); #elif CYTHON_FAST_THREAD_STATE PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #else PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #endif } bad: Py_XDECREF(owned_instance); return; } /* SetStringIndexingError */ static void __Pyx_SetStringIndexingError(const char* message, int has_gil) { if (!has_gil) { PyGILState_STATE gil_state = PyGILState_Ensure(); PyErr_SetString(PyExc_IndexError, message); PyGILState_Release(gil_state); } else PyErr_SetString(PyExc_IndexError, message); } /* GetItemIntByteArray */ static CYTHON_INLINE int __Pyx_GetItemInt_ByteArray_Fast_Locked(PyObject* string, Py_ssize_t i, int wraparound, int boundscheck, int has_gil) { Py_ssize_t length = __Pyx_PyByteArray_GET_SIZE(string); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(length < 0)) return -1; #endif if (wraparound & unlikely(i < 0)) i += length; if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) { #if !CYTHON_ASSUME_SAFE_MACROS char *asString = PyByteArray_AsString(string); return likely(asString) ? (unsigned char) asString[i] : -1; #else return (unsigned char) (PyByteArray_AS_STRING(string)[i]); #endif } else { __Pyx_SetStringIndexingError("bytearray index out of range", has_gil); return -1; } } static CYTHON_INLINE int __Pyx_GetItemInt_ByteArray_Fast(PyObject* string, Py_ssize_t i, int wraparound, int boundscheck, int has_gil, int unsafe_shared) { CYTHON_MAYBE_UNUSED_VAR(unsafe_shared); #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING wraparound = wraparound && i<0; #endif if (wraparound | boundscheck) { int result; __Pyx_PyCriticalSection cs; int lock = CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && has_gil && !__Pyx_IS_UNIQUELY_REFERENCED(string, unsafe_shared); if (lock) { __Pyx_PyCriticalSection_Begin(&cs, string); } result = __Pyx_GetItemInt_ByteArray_Fast_Locked(string, i, wraparound, boundscheck, has_gil); if (lock) { __Pyx_PyCriticalSection_End(&cs); } return result; } else { #if !CYTHON_ASSUME_SAFE_MACROS char *asString = PyByteArray_AsString(string); return likely(asString) ? (unsigned char) asString[i] : -1; #else return (unsigned char) (PyByteArray_AS_STRING(string)[i]); #endif } } /* decode_c_string */ static CYTHON_INLINE PyObject* __Pyx_decode_c_string( const char* cstring, Py_ssize_t start, Py_ssize_t stop, const char* encoding, const char* errors, PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { Py_ssize_t length; if (unlikely((start < 0) | (stop < 0))) { size_t slen = strlen(cstring); if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) { PyErr_SetString(PyExc_OverflowError, "c-string too long to convert to Python"); return NULL; } length = (Py_ssize_t) slen; if (start < 0) { start += length; if (start < 0) start = 0; } if (stop < 0) stop += length; } if (unlikely(stop <= start)) return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_unicode); length = stop - start; cstring += start; if (decode_func) { return decode_func(cstring, length, errors); } else { return PyUnicode_Decode(cstring, length, encoding, errors); } } /* GetTopmostException */ #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate) { _PyErr_StackItem *exc_info = tstate->exc_info; while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) && exc_info->previous_item != NULL) { exc_info = exc_info->previous_item; } return exc_info; } #endif /* SaveResetException */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4 _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); PyObject *exc_value = exc_info->exc_value; if (exc_value == NULL || exc_value == Py_None) { *value = NULL; *type = NULL; *tb = NULL; } else { *value = exc_value; Py_INCREF(*value); *type = (PyObject*) Py_TYPE(exc_value); Py_INCREF(*type); *tb = PyException_GetTraceback(exc_value); } #elif CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); *type = exc_info->exc_type; *value = exc_info->exc_value; *tb = exc_info->exc_traceback; Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); #else *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); #endif } static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4 _PyErr_StackItem *exc_info = tstate->exc_info; PyObject *tmp_value = exc_info->exc_value; exc_info->exc_value = value; Py_XDECREF(tmp_value); Py_XDECREF(type); Py_XDECREF(tb); #else PyObject *tmp_type, *tmp_value, *tmp_tb; #if CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = tstate->exc_info; tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = type; exc_info->exc_value = value; exc_info->exc_traceback = tb; #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = type; tstate->exc_value = value; tstate->exc_traceback = tb; #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #endif } #endif /* GetException */ #if CYTHON_FAST_THREAD_STATE static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) #endif { PyObject *local_type = NULL, *local_value, *local_tb = NULL; #if CYTHON_FAST_THREAD_STATE PyObject *tmp_type, *tmp_value, *tmp_tb; #if PY_VERSION_HEX >= 0x030C0000 local_value = tstate->current_exception; tstate->current_exception = 0; #else local_type = tstate->curexc_type; local_value = tstate->curexc_value; local_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #endif #elif __PYX_LIMITED_VERSION_HEX > 0x030C0000 local_value = PyErr_GetRaisedException(); #else PyErr_Fetch(&local_type, &local_value, &local_tb); #endif #if __PYX_LIMITED_VERSION_HEX > 0x030C0000 if (likely(local_value)) { local_type = (PyObject*) Py_TYPE(local_value); Py_INCREF(local_type); local_tb = PyException_GetTraceback(local_value); } #else PyErr_NormalizeException(&local_type, &local_value, &local_tb); #if CYTHON_FAST_THREAD_STATE if (unlikely(tstate->curexc_type)) #else if (unlikely(PyErr_Occurred())) #endif goto bad; if (local_tb) { if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) goto bad; } #endif // __PYX_LIMITED_VERSION_HEX > 0x030C0000 Py_XINCREF(local_tb); Py_XINCREF(local_type); Py_XINCREF(local_value); *type = local_type; *value = local_value; *tb = local_tb; #if CYTHON_FAST_THREAD_STATE #if CYTHON_USE_EXC_INFO_STACK { _PyErr_StackItem *exc_info = tstate->exc_info; #if PY_VERSION_HEX >= 0x030B00a4 tmp_value = exc_info->exc_value; exc_info->exc_value = local_value; tmp_type = NULL; tmp_tb = NULL; Py_XDECREF(local_type); Py_XDECREF(local_tb); #else tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = local_type; exc_info->exc_value = local_value; exc_info->exc_traceback = local_tb; #endif } #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = local_type; tstate->exc_value = local_value; tstate->exc_traceback = local_tb; #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #elif __PYX_LIMITED_VERSION_HEX >= 0x030b0000 PyErr_SetHandledException(local_value); Py_XDECREF(local_value); Py_XDECREF(local_type); Py_XDECREF(local_tb); #else PyErr_SetExcInfo(local_type, local_value, local_tb); #endif return 0; #if __PYX_LIMITED_VERSION_HEX <= 0x030C0000 bad: *type = 0; *value = 0; *tb = 0; Py_XDECREF(local_type); Py_XDECREF(local_value); Py_XDECREF(local_tb); return -1; #endif } /* RaiseUnexpectedTypeError */ static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj) { __Pyx_TypeName obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj)); PyErr_Format(PyExc_TypeError, "Expected %s, got " __Pyx_FMT_TYPENAME, expected, obj_type_name); __Pyx_DECREF_TypeName(obj_type_name); return 0; } /* GetAttr3 */ #if __PYX_LIMITED_VERSION_HEX < 0x030d0000 static PyObject *__Pyx_GetAttr3Default(PyObject *d) { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) return NULL; __Pyx_PyErr_Clear(); Py_INCREF(d); return d; } #endif static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) { PyObject *r; #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 int res = PyObject_GetOptionalAttr(o, n, &r); return (res != 0) ? r : __Pyx_NewRef(d); #else #if CYTHON_USE_TYPE_SLOTS if (likely(PyUnicode_Check(n))) { r = __Pyx_PyObject_GetAttrStrNoError(o, n); if (unlikely(!r) && likely(!PyErr_Occurred())) { r = __Pyx_NewRef(d); } return r; } #endif r = PyObject_GetAttr(o, n); return (likely(r)) ? r : __Pyx_GetAttr3Default(d); #endif } /* PyDictVersioning */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { PyObject *dict = Py_TYPE(obj)->tp_dict; return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; } static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { PyObject **dictptr = NULL; Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; if (offset) { #if CYTHON_COMPILING_IN_CPYTHON dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); #else dictptr = _PyObject_GetDictPtr(obj); #endif } return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; } static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { PyObject *dict = Py_TYPE(obj)->tp_dict; if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) return 0; return obj_dict_version == __Pyx_get_object_dict_version(obj); } #endif /* GetModuleGlobalName */ #if CYTHON_USE_DICT_VERSIONS static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) #else static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) #endif { PyObject *result; #if CYTHON_COMPILING_IN_LIMITED_API if (unlikely(!__pyx_m)) { if (!PyErr_Occurred()) PyErr_SetNone(PyExc_NameError); return NULL; } result = PyObject_GetAttr(__pyx_m, name); if (likely(result)) { return result; } PyErr_Clear(); #elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS if (unlikely(__Pyx_PyDict_GetItemRef(__pyx_mstate_global->__pyx_d, name, &result) == -1)) PyErr_Clear(); __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return result; } #else result = _PyDict_GetItem_KnownHash(__pyx_mstate_global->__pyx_d, name, ((PyASCIIObject *) name)->hash); __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } PyErr_Clear(); #endif return __Pyx_GetBuiltinName(name); } /* ArgTypeTestFunc */ static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { __Pyx_TypeName type_name; __Pyx_TypeName obj_type_name; PyObject *extra_info = __pyx_mstate_global->__pyx_empty_unicode; int from_annotation_subclass = 0; if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } else if (!exact) { if (likely(__Pyx_TypeCheck(obj, type))) return 1; } else if (exact == 2) { if (__Pyx_TypeCheck(obj, type)) { from_annotation_subclass = 1; extra_info = __pyx_mstate_global->__pyx_kp_u_Note_that_Cython_is_deliberately; } } type_name = __Pyx_PyType_GetFullyQualifiedName(type); obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj)); PyErr_Format(PyExc_TypeError, "Argument '%.200s' has incorrect type (expected " __Pyx_FMT_TYPENAME ", got " __Pyx_FMT_TYPENAME ")" #if __PYX_LIMITED_VERSION_HEX < 0x030C0000 "%s%U" #endif , name, type_name, obj_type_name #if __PYX_LIMITED_VERSION_HEX < 0x030C0000 , (from_annotation_subclass ? ". " : ""), extra_info #endif ); #if __PYX_LIMITED_VERSION_HEX >= 0x030C0000 if (exact == 2 && from_annotation_subclass) { PyObject *res; PyObject *vargs[2]; vargs[0] = PyErr_GetRaisedException(); vargs[1] = extra_info; res = PyObject_VectorcallMethod(__pyx_mstate_global->__pyx_kp_u_add_note, vargs, 2, NULL); Py_XDECREF(res); PyErr_SetRaisedException(vargs[0]); } #endif __Pyx_DECREF_TypeName(type_name); __Pyx_DECREF_TypeName(obj_type_name); return 0; } /* GetItemInt */ static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; if (unlikely(!j)) return NULL; r = PyObject_GetItem(o, j); Py_DECREF(j); return r; } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck, int unsafe_shared) { CYTHON_MAYBE_UNUSED_VAR(unsafe_shared); #if CYTHON_ASSUME_SAFE_SIZE Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyList_GET_SIZE(o); } if ((CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS || !CYTHON_ASSUME_SAFE_MACROS)) { return __Pyx_PyList_GetItemRefFast(o, wrapped_i, unsafe_shared); } else if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { return __Pyx_NewRef(PyList_GET_ITEM(o, wrapped_i)); } return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i)); #else (void)wraparound; (void)boundscheck; return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck, int unsafe_shared) { CYTHON_MAYBE_UNUSED_VAR(unsafe_shared); #if CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyTuple_GET_SIZE(o); } if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { return __Pyx_NewRef(PyTuple_GET_ITEM(o, wrapped_i)); } return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i)); #else (void)wraparound; (void)boundscheck; return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck, int unsafe_shared) { CYTHON_MAYBE_UNUSED_VAR(unsafe_shared); #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); if ((CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)) { return __Pyx_PyList_GetItemRefFast(o, n, unsafe_shared); } else if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { return __Pyx_NewRef(PyList_GET_ITEM(o, n)); } } else #if !CYTHON_AVOID_BORROWED_REFS if (PyTuple_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { return __Pyx_NewRef(PyTuple_GET_ITEM(o, n)); } } else #endif #endif #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY { PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping; PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence; if (!is_list && mm && mm->mp_subscript) { PyObject *r, *key = PyLong_FromSsize_t(i); if (unlikely(!key)) return NULL; r = mm->mp_subscript(o, key); Py_DECREF(key); return r; } if (is_list || likely(sm && sm->sq_item)) { if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) { Py_ssize_t l = sm->sq_length(o); if (likely(l >= 0)) { i += l; } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) return NULL; PyErr_Clear(); } } return sm->sq_item(o, i); } } #else if (is_list || !PyMapping_Check(o)) { return PySequence_GetItem(o, i); } #endif (void)wraparound; (void)boundscheck; return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i)); } /* AllocateExtensionType */ static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final) { if (is_final || likely(!__Pyx_PyType_HasFeature(t, Py_TPFLAGS_IS_ABSTRACT))) { allocfunc alloc_func = __Pyx_PyType_GetSlot(t, tp_alloc, allocfunc); return alloc_func(t, 0); } else { newfunc tp_new = __Pyx_PyType_TryGetSlot(&PyBaseObject_Type, tp_new, newfunc); #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 if (!tp_new) { PyObject *new_str = PyUnicode_FromString("__new__"); if (likely(new_str)) { PyObject *o = PyObject_CallMethodObjArgs((PyObject *)&PyBaseObject_Type, new_str, t, NULL); Py_DECREF(new_str); return o; } else return NULL; } else #endif return tp_new(t, __pyx_mstate_global->__pyx_empty_tuple, 0); } } /* CallNextTpTraverse */ static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) { PyTypeObject* type = Py_TYPE(obj); traverseproc tp_traverse = NULL; while (type && __Pyx_PyType_GetSlot(type, tp_traverse, traverseproc) != current_tp_traverse) type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*); while (type && (tp_traverse = __Pyx_PyType_GetSlot(type, tp_traverse, traverseproc)) == current_tp_traverse) type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*); if (type && tp_traverse) return tp_traverse(obj, v, a); return 0; } /* CallTypeTraverse */ #if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000) #else static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg) { #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x03090000 if (__Pyx_get_runtime_version() < 0x03090000) return 0; #endif if (!always_call) { PyTypeObject *base = __Pyx_PyObject_GetSlot(o, tp_base, PyTypeObject*); unsigned long flags = PyType_GetFlags(base); if (flags & Py_TPFLAGS_HEAPTYPE) { return 0; } } Py_VISIT((PyObject*)Py_TYPE(o)); return 0; } #endif /* CallNextTpClear */ static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) { PyTypeObject* type = Py_TYPE(obj); inquiry tp_clear = NULL; while (type && __Pyx_PyType_GetSlot(type, tp_clear, inquiry) != current_tp_clear) type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*); while (type && (tp_clear = __Pyx_PyType_GetSlot(type, tp_clear, inquiry)) == current_tp_clear) type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*); if (type && tp_clear) tp_clear(obj); } /* LimitedApiGetTypeDict */ #if CYTHON_COMPILING_IN_LIMITED_API static Py_ssize_t __Pyx_GetTypeDictOffset(void) { PyObject *tp_dictoffset_o; Py_ssize_t tp_dictoffset; tp_dictoffset_o = PyObject_GetAttrString((PyObject*)(&PyType_Type), "__dictoffset__"); if (unlikely(!tp_dictoffset_o)) return -1; tp_dictoffset = PyLong_AsSsize_t(tp_dictoffset_o); Py_DECREF(tp_dictoffset_o); if (unlikely(tp_dictoffset == 0)) { PyErr_SetString( PyExc_TypeError, "'type' doesn't have a dictoffset"); return -1; } else if (unlikely(tp_dictoffset < 0)) { PyErr_SetString( PyExc_TypeError, "'type' has an unexpected negative dictoffset. " "Please report this as Cython bug"); return -1; } return tp_dictoffset; } static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp) { static Py_ssize_t tp_dictoffset = 0; if (unlikely(tp_dictoffset == 0)) { tp_dictoffset = __Pyx_GetTypeDictOffset(); if (unlikely(tp_dictoffset == -1 && PyErr_Occurred())) { tp_dictoffset = 0; // try again next time? return NULL; } } return *(PyObject**)((char*)tp + tp_dictoffset); } #endif /* SetItemOnTypeDict */ static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v) { int result; PyObject *tp_dict; #if CYTHON_COMPILING_IN_LIMITED_API tp_dict = __Pyx_GetTypeDict(tp); if (unlikely(!tp_dict)) return -1; #else tp_dict = tp->tp_dict; #endif result = PyDict_SetItem(tp_dict, k, v); if (likely(!result)) { PyType_Modified(tp); if (unlikely(PyObject_HasAttr(v, __pyx_mstate_global->__pyx_n_u_set_name))) { PyObject *setNameResult = PyObject_CallMethodObjArgs(v, __pyx_mstate_global->__pyx_n_u_set_name, (PyObject *) tp, k, NULL); if (!setNameResult) return -1; Py_DECREF(setNameResult); } } return result; } /* FixUpExtensionType */ static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type) { #if __PYX_LIMITED_VERSION_HEX > 0x030900B1 CYTHON_UNUSED_VAR(spec); CYTHON_UNUSED_VAR(type); CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict); #else const PyType_Slot *slot = spec->slots; int changed = 0; #if !CYTHON_COMPILING_IN_LIMITED_API while (slot && slot->slot && slot->slot != Py_tp_members) slot++; if (slot && slot->slot == Py_tp_members) { #if !CYTHON_COMPILING_IN_CPYTHON const #endif // !CYTHON_COMPILING_IN_CPYTHON) PyMemberDef *memb = (PyMemberDef*) slot->pfunc; while (memb && memb->name) { if (memb->name[0] == '_' && memb->name[1] == '_') { if (strcmp(memb->name, "__weaklistoffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); type->tp_weaklistoffset = memb->offset; changed = 1; } else if (strcmp(memb->name, "__dictoffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); type->tp_dictoffset = memb->offset; changed = 1; } #if CYTHON_METH_FASTCALL else if (strcmp(memb->name, "__vectorcalloffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); type->tp_vectorcall_offset = memb->offset; changed = 1; } #endif // CYTHON_METH_FASTCALL #if !CYTHON_COMPILING_IN_PYPY else if (strcmp(memb->name, "__module__") == 0) { PyObject *descr; assert(memb->type == T_OBJECT); assert(memb->flags == 0 || memb->flags == READONLY); descr = PyDescr_NewMember(type, memb); if (unlikely(!descr)) return -1; int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr); Py_DECREF(descr); if (unlikely(set_item_result < 0)) { return -1; } changed = 1; } #endif // !CYTHON_COMPILING_IN_PYPY } memb++; } } #endif // !CYTHON_COMPILING_IN_LIMITED_API #if !CYTHON_COMPILING_IN_PYPY slot = spec->slots; while (slot && slot->slot && slot->slot != Py_tp_getset) slot++; if (slot && slot->slot == Py_tp_getset) { PyGetSetDef *getset = (PyGetSetDef*) slot->pfunc; while (getset && getset->name) { if (getset->name[0] == '_' && getset->name[1] == '_' && strcmp(getset->name, "__module__") == 0) { PyObject *descr = PyDescr_NewGetSet(type, getset); if (unlikely(!descr)) return -1; #if CYTHON_COMPILING_IN_LIMITED_API PyObject *pyname = PyUnicode_FromString(getset->name); if (unlikely(!pyname)) { Py_DECREF(descr); return -1; } int set_item_result = __Pyx_SetItemOnTypeDict(type, pyname, descr); Py_DECREF(pyname); #else CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict); int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr); #endif Py_DECREF(descr); if (unlikely(set_item_result < 0)) { return -1; } changed = 1; } ++getset; } } #else CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict); #endif // !CYTHON_COMPILING_IN_PYPY if (changed) PyType_Modified(type); #endif // PY_VERSION_HEX > 0x030900B1 return 0; } /* PyObjectCallNoArg */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { PyObject *arg[2] = {NULL, NULL}; return __Pyx_PyObject_FastCall(func, arg + 1, 0 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } /* PyObjectGetMethod */ #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))) static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) { PyObject *attr; #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP __Pyx_TypeName type_name; PyTypeObject *tp = Py_TYPE(obj); PyObject *descr; descrgetfunc f = NULL; PyObject **dictptr, *dict; int meth_found = 0; assert (*method == NULL); if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) { attr = __Pyx_PyObject_GetAttrStr(obj, name); goto try_unpack; } if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) { return 0; } descr = _PyType_Lookup(tp, name); if (likely(descr != NULL)) { Py_INCREF(descr); #if defined(Py_TPFLAGS_METHOD_DESCRIPTOR) && Py_TPFLAGS_METHOD_DESCRIPTOR if (__Pyx_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR)) #else #ifdef __Pyx_CyFunction_USED if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr))) #else if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type))) #endif #endif { meth_found = 1; } else { f = Py_TYPE(descr)->tp_descr_get; if (f != NULL && PyDescr_IsData(descr)) { attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); Py_DECREF(descr); goto try_unpack; } } } dictptr = _PyObject_GetDictPtr(obj); if (dictptr != NULL && (dict = *dictptr) != NULL) { Py_INCREF(dict); attr = __Pyx_PyDict_GetItemStr(dict, name); if (attr != NULL) { Py_INCREF(attr); Py_DECREF(dict); Py_XDECREF(descr); goto try_unpack; } Py_DECREF(dict); } if (meth_found) { *method = descr; return 1; } if (f != NULL) { attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); Py_DECREF(descr); goto try_unpack; } if (likely(descr != NULL)) { *method = descr; return 0; } type_name = __Pyx_PyType_GetFullyQualifiedName(tp); PyErr_Format(PyExc_AttributeError, "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'", type_name, name); __Pyx_DECREF_TypeName(type_name); return 0; #else attr = __Pyx_PyObject_GetAttrStr(obj, name); goto try_unpack; #endif try_unpack: #if CYTHON_UNPACK_METHODS if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) { PyObject *function = PyMethod_GET_FUNCTION(attr); Py_INCREF(function); Py_DECREF(attr); *method = function; return 1; } #endif *method = attr; return 0; } #endif /* PyObjectCallMethod0 */ static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) { #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)) PyObject *args[1] = {obj}; (void) __Pyx_PyObject_CallOneArg; (void) __Pyx_PyObject_CallNoArg; return PyObject_VectorcallMethod(method_name, args, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); #else PyObject *method = NULL, *result = NULL; int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); if (likely(is_method)) { result = __Pyx_PyObject_CallOneArg(method, obj); Py_DECREF(method); return result; } if (unlikely(!method)) goto bad; result = __Pyx_PyObject_CallNoArg(method); Py_DECREF(method); bad: return result; #endif } /* ValidateBasesTuple */ #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases) { Py_ssize_t i, n; #if CYTHON_ASSUME_SAFE_SIZE n = PyTuple_GET_SIZE(bases); #else n = PyTuple_Size(bases); if (unlikely(n < 0)) return -1; #endif for (i = 1; i < n; i++) { PyTypeObject *b; #if CYTHON_AVOID_BORROWED_REFS PyObject *b0 = PySequence_GetItem(bases, i); if (!b0) return -1; #elif CYTHON_ASSUME_SAFE_MACROS PyObject *b0 = PyTuple_GET_ITEM(bases, i); #else PyObject *b0 = PyTuple_GetItem(bases, i); if (!b0) return -1; #endif b = (PyTypeObject*) b0; if (!__Pyx_PyType_HasFeature(b, Py_TPFLAGS_HEAPTYPE)) { __Pyx_TypeName b_name = __Pyx_PyType_GetFullyQualifiedName(b); PyErr_Format(PyExc_TypeError, "base class '" __Pyx_FMT_TYPENAME "' is not a heap type", b_name); __Pyx_DECREF_TypeName(b_name); #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(b0); #endif return -1; } if (dictoffset == 0) { Py_ssize_t b_dictoffset = 0; #if CYTHON_USE_TYPE_SLOTS b_dictoffset = b->tp_dictoffset; #else PyObject *py_b_dictoffset = PyObject_GetAttrString((PyObject*)b, "__dictoffset__"); if (!py_b_dictoffset) goto dictoffset_return; b_dictoffset = PyLong_AsSsize_t(py_b_dictoffset); Py_DECREF(py_b_dictoffset); if (b_dictoffset == -1 && PyErr_Occurred()) goto dictoffset_return; #endif if (b_dictoffset) { { __Pyx_TypeName b_name = __Pyx_PyType_GetFullyQualifiedName(b); PyErr_Format(PyExc_TypeError, "extension type '%.200s' has no __dict__ slot, " "but base type '" __Pyx_FMT_TYPENAME "' has: " "either add 'cdef dict __dict__' to the extension type " "or add '__slots__ = [...]' to the base type", type_name, b_name); __Pyx_DECREF_TypeName(b_name); } #if !CYTHON_USE_TYPE_SLOTS dictoffset_return: #endif #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(b0); #endif return -1; } } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(b0); #endif } return 0; } #endif /* PyType_Ready */ CYTHON_UNUSED static int __Pyx_PyType_HasMultipleInheritance(PyTypeObject *t) { while (t) { PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*); if (bases) { return 1; } t = __Pyx_PyType_GetSlot(t, tp_base, PyTypeObject*); } return 0; } static int __Pyx_PyType_Ready(PyTypeObject *t) { #if CYTHON_USE_TYPE_SPECS || !CYTHON_COMPILING_IN_CPYTHON || defined(PYSTON_MAJOR_VERSION) (void)__Pyx_PyObject_CallMethod0; #if CYTHON_USE_TYPE_SPECS (void)__Pyx_validate_bases_tuple; #endif return PyType_Ready(t); #else int r; if (!__Pyx_PyType_HasMultipleInheritance(t)) { return PyType_Ready(t); } PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*); if (bases && unlikely(__Pyx_validate_bases_tuple(t->tp_name, t->tp_dictoffset, bases) == -1)) return -1; #if !defined(PYSTON_MAJOR_VERSION) { int gc_was_enabled; #if PY_VERSION_HEX >= 0x030A00b1 gc_was_enabled = PyGC_Disable(); (void)__Pyx_PyObject_CallMethod0; #else PyObject *ret, *py_status; PyObject *gc = NULL; #if (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM+0 >= 0x07030400) &&\ !CYTHON_COMPILING_IN_GRAAL gc = PyImport_GetModule(__pyx_mstate_global->__pyx_kp_u_gc); #endif if (unlikely(!gc)) gc = PyImport_Import(__pyx_mstate_global->__pyx_kp_u_gc); if (unlikely(!gc)) return -1; py_status = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_isenabled); if (unlikely(!py_status)) { Py_DECREF(gc); return -1; } gc_was_enabled = __Pyx_PyObject_IsTrue(py_status); Py_DECREF(py_status); if (gc_was_enabled > 0) { ret = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_disable); if (unlikely(!ret)) { Py_DECREF(gc); return -1; } Py_DECREF(ret); } else if (unlikely(gc_was_enabled == -1)) { Py_DECREF(gc); return -1; } #endif t->tp_flags |= Py_TPFLAGS_HEAPTYPE; #if PY_VERSION_HEX >= 0x030A0000 t->tp_flags |= Py_TPFLAGS_IMMUTABLETYPE; #endif #else (void)__Pyx_PyObject_CallMethod0; #endif r = PyType_Ready(t); #if !defined(PYSTON_MAJOR_VERSION) t->tp_flags &= ~Py_TPFLAGS_HEAPTYPE; #if PY_VERSION_HEX >= 0x030A00b1 if (gc_was_enabled) PyGC_Enable(); #else if (gc_was_enabled) { PyObject *tp, *v, *tb; PyErr_Fetch(&tp, &v, &tb); ret = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_enable); if (likely(ret || r == -1)) { Py_XDECREF(ret); PyErr_Restore(tp, v, tb); } else { Py_XDECREF(tp); Py_XDECREF(v); Py_XDECREF(tb); r = -1; } } Py_DECREF(gc); #endif } #endif return r; #endif } /* DelItemOnTypeDict */ static int __Pyx__DelItemOnTypeDict(PyTypeObject *tp, PyObject *k) { int result; PyObject *tp_dict; #if CYTHON_COMPILING_IN_LIMITED_API tp_dict = __Pyx_GetTypeDict(tp); if (unlikely(!tp_dict)) return -1; #else tp_dict = tp->tp_dict; #endif result = PyDict_DelItem(tp_dict, k); if (likely(!result)) PyType_Modified(tp); return result; } /* SetupReduce */ static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { int ret; PyObject *name_attr; name_attr = __Pyx_PyObject_GetAttrStrNoError(meth, __pyx_mstate_global->__pyx_n_u_name); if (likely(name_attr)) { ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); } else { ret = -1; } if (unlikely(ret < 0)) { PyErr_Clear(); ret = 0; } Py_XDECREF(name_attr); return ret; } static int __Pyx_setup_reduce(PyObject* type_obj) { int ret = 0; PyObject *object_reduce = NULL; PyObject *object_getstate = NULL; PyObject *object_reduce_ex = NULL; PyObject *reduce = NULL; PyObject *reduce_ex = NULL; PyObject *reduce_cython = NULL; PyObject *setstate = NULL; PyObject *setstate_cython = NULL; PyObject *getstate = NULL; #if CYTHON_USE_PYTYPE_LOOKUP getstate = _PyType_Lookup((PyTypeObject*)type_obj, __pyx_mstate_global->__pyx_n_u_getstate); #else getstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_mstate_global->__pyx_n_u_getstate); if (!getstate && PyErr_Occurred()) { goto __PYX_BAD; } #endif if (getstate) { #if CYTHON_USE_PYTYPE_LOOKUP object_getstate = _PyType_Lookup(&PyBaseObject_Type, __pyx_mstate_global->__pyx_n_u_getstate); #else object_getstate = __Pyx_PyObject_GetAttrStrNoError((PyObject*)&PyBaseObject_Type, __pyx_mstate_global->__pyx_n_u_getstate); if (!object_getstate && PyErr_Occurred()) { goto __PYX_BAD; } #endif if (object_getstate != getstate) { goto __PYX_GOOD; } } #if CYTHON_USE_PYTYPE_LOOKUP object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_mstate_global->__pyx_n_u_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD; #else object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_mstate_global->__pyx_n_u_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD; #endif reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_mstate_global->__pyx_n_u_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD; if (reduce_ex == object_reduce_ex) { #if CYTHON_USE_PYTYPE_LOOKUP object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_mstate_global->__pyx_n_u_reduce); if (!object_reduce) goto __PYX_BAD; #else object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_mstate_global->__pyx_n_u_reduce); if (!object_reduce) goto __PYX_BAD; #endif reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_mstate_global->__pyx_n_u_reduce); if (unlikely(!reduce)) goto __PYX_BAD; if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_mstate_global->__pyx_n_u_reduce_cython)) { reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_mstate_global->__pyx_n_u_reduce_cython); if (likely(reduce_cython)) { ret = __Pyx_SetItemOnTypeDict((PyTypeObject*)type_obj, __pyx_mstate_global->__pyx_n_u_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD; ret = __Pyx_DelItemOnTypeDict((PyTypeObject*)type_obj, __pyx_mstate_global->__pyx_n_u_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD; } else if (reduce == object_reduce || PyErr_Occurred()) { goto __PYX_BAD; } setstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_mstate_global->__pyx_n_u_setstate); if (!setstate) PyErr_Clear(); if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_mstate_global->__pyx_n_u_setstate_cython)) { setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_mstate_global->__pyx_n_u_setstate_cython); if (likely(setstate_cython)) { ret = __Pyx_SetItemOnTypeDict((PyTypeObject*)type_obj, __pyx_mstate_global->__pyx_n_u_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD; ret = __Pyx_DelItemOnTypeDict((PyTypeObject*)type_obj, __pyx_mstate_global->__pyx_n_u_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD; } else if (!setstate || PyErr_Occurred()) { goto __PYX_BAD; } } PyType_Modified((PyTypeObject*)type_obj); } } goto __PYX_GOOD; __PYX_BAD: if (!PyErr_Occurred()) { __Pyx_TypeName type_obj_name = __Pyx_PyType_GetFullyQualifiedName((PyTypeObject*)type_obj); PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for " __Pyx_FMT_TYPENAME, type_obj_name); __Pyx_DECREF_TypeName(type_obj_name); } ret = -1; __PYX_GOOD: #if !CYTHON_USE_PYTYPE_LOOKUP Py_XDECREF(object_reduce); Py_XDECREF(object_reduce_ex); Py_XDECREF(object_getstate); Py_XDECREF(getstate); #endif Py_XDECREF(reduce); Py_XDECREF(reduce_ex); Py_XDECREF(reduce_cython); Py_XDECREF(setstate); Py_XDECREF(setstate_cython); return ret; } /* TypeImport */ #ifndef __PYX_HAVE_RT_ImportType_3_2_0 #define __PYX_HAVE_RT_ImportType_3_2_0 static PyTypeObject *__Pyx_ImportType_3_2_0(PyObject *module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_2_0 check_size) { PyObject *result = 0; Py_ssize_t basicsize; Py_ssize_t itemsize; #if defined(Py_LIMITED_API) || (defined(CYTHON_COMPILING_IN_LIMITED_API) && CYTHON_COMPILING_IN_LIMITED_API) PyObject *py_basicsize; PyObject *py_itemsize; #endif result = PyObject_GetAttrString(module, class_name); if (!result) goto bad; if (!PyType_Check(result)) { PyErr_Format(PyExc_TypeError, "%.200s.%.200s is not a type object", module_name, class_name); goto bad; } #if !( defined(Py_LIMITED_API) || (defined(CYTHON_COMPILING_IN_LIMITED_API) && CYTHON_COMPILING_IN_LIMITED_API) ) basicsize = ((PyTypeObject *)result)->tp_basicsize; itemsize = ((PyTypeObject *)result)->tp_itemsize; #else if (size == 0) { return (PyTypeObject *)result; } py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); if (!py_basicsize) goto bad; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = 0; if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; py_itemsize = PyObject_GetAttrString(result, "__itemsize__"); if (!py_itemsize) goto bad; itemsize = PyLong_AsSsize_t(py_itemsize); Py_DECREF(py_itemsize); py_itemsize = 0; if (itemsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; #endif if (itemsize) { if (size % alignment) { alignment = size % alignment; } if (itemsize < (Py_ssize_t)alignment) itemsize = (Py_ssize_t)alignment; } if ((size_t)(basicsize + itemsize) < size) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", module_name, class_name, size, basicsize+itemsize); goto bad; } if (check_size == __Pyx_ImportType_CheckSize_Error_3_2_0 && ((size_t)basicsize > size || (size_t)(basicsize + itemsize) < size)) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd-%zd from PyObject", module_name, class_name, size, basicsize, basicsize+itemsize); goto bad; } else if (check_size == __Pyx_ImportType_CheckSize_Warn_3_2_0 && (size_t)basicsize > size) { if (PyErr_WarnFormat(NULL, 0, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", module_name, class_name, size, basicsize) < 0) { goto bad; } } return (PyTypeObject *)result; bad: Py_XDECREF(result); return NULL; } #endif /* dict_setdefault */ static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value) { PyObject* value; #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX >= 0x030C0000 PyObject *args[] = {d, key, default_value}; value = PyObject_VectorcallMethod(__pyx_mstate_global->__pyx_n_u_setdefault, args, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); #elif CYTHON_COMPILING_IN_LIMITED_API value = PyObject_CallMethodObjArgs(d, __pyx_mstate_global->__pyx_n_u_setdefault, key, default_value, NULL); #elif PY_VERSION_HEX >= 0x030d0000 PyDict_SetDefaultRef(d, key, default_value, &value); #else value = PyDict_SetDefault(d, key, default_value); if (unlikely(!value)) return NULL; Py_INCREF(value); #endif return value; } /* AddModuleRef */ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING static PyObject *__Pyx_PyImport_AddModuleObjectRef(PyObject *name) { PyObject *module_dict = PyImport_GetModuleDict(); PyObject *m; if (PyMapping_GetOptionalItem(module_dict, name, &m) < 0) { return NULL; } if (m != NULL && PyModule_Check(m)) { return m; } Py_XDECREF(m); m = PyModule_NewObject(name); if (m == NULL) return NULL; if (PyDict_CheckExact(module_dict)) { PyObject *new_m; (void)PyDict_SetDefaultRef(module_dict, name, m, &new_m); Py_DECREF(m); return new_m; } else { if (PyObject_SetItem(module_dict, name, m) != 0) { Py_DECREF(m); return NULL; } return m; } } static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) { PyObject *py_name = PyUnicode_FromString(name); if (!py_name) return NULL; PyObject *module = __Pyx_PyImport_AddModuleObjectRef(py_name); Py_DECREF(py_name); return module; } #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name) #else static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) { PyObject *module = PyImport_AddModule(name); Py_XINCREF(module); return module; } #endif /* FetchSharedCythonModule */ static PyObject *__Pyx_FetchSharedCythonABIModule(void) { return __Pyx_PyImport_AddModuleRef(__PYX_ABI_MODULE_NAME); } /* FetchCommonType */ #if __PYX_LIMITED_VERSION_HEX < 0x030C0000 static PyObject* __Pyx_PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) { PyObject *result = __Pyx_PyType_FromModuleAndSpec(module, spec, bases); if (result && metaclass) { PyObject *old_tp = (PyObject*)Py_TYPE(result); Py_INCREF((PyObject*)metaclass); #if __PYX_LIMITED_VERSION_HEX >= 0x03090000 Py_SET_TYPE(result, metaclass); #else result->ob_type = metaclass; #endif Py_DECREF(old_tp); } return result; } #else #define __Pyx_PyType_FromMetaclass(me, mo, s, b) PyType_FromMetaclass(me, mo, s, b) #endif static int __Pyx_VerifyCachedType(PyObject *cached_type, const char *name, Py_ssize_t expected_basicsize) { Py_ssize_t basicsize; if (!PyType_Check(cached_type)) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s is not a type object", name); return -1; } if (expected_basicsize == 0) { return 0; // size is inherited, nothing useful to check } #if CYTHON_COMPILING_IN_LIMITED_API PyObject *py_basicsize; py_basicsize = PyObject_GetAttrString(cached_type, "__basicsize__"); if (unlikely(!py_basicsize)) return -1; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = NULL; if (unlikely(basicsize == (Py_ssize_t)-1) && PyErr_Occurred()) return -1; #else basicsize = ((PyTypeObject*) cached_type)->tp_basicsize; #endif if (basicsize != expected_basicsize) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s has the wrong size, try recompiling", name); return -1; } return 0; } static PyTypeObject *__Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) { PyObject *abi_module = NULL, *cached_type = NULL, *abi_module_dict, *new_cached_type, *py_object_name; int get_item_ref_result; const char* object_name = strrchr(spec->name, '.'); object_name = object_name ? object_name+1 : spec->name; py_object_name = PyUnicode_FromString(object_name); if (!py_object_name) return NULL; abi_module = __Pyx_FetchSharedCythonABIModule(); if (!abi_module) goto done; abi_module_dict = PyModule_GetDict(abi_module); if (!abi_module_dict) goto done; get_item_ref_result = __Pyx_PyDict_GetItemRef(abi_module_dict, py_object_name, &cached_type); if (get_item_ref_result == 1) { if (__Pyx_VerifyCachedType( cached_type, object_name, spec->basicsize) < 0) { goto bad; } goto done; } else if (unlikely(get_item_ref_result == -1)) { goto bad; } cached_type = __Pyx_PyType_FromMetaclass( metaclass, CYTHON_USE_MODULE_STATE ? module : abi_module, spec, bases); if (unlikely(!cached_type)) goto bad; if (unlikely(__Pyx_fix_up_extension_type_from_spec(spec, (PyTypeObject *) cached_type) < 0)) goto bad; new_cached_type = __Pyx_PyDict_SetDefault(abi_module_dict, py_object_name, cached_type); if (unlikely(new_cached_type != cached_type)) { if (unlikely(!new_cached_type)) goto bad; Py_DECREF(cached_type); cached_type = new_cached_type; if (__Pyx_VerifyCachedType( cached_type, object_name, spec->basicsize) < 0) { goto bad; } goto done; } else { Py_DECREF(new_cached_type); } done: Py_XDECREF(abi_module); Py_DECREF(py_object_name); assert(cached_type == NULL || PyType_Check(cached_type)); return (PyTypeObject *) cached_type; bad: Py_XDECREF(cached_type); cached_type = NULL; goto done; } /* CommonTypesMetaclass */ static PyObject* __pyx_CommonTypesMetaclass_get_module(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED void* context) { return PyUnicode_FromString(__PYX_ABI_MODULE_NAME); } #if __PYX_LIMITED_VERSION_HEX < 0x030A0000 static PyObject* __pyx_CommonTypesMetaclass_call(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *args, CYTHON_UNUSED PyObject *kwds) { PyErr_SetString(PyExc_TypeError, "Cannot instantiate Cython internal types"); return NULL; } static int __pyx_CommonTypesMetaclass_setattr(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *attr, CYTHON_UNUSED PyObject *value) { PyErr_SetString(PyExc_TypeError, "Cython internal types are immutable"); return -1; } #endif static PyGetSetDef __pyx_CommonTypesMetaclass_getset[] = { {"__module__", __pyx_CommonTypesMetaclass_get_module, NULL, NULL, NULL}, {0, 0, 0, 0, 0} }; static PyType_Slot __pyx_CommonTypesMetaclass_slots[] = { {Py_tp_getset, (void *)__pyx_CommonTypesMetaclass_getset}, #if __PYX_LIMITED_VERSION_HEX < 0x030A0000 {Py_tp_call, (void*)__pyx_CommonTypesMetaclass_call}, {Py_tp_new, (void*)__pyx_CommonTypesMetaclass_call}, {Py_tp_setattro, (void*)__pyx_CommonTypesMetaclass_setattr}, #endif {0, 0} }; static PyType_Spec __pyx_CommonTypesMetaclass_spec = { __PYX_TYPE_MODULE_PREFIX "_common_types_metatype", 0, 0, Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_DEFAULT, __pyx_CommonTypesMetaclass_slots }; static int __pyx_CommonTypesMetaclass_init(PyObject *module) { __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module); PyObject *bases = PyTuple_Pack(1, &PyType_Type); if (unlikely(!bases)) { return -1; } mstate->__pyx_CommonTypesMetaclassType = __Pyx_FetchCommonTypeFromSpec(NULL, module, &__pyx_CommonTypesMetaclass_spec, bases); Py_DECREF(bases); if (unlikely(mstate->__pyx_CommonTypesMetaclassType == NULL)) { return -1; } return 0; } /* PyMethodNew */ #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) { PyObject *result; CYTHON_UNUSED_VAR(typ); if (!self) return __Pyx_NewRef(func); #if __PYX_LIMITED_VERSION_HEX >= 0x030C0000 { PyObject *args[] = {func, self}; result = PyObject_Vectorcall(__pyx_mstate_global->__Pyx_CachedMethodType, args, 2, NULL); } #else result = PyObject_CallFunctionObjArgs(__pyx_mstate_global->__Pyx_CachedMethodType, func, self, NULL); #endif return result; } #else static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) { CYTHON_UNUSED_VAR(typ); if (!self) return __Pyx_NewRef(func); return PyMethod_New(func, self); } #endif /* PyVectorcallFastCallDict */ #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL static PyObject *__Pyx_PyVectorcall_FastCallDict_kw(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw) { PyObject *res = NULL; PyObject *kwnames; PyObject **newargs; PyObject **kwvalues; Py_ssize_t i; #if CYTHON_AVOID_BORROWED_REFS PyObject *pos; #else Py_ssize_t pos; #endif size_t j; PyObject *key, *value; unsigned long keys_are_strings; #if !CYTHON_ASSUME_SAFE_SIZE Py_ssize_t nkw = PyDict_Size(kw); if (unlikely(nkw == -1)) return NULL; #else Py_ssize_t nkw = PyDict_GET_SIZE(kw); #endif newargs = (PyObject **)PyMem_Malloc((nargs + (size_t)nkw) * sizeof(args[0])); if (unlikely(newargs == NULL)) { PyErr_NoMemory(); return NULL; } for (j = 0; j < nargs; j++) newargs[j] = args[j]; kwnames = PyTuple_New(nkw); if (unlikely(kwnames == NULL)) { PyMem_Free(newargs); return NULL; } kwvalues = newargs + nargs; pos = 0; i = 0; keys_are_strings = Py_TPFLAGS_UNICODE_SUBCLASS; while (__Pyx_PyDict_NextRef(kw, &pos, &key, &value)) { keys_are_strings &= #if CYTHON_COMPILING_IN_LIMITED_API PyType_GetFlags(Py_TYPE(key)); #else Py_TYPE(key)->tp_flags; #endif #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely(PyTuple_SetItem(kwnames, i, key) < 0)) goto cleanup; #else PyTuple_SET_ITEM(kwnames, i, key); #endif kwvalues[i] = value; i++; } if (unlikely(!keys_are_strings)) { PyErr_SetString(PyExc_TypeError, "keywords must be strings"); goto cleanup; } res = vc(func, newargs, nargs, kwnames); cleanup: #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(pos); #endif Py_DECREF(kwnames); for (i = 0; i < nkw; i++) Py_DECREF(kwvalues[i]); PyMem_Free(newargs); return res; } static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw) { Py_ssize_t kw_size = likely(kw == NULL) ? 0 : #if !CYTHON_ASSUME_SAFE_SIZE PyDict_Size(kw); #else PyDict_GET_SIZE(kw); #endif if (kw_size == 0) { return vc(func, args, nargs, NULL); } #if !CYTHON_ASSUME_SAFE_SIZE else if (unlikely(kw_size == -1)) { return NULL; } #endif return __Pyx_PyVectorcall_FastCallDict_kw(func, vc, args, nargs, kw); } #endif /* CythonFunctionShared */ #if CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE int __Pyx__IsSameCyOrCFunctionNoMethod(PyObject *func, void (*cfunc)(void)) { if (__Pyx_CyFunction_Check(func)) { return PyCFunction_GetFunction(((__pyx_CyFunctionObject*)func)->func) == (PyCFunction) cfunc; } else if (PyCFunction_Check(func)) { return PyCFunction_GetFunction(func) == (PyCFunction) cfunc; } return 0; } static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) { if ((PyObject*)Py_TYPE(func) == __pyx_mstate_global->__Pyx_CachedMethodType) { int result; PyObject *newFunc = PyObject_GetAttr(func, __pyx_mstate_global->__pyx_n_u_func); if (unlikely(!newFunc)) { PyErr_Clear(); // It's only an optimization, so don't throw an error return 0; } result = __Pyx__IsSameCyOrCFunctionNoMethod(newFunc, cfunc); Py_DECREF(newFunc); return result; } return __Pyx__IsSameCyOrCFunctionNoMethod(func, cfunc); } #else static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) { if (PyMethod_Check(func)) { func = PyMethod_GET_FUNCTION(func); } return __Pyx_CyOrPyCFunction_Check(func) && __Pyx_CyOrPyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; } #endif static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) { #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API __Pyx_Py_XDECREF_SET( __Pyx_CyFunction_GetClassObj(f), ((classobj) ? __Pyx_NewRef(classobj) : NULL)); #else __Pyx_Py_XDECREF_SET( ((PyCMethodObject *) (f))->mm_class, (PyTypeObject*)((classobj) ? __Pyx_NewRef(classobj) : NULL)); #endif } static PyObject * __Pyx_CyFunction_get_doc_locked(__pyx_CyFunctionObject *op) { if (unlikely(op->func_doc == NULL)) { #if CYTHON_COMPILING_IN_LIMITED_API op->func_doc = PyObject_GetAttrString(op->func, "__doc__"); if (unlikely(!op->func_doc)) return NULL; #else if (((PyCFunctionObject*)op)->m_ml->ml_doc) { op->func_doc = PyUnicode_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc); if (unlikely(op->func_doc == NULL)) return NULL; } else { Py_INCREF(Py_None); return Py_None; } #endif } Py_INCREF(op->func_doc); return op->func_doc; } static PyObject * __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, void *closure) { PyObject *result; CYTHON_UNUSED_VAR(closure); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_doc_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); if (value == NULL) { value = Py_None; } Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->func_doc, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_name_locked(__pyx_CyFunctionObject *op) { if (unlikely(op->func_name == NULL)) { #if CYTHON_COMPILING_IN_LIMITED_API op->func_name = PyObject_GetAttrString(op->func, "__name__"); #else op->func_name = PyUnicode_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name); #endif if (unlikely(op->func_name == NULL)) return NULL; } Py_INCREF(op->func_name); return op->func_name; } static PyObject * __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, void *context) { PyObject *result = NULL; CYTHON_UNUSED_VAR(context); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_name_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(value == NULL || !PyUnicode_Check(value))) { PyErr_SetString(PyExc_TypeError, "__name__ must be set to a string object"); return -1; } Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->func_name, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); PyObject *result; __Pyx_BEGIN_CRITICAL_SECTION(op); Py_INCREF(op->func_qualname); result = op->func_qualname; __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(value == NULL || !PyUnicode_Check(value))) { PyErr_SetString(PyExc_TypeError, "__qualname__ must be set to a string object"); return -1; } Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->func_qualname, value); __Pyx_END_CRITICAL_SECTION(); return 0; } #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 static PyObject * __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(op->func_dict == NULL)) { op->func_dict = PyDict_New(); if (unlikely(op->func_dict == NULL)) return NULL; } Py_INCREF(op->func_dict); return op->func_dict; } #endif static PyObject * __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); Py_INCREF(op->func_globals); return op->func_globals; } static PyObject * __Pyx_CyFunction_get_closure(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(op); CYTHON_UNUSED_VAR(context); Py_INCREF(Py_None); return Py_None; } static PyObject * __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, void *context) { PyObject* result = (op->func_code) ? op->func_code : Py_None; CYTHON_UNUSED_VAR(context); Py_INCREF(result); return result; } static int __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { int result = 0; PyObject *res = op->defaults_getter((PyObject *) op); if (unlikely(!res)) return -1; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS op->defaults_tuple = PyTuple_GET_ITEM(res, 0); Py_INCREF(op->defaults_tuple); op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); Py_INCREF(op->defaults_kwdict); #else op->defaults_tuple = __Pyx_PySequence_ITEM(res, 0); if (unlikely(!op->defaults_tuple)) result = -1; else { op->defaults_kwdict = __Pyx_PySequence_ITEM(res, 1); if (unlikely(!op->defaults_kwdict)) result = -1; } #endif Py_DECREF(res); return result; } static int __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value) { value = Py_None; } else if (unlikely(value != Py_None && !PyTuple_Check(value))) { PyErr_SetString(PyExc_TypeError, "__defaults__ must be set to a tuple object"); return -1; } PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__defaults__ will not " "currently affect the values used in function calls", 1); Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->defaults_tuple, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_defaults_locked(__pyx_CyFunctionObject *op) { PyObject* result = op->defaults_tuple; if (unlikely(!result)) { if (op->defaults_getter) { if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL; result = op->defaults_tuple; } else { result = Py_None; } } Py_INCREF(result); return result; } static PyObject * __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, void *context) { PyObject* result = NULL; CYTHON_UNUSED_VAR(context); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_defaults_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value) { value = Py_None; } else if (unlikely(value != Py_None && !PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "__kwdefaults__ must be set to a dict object"); return -1; } PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__kwdefaults__ will not " "currently affect the values used in function calls", 1); Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->defaults_kwdict, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_kwdefaults_locked(__pyx_CyFunctionObject *op) { PyObject* result = op->defaults_kwdict; if (unlikely(!result)) { if (op->defaults_getter) { if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL; result = op->defaults_kwdict; } else { result = Py_None; } } Py_INCREF(result); return result; } static PyObject * __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, void *context) { PyObject* result; CYTHON_UNUSED_VAR(context); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_kwdefaults_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value || value == Py_None) { value = NULL; } else if (unlikely(!PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "__annotations__ must be set to a dict object"); return -1; } Py_XINCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->func_annotations, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_annotations_locked(__pyx_CyFunctionObject *op) { PyObject* result = op->func_annotations; if (unlikely(!result)) { result = PyDict_New(); if (unlikely(!result)) return NULL; op->func_annotations = result; } Py_INCREF(result); return result; } static PyObject * __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, void *context) { PyObject *result; CYTHON_UNUSED_VAR(context); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_annotations_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static PyObject * __Pyx_CyFunction_get_is_coroutine_value(__pyx_CyFunctionObject *op) { int is_coroutine = op->flags & __Pyx_CYFUNCTION_COROUTINE; if (is_coroutine) { PyObject *is_coroutine_value, *module, *fromlist, *marker = __pyx_mstate_global->__pyx_n_u_is_coroutine; fromlist = PyList_New(1); if (unlikely(!fromlist)) return NULL; Py_INCREF(marker); #if CYTHON_ASSUME_SAFE_MACROS PyList_SET_ITEM(fromlist, 0, marker); #else if (unlikely(PyList_SetItem(fromlist, 0, marker) < 0)) { Py_DECREF(marker); Py_DECREF(fromlist); return NULL; } #endif module = PyImport_ImportModuleLevelObject(__pyx_mstate_global->__pyx_n_u_asyncio_coroutines, NULL, NULL, fromlist, 0); Py_DECREF(fromlist); if (unlikely(!module)) goto ignore; is_coroutine_value = __Pyx_PyObject_GetAttrStr(module, marker); Py_DECREF(module); if (likely(is_coroutine_value)) { return is_coroutine_value; } ignore: PyErr_Clear(); } return __Pyx_PyBool_FromLong(is_coroutine); } static PyObject * __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) { PyObject *result; CYTHON_UNUSED_VAR(context); if (op->func_is_coroutine) { return __Pyx_NewRef(op->func_is_coroutine); } result = __Pyx_CyFunction_get_is_coroutine_value(op); if (unlikely(!result)) return NULL; __Pyx_BEGIN_CRITICAL_SECTION(op); if (op->func_is_coroutine) { Py_DECREF(result); result = __Pyx_NewRef(op->func_is_coroutine); } else { op->func_is_coroutine = __Pyx_NewRef(result); } __Pyx_END_CRITICAL_SECTION(); return result; } static void __Pyx_CyFunction_raise_argument_count_error(__pyx_CyFunctionObject *func, const char* message, Py_ssize_t size) { #if CYTHON_COMPILING_IN_LIMITED_API PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL); if (!py_name) return; PyErr_Format(PyExc_TypeError, "%.200S() %s (%" CYTHON_FORMAT_SSIZE_T "d given)", py_name, message, size); Py_DECREF(py_name); #else const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name; PyErr_Format(PyExc_TypeError, "%.200s() %s (%" CYTHON_FORMAT_SSIZE_T "d given)", name, message, size); #endif } static void __Pyx_CyFunction_raise_type_error(__pyx_CyFunctionObject *func, const char* message) { #if CYTHON_COMPILING_IN_LIMITED_API PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL); if (!py_name) return; PyErr_Format(PyExc_TypeError, "%.200S() %s", py_name, message); Py_DECREF(py_name); #else const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name; PyErr_Format(PyExc_TypeError, "%.200s() %s", name, message); #endif } #if CYTHON_COMPILING_IN_LIMITED_API static PyObject * __Pyx_CyFunction_get_module(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); return PyObject_GetAttrString(op->func, "__module__"); } static int __Pyx_CyFunction_set_module(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); return PyObject_SetAttrString(op->func, "__module__", value); } #endif static PyGetSetDef __pyx_CyFunction_getsets[] = { {"func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {"__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {"func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {"__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {"__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 {"func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0}, {"__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0}, #else {"func_dict", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0}, {"__dict__", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0}, #endif {"func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {"__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {"func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {"__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {"func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {"__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {"func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {"__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {"__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, {"__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, {"_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0}, #if CYTHON_COMPILING_IN_LIMITED_API {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0}, #endif {0, 0, 0, 0, 0} }; static PyMemberDef __pyx_CyFunction_members[] = { #if !CYTHON_COMPILING_IN_LIMITED_API {"__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0}, #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API {"__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict), READONLY, 0}, #endif #if CYTHON_METH_FASTCALL #if CYTHON_COMPILING_IN_LIMITED_API {"__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall), READONLY, 0}, #else {"__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0}, #endif #if CYTHON_COMPILING_IN_LIMITED_API {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist), READONLY, 0}, #else {"__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0}, #endif #endif {0, 0, 0, 0, 0} }; static PyObject * __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, PyObject *args) { PyObject *result = NULL; CYTHON_UNUSED_VAR(args); __Pyx_BEGIN_CRITICAL_SECTION(m); Py_INCREF(m->func_qualname); result = m->func_qualname; __Pyx_END_CRITICAL_SECTION(); return result; } static PyMethodDef __pyx_CyFunction_methods[] = { {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, {0, 0, 0, 0} }; #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) #else #define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist) #endif static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { #if !CYTHON_COMPILING_IN_LIMITED_API PyCFunctionObject *cf = (PyCFunctionObject*) op; #endif if (unlikely(op == NULL)) return NULL; #if CYTHON_COMPILING_IN_LIMITED_API op->func = PyCFunction_NewEx(ml, (PyObject*)op, module); if (unlikely(!op->func)) return NULL; #endif op->flags = flags; __Pyx_CyFunction_weakreflist(op) = NULL; #if !CYTHON_COMPILING_IN_LIMITED_API cf->m_ml = ml; cf->m_self = (PyObject *) op; #endif Py_XINCREF(closure); op->func_closure = closure; #if !CYTHON_COMPILING_IN_LIMITED_API Py_XINCREF(module); cf->m_module = module; #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API op->func_dict = NULL; #endif op->func_name = NULL; Py_INCREF(qualname); op->func_qualname = qualname; op->func_doc = NULL; #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API op->func_classobj = NULL; #else ((PyCMethodObject*)op)->mm_class = NULL; #endif op->func_globals = globals; Py_INCREF(op->func_globals); Py_XINCREF(code); op->func_code = code; op->defaults = NULL; op->defaults_tuple = NULL; op->defaults_kwdict = NULL; op->defaults_getter = NULL; op->func_annotations = NULL; op->func_is_coroutine = NULL; #if CYTHON_METH_FASTCALL switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) { case METH_NOARGS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_NOARGS; break; case METH_O: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_O; break; case METH_METHOD | METH_FASTCALL | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD; break; case METH_FASTCALL | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS; break; case METH_VARARGS | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = NULL; break; default: PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction"); Py_DECREF(op); return NULL; } #endif return (PyObject *) op; } static int __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) { Py_CLEAR(m->func_closure); #if CYTHON_COMPILING_IN_LIMITED_API Py_CLEAR(m->func); #else Py_CLEAR(((PyCFunctionObject*)m)->m_module); #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API Py_CLEAR(m->func_dict); #elif PY_VERSION_HEX < 0x030d0000 _PyObject_ClearManagedDict((PyObject*)m); #else PyObject_ClearManagedDict((PyObject*)m); #endif Py_CLEAR(m->func_name); Py_CLEAR(m->func_qualname); Py_CLEAR(m->func_doc); Py_CLEAR(m->func_globals); Py_CLEAR(m->func_code); #if !CYTHON_COMPILING_IN_LIMITED_API #if PY_VERSION_HEX < 0x030900B1 Py_CLEAR(__Pyx_CyFunction_GetClassObj(m)); #else { PyObject *cls = (PyObject*) ((PyCMethodObject *) (m))->mm_class; ((PyCMethodObject *) (m))->mm_class = NULL; Py_XDECREF(cls); } #endif #endif Py_CLEAR(m->defaults_tuple); Py_CLEAR(m->defaults_kwdict); Py_CLEAR(m->func_annotations); Py_CLEAR(m->func_is_coroutine); Py_CLEAR(m->defaults); return 0; } static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m) { if (__Pyx_CyFunction_weakreflist(m) != NULL) PyObject_ClearWeakRefs((PyObject *) m); __Pyx_CyFunction_clear(m); __Pyx_PyHeapTypeObject_GC_Del(m); } static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) { PyObject_GC_UnTrack(m); __Pyx__CyFunction_dealloc(m); } static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) { { int e = __Pyx_call_type_traverse((PyObject*)m, 1, visit, arg); if (e) return e; } Py_VISIT(m->func_closure); #if CYTHON_COMPILING_IN_LIMITED_API Py_VISIT(m->func); #else Py_VISIT(((PyCFunctionObject*)m)->m_module); #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API Py_VISIT(m->func_dict); #else { int e = #if PY_VERSION_HEX < 0x030d0000 _PyObject_VisitManagedDict #else PyObject_VisitManagedDict #endif ((PyObject*)m, visit, arg); if (e != 0) return e; } #endif __Pyx_VISIT_CONST(m->func_name); __Pyx_VISIT_CONST(m->func_qualname); Py_VISIT(m->func_doc); Py_VISIT(m->func_globals); __Pyx_VISIT_CONST(m->func_code); #if !CYTHON_COMPILING_IN_LIMITED_API Py_VISIT(__Pyx_CyFunction_GetClassObj(m)); #endif Py_VISIT(m->defaults_tuple); Py_VISIT(m->defaults_kwdict); Py_VISIT(m->func_is_coroutine); Py_VISIT(m->defaults); return 0; } static PyObject* __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) { PyObject *repr; __Pyx_BEGIN_CRITICAL_SECTION(op); repr = PyUnicode_FromFormat("", op->func_qualname, (void *)op); __Pyx_END_CRITICAL_SECTION(); return repr; } static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { #if CYTHON_COMPILING_IN_LIMITED_API PyObject *f = ((__pyx_CyFunctionObject*)func)->func; PyCFunction meth; int flags; meth = PyCFunction_GetFunction(f); if (unlikely(!meth)) return NULL; flags = PyCFunction_GetFlags(f); if (unlikely(flags < 0)) return NULL; #else PyCFunctionObject* f = (PyCFunctionObject*)func; PyCFunction meth = f->m_ml->ml_meth; int flags = f->m_ml->ml_flags; #endif Py_ssize_t size; switch (flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { case METH_VARARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) return (*meth)(self, arg); break; case METH_VARARGS | METH_KEYWORDS: return (*(PyCFunctionWithKeywords)(void(*)(void))meth)(self, arg, kw); case METH_NOARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { #if CYTHON_ASSUME_SAFE_SIZE size = PyTuple_GET_SIZE(arg); #else size = PyTuple_Size(arg); if (unlikely(size < 0)) return NULL; #endif if (likely(size == 0)) return (*meth)(self, NULL); __Pyx_CyFunction_raise_argument_count_error( (__pyx_CyFunctionObject*)func, "takes no arguments", size); return NULL; } break; case METH_O: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { #if CYTHON_ASSUME_SAFE_SIZE size = PyTuple_GET_SIZE(arg); #else size = PyTuple_Size(arg); if (unlikely(size < 0)) return NULL; #endif if (likely(size == 1)) { PyObject *result, *arg0; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS arg0 = PyTuple_GET_ITEM(arg, 0); #else arg0 = __Pyx_PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; #endif result = (*meth)(self, arg0); #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) Py_DECREF(arg0); #endif return result; } __Pyx_CyFunction_raise_argument_count_error( (__pyx_CyFunctionObject*)func, "takes exactly one argument", size); return NULL; } break; default: PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction"); return NULL; } __Pyx_CyFunction_raise_type_error( (__pyx_CyFunctionObject*)func, "takes no keyword arguments"); return NULL; } static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *self, *result; #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)func)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)func)->m_self; #endif result = __Pyx_CyFunction_CallMethod(func, self, arg, kw); return result; } static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { PyObject *result; __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc); if (vc) { #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw); #else (void) &__Pyx_PyVectorcall_FastCallDict; return PyVectorcall_Call(func, args, kw); #endif } #endif if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { Py_ssize_t argc; PyObject *new_args; PyObject *self; #if CYTHON_ASSUME_SAFE_SIZE argc = PyTuple_GET_SIZE(args); #else argc = PyTuple_Size(args); if (unlikely(argc < 0)) return NULL; #endif new_args = PyTuple_GetSlice(args, 1, argc); if (unlikely(!new_args)) return NULL; self = PyTuple_GetItem(args, 0); if (unlikely(!self)) { Py_DECREF(new_args); PyErr_Format(PyExc_TypeError, "unbound method %.200S() needs an argument", cyfunc->func_qualname); return NULL; } result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); Py_DECREF(new_args); } else { result = __Pyx_CyFunction_Call(func, args, kw); } return result; } #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(__pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames) { int ret = 0; if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { if (unlikely(nargs < 1)) { __Pyx_CyFunction_raise_type_error( cyfunc, "needs an argument"); return -1; } ret = 1; } if (unlikely(kwnames) && unlikely(__Pyx_PyTuple_GET_SIZE(kwnames))) { __Pyx_CyFunction_raise_type_error( cyfunc, "takes no keyword arguments"); return -1; } return ret; } static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); PyObject *self; #if CYTHON_COMPILING_IN_LIMITED_API PyCFunction meth = PyCFunction_GetFunction(cyfunc->func); if (unlikely(!meth)) return NULL; #else PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth; #endif switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)cyfunc)->m_self; #endif break; default: return NULL; } if (unlikely(nargs != 0)) { __Pyx_CyFunction_raise_argument_count_error( cyfunc, "takes no arguments", nargs); return NULL; } return meth(self, NULL); } static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); PyObject *self; #if CYTHON_COMPILING_IN_LIMITED_API PyCFunction meth = PyCFunction_GetFunction(cyfunc->func); if (unlikely(!meth)) return NULL; #else PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth; #endif switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)cyfunc)->m_self; #endif break; default: return NULL; } if (unlikely(nargs != 1)) { __Pyx_CyFunction_raise_argument_count_error( cyfunc, "takes exactly one argument", nargs); return NULL; } return meth(self, args[0]); } static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); PyObject *self; #if CYTHON_COMPILING_IN_LIMITED_API PyCFunction meth = PyCFunction_GetFunction(cyfunc->func); if (unlikely(!meth)) return NULL; #else PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth; #endif switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)cyfunc)->m_self; #endif break; default: return NULL; } return ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))meth)(self, args, nargs, kwnames); } static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; PyTypeObject *cls = (PyTypeObject *) __Pyx_CyFunction_GetClassObj(cyfunc); Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); PyObject *self; #if CYTHON_COMPILING_IN_LIMITED_API PyCFunction meth = PyCFunction_GetFunction(cyfunc->func); if (unlikely(!meth)) return NULL; #else PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth; #endif switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)cyfunc)->m_self; #endif break; default: return NULL; } #if PY_VERSION_HEX < 0x030e00A6 size_t nargs_value = (size_t) nargs; #else Py_ssize_t nargs_value = nargs; #endif return ((__Pyx_PyCMethod)(void(*)(void))meth)(self, cls, args, nargs_value, kwnames); } #endif static PyType_Slot __pyx_CyFunctionType_slots[] = { {Py_tp_dealloc, (void *)__Pyx_CyFunction_dealloc}, {Py_tp_repr, (void *)__Pyx_CyFunction_repr}, {Py_tp_call, (void *)__Pyx_CyFunction_CallAsMethod}, {Py_tp_traverse, (void *)__Pyx_CyFunction_traverse}, {Py_tp_clear, (void *)__Pyx_CyFunction_clear}, {Py_tp_methods, (void *)__pyx_CyFunction_methods}, {Py_tp_members, (void *)__pyx_CyFunction_members}, {Py_tp_getset, (void *)__pyx_CyFunction_getsets}, {Py_tp_descr_get, (void *)__Pyx_PyMethod_New}, {0, 0}, }; static PyType_Spec __pyx_CyFunctionType_spec = { __PYX_TYPE_MODULE_PREFIX "cython_function_or_method", sizeof(__pyx_CyFunctionObject), 0, #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR Py_TPFLAGS_METHOD_DESCRIPTOR | #endif #if CYTHON_METH_FASTCALL #if defined(Py_TPFLAGS_HAVE_VECTORCALL) Py_TPFLAGS_HAVE_VECTORCALL | #elif defined(_Py_TPFLAGS_HAVE_VECTORCALL) _Py_TPFLAGS_HAVE_VECTORCALL | #endif #endif // CYTHON_METH_FASTCALL #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API Py_TPFLAGS_MANAGED_DICT | #endif Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, __pyx_CyFunctionType_slots }; static int __pyx_CyFunction_init(PyObject *module) { __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module); mstate->__pyx_CyFunctionType = __Pyx_FetchCommonTypeFromSpec( mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_CyFunctionType_spec, NULL); if (unlikely(mstate->__pyx_CyFunctionType == NULL)) { return -1; } return 0; } static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults = PyObject_CallObject((PyObject*)defaults_type, NULL); // _PyObject_New(defaults_type); if (unlikely(!m->defaults)) return NULL; return m->defaults; } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_tuple = tuple; Py_INCREF(tuple); } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_kwdict = dict; Py_INCREF(dict); } static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->func_annotations = dict; Py_INCREF(dict); } /* CythonFunction */ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { PyObject *op = __Pyx_CyFunction_Init( PyObject_GC_New(__pyx_CyFunctionObject, __pyx_mstate_global->__pyx_CyFunctionType), ml, flags, qualname, closure, module, globals, code ); if (likely(op)) { PyObject_GC_Track(op); } return op; } /* CLineInTraceback */ #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 #define __Pyx_PyProbablyModule_GetDict(o) __Pyx_XNewRef(PyModule_GetDict(o)) #elif !CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #define __Pyx_PyProbablyModule_GetDict(o) PyObject_GenericGetDict(o, NULL); #else PyObject* __Pyx_PyProbablyModule_GetDict(PyObject *o) { PyObject **dict_ptr = _PyObject_GetDictPtr(o); return dict_ptr ? __Pyx_XNewRef(*dict_ptr) : NULL; } #endif static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) { PyObject *use_cline = NULL; PyObject *ptype, *pvalue, *ptraceback; PyObject *cython_runtime_dict; CYTHON_MAYBE_UNUSED_VAR(tstate); if (unlikely(!__pyx_mstate_global->__pyx_cython_runtime)) { return c_line; } __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); cython_runtime_dict = __Pyx_PyProbablyModule_GetDict(__pyx_mstate_global->__pyx_cython_runtime); if (likely(cython_runtime_dict)) { __PYX_PY_DICT_LOOKUP_IF_MODIFIED( use_cline, cython_runtime_dict, __Pyx_PyDict_SetDefault(cython_runtime_dict, __pyx_mstate_global->__pyx_n_u_cline_in_traceback, Py_False)) } if (use_cline == NULL || use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { c_line = 0; } Py_XDECREF(use_cline); Py_XDECREF(cython_runtime_dict); __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); return c_line; } #endif /* CodeObjectCache */ static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static __Pyx_CachedCodeObjectType *__pyx__find_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line) { __Pyx_CachedCodeObjectType* code_object; int pos; if (unlikely(!code_line) || unlikely(!code_cache->entries)) { return NULL; } pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line); if (unlikely(pos >= code_cache->count) || unlikely(code_cache->entries[pos].code_line != code_line)) { return NULL; } code_object = code_cache->entries[pos].code_object; Py_INCREF(code_object); return code_object; } static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS (void)__pyx__find_code_object; return NULL; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just miss. #else struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_nonatomic_int_type old_count = __pyx_atomic_incr_acq_rel(&code_cache->accessor_count); if (old_count < 0) { __pyx_atomic_decr_acq_rel(&code_cache->accessor_count); return NULL; } #endif __Pyx_CachedCodeObjectType *result = __pyx__find_code_object(code_cache, code_line); #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_atomic_decr_acq_rel(&code_cache->accessor_count); #endif return result; #endif } static void __pyx__insert_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line, __Pyx_CachedCodeObjectType* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = code_cache->entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { code_cache->entries = entries; code_cache->max_count = 64; code_cache->count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line); if ((pos < code_cache->count) && unlikely(code_cache->entries[pos].code_line == code_line)) { __Pyx_CachedCodeObjectType* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_INCREF(code_object); Py_DECREF(tmp); return; } if (code_cache->count == code_cache->max_count) { int new_max = code_cache->max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( code_cache->entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } code_cache->entries = entries; code_cache->max_count = new_max; } for (i=code_cache->count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; code_cache->count++; Py_INCREF(code_object); } static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS (void)__pyx__insert_code_object; return; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just fail. #else struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_nonatomic_int_type expected = 0; if (!__pyx_atomic_int_cmp_exchange(&code_cache->accessor_count, &expected, INT_MIN)) { return; } #endif __pyx__insert_code_object(code_cache, code_line, code_object); #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_atomic_sub(&code_cache->accessor_count, INT_MIN); #endif #endif } /* AddTraceback */ #include "compile.h" #include "frameobject.h" #include "traceback.h" #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION) #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif #include "internal/pycore_frame.h" #endif #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict, PyObject *firstlineno, PyObject *name) { PyObject *replace = NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL; replace = PyObject_GetAttrString(code, "replace"); if (likely(replace)) { PyObject *result = PyObject_Call(replace, __pyx_mstate_global->__pyx_empty_tuple, scratch_dict); Py_DECREF(replace); return result; } PyErr_Clear(); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL; PyObject *replace = NULL, *getframe = NULL, *frame = NULL; PyObject *exc_type, *exc_value, *exc_traceback; int success = 0; if (c_line) { c_line = __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line); } PyErr_Fetch(&exc_type, &exc_value, &exc_traceback); code_object = __pyx_find_code_object(c_line ? -c_line : py_line); if (!code_object) { code_object = Py_CompileString("_getframe()", filename, Py_eval_input); if (unlikely(!code_object)) goto bad; py_py_line = PyLong_FromLong(py_line); if (unlikely(!py_py_line)) goto bad; if (c_line) { py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); } else { py_funcname = PyUnicode_FromString(funcname); } if (unlikely(!py_funcname)) goto bad; dict = PyDict_New(); if (unlikely(!dict)) goto bad; { PyObject *old_code_object = code_object; code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname); Py_DECREF(old_code_object); } if (unlikely(!code_object)) goto bad; __pyx_insert_code_object(c_line ? -c_line : py_line, code_object); } else { dict = PyDict_New(); } getframe = PySys_GetObject("_getframe"); if (unlikely(!getframe)) goto bad; if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad; frame = PyEval_EvalCode(code_object, dict, dict); if (unlikely(!frame) || frame == Py_None) goto bad; success = 1; bad: PyErr_Restore(exc_type, exc_value, exc_traceback); Py_XDECREF(code_object); Py_XDECREF(py_py_line); Py_XDECREF(py_funcname); Py_XDECREF(dict); Py_XDECREF(replace); if (success) { PyTraceBack_Here( (struct _frame*)frame); } Py_XDECREF(frame); } #else static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = NULL; PyObject *py_funcname = NULL; if (c_line) { py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); if (!py_funcname) goto bad; funcname = PyUnicode_AsUTF8(py_funcname); if (!funcname) goto bad; } py_code = PyCode_NewEmpty(filename, funcname, py_line); Py_XDECREF(py_funcname); return py_code; bad: Py_XDECREF(py_funcname); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject *ptype, *pvalue, *ptraceback; if (c_line) { c_line = __Pyx_CLineForTraceback(tstate, c_line); } py_code = __pyx_find_code_object(c_line ? -c_line : py_line); if (!py_code) { __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) { /* If the code object creation fails, then we should clear the fetched exception references and propagate the new exception */ Py_XDECREF(ptype); Py_XDECREF(pvalue); Py_XDECREF(ptraceback); goto bad; } __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); } py_frame = PyFrame_New( tstate, /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_mstate_global->__pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } #endif /* CIntFromPyVerify */ #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } /* CheckUnpickleChecksum */ static void __Pyx_RaiseUnpickleChecksumError(long checksum, long checksum1, long checksum2, long checksum3, const char *members) { PyObject *pickle_module = PyImport_ImportModule("pickle"); if (unlikely(!pickle_module)) return; PyObject *pickle_error = PyObject_GetAttrString(pickle_module, "PickleError"); Py_DECREF(pickle_module); if (unlikely(!pickle_error)) return; if (checksum2 == checksum1) { PyErr_Format(pickle_error, "Incompatible checksums (0x%x vs (0x%x) = (%s))", checksum, checksum1, members); } else if (checksum3 == checksum2) { PyErr_Format(pickle_error, "Incompatible checksums (0x%x vs (0x%x, 0x%x) = (%s))", checksum, checksum1, checksum2, members); } else { PyErr_Format(pickle_error, "Incompatible checksums (0x%x vs (0x%x, 0x%x, 0x%x) = (%s))", checksum, checksum1, checksum2, checksum3, members); } Py_DECREF(pickle_error); } static int __Pyx_CheckUnpickleChecksum(long checksum, long checksum1, long checksum2, long checksum3, const char *members) { int found = 0; found |= checksum1 == checksum; found |= checksum2 == checksum; found |= checksum3 == checksum; if (likely(found)) return 0; __Pyx_RaiseUnpickleChecksumError(checksum, checksum1, checksum2, checksum3, members); return -1; } /* PyObjectVectorCallKwBuilder */ #if CYTHON_VECTORCALL static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) { (void)__Pyx_PyObject_FastCallDict; if (__Pyx_PyTuple_SET_ITEM(builder, n, key) != (0)) return -1; Py_INCREF(key); args[n] = value; return 0; } CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) { (void)__Pyx_VectorcallBuilder_AddArgStr; if (unlikely(!PyUnicode_Check(key))) { PyErr_SetString(PyExc_TypeError, "keywords must be strings"); return -1; } return __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n); } static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n) { PyObject *pyKey = PyUnicode_FromString(key); if (!pyKey) return -1; return __Pyx_VectorcallBuilder_AddArg(pyKey, value, builder, args, n); } #else // CYTHON_VECTORCALL CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, CYTHON_UNUSED PyObject **args, CYTHON_UNUSED int n) { if (unlikely(!PyUnicode_Check(key))) { PyErr_SetString(PyExc_TypeError, "keywords must be strings"); return -1; } return PyDict_SetItem(builder, key, value); } #endif /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) -1, const_zero = (unsigned PY_LONG_LONG) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(unsigned PY_LONG_LONG) < sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #if !CYTHON_COMPILING_IN_PYPY } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(unsigned PY_LONG_LONG) <= sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4 if (is_unsigned) { return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1); } else { return PyLong_FromNativeBytes(bytes, sizeof(value), -1); } #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 int one = 1; int little = (int)*(unsigned char *)&one; return _PyLong_FromByteArray(bytes, sizeof(unsigned PY_LONG_LONG), little, !is_unsigned); #else int one = 1; int little = (int)*(unsigned char *)&one; PyObject *from_bytes, *result = NULL, *kwds = NULL; PyObject *py_bytes = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(unsigned PY_LONG_LONG)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; { PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str }; if (!is_unsigned) { kwds = __Pyx_MakeVectorcallBuilderKwds(1); if (!kwds) goto limited_bad; if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad; } result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds); } limited_bad: Py_XDECREF(kwds); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* CIntFromPy */ static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyLong_As_unsigned_PY_LONG_LONG(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) -1, const_zero = (unsigned PY_LONG_LONG) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (unlikely(!PyLong_Check(x))) { unsigned PY_LONG_LONG val; PyObject *tmp = __Pyx_PyNumber_Long(x); if (!tmp) return (unsigned PY_LONG_LONG) -1; val = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(tmp); Py_DECREF(tmp); return val; } if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) >= 2 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); } } break; case 3: if ((8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) >= 3 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); } } break; case 4: if ((8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) >= 4 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (unsigned PY_LONG_LONG) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned long, PyLong_AsUnsignedLong(x)) } else if ((sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case 2: if ((8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) ((((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case -3: if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case 3: if ((8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) ((((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case -4: if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case 4: if ((8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) ((((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; } } #endif if ((sizeof(unsigned PY_LONG_LONG) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, long, PyLong_AsLong(x)) } else if ((sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { unsigned PY_LONG_LONG val; int ret = -1; #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API Py_ssize_t bytes_copied = PyLong_AsNativeBytes( x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0)); if (unlikely(bytes_copied == -1)) { } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) { goto raise_overflow; } else { ret = 0; } #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)x, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *v; PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (likely(PyLong_CheckExact(x))) { v = __Pyx_NewRef(x); } else { v = PyNumber_Long(x); if (unlikely(!v)) return (unsigned PY_LONG_LONG) -1; assert(PyLong_CheckExact(v)); } { int result = PyObject_RichCompareBool(v, Py_False, Py_LT); if (unlikely(result < 0)) { Py_DECREF(v); return (unsigned PY_LONG_LONG) -1; } is_negative = result == 1; } if (is_unsigned && unlikely(is_negative)) { Py_DECREF(v); goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); Py_DECREF(v); if (unlikely(!stepval)) return (unsigned PY_LONG_LONG) -1; } else { stepval = v; } v = NULL; val = (unsigned PY_LONG_LONG) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(unsigned PY_LONG_LONG) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; long idigit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; val |= ((unsigned PY_LONG_LONG) idigit) << bits; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; } Py_DECREF(shift); shift = NULL; Py_DECREF(mask); mask = NULL; { long idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(unsigned PY_LONG_LONG) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((unsigned PY_LONG_LONG) idigit) << bits; } if (!is_unsigned) { if (unlikely(val & (((unsigned PY_LONG_LONG) 1) << (sizeof(unsigned PY_LONG_LONG) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif if (unlikely(ret)) return (unsigned PY_LONG_LONG) -1; return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned PY_LONG_LONG"); return (unsigned PY_LONG_LONG) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to unsigned PY_LONG_LONG"); return (unsigned PY_LONG_LONG) -1; } /* CIntFromPy */ static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (unlikely(!PyLong_Check(x))) { long val; PyObject *tmp = __Pyx_PyNumber_Long(x); if (!tmp) return (long) -1; val = __Pyx_PyLong_As_long(tmp); Py_DECREF(tmp); return val; } if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(long) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } } #endif if ((sizeof(long) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { long val; int ret = -1; #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API Py_ssize_t bytes_copied = PyLong_AsNativeBytes( x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0)); if (unlikely(bytes_copied == -1)) { } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) { goto raise_overflow; } else { ret = 0; } #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)x, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *v; PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (likely(PyLong_CheckExact(x))) { v = __Pyx_NewRef(x); } else { v = PyNumber_Long(x); if (unlikely(!v)) return (long) -1; assert(PyLong_CheckExact(v)); } { int result = PyObject_RichCompareBool(v, Py_False, Py_LT); if (unlikely(result < 0)) { Py_DECREF(v); return (long) -1; } is_negative = result == 1; } if (is_unsigned && unlikely(is_negative)) { Py_DECREF(v); goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); Py_DECREF(v); if (unlikely(!stepval)) return (long) -1; } else { stepval = v; } v = NULL; val = (long) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; long idigit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; val |= ((long) idigit) << bits; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; } Py_DECREF(shift); shift = NULL; Py_DECREF(mask); mask = NULL; { long idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((long) idigit) << bits; } if (!is_unsigned) { if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif if (unlikely(ret)) return (long) -1; return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_unsigned_char(unsigned char value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const unsigned char neg_one = (unsigned char) -1, const_zero = (unsigned char) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(unsigned char) < sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(unsigned char) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #if !CYTHON_COMPILING_IN_PYPY } else if (sizeof(unsigned char) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(unsigned char) <= sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(unsigned char) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4 if (is_unsigned) { return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1); } else { return PyLong_FromNativeBytes(bytes, sizeof(value), -1); } #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 int one = 1; int little = (int)*(unsigned char *)&one; return _PyLong_FromByteArray(bytes, sizeof(unsigned char), little, !is_unsigned); #else int one = 1; int little = (int)*(unsigned char *)&one; PyObject *from_bytes, *result = NULL, *kwds = NULL; PyObject *py_bytes = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(unsigned char)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; { PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str }; if (!is_unsigned) { kwds = __Pyx_MakeVectorcallBuilderKwds(1); if (!kwds) goto limited_bad; if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad; } result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds); } limited_bad: Py_XDECREF(kwds); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #if !CYTHON_COMPILING_IN_PYPY } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(long) <= sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4 if (is_unsigned) { return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1); } else { return PyLong_FromNativeBytes(bytes, sizeof(value), -1); } #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 int one = 1; int little = (int)*(unsigned char *)&one; return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); #else int one = 1; int little = (int)*(unsigned char *)&one; PyObject *from_bytes, *result = NULL, *kwds = NULL; PyObject *py_bytes = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(long)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; { PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str }; if (!is_unsigned) { kwds = __Pyx_MakeVectorcallBuilderKwds(1); if (!kwds) goto limited_bad; if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad; } result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds); } limited_bad: Py_XDECREF(kwds); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* PyObjectCall2Args */ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { PyObject *args[3] = {NULL, arg1, arg2}; return __Pyx_PyObject_FastCall(function, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } /* PyObjectCallMethod1 */ #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))) static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) { PyObject *result = __Pyx_PyObject_CallOneArg(method, arg); Py_DECREF(method); return result; } #endif static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)) PyObject *args[2] = {obj, arg}; (void) __Pyx_PyObject_CallOneArg; (void) __Pyx_PyObject_Call2Args; return PyObject_VectorcallMethod(method_name, args, 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); #else PyObject *method = NULL, *result; int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); if (likely(is_method)) { result = __Pyx_PyObject_Call2Args(method, obj, arg); Py_DECREF(method); return result; } if (unlikely(!method)) return NULL; return __Pyx__PyObject_CallMethod1(method, arg); #endif } /* UpdateUnpickledDict */ static int __Pyx__UpdateUnpickledDict(PyObject *obj, PyObject *state, Py_ssize_t index) { PyObject *state_dict = __Pyx_PySequence_ITEM(state, index); if (unlikely(!state_dict)) { return -1; } int non_empty = PyObject_IsTrue(state_dict); if (non_empty == 0) { Py_DECREF(state_dict); return 0; } else if (unlikely(non_empty == -1)) { return -1; } PyObject *dict; #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 dict = PyObject_GetAttrString(obj, "__dict__"); #else dict = PyObject_GenericGetDict(obj, NULL); #endif if (unlikely(!dict)) { Py_DECREF(state_dict); return -1; } int result; if (likely(PyDict_CheckExact(dict))) { result = PyDict_Update(dict, state_dict); } else { PyObject *obj_result = __Pyx_PyObject_CallMethod1(dict, __pyx_mstate_global->__pyx_n_u_update, state_dict); if (likely(obj_result)) { Py_DECREF(obj_result); result = 0; } else { result = -1; } } Py_DECREF(state_dict); Py_DECREF(dict); return result; } static int __Pyx_UpdateUnpickledDict(PyObject *obj, PyObject *state, Py_ssize_t index) { Py_ssize_t state_size = __Pyx_PyTuple_GET_SIZE(state); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(state_size == -1)) return -1; #endif if (state_size <= index) { return 0; } return __Pyx__UpdateUnpickledDict(obj, state, index); } /* FormatTypeName */ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000 static __Pyx_TypeName __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp) { PyObject *module = NULL, *name = NULL, *result = NULL; #if __PYX_LIMITED_VERSION_HEX < 0x030b0000 name = __Pyx_PyObject_GetAttrStr((PyObject *)tp, __pyx_mstate_global->__pyx_n_u_qualname); #else name = PyType_GetQualName(tp); #endif if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) goto bad; module = __Pyx_PyObject_GetAttrStr((PyObject *)tp, __pyx_mstate_global->__pyx_n_u_module); if (unlikely(module == NULL) || unlikely(!PyUnicode_Check(module))) goto bad; if (PyUnicode_CompareWithASCIIString(module, "builtins") == 0) { result = name; name = NULL; goto done; } result = PyUnicode_FromFormat("%U.%U", module, name); if (unlikely(result == NULL)) goto bad; done: Py_XDECREF(name); Py_XDECREF(module); return result; bad: PyErr_Clear(); if (name) { result = name; name = NULL; } else { result = __Pyx_NewRef(__pyx_mstate_global->__pyx_kp_u_); } goto done; } #endif /* CIntFromPy */ static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const int neg_one = (int) -1, const_zero = (int) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (unlikely(!PyLong_Check(x))) { int val; PyObject *tmp = __Pyx_PyNumber_Long(x); if (!tmp) return (int) -1; val = __Pyx_PyLong_As_int(tmp); Py_DECREF(tmp); return val; } if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(int) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } } #endif if ((sizeof(int) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { int val; int ret = -1; #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API Py_ssize_t bytes_copied = PyLong_AsNativeBytes( x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0)); if (unlikely(bytes_copied == -1)) { } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) { goto raise_overflow; } else { ret = 0; } #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)x, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *v; PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (likely(PyLong_CheckExact(x))) { v = __Pyx_NewRef(x); } else { v = PyNumber_Long(x); if (unlikely(!v)) return (int) -1; assert(PyLong_CheckExact(v)); } { int result = PyObject_RichCompareBool(v, Py_False, Py_LT); if (unlikely(result < 0)) { Py_DECREF(v); return (int) -1; } is_negative = result == 1; } if (is_unsigned && unlikely(is_negative)) { Py_DECREF(v); goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); Py_DECREF(v); if (unlikely(!stepval)) return (int) -1; } else { stepval = v; } v = NULL; val = (int) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; long idigit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; val |= ((int) idigit) << bits; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; } Py_DECREF(shift); shift = NULL; Py_DECREF(mask); mask = NULL; { long idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((int) idigit) << bits; } if (!is_unsigned) { if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif if (unlikely(ret)) return (int) -1; return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } /* FastTypeChecks */ #if CYTHON_COMPILING_IN_CPYTHON static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { while (a) { a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*); if (a == b) return 1; } return b == &PyBaseObject_Type; } static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (a == b) return 1; mro = a->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(a, b); } static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (cls == a || cls == b) return 1; mro = cls->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { PyObject *base = PyTuple_GET_ITEM(mro, i); if (base == (PyObject *)a || base == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b); } static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { if (exc_type1) { return __Pyx_IsAnySubtype2((PyTypeObject*)err, (PyTypeObject*)exc_type1, (PyTypeObject*)exc_type2); } else { return __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); } } static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; assert(PyExceptionClass_Check(exc_type)); n = PyTuple_GET_SIZE(tuple); for (i=0; i>= 8; ++i; } __Pyx_cached_runtime_version = version; } } #endif static unsigned long __Pyx_get_runtime_version(void) { #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000 return Py_Version & ~0xFFUL; #else return __Pyx_cached_runtime_version; #endif } /* CheckBinaryVersion */ static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) { const unsigned long MAJOR_MINOR = 0xFFFF0000UL; if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR)) return 0; if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR))) return 1; { char message[200]; PyOS_snprintf(message, sizeof(message), "compile time Python version %d.%d " "of module '%.100s' " "%s " "runtime version %d.%d", (int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF), __Pyx_MODULE_NAME, (allow_newer) ? "was newer than" : "does not match", (int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF) ); return PyErr_WarnEx(NULL, message, 1); } } /* NewCodeObj */ #if CYTHON_COMPILING_IN_LIMITED_API static PyObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f, PyObject *code, PyObject *c, PyObject* n, PyObject *v, PyObject *fv, PyObject *cell, PyObject* fn, PyObject *name, int fline, PyObject *lnos) { PyObject *exception_table = NULL; PyObject *types_module=NULL, *code_type=NULL, *result=NULL; #if __PYX_LIMITED_VERSION_HEX < 0x030b0000 PyObject *version_info; PyObject *py_minor_version = NULL; #endif long minor_version = 0; PyObject *type, *value, *traceback; PyErr_Fetch(&type, &value, &traceback); #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000 minor_version = 11; #else if (!(version_info = PySys_GetObject("version_info"))) goto end; if (!(py_minor_version = PySequence_GetItem(version_info, 1))) goto end; minor_version = PyLong_AsLong(py_minor_version); Py_DECREF(py_minor_version); if (minor_version == -1 && PyErr_Occurred()) goto end; #endif if (!(types_module = PyImport_ImportModule("types"))) goto end; if (!(code_type = PyObject_GetAttrString(types_module, "CodeType"))) goto end; if (minor_version <= 7) { (void)p; result = PyObject_CallFunction(code_type, "iiiiiOOOOOOiOOO", a, k, l, s, f, code, c, n, v, fn, name, fline, lnos, fv, cell); } else if (minor_version <= 10) { result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOiOOO", a,p, k, l, s, f, code, c, n, v, fn, name, fline, lnos, fv, cell); } else { if (!(exception_table = PyBytes_FromStringAndSize(NULL, 0))) goto end; result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOOiOOOO", a,p, k, l, s, f, code, c, n, v, fn, name, name, fline, lnos, exception_table, fv, cell); } end: Py_XDECREF(code_type); Py_XDECREF(exception_table); Py_XDECREF(types_module); if (type) { PyErr_Restore(type, value, traceback); } return result; } #elif PY_VERSION_HEX >= 0x030B0000 static PyCodeObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f, PyObject *code, PyObject *c, PyObject* n, PyObject *v, PyObject *fv, PyObject *cell, PyObject* fn, PyObject *name, int fline, PyObject *lnos) { PyCodeObject *result; result = #if PY_VERSION_HEX >= 0x030C0000 PyUnstable_Code_NewWithPosOnlyArgs #else PyCode_NewWithPosOnlyArgs #endif (a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, name, fline, lnos, __pyx_mstate_global->__pyx_empty_bytes); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030c00A1 if (likely(result)) result->_co_firsttraceable = 0; #endif return result; } #elif !CYTHON_COMPILING_IN_PYPY #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #else #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #endif static PyObject* __Pyx_PyCode_New( const __Pyx_PyCode_New_function_description descr, PyObject * const *varnames, PyObject *filename, PyObject *funcname, PyObject *line_table, PyObject *tuple_dedup_map ) { PyObject *code_obj = NULL, *varnames_tuple_dedup = NULL, *code_bytes = NULL; Py_ssize_t var_count = (Py_ssize_t) descr.nlocals; PyObject *varnames_tuple = PyTuple_New(var_count); if (unlikely(!varnames_tuple)) return NULL; for (Py_ssize_t i=0; i < var_count; i++) { Py_INCREF(varnames[i]); if (__Pyx_PyTuple_SET_ITEM(varnames_tuple, i, varnames[i]) != (0)) goto done; } #if CYTHON_COMPILING_IN_LIMITED_API varnames_tuple_dedup = PyDict_GetItem(tuple_dedup_map, varnames_tuple); if (!varnames_tuple_dedup) { if (unlikely(PyDict_SetItem(tuple_dedup_map, varnames_tuple, varnames_tuple) < 0)) goto done; varnames_tuple_dedup = varnames_tuple; } #else varnames_tuple_dedup = PyDict_SetDefault(tuple_dedup_map, varnames_tuple, varnames_tuple); if (unlikely(!varnames_tuple_dedup)) goto done; #endif #if CYTHON_AVOID_BORROWED_REFS Py_INCREF(varnames_tuple_dedup); #endif if (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table != NULL && !CYTHON_COMPILING_IN_GRAAL) { Py_ssize_t line_table_length = __Pyx_PyBytes_GET_SIZE(line_table); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(line_table_length == -1)) goto done; #endif Py_ssize_t code_len = (line_table_length * 2 + 4) & ~3LL; code_bytes = PyBytes_FromStringAndSize(NULL, code_len); if (unlikely(!code_bytes)) goto done; char* c_code_bytes = PyBytes_AsString(code_bytes); if (unlikely(!c_code_bytes)) goto done; memset(c_code_bytes, 0, (size_t) code_len); } code_obj = (PyObject*) __Pyx__PyCode_New( (int) descr.argcount, (int) descr.num_posonly_args, (int) descr.num_kwonly_args, (int) descr.nlocals, 0, (int) descr.flags, code_bytes ? code_bytes : __pyx_mstate_global->__pyx_empty_bytes, __pyx_mstate_global->__pyx_empty_tuple, __pyx_mstate_global->__pyx_empty_tuple, varnames_tuple_dedup, __pyx_mstate_global->__pyx_empty_tuple, __pyx_mstate_global->__pyx_empty_tuple, filename, funcname, (int) descr.first_line, (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table) ? line_table : __pyx_mstate_global->__pyx_empty_bytes ); done: Py_XDECREF(code_bytes); #if CYTHON_AVOID_BORROWED_REFS Py_XDECREF(varnames_tuple_dedup); #endif Py_DECREF(varnames_tuple); return code_obj; } /* DecompressString */ static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo) { PyObject *module, *decompress, *compressed_bytes, *decompressed; const char* module_name = algo == 3 ? "compression.zstd" : algo == 2 ? "bz2" : "zlib"; PyObject *methodname = PyUnicode_FromString("decompress"); if (unlikely(!methodname)) return NULL; #if __PYX_LIMITED_VERSION_HEX >= 0x030e0000 if (algo == 3) { PyObject *fromlist = Py_BuildValue("[O]", methodname); if (unlikely(!fromlist)) return NULL; module = PyImport_ImportModuleLevel("compression.zstd", NULL, NULL, fromlist, 0); Py_DECREF(fromlist); } else #endif module = PyImport_ImportModule(module_name); if (unlikely(!module)) goto import_failed; decompress = PyObject_GetAttr(module, methodname); if (unlikely(!decompress)) goto import_failed; { #ifdef __cplusplus char *memview_bytes = const_cast(s); #else #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wcast-qual" #elif !defined(__INTEL_COMPILER) && defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-qual" #endif char *memview_bytes = (char*) s; #if defined(__clang__) #pragma clang diagnostic pop #elif !defined(__INTEL_COMPILER) && defined(__GNUC__) #pragma GCC diagnostic pop #endif #endif #if CYTHON_COMPILING_IN_LIMITED_API && !defined(PyBUF_READ) int memview_flags = 0x100; #else int memview_flags = PyBUF_READ; #endif compressed_bytes = PyMemoryView_FromMemory(memview_bytes, length, memview_flags); } if (unlikely(!compressed_bytes)) { Py_DECREF(decompress); goto bad; } decompressed = PyObject_CallFunctionObjArgs(decompress, compressed_bytes, NULL); Py_DECREF(compressed_bytes); Py_DECREF(decompress); Py_DECREF(module); Py_DECREF(methodname); return decompressed; import_failed: PyErr_Format(PyExc_ImportError, "Failed to import '%.20s.decompress' - cannot initialise module strings. " "String compression was configured with the C macro 'CYTHON_COMPRESS_STRINGS=%d'.", module_name, algo); bad: Py_XDECREF(module); Py_DECREF(methodname); return NULL; } #include static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s) { size_t len = strlen(s); if (unlikely(len > (size_t) PY_SSIZE_T_MAX)) { PyErr_SetString(PyExc_OverflowError, "byte string is too long"); return -1; } return (Py_ssize_t) len; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { Py_ssize_t len = __Pyx_ssize_strlen(c_str); if (unlikely(len < 0)) return NULL; return __Pyx_PyUnicode_FromStringAndSize(c_str, len); } static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char* c_str) { Py_ssize_t len = __Pyx_ssize_strlen(c_str); if (unlikely(len < 0)) return NULL; return PyByteArray_FromStringAndSize(c_str, len); } static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if CYTHON_COMPILING_IN_LIMITED_API { const char* result; Py_ssize_t unicode_length; CYTHON_MAYBE_UNUSED_VAR(unicode_length); // only for __PYX_DEFAULT_STRING_ENCODING_IS_ASCII #if __PYX_LIMITED_VERSION_HEX < 0x030A0000 if (unlikely(PyArg_Parse(o, "s#", &result, length) < 0)) return NULL; #else result = PyUnicode_AsUTF8AndSize(o, length); #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII unicode_length = PyUnicode_GetLength(o); if (unlikely(unicode_length < 0)) return NULL; if (unlikely(unicode_length != *length)) { PyUnicode_AsASCIIString(o); return NULL; } #endif return result; } #else #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (likely(PyUnicode_IS_ASCII(o))) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif #endif } #endif static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 if (PyUnicode_Check(o)) { return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif if (PyByteArray_Check(o)) { #if (CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS) || (CYTHON_COMPILING_IN_PYPY && (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))) *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); #else *length = PyByteArray_Size(o); if (*length == -1) return NULL; return PyByteArray_AsString(o); #endif } else { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { int retval; if (unlikely(!x)) return -1; retval = __Pyx_PyObject_IsTrue(x); Py_DECREF(x); return retval; } static PyObject* __Pyx_PyNumber_LongWrongResultType(PyObject* result) { __Pyx_TypeName result_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(result)); if (PyLong_Check(result)) { if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, "__int__ returned non-int (type " __Pyx_FMT_TYPENAME "). " "The ability to return an instance of a strict subclass of int is deprecated, " "and may be removed in a future version of Python.", result_type_name)) { __Pyx_DECREF_TypeName(result_type_name); Py_DECREF(result); return NULL; } __Pyx_DECREF_TypeName(result_type_name); return result; } PyErr_Format(PyExc_TypeError, "__int__ returned non-int (type " __Pyx_FMT_TYPENAME ")", result_type_name); __Pyx_DECREF_TypeName(result_type_name); Py_DECREF(result); return NULL; } static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; #endif PyObject *res = NULL; if (likely(PyLong_Check(x))) return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS m = Py_TYPE(x)->tp_as_number; if (likely(m && m->nb_int)) { res = m->nb_int(x); } #else if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { res = PyNumber_Long(x); } #endif if (likely(res)) { if (unlikely(!PyLong_CheckExact(res))) { return __Pyx_PyNumber_LongWrongResultType(res); } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS if (likely(__Pyx_PyLong_IsCompact(b))) { return __Pyx_PyLong_CompactValue(b); } else { const digit* digits = __Pyx_PyLong_Digits(b); const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(b); switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyLong_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) { if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) { return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o); } else { Py_ssize_t ival; PyObject *x; x = PyNumber_Index(o); if (!x) return -1; ival = PyLong_AsLong(x); Py_DECREF(x); return ival; } } static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b) { CYTHON_UNUSED_VAR(b); return __Pyx_NewRef(Py_None); } static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { return __Pyx_NewRef(b ? Py_True: Py_False); } static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t ival) { return PyLong_FromSize_t(ival); } /* MultiPhaseInitModuleState */ #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE #ifndef CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE #if (CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX >= 0x030C0000) #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 1 #else #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 0 #endif #endif #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE && !CYTHON_ATOMICS #error "Module state with PEP489 requires atomics. Currently that's one of\ C11, C++11, gcc atomic intrinsics or MSVC atomic intrinsics" #endif #if !CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE #define __Pyx_ModuleStateLookup_Lock() #define __Pyx_ModuleStateLookup_Unlock() #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000 static PyMutex __Pyx_ModuleStateLookup_mutex = {0}; #define __Pyx_ModuleStateLookup_Lock() PyMutex_Lock(&__Pyx_ModuleStateLookup_mutex) #define __Pyx_ModuleStateLookup_Unlock() PyMutex_Unlock(&__Pyx_ModuleStateLookup_mutex) #elif defined(__cplusplus) && __cplusplus >= 201103L #include static std::mutex __Pyx_ModuleStateLookup_mutex; #define __Pyx_ModuleStateLookup_Lock() __Pyx_ModuleStateLookup_mutex.lock() #define __Pyx_ModuleStateLookup_Unlock() __Pyx_ModuleStateLookup_mutex.unlock() #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201112L) && !defined(__STDC_NO_THREADS__) #include static mtx_t __Pyx_ModuleStateLookup_mutex; static once_flag __Pyx_ModuleStateLookup_mutex_once_flag = ONCE_FLAG_INIT; static void __Pyx_ModuleStateLookup_initialize_mutex(void) { mtx_init(&__Pyx_ModuleStateLookup_mutex, mtx_plain); } #define __Pyx_ModuleStateLookup_Lock()\ call_once(&__Pyx_ModuleStateLookup_mutex_once_flag, __Pyx_ModuleStateLookup_initialize_mutex);\ mtx_lock(&__Pyx_ModuleStateLookup_mutex) #define __Pyx_ModuleStateLookup_Unlock() mtx_unlock(&__Pyx_ModuleStateLookup_mutex) #elif defined(HAVE_PTHREAD_H) #include static pthread_mutex_t __Pyx_ModuleStateLookup_mutex = PTHREAD_MUTEX_INITIALIZER; #define __Pyx_ModuleStateLookup_Lock() pthread_mutex_lock(&__Pyx_ModuleStateLookup_mutex) #define __Pyx_ModuleStateLookup_Unlock() pthread_mutex_unlock(&__Pyx_ModuleStateLookup_mutex) #elif defined(_WIN32) #include // synchapi.h on its own doesn't work static SRWLOCK __Pyx_ModuleStateLookup_mutex = SRWLOCK_INIT; #define __Pyx_ModuleStateLookup_Lock() AcquireSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex) #define __Pyx_ModuleStateLookup_Unlock() ReleaseSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex) #else #error "No suitable lock available for CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE.\ Requires C standard >= C11, or C++ standard >= C++11,\ or pthreads, or the Windows 32 API, or Python >= 3.13." #endif typedef struct { int64_t id; PyObject *module; } __Pyx_InterpreterIdAndModule; typedef struct { char interpreter_id_as_index; Py_ssize_t count; Py_ssize_t allocated; __Pyx_InterpreterIdAndModule table[1]; } __Pyx_ModuleStateLookupData; #define __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE 32 #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE static __pyx_atomic_int_type __Pyx_ModuleStateLookup_read_counter = 0; #endif #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE static __pyx_atomic_ptr_type __Pyx_ModuleStateLookup_data = 0; #else static __Pyx_ModuleStateLookupData* __Pyx_ModuleStateLookup_data = NULL; #endif static __Pyx_InterpreterIdAndModule* __Pyx_State_FindModuleStateLookupTableLowerBound( __Pyx_InterpreterIdAndModule* table, Py_ssize_t count, int64_t interpreterId) { __Pyx_InterpreterIdAndModule* begin = table; __Pyx_InterpreterIdAndModule* end = begin + count; if (begin->id == interpreterId) { return begin; } while ((end - begin) > __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) { __Pyx_InterpreterIdAndModule* halfway = begin + (end - begin)/2; if (halfway->id == interpreterId) { return halfway; } if (halfway->id < interpreterId) { begin = halfway; } else { end = halfway; } } for (; begin < end; ++begin) { if (begin->id >= interpreterId) return begin; } return begin; } static PyObject *__Pyx_State_FindModule(CYTHON_UNUSED void* dummy) { int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get()); if (interpreter_id == -1) return NULL; #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __Pyx_ModuleStateLookupData* data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data); { __pyx_atomic_incr_acq_rel(&__Pyx_ModuleStateLookup_read_counter); if (likely(data)) { __Pyx_ModuleStateLookupData* new_data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_acquire(&__Pyx_ModuleStateLookup_data); if (likely(data == new_data)) { goto read_finished; } } __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter); __Pyx_ModuleStateLookup_Lock(); __pyx_atomic_incr_relaxed(&__Pyx_ModuleStateLookup_read_counter); data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data); __Pyx_ModuleStateLookup_Unlock(); } read_finished:; #else __Pyx_ModuleStateLookupData* data = __Pyx_ModuleStateLookup_data; #endif __Pyx_InterpreterIdAndModule* found = NULL; if (unlikely(!data)) goto end; if (data->interpreter_id_as_index) { if (interpreter_id < data->count) { found = data->table+interpreter_id; } } else { found = __Pyx_State_FindModuleStateLookupTableLowerBound( data->table, data->count, interpreter_id); } end: { PyObject *result=NULL; if (found && found->id == interpreter_id) { result = found->module; } #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter); #endif return result; } } #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE static void __Pyx_ModuleStateLookup_wait_until_no_readers(void) { while (__pyx_atomic_load(&__Pyx_ModuleStateLookup_read_counter) != 0); } #else #define __Pyx_ModuleStateLookup_wait_until_no_readers() #endif static int __Pyx_State_AddModuleInterpIdAsIndex(__Pyx_ModuleStateLookupData **old_data, PyObject* module, int64_t interpreter_id) { Py_ssize_t to_allocate = (*old_data)->allocated; while (to_allocate <= interpreter_id) { if (to_allocate == 0) to_allocate = 1; else to_allocate *= 2; } __Pyx_ModuleStateLookupData *new_data = *old_data; if (to_allocate != (*old_data)->allocated) { new_data = (__Pyx_ModuleStateLookupData *)realloc( *old_data, sizeof(__Pyx_ModuleStateLookupData)+(to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule)); if (!new_data) { PyErr_NoMemory(); return -1; } for (Py_ssize_t i = new_data->allocated; i < to_allocate; ++i) { new_data->table[i].id = i; new_data->table[i].module = NULL; } new_data->allocated = to_allocate; } new_data->table[interpreter_id].module = module; if (new_data->count < interpreter_id+1) { new_data->count = interpreter_id+1; } *old_data = new_data; return 0; } static void __Pyx_State_ConvertFromInterpIdAsIndex(__Pyx_ModuleStateLookupData *data) { __Pyx_InterpreterIdAndModule *read = data->table; __Pyx_InterpreterIdAndModule *write = data->table; __Pyx_InterpreterIdAndModule *end = read + data->count; for (; readmodule) { write->id = read->id; write->module = read->module; ++write; } } data->count = write - data->table; for (; writeid = 0; write->module = NULL; } data->interpreter_id_as_index = 0; } static int __Pyx_State_AddModule(PyObject* module, CYTHON_UNUSED void* dummy) { int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get()); if (interpreter_id == -1) return -1; int result = 0; __Pyx_ModuleStateLookup_Lock(); #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __Pyx_ModuleStateLookupData *old_data = (__Pyx_ModuleStateLookupData *) __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0); #else __Pyx_ModuleStateLookupData *old_data = __Pyx_ModuleStateLookup_data; #endif __Pyx_ModuleStateLookupData *new_data = old_data; if (!new_data) { new_data = (__Pyx_ModuleStateLookupData *)calloc(1, sizeof(__Pyx_ModuleStateLookupData)); if (!new_data) { result = -1; PyErr_NoMemory(); goto end; } new_data->allocated = 1; new_data->interpreter_id_as_index = 1; } __Pyx_ModuleStateLookup_wait_until_no_readers(); if (new_data->interpreter_id_as_index) { if (interpreter_id < __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) { result = __Pyx_State_AddModuleInterpIdAsIndex(&new_data, module, interpreter_id); goto end; } __Pyx_State_ConvertFromInterpIdAsIndex(new_data); } { Py_ssize_t insert_at = 0; { __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound( new_data->table, new_data->count, interpreter_id); assert(lower_bound); insert_at = lower_bound - new_data->table; if (unlikely(insert_at < new_data->count && lower_bound->id == interpreter_id)) { lower_bound->module = module; goto end; // already in table, nothing more to do } } if (new_data->count+1 >= new_data->allocated) { Py_ssize_t to_allocate = (new_data->count+1)*2; new_data = (__Pyx_ModuleStateLookupData*)realloc( new_data, sizeof(__Pyx_ModuleStateLookupData) + (to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule)); if (!new_data) { result = -1; new_data = old_data; PyErr_NoMemory(); goto end; } new_data->allocated = to_allocate; } ++new_data->count; int64_t last_id = interpreter_id; PyObject *last_module = module; for (Py_ssize_t i=insert_at; icount; ++i) { int64_t current_id = new_data->table[i].id; new_data->table[i].id = last_id; last_id = current_id; PyObject *current_module = new_data->table[i].module; new_data->table[i].module = last_module; last_module = current_module; } } end: #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, new_data); #else __Pyx_ModuleStateLookup_data = new_data; #endif __Pyx_ModuleStateLookup_Unlock(); return result; } static int __Pyx_State_RemoveModule(CYTHON_UNUSED void* dummy) { int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get()); if (interpreter_id == -1) return -1; __Pyx_ModuleStateLookup_Lock(); #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __Pyx_ModuleStateLookupData *data = (__Pyx_ModuleStateLookupData *) __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0); #else __Pyx_ModuleStateLookupData *data = __Pyx_ModuleStateLookup_data; #endif if (data->interpreter_id_as_index) { if (interpreter_id < data->count) { data->table[interpreter_id].module = NULL; } goto done; } { __Pyx_ModuleStateLookup_wait_until_no_readers(); __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound( data->table, data->count, interpreter_id); if (!lower_bound) goto done; if (lower_bound->id != interpreter_id) goto done; __Pyx_InterpreterIdAndModule *end = data->table+data->count; for (;lower_boundid = (lower_bound+1)->id; lower_bound->module = (lower_bound+1)->module; } } --data->count; if (data->count == 0) { free(data); data = NULL; } done: #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, data); #else __Pyx_ModuleStateLookup_data = data; #endif __Pyx_ModuleStateLookup_Unlock(); return 0; } #endif /* #### Code section: utility_code_pragmas_end ### */ #ifdef _MSC_VER #pragma warning( pop ) #endif /* #### Code section: end ### */ #endif /* Py_PYTHON_H */ clickhouse-driver-0.2.11/clickhouse_driver/bufferedreader.pyx000066400000000000000000000274231522645447600244570ustar00rootroot00000000000000from cpython cimport Py_INCREF, PyBytes_FromStringAndSize, PyBytes_AsString from cpython.bytearray cimport PyByteArray_AsString, PyByteArray_Resize # Using python's versions of pure c memory management functions for # proper memory statistics count. from cpython.mem cimport PyMem_Malloc, PyMem_Realloc, PyMem_Free from cpython.tuple cimport PyTuple_New, PyTuple_SET_ITEM from libc.string cimport memcpy cdef class BufferedReader(object): cdef public unsigned long long position, current_buffer_size cdef public bytearray buffer def __init__(self, bufsize): self.buffer = bytearray(bufsize) self.position = 0 self.current_buffer_size = 0 super(BufferedReader, self).__init__() def read_into_buffer(self): raise NotImplementedError def read(self, unsigned long long unread): # When the buffer is large enough bytes read are almost # always hit the buffer. cdef unsigned long long next_position = unread + self.position if next_position < self.current_buffer_size: t = self.position self.position = next_position return bytes(self.buffer[t:self.position]) cdef char* buffer_ptr = PyByteArray_AsString(self.buffer) cdef unsigned long long read_bytes rv = bytes() while unread > 0: if self.position == self.current_buffer_size: self.read_into_buffer() buffer_ptr = PyByteArray_AsString(self.buffer) self.position = 0 read_bytes = min(unread, self.current_buffer_size - self.position) rv += PyBytes_FromStringAndSize( &buffer_ptr[self.position], read_bytes ) self.position += read_bytes unread -= read_bytes return rv def read_one(self): if self.position == self.current_buffer_size: self.read_into_buffer() self.position = 0 rv = self.buffer[self.position] self.position += 1 return rv def read_strings(self, unsigned long long n_items, encoding=None): """ Python has great overhead between function calls. We inline strings reading logic here to avoid this overhead. """ items = PyTuple_New(n_items) cdef unsigned long long i # Buffer vars cdef char* buffer_ptr = PyByteArray_AsString(self.buffer) cdef unsigned long long right # String length vars cdef unsigned long long size, shift, bytes_read cdef unsigned long long b # String for decode vars. cdef char *c_string = NULL cdef unsigned long long c_string_size = 1024 cdef char *c_encoding = NULL if encoding: encoding = encoding.encode('utf-8') c_encoding = encoding cdef object rv = object() # String for decode vars. if c_encoding: c_string = PyMem_Realloc(NULL, c_string_size) for i in range(n_items): shift = size = 0 # Read string size while True: if self.position == self.current_buffer_size: self.read_into_buffer() # `read_into_buffer` can override buffer buffer_ptr = PyByteArray_AsString(self.buffer) self.position = 0 b = buffer_ptr[self.position] self.position += 1 size |= (b & 0x7f) << shift if b < 0x80: break shift += 7 right = self.position + size if c_encoding: if size + 1 > c_string_size: c_string_size = size + 1 c_string = PyMem_Realloc(c_string, c_string_size) if c_string is NULL: raise MemoryError() c_string[size] = 0 bytes_read = 0 # Decoding pure c strings in Cython is faster than in pure Python. # We need to copy it into buffer for adding null symbol at the end. # In ClickHouse block there is no null if right > self.current_buffer_size: if c_encoding: memcpy(&c_string[bytes_read], &buffer_ptr[self.position], self.current_buffer_size - self.position) else: rv = PyBytes_FromStringAndSize( &buffer_ptr[self.position], self.current_buffer_size - self.position ) bytes_read = self.current_buffer_size - self.position # Read the rest of the string. while bytes_read != size: self.position = size - bytes_read self.read_into_buffer() # `read_into_buffer` can override buffer buffer_ptr = PyByteArray_AsString(self.buffer) # There can be not enough data in buffer. self.position = min( self.position, self.current_buffer_size ) if c_encoding: memcpy( &c_string[bytes_read], buffer_ptr, self.position ) else: rv += PyBytes_FromStringAndSize( buffer_ptr, self.position ) bytes_read += self.position else: if c_encoding: memcpy(c_string, &buffer_ptr[self.position], size) else: rv = PyBytes_FromStringAndSize( &buffer_ptr[self.position], size ) self.position = right if c_encoding: try: rv = c_string[:size].decode(c_encoding) except UnicodeDecodeError: rv = PyBytes_FromStringAndSize(c_string, size) Py_INCREF(rv) PyTuple_SET_ITEM(items, i, rv) if c_string: PyMem_Free(c_string) return items def read_strings_arrow(self, unsigned long long n_items): """ Reads ``n_items`` varint-prefixed strings into Arrow-style buffers without creating per-string Python objects. Returns (offsets, data) pair of bytearrays: ``offsets`` holds ``n_items + 1`` little-endian int64 values, ``data`` holds concatenated string bytes. """ cdef unsigned long long i # Buffer vars cdef char* buffer_ptr = PyByteArray_AsString(self.buffer) cdef unsigned long long right # String length vars cdef unsigned long long size, shift, bytes_read cdef unsigned long long b offsets = bytearray((n_items + 1) * 8) cdef long long* offsets_ptr = PyByteArray_AsString( offsets ) offsets_ptr[0] = 0 cdef unsigned long long data_size = 0 cdef unsigned long long data_capacity = 65536 if \ n_items * 8 < 65536 else n_items * 8 data = bytearray(data_capacity) cdef char* data_ptr = PyByteArray_AsString(data) for i in range(n_items): shift = size = 0 # Read string size while True: if self.position == self.current_buffer_size: self.read_into_buffer() # `read_into_buffer` can override buffer buffer_ptr = PyByteArray_AsString(self.buffer) self.position = 0 b = buffer_ptr[self.position] self.position += 1 size |= (b & 0x7f) << shift if b < 0x80: break shift += 7 if data_size + size > data_capacity: while data_capacity < data_size + size: data_capacity *= 2 PyByteArray_Resize(data, data_capacity) data_ptr = PyByteArray_AsString(data) right = self.position + size if right > self.current_buffer_size: # String spans multiple reader buffers. bytes_read = self.current_buffer_size - self.position memcpy(&data_ptr[data_size], &buffer_ptr[self.position], bytes_read) while bytes_read != size: self.position = size - bytes_read self.read_into_buffer() # `read_into_buffer` can override buffer buffer_ptr = PyByteArray_AsString(self.buffer) # There can be not enough data in buffer. self.position = min( self.position, self.current_buffer_size ) memcpy(&data_ptr[data_size + bytes_read], buffer_ptr, self.position) bytes_read += self.position else: memcpy(&data_ptr[data_size], &buffer_ptr[self.position], size) self.position = right data_size += size offsets_ptr[i + 1] = data_size PyByteArray_Resize(data, data_size) return offsets, data def read_fixed_strings_as_bytes(self, Py_ssize_t n_items, Py_ssize_t length): cdef Py_ssize_t i data = self.read(length * n_items) cdef char* data_ptr = PyBytes_AsString(data) items = PyTuple_New(n_items) for i in range(n_items): item = PyBytes_FromStringAndSize(&data_ptr[i * length], length) Py_INCREF(item) PyTuple_SET_ITEM(items, i, item) return items def read_fixed_strings(self, Py_ssize_t n_items, Py_ssize_t length, encoding=None): if encoding is None: return self.read_fixed_strings_as_bytes(n_items, length) cdef Py_ssize_t i, j encoding = encoding.encode('utf-8') cdef char* c_encoding = encoding data = self.read(length * n_items) cdef char* data_ptr = PyBytes_AsString(data) cdef char* c_string = PyMem_Malloc(length + 1) if not c_string: raise MemoryError() c_string[length] = 0 items = PyTuple_New(n_items) for i in range(n_items): memcpy(c_string, &data_ptr[i * length], length) # Get last non zero byte of string from the end. j = length - 1 while j >= 0 and not c_string[j]: j -= 1 try: item = c_string[:j + 1].decode(c_encoding) except UnicodeDecodeError: item = PyBytes_FromStringAndSize(c_string, length) Py_INCREF(item) PyTuple_SET_ITEM(items, i, item) PyMem_Free(c_string) return items cdef class BufferedSocketReader(BufferedReader): cdef object sock def __init__(self, sock, bufsize): self.sock = sock super(BufferedSocketReader, self).__init__(bufsize) def read_into_buffer(self): self.current_buffer_size = self.sock.recv_into(self.buffer) if self.current_buffer_size == 0: raise EOFError('Unexpected EOF while reading bytes') cdef class CompressedBufferedReader(BufferedReader): cdef object read_block def __init__(self, read_block, bufsize): self.read_block = read_block super(CompressedBufferedReader, self).__init__(bufsize) def read_into_buffer(self): self.buffer = bytearray(self.read_block()) self.current_buffer_size = len(self.buffer) if self.current_buffer_size == 0: raise EOFError('Unexpected EOF while reading bytes') clickhouse-driver-0.2.11/clickhouse_driver/bufferedwriter.c000066400000000000000000026062331522645447600241370ustar00rootroot00000000000000/* Generated by Cython 3.2.0 */ #ifndef PY_SSIZE_T_CLEAN #define PY_SSIZE_T_CLEAN #endif /* PY_SSIZE_T_CLEAN */ /* InitLimitedAPI */ #if defined(Py_LIMITED_API) #if !defined(CYTHON_LIMITED_API) #define CYTHON_LIMITED_API 1 #endif #elif defined(CYTHON_LIMITED_API) #ifdef _MSC_VER #pragma message ("Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead.") #else #warning Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead. #endif #endif #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x03080000 #error Cython requires Python 3.8+. #else #define __PYX_ABI_VERSION "3_2_0" #define CYTHON_HEX_VERSION 0x030200F0 #define CYTHON_FUTURE_DIVISION 1 /* CModulePreamble */ #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(_WIN32) && !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #define __PYX_COMMA , #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #define __PYX_LIMITED_VERSION_HEX PY_VERSION_HEX #if defined(GRAALVM_PYTHON) /* For very preliminary testing purposes. Most variables are set the same as PyPy. The existence of this section does not imply that anything works or is even tested */ #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 1 #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_ASSUME_SAFE_SIZE #define CYTHON_ASSUME_SAFE_SIZE 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #undef CYTHON_USE_SYS_MONITORING #define CYTHON_USE_SYS_MONITORING 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #undef CYTHON_USE_AM_SEND #define CYTHON_USE_AM_SEND 0 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 1 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #undef CYTHON_USE_FREELISTS #define CYTHON_USE_FREELISTS 0 #undef CYTHON_IMMORTAL_CONSTANTS #define CYTHON_IMMORTAL_CONSTANTS 0 #elif defined(PYPY_VERSION) #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #ifndef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #endif #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #ifndef CYTHON_ASSUME_SAFE_SIZE #define CYTHON_ASSUME_SAFE_SIZE 1 #endif #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #if PY_VERSION_HEX < 0x03090000 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT) #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #undef CYTHON_USE_SYS_MONITORING #define CYTHON_USE_SYS_MONITORING 0 #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE (PYPY_VERSION_NUM >= 0x07030C00) #endif #undef CYTHON_USE_AM_SEND #define CYTHON_USE_AM_SEND 0 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_NUM >= 0x07031100) #endif #undef CYTHON_USE_FREELISTS #define CYTHON_USE_FREELISTS 0 #undef CYTHON_IMMORTAL_CONSTANTS #define CYTHON_IMMORTAL_CONSTANTS 0 #elif defined(CYTHON_LIMITED_API) #ifdef Py_LIMITED_API #undef __PYX_LIMITED_VERSION_HEX #define __PYX_LIMITED_VERSION_HEX Py_LIMITED_API #endif #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 1 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 1 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #ifndef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #endif #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0 #endif #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_ASSUME_SAFE_SIZE #define CYTHON_ASSUME_SAFE_SIZE 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL (__PYX_LIMITED_VERSION_HEX >= 0x030C0000) #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #ifndef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #endif #undef CYTHON_USE_SYS_MONITORING #define CYTHON_USE_SYS_MONITORING 0 #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #endif #ifndef CYTHON_USE_AM_SEND #define CYTHON_USE_AM_SEND (__PYX_LIMITED_VERSION_HEX >= 0x030A0000) #endif #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #ifndef CYTHON_USE_FREELISTS #define CYTHON_USE_FREELISTS 1 #endif #undef CYTHON_IMMORTAL_CONSTANTS #define CYTHON_IMMORTAL_CONSTANTS 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 0 #ifdef Py_GIL_DISABLED #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 1 #else #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0 #endif #if PY_VERSION_HEX < 0x030A0000 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #elif !defined(CYTHON_USE_TYPE_SLOTS) #define CYTHON_USE_TYPE_SLOTS 1 #endif #ifndef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #endif #ifndef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 1 #endif #ifndef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #elif !defined(CYTHON_USE_PYLIST_INTERNALS) #define CYTHON_USE_PYLIST_INTERNALS 1 #endif #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING || PY_VERSION_HEX >= 0x030B00A2 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #elif !defined(CYTHON_USE_UNICODE_WRITER) #define CYTHON_USE_UNICODE_WRITER 1 #endif #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1 #elif !defined(CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS) #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_ASSUME_SAFE_SIZE #define CYTHON_ASSUME_SAFE_SIZE 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #ifndef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 1 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #elif !defined(CYTHON_FAST_GIL) #define CYTHON_FAST_GIL (PY_VERSION_HEX < 0x030C00A6) #endif #ifndef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 1 #endif #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #ifndef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #endif #ifndef CYTHON_USE_SYS_MONITORING #define CYTHON_USE_SYS_MONITORING (PY_VERSION_HEX >= 0x030d00B1) #endif #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 1 #endif #ifndef CYTHON_USE_AM_SEND #define CYTHON_USE_AM_SEND 1 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #elif !defined(CYTHON_USE_DICT_VERSIONS) #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX < 0x030C00A5 && !CYTHON_USE_MODULE_STATE) #endif #ifndef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 1 #endif #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 1 #endif #ifndef CYTHON_USE_FREELISTS #define CYTHON_USE_FREELISTS (!CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) #endif #if defined(CYTHON_IMMORTAL_CONSTANTS) && PY_VERSION_HEX < 0x030C0000 #undef CYTHON_IMMORTAL_CONSTANTS #define CYTHON_IMMORTAL_CONSTANTS 0 // definitely won't work #elif !defined(CYTHON_IMMORTAL_CONSTANTS) #define CYTHON_IMMORTAL_CONSTANTS (PY_VERSION_HEX >= 0x030C0000 && !CYTHON_USE_MODULE_STATE && CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) #endif #endif #ifndef CYTHON_COMPRESS_STRINGS #define CYTHON_COMPRESS_STRINGS 1 #endif #ifndef CYTHON_FAST_PYCCALL #define CYTHON_FAST_PYCCALL CYTHON_FAST_PYCALL #endif #ifndef CYTHON_VECTORCALL #if CYTHON_COMPILING_IN_LIMITED_API #define CYTHON_VECTORCALL (__PYX_LIMITED_VERSION_HEX >= 0x030C0000) #else #define CYTHON_VECTORCALL (CYTHON_FAST_PYCCALL) #endif #endif #if CYTHON_USE_PYLONG_INTERNALS #undef SHIFT #undef BASE #undef MASK #ifdef SIZEOF_VOID_P enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; #endif #endif #ifndef __has_attribute #define __has_attribute(x) 0 #endif #ifndef __has_cpp_attribute #define __has_cpp_attribute(x) 0 #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #ifndef CYTHON_UNUSED #if defined(__cplusplus) /* for clang __has_cpp_attribute(maybe_unused) is true even before C++17 * but leads to warnings with -pedantic, since it is a C++17 feature */ #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) #if __has_cpp_attribute(maybe_unused) #define CYTHON_UNUSED [[maybe_unused]] #endif #endif #endif #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_UNUSED_VAR # if defined(__cplusplus) template void CYTHON_UNUSED_VAR( const T& ) { } # else # define CYTHON_UNUSED_VAR(x) (void)(x) # endif #endif #ifndef CYTHON_MAYBE_UNUSED_VAR #define CYTHON_MAYBE_UNUSED_VAR(x) CYTHON_UNUSED_VAR(x) #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif #ifndef CYTHON_USE_CPP_STD_MOVE #if defined(__cplusplus) && (\ __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)) #define CYTHON_USE_CPP_STD_MOVE 1 #else #define CYTHON_USE_CPP_STD_MOVE 0 #endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #include typedef uintptr_t __pyx_uintptr_t; #ifndef CYTHON_FALLTHROUGH #if defined(__cplusplus) /* for clang __has_cpp_attribute(fallthrough) is true even before C++17 * but leads to warnings with -pedantic, since it is a C++17 feature */ #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) #if __has_cpp_attribute(fallthrough) #define CYTHON_FALLTHROUGH [[fallthrough]] #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_cpp_attribute(clang::fallthrough) #define CYTHON_FALLTHROUGH [[clang::fallthrough]] #elif __has_cpp_attribute(gnu::fallthrough) #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] #endif #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_attribute(fallthrough) #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) #else #define CYTHON_FALLTHROUGH #endif #endif #if defined(__clang__) && defined(__apple_build_version__) #if __apple_build_version__ < 7000000 #undef CYTHON_FALLTHROUGH #define CYTHON_FALLTHROUGH #endif #endif #endif #ifndef Py_UNREACHABLE #define Py_UNREACHABLE() assert(0); abort() #endif #ifdef __cplusplus template struct __PYX_IS_UNSIGNED_IMPL {static const bool value = T(0) < T(-1);}; #define __PYX_IS_UNSIGNED(type) (__PYX_IS_UNSIGNED_IMPL::value) #else #define __PYX_IS_UNSIGNED(type) (((type)-1) > 0) #endif #if CYTHON_COMPILING_IN_PYPY == 1 #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX < 0x030A0000) #else #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX < 0x03090000) #endif #define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer)) /* CInitCode */ #ifndef CYTHON_INLINE #if defined(__clang__) #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) #elif defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #endif /* PythonCompatibility */ #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_DefaultClassType PyType_Type #if CYTHON_COMPILING_IN_LIMITED_API #ifndef CO_OPTIMIZED static int CO_OPTIMIZED; #endif #ifndef CO_NEWLOCALS static int CO_NEWLOCALS; #endif #ifndef CO_VARARGS static int CO_VARARGS; #endif #ifndef CO_VARKEYWORDS static int CO_VARKEYWORDS; #endif #ifndef CO_ASYNC_GENERATOR static int CO_ASYNC_GENERATOR; #endif #ifndef CO_GENERATOR static int CO_GENERATOR; #endif #ifndef CO_COROUTINE static int CO_COROUTINE; #endif #else #ifndef CO_COROUTINE #define CO_COROUTINE 0x80 #endif #ifndef CO_ASYNC_GENERATOR #define CO_ASYNC_GENERATOR 0x200 #endif #endif static int __Pyx_init_co_variables(void); #if PY_VERSION_HEX >= 0x030900A4 || defined(Py_IS_TYPE) #define __Pyx_IS_TYPE(ob, type) Py_IS_TYPE(ob, type) #else #define __Pyx_IS_TYPE(ob, type) (((const PyObject*)ob)->ob_type == (type)) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_Is) #define __Pyx_Py_Is(x, y) Py_Is(x, y) #else #define __Pyx_Py_Is(x, y) ((x) == (y)) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsNone) #define __Pyx_Py_IsNone(ob) Py_IsNone(ob) #else #define __Pyx_Py_IsNone(ob) __Pyx_Py_Is((ob), Py_None) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsTrue) #define __Pyx_Py_IsTrue(ob) Py_IsTrue(ob) #else #define __Pyx_Py_IsTrue(ob) __Pyx_Py_Is((ob), Py_True) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsFalse) #define __Pyx_Py_IsFalse(ob) Py_IsFalse(ob) #else #define __Pyx_Py_IsFalse(ob) __Pyx_Py_Is((ob), Py_False) #endif #define __Pyx_NoneAsNull(obj) (__Pyx_Py_IsNone(obj) ? NULL : (obj)) #if PY_VERSION_HEX >= 0x030900F0 && !CYTHON_COMPILING_IN_PYPY #define __Pyx_PyObject_GC_IsFinalized(o) PyObject_GC_IsFinalized(o) #else #define __Pyx_PyObject_GC_IsFinalized(o) _PyGC_FINALIZED(o) #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #ifndef Py_TPFLAGS_SEQUENCE #define Py_TPFLAGS_SEQUENCE 0 #endif #ifndef Py_TPFLAGS_MAPPING #define Py_TPFLAGS_MAPPING 0 #endif #ifndef Py_TPFLAGS_IMMUTABLETYPE #define Py_TPFLAGS_IMMUTABLETYPE (1UL << 8) #endif #ifndef Py_TPFLAGS_DISALLOW_INSTANTIATION #define Py_TPFLAGS_DISALLOW_INSTANTIATION (1UL << 7) #endif #ifndef METH_STACKLESS #define METH_STACKLESS 0 #endif #ifndef METH_FASTCALL #ifndef METH_FASTCALL #define METH_FASTCALL 0x80 #endif typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames); #else #if PY_VERSION_HEX >= 0x030d00A4 # define __Pyx_PyCFunctionFast PyCFunctionFast # define __Pyx_PyCFunctionFastWithKeywords PyCFunctionFastWithKeywords #else # define __Pyx_PyCFunctionFast _PyCFunctionFast # define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords #endif #endif #if CYTHON_METH_FASTCALL #define __Pyx_METH_FASTCALL METH_FASTCALL #define __Pyx_PyCFunction_FastCall __Pyx_PyCFunctionFast #define __Pyx_PyCFunction_FastCallWithKeywords __Pyx_PyCFunctionFastWithKeywords #else #define __Pyx_METH_FASTCALL METH_VARARGS #define __Pyx_PyCFunction_FastCall PyCFunction #define __Pyx_PyCFunction_FastCallWithKeywords PyCFunctionWithKeywords #endif #if CYTHON_VECTORCALL #define __pyx_vectorcallfunc vectorcallfunc #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET PY_VECTORCALL_ARGUMENTS_OFFSET #define __Pyx_PyVectorcall_NARGS(n) PyVectorcall_NARGS((size_t)(n)) #else #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET 0 #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(n)) #endif #if PY_VERSION_HEX >= 0x030900B1 #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_CheckExact(func) #else #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_Check(func) #endif #define __Pyx_CyOrPyCFunction_Check(func) PyCFunction_Check(func) #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) (((PyCFunctionObject*)(func))->m_ml->ml_meth) #elif !CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(func) #endif #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CyOrPyCFunction_GET_FLAGS(func) (((PyCFunctionObject*)(func))->m_ml->ml_flags) static CYTHON_INLINE PyObject* __Pyx_CyOrPyCFunction_GET_SELF(PyObject *func) { return (__Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_STATIC) ? NULL : ((PyCFunctionObject*)func)->m_self; } #endif static CYTHON_INLINE int __Pyx__IsSameCFunction(PyObject *func, void (*cfunc)(void)) { #if CYTHON_COMPILING_IN_LIMITED_API return PyCFunction_Check(func) && PyCFunction_GetFunction(func) == (PyCFunction) cfunc; #else return PyCFunction_Check(func) && PyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; #endif } #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCFunction(func, cfunc) #if PY_VERSION_HEX < 0x03090000 || (CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000) #define __Pyx_PyType_FromModuleAndSpec(m, s, b) ((void)m, PyType_FromSpecWithBases(s, b)) typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *); #else #define __Pyx_PyType_FromModuleAndSpec(m, s, b) PyType_FromModuleAndSpec(m, s, b) #define __Pyx_PyCMethod PyCMethod #endif #ifndef METH_METHOD #define METH_METHOD 0x200 #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) #define PyObject_Malloc(s) PyMem_Malloc(s) #define PyObject_Free(p) PyMem_Free(p) #define PyObject_Realloc(p) PyMem_Realloc(p) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyFrame_SetLineNumber(frame, lineno) #elif CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) GraalPyFrame_SetLineNumber((frame), (lineno)) #elif CYTHON_COMPILING_IN_GRAAL #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) _PyFrame_SetLineNumber((frame), (lineno)) #else #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyThreadState_Current PyThreadState_Get() #elif !CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_Current PyThreadState_GET() #elif PY_VERSION_HEX >= 0x030d00A1 #define __Pyx_PyThreadState_Current PyThreadState_GetUnchecked() #else #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() #endif #if CYTHON_USE_MODULE_STATE static CYTHON_INLINE void *__Pyx__PyModule_GetState(PyObject *op) { void *result; result = PyModule_GetState(op); if (!result) Py_FatalError("Couldn't find the module state"); return result; } #define __Pyx_PyModule_GetState(o) (__pyx_mstatetype *)__Pyx__PyModule_GetState(o) #else #define __Pyx_PyModule_GetState(op) ((void)op,__pyx_mstate_global) #endif #define __Pyx_PyObject_GetSlot(obj, name, func_ctype) __Pyx_PyType_GetSlot(Py_TYPE((PyObject *) obj), name, func_ctype) #define __Pyx_PyObject_TryGetSlot(obj, name, func_ctype) __Pyx_PyType_TryGetSlot(Py_TYPE(obj), name, func_ctype) #define __Pyx_PyObject_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(Py_TYPE(obj), sub, name, func_ctype) #define __Pyx_PyObject_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSubSlot(Py_TYPE(obj), sub, name, func_ctype) #if CYTHON_USE_TYPE_SLOTS #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((type)->name) #define __Pyx_PyType_TryGetSlot(type, name, func_ctype) __Pyx_PyType_GetSlot(type, name, func_ctype) #define __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype) (((type)->sub) ? ((type)->sub->name) : NULL) #define __Pyx_PyType_TryGetSubSlot(type, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype) #else #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((func_ctype) PyType_GetSlot((type), Py_##name)) #define __Pyx_PyType_TryGetSlot(type, name, func_ctype)\ ((__PYX_LIMITED_VERSION_HEX >= 0x030A0000 ||\ (PyType_GetFlags(type) & Py_TPFLAGS_HEAPTYPE) || __Pyx_get_runtime_version() >= 0x030A0000) ?\ __Pyx_PyType_GetSlot(type, name, func_ctype) : NULL) #define __Pyx_PyType_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSlot(obj, name, func_ctype) #define __Pyx_PyType_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSlot(obj, name, func_ctype) #endif #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) #else #define __Pyx_PyDict_NewPresized(n) PyDict_New() #endif #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_UNICODE_INTERNALS #define __Pyx_PyDict_GetItemStrWithError(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) { PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name); if (res == NULL) PyErr_Clear(); return res; } #elif !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000 #define __Pyx_PyDict_GetItemStrWithError PyDict_GetItemWithError #define __Pyx_PyDict_GetItemStr PyDict_GetItem #else static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, PyObject *name) { #if CYTHON_COMPILING_IN_PYPY return PyDict_GetItem(dict, name); #else PyDictEntry *ep; PyDictObject *mp = (PyDictObject*) dict; long hash = ((PyStringObject *) name)->ob_shash; assert(hash != -1); ep = (mp->ma_lookup)(mp, name, hash); if (ep == NULL) { return NULL; } return ep->me_value; #endif } #define __Pyx_PyDict_GetItemStr PyDict_GetItem #endif #if CYTHON_USE_TYPE_SLOTS #define __Pyx_PyType_GetFlags(tp) (((PyTypeObject *)tp)->tp_flags) #define __Pyx_PyType_HasFeature(type, feature) ((__Pyx_PyType_GetFlags(type) & (feature)) != 0) #else #define __Pyx_PyType_GetFlags(tp) (PyType_GetFlags((PyTypeObject *)tp)) #define __Pyx_PyType_HasFeature(type, feature) PyType_HasFeature(type, feature) #endif #define __Pyx_PyObject_GetIterNextFunc(iterator) __Pyx_PyObject_GetSlot(iterator, tp_iternext, iternextfunc) #if CYTHON_USE_TYPE_SPECS #define __Pyx_PyHeapTypeObject_GC_Del(obj) {\ PyTypeObject *type = Py_TYPE((PyObject*)obj);\ assert(__Pyx_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE));\ PyObject_GC_Del(obj);\ Py_DECREF(type);\ } #else #define __Pyx_PyHeapTypeObject_GC_Del(obj) PyObject_GC_Del(obj) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_ReadChar(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((void)u, 1114111U) #define __Pyx_PyUnicode_KIND(u) ((void)u, (0)) #define __Pyx_PyUnicode_DATA(u) ((void*)u) #define __Pyx_PyUnicode_READ(k, d, i) ((void)k, PyUnicode_ReadChar((PyObject*)(d), i)) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GetLength(u)) #else #if PY_VERSION_HEX >= 0x030C0000 #define __Pyx_PyUnicode_READY(op) (0) #else #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #endif #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) #define __Pyx_PyUnicode_KIND(u) ((int)PyUnicode_KIND(u)) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, (Py_UCS4) ch) #if PY_VERSION_HEX >= 0x030C0000 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) #else #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) #else #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) #endif #endif #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY #if !defined(PyUnicode_DecodeUnicodeEscape) #define PyUnicode_DecodeUnicodeEscape(s, size, errors) PyUnicode_Decode(s, size, "unicode_escape", errors) #endif #if !defined(PyUnicode_Contains) #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #if !defined(PyByteArray_Check) #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) #endif #if !defined(PyObject_Format) #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) #endif #endif #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 #define __Pyx_PySequence_ListKeepNew(obj)\ (likely(PyList_CheckExact(obj) && PyUnstable_Object_IsUniquelyReferenced(obj)) ? __Pyx_NewRef(obj) : PySequence_List(obj)) #elif CYTHON_COMPILING_IN_CPYTHON #define __Pyx_PySequence_ListKeepNew(obj)\ (likely(PyList_CheckExact(obj) && Py_REFCNT(obj) == 1) ? __Pyx_NewRef(obj) : PySequence_List(obj)) #else #define __Pyx_PySequence_ListKeepNew(obj) PySequence_List(obj) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) __Pyx_IS_TYPE(obj, &PySet_Type) #endif #if PY_VERSION_HEX >= 0x030900A4 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) #else #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) #endif enum __Pyx_ReferenceSharing { __Pyx_ReferenceSharing_DefinitelyUnique, // We created it so we know it's unshared - no need to check __Pyx_ReferenceSharing_OwnStrongReference, __Pyx_ReferenceSharing_FunctionArgument, __Pyx_ReferenceSharing_SharedReference, // Never trust it to be unshared because it's a global or similar }; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && PY_VERSION_HEX >= 0x030E0000 #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing)\ (sharing == __Pyx_ReferenceSharing_DefinitelyUnique ? 1 :\ (sharing == __Pyx_ReferenceSharing_FunctionArgument ? PyUnstable_Object_IsUniqueReferencedTemporary(o) :\ (sharing == __Pyx_ReferenceSharing_OwnStrongReference ? PyUnstable_Object_IsUniquelyReferenced(o) : 0))) #elif (CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)sharing), Py_REFCNT(o) == 1) #else #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)o), ((void)sharing), 0) #endif #if CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyList_GetItemRef(o, i) PyList_GetItemRef(o, i) #elif CYTHON_COMPILING_IN_LIMITED_API || !CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PyList_GetItemRef(o, i) (likely((i) >= 0) ? PySequence_GetItem(o, i) : (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) #else #define __Pyx_PyList_GetItemRef(o, i) PySequence_ITEM(o, i) #endif #elif CYTHON_COMPILING_IN_LIMITED_API || !CYTHON_ASSUME_SAFE_MACROS #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyList_GetItemRef(o, i) PyList_GetItemRef(o, i) #else #define __Pyx_PyList_GetItemRef(o, i) __Pyx_XNewRef(PyList_GetItem(o, i)) #endif #else #define __Pyx_PyList_GetItemRef(o, i) __Pyx_NewRef(PyList_GET_ITEM(o, i)) #endif #if CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS && !CYTHON_COMPILING_IN_LIMITED_API && CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PyList_GetItemRefFast(o, i, unsafe_shared) (__Pyx_IS_UNIQUELY_REFERENCED(o, unsafe_shared) ?\ __Pyx_NewRef(PyList_GET_ITEM(o, i)) : __Pyx_PyList_GetItemRef(o, i)) #else #define __Pyx_PyList_GetItemRefFast(o, i, unsafe_shared) __Pyx_PyList_GetItemRef(o, i) #endif #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyDict_GetItemRef(dict, key, result) PyDict_GetItemRef(dict, key, result) #elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) { *result = PyObject_GetItem(dict, key); if (*result == NULL) { if (PyErr_ExceptionMatches(PyExc_KeyError)) { PyErr_Clear(); return 0; } return -1; } return 1; } #else static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) { *result = PyDict_GetItemWithError(dict, key); if (*result == NULL) { return PyErr_Occurred() ? -1 : 0; } Py_INCREF(*result); return 1; } #endif #if defined(CYTHON_DEBUG_VISIT_CONST) && CYTHON_DEBUG_VISIT_CONST #define __Pyx_VISIT_CONST(obj) Py_VISIT(obj) #else #define __Pyx_VISIT_CONST(obj) #endif #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PySequence_ITEM(o, i) PySequence_ITEM(o, i) #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) #define __Pyx_PyTuple_SET_ITEM(o, i, v) (PyTuple_SET_ITEM(o, i, v), (0)) #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GET_ITEM(o, i) #define __Pyx_PyList_SET_ITEM(o, i, v) (PyList_SET_ITEM(o, i, v), (0)) #define __Pyx_PyList_GET_ITEM(o, i) PyList_GET_ITEM(o, i) #else #define __Pyx_PySequence_ITEM(o, i) PySequence_GetItem(o, i) #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) #define __Pyx_PyTuple_SET_ITEM(o, i, v) PyTuple_SetItem(o, i, v) #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GetItem(o, i) #define __Pyx_PyList_SET_ITEM(o, i, v) PyList_SetItem(o, i, v) #define __Pyx_PyList_GET_ITEM(o, i) PyList_GetItem(o, i) #endif #if CYTHON_ASSUME_SAFE_SIZE #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_GET_SIZE(o) #define __Pyx_PyList_GET_SIZE(o) PyList_GET_SIZE(o) #define __Pyx_PySet_GET_SIZE(o) PySet_GET_SIZE(o) #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o) #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_GET_SIZE(o) #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GET_LENGTH(o) #else #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_Size(o) #define __Pyx_PyList_GET_SIZE(o) PyList_Size(o) #define __Pyx_PySet_GET_SIZE(o) PySet_Size(o) #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_Size(o) #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_Size(o) #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GetLength(o) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_InternFromString) #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #define __Pyx_PyLong_FromHash_t PyLong_FromSsize_t #define __Pyx_PyLong_AsHash_t __Pyx_PyIndex_AsSsize_t #if __PYX_LIMITED_VERSION_HEX >= 0x030A0000 #define __Pyx_PySendResult PySendResult #else typedef enum { PYGEN_RETURN = 0, PYGEN_ERROR = -1, PYGEN_NEXT = 1, } __Pyx_PySendResult; #endif #if CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX < 0x030A00A3 typedef __Pyx_PySendResult (*__Pyx_pyiter_sendfunc)(PyObject *iter, PyObject *value, PyObject **result); #else #define __Pyx_pyiter_sendfunc sendfunc #endif #if !CYTHON_USE_AM_SEND #define __PYX_HAS_PY_AM_SEND 0 #elif __PYX_LIMITED_VERSION_HEX >= 0x030A0000 #define __PYX_HAS_PY_AM_SEND 1 #else #define __PYX_HAS_PY_AM_SEND 2 // our own backported implementation #endif #if __PYX_HAS_PY_AM_SEND < 2 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #else typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; __Pyx_pyiter_sendfunc am_send; } __Pyx_PyAsyncMethodsStruct; #define __Pyx_SlotTpAsAsync(s) ((PyAsyncMethods*)(s)) #endif #if CYTHON_USE_AM_SEND && PY_VERSION_HEX < 0x030A00F0 #define __Pyx_TPFLAGS_HAVE_AM_SEND (1UL << 21) #else #define __Pyx_TPFLAGS_HAVE_AM_SEND (0) #endif #if PY_VERSION_HEX >= 0x03090000 #define __Pyx_PyInterpreterState_Get() PyInterpreterState_Get() #else #define __Pyx_PyInterpreterState_Get() PyThreadState_Get()->interp #endif #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030A0000 #ifdef __cplusplus extern "C" #endif PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize); #endif #if CYTHON_COMPILING_IN_LIMITED_API static int __Pyx_init_co_variable(PyObject *inspect, const char* name, int *write_to) { int value; PyObject *py_value = PyObject_GetAttrString(inspect, name); if (!py_value) return 0; value = (int) PyLong_AsLong(py_value); Py_DECREF(py_value); *write_to = value; return value != -1 || !PyErr_Occurred(); } static int __Pyx_init_co_variables(void) { PyObject *inspect; int result; inspect = PyImport_ImportModule("inspect"); result = #if !defined(CO_OPTIMIZED) __Pyx_init_co_variable(inspect, "CO_OPTIMIZED", &CO_OPTIMIZED) && #endif #if !defined(CO_NEWLOCALS) __Pyx_init_co_variable(inspect, "CO_NEWLOCALS", &CO_NEWLOCALS) && #endif #if !defined(CO_VARARGS) __Pyx_init_co_variable(inspect, "CO_VARARGS", &CO_VARARGS) && #endif #if !defined(CO_VARKEYWORDS) __Pyx_init_co_variable(inspect, "CO_VARKEYWORDS", &CO_VARKEYWORDS) && #endif #if !defined(CO_ASYNC_GENERATOR) __Pyx_init_co_variable(inspect, "CO_ASYNC_GENERATOR", &CO_ASYNC_GENERATOR) && #endif #if !defined(CO_GENERATOR) __Pyx_init_co_variable(inspect, "CO_GENERATOR", &CO_GENERATOR) && #endif #if !defined(CO_COROUTINE) __Pyx_init_co_variable(inspect, "CO_COROUTINE", &CO_COROUTINE) && #endif 1; Py_DECREF(inspect); return result ? 0 : -1; } #else static int __Pyx_init_co_variables(void) { return 0; // It's a limited API-only feature } #endif /* MathInitCode */ #if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS) #ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES #endif #endif #include #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) #define __Pyx_truncl trunc #else #define __Pyx_truncl truncl #endif #ifndef CYTHON_CLINE_IN_TRACEBACK_RUNTIME #define CYTHON_CLINE_IN_TRACEBACK_RUNTIME 0 #endif #ifndef CYTHON_CLINE_IN_TRACEBACK #define CYTHON_CLINE_IN_TRACEBACK CYTHON_CLINE_IN_TRACEBACK_RUNTIME #endif #if CYTHON_CLINE_IN_TRACEBACK #define __PYX_MARK_ERR_POS(f_index, lineno) { __pyx_filename = __pyx_f[f_index]; (void) __pyx_filename; __pyx_lineno = lineno; (void) __pyx_lineno; __pyx_clineno = __LINE__; (void) __pyx_clineno; } #else #define __PYX_MARK_ERR_POS(f_index, lineno) { __pyx_filename = __pyx_f[f_index]; (void) __pyx_filename; __pyx_lineno = lineno; (void) __pyx_lineno; (void) __pyx_clineno; } #endif #define __PYX_ERR(f_index, lineno, Ln_error) \ { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } #ifdef CYTHON_EXTERN_C #undef __PYX_EXTERN_C #define __PYX_EXTERN_C CYTHON_EXTERN_C #elif defined(__PYX_EXTERN_C) #ifdef _MSC_VER #pragma message ("Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.") #else #warning Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead. #endif #else #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__clickhouse_driver__bufferedwriter #define __PYX_HAVE_API__clickhouse_driver__bufferedwriter /* Early includes */ #include #include #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyFloat_FromString(obj) PyFloat_FromString(obj) #else #define __Pyx_PyFloat_FromString(obj) PyFloat_FromString(obj, NULL) #endif #include #if PY_MAJOR_VERSION <= 2 #define PyDict_GetItemWithError _PyDict_GetItemWithError #endif #if PY_VERSION_HEX < 0x030d0000 static CYTHON_INLINE int __Pyx_PyWeakref_GetRef(PyObject *ref, PyObject **pobj) { PyObject *obj = PyWeakref_GetObject(ref); if (obj == NULL) { // SystemError if ref is NULL *pobj = NULL; return -1; } if (obj == Py_None) { *pobj = NULL; return 0; } Py_INCREF(obj); *pobj = obj; return 1; } #else #define __Pyx_PyWeakref_GetRef PyWeakref_GetRef #endif #include "pythread.h" #if (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030600) && !defined(PyContextVar_Get) #define PyContextVar_Get(var, d, v) ((d) ? ((void)(var), Py_INCREF(d), (v)[0] = (d), 0) : ((v)[0] = NULL, 0) ) #endif #ifdef _OPENMP #include #endif /* _OPENMP */ #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0 #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { return (size_t) i < (size_t) limit; } #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s); static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char*); #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyByteArray_AsString(s) PyByteArray_AS_STRING(s) #else #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AsString(s)) #define __Pyx_PyByteArray_AsString(s) PyByteArray_AsString(s) #endif #define __Pyx_PyObject_AsWritableString(s) ((char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) #define __Pyx_PyUnicode_FromOrdinal(o) PyUnicode_FromOrdinal((int)o) #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode static CYTHON_INLINE PyObject *__Pyx_NewRef(PyObject *obj) { #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_NewRef) return Py_NewRef(obj); #else Py_INCREF(obj); return obj; #endif } static CYTHON_INLINE PyObject *__Pyx_XNewRef(PyObject *obj) { #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_XNewRef) return Py_XNewRef(obj); #else Py_XINCREF(obj); return obj; #endif } static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b); static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x); #define __Pyx_PySequence_Tuple(obj)\ (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t); static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AS_DOUBLE(x) #else #define __Pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AsDouble(x) #endif #define __Pyx_PyFloat_AsFloat(x) ((float) __Pyx_PyFloat_AsDouble(x)) #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) #if CYTHON_USE_PYLONG_INTERNALS #if PY_VERSION_HEX >= 0x030C00A7 #ifndef _PyLong_SIGN_MASK #define _PyLong_SIGN_MASK 3 #endif #ifndef _PyLong_NON_SIZE_BITS #define _PyLong_NON_SIZE_BITS 3 #endif #define __Pyx_PyLong_Sign(x) (((PyLongObject*)x)->long_value.lv_tag & _PyLong_SIGN_MASK) #define __Pyx_PyLong_IsNeg(x) ((__Pyx_PyLong_Sign(x) & 2) != 0) #define __Pyx_PyLong_IsNonNeg(x) (!__Pyx_PyLong_IsNeg(x)) #define __Pyx_PyLong_IsZero(x) (__Pyx_PyLong_Sign(x) & 1) #define __Pyx_PyLong_IsPos(x) (__Pyx_PyLong_Sign(x) == 0) #define __Pyx_PyLong_CompactValueUnsigned(x) (__Pyx_PyLong_Digits(x)[0]) #define __Pyx_PyLong_DigitCount(x) ((Py_ssize_t) (((PyLongObject*)x)->long_value.lv_tag >> _PyLong_NON_SIZE_BITS)) #define __Pyx_PyLong_SignedDigitCount(x)\ ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * __Pyx_PyLong_DigitCount(x)) #if defined(PyUnstable_Long_IsCompact) && defined(PyUnstable_Long_CompactValue) #define __Pyx_PyLong_IsCompact(x) PyUnstable_Long_IsCompact((PyLongObject*) x) #define __Pyx_PyLong_CompactValue(x) PyUnstable_Long_CompactValue((PyLongObject*) x) #else #define __Pyx_PyLong_IsCompact(x) (((PyLongObject*)x)->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS)) #define __Pyx_PyLong_CompactValue(x) ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_Digits(x)[0]) #endif typedef Py_ssize_t __Pyx_compact_pylong; typedef size_t __Pyx_compact_upylong; #else #define __Pyx_PyLong_IsNeg(x) (Py_SIZE(x) < 0) #define __Pyx_PyLong_IsNonNeg(x) (Py_SIZE(x) >= 0) #define __Pyx_PyLong_IsZero(x) (Py_SIZE(x) == 0) #define __Pyx_PyLong_IsPos(x) (Py_SIZE(x) > 0) #define __Pyx_PyLong_CompactValueUnsigned(x) ((Py_SIZE(x) == 0) ? 0 : __Pyx_PyLong_Digits(x)[0]) #define __Pyx_PyLong_DigitCount(x) __Pyx_sst_abs(Py_SIZE(x)) #define __Pyx_PyLong_SignedDigitCount(x) Py_SIZE(x) #define __Pyx_PyLong_IsCompact(x) (Py_SIZE(x) == 0 || Py_SIZE(x) == 1 || Py_SIZE(x) == -1) #define __Pyx_PyLong_CompactValue(x)\ ((Py_SIZE(x) == 0) ? (sdigit) 0 : ((Py_SIZE(x) < 0) ? -(sdigit)__Pyx_PyLong_Digits(x)[0] : (sdigit)__Pyx_PyLong_Digits(x)[0])) typedef sdigit __Pyx_compact_pylong; typedef digit __Pyx_compact_upylong; #endif #if PY_VERSION_HEX >= 0x030C00A5 #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->long_value.ob_digit) #else #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->ob_digit) #endif #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #elif __PYX_DEFAULT_STRING_ENCODING_IS_ASCII #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeASCII(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ /* PretendToInitialize */ #ifdef __cplusplus #if __cplusplus > 201103L #include #endif template static void __Pyx_pretend_to_initialize(T* ptr) { #if __cplusplus > 201103L if ((std::is_trivially_default_constructible::value)) #endif *ptr = T(); (void)ptr; } #else static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } #endif #if !CYTHON_USE_MODULE_STATE static PyObject *__pyx_m = NULL; #endif static int __pyx_lineno; static int __pyx_clineno = 0; static const char * const __pyx_cfilenm = __FILE__; static const char *__pyx_filename; /* #### Code section: filename_table ### */ static const char* const __pyx_f[] = { "clickhouse_driver/bufferedwriter.pyx", "cpython/contextvars.pxd", "", "cpython/type.pxd", "cpython/bool.pxd", "cpython/complex.pxd", }; /* #### Code section: utility_code_proto_before_types ### */ /* Atomics.proto */ #include #ifndef CYTHON_ATOMICS #define CYTHON_ATOMICS 1 #endif #define __PYX_CYTHON_ATOMICS_ENABLED() CYTHON_ATOMICS #define __PYX_GET_CYTHON_COMPILING_IN_CPYTHON_FREETHREADING() CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #define __pyx_atomic_int_type int #define __pyx_nonatomic_int_type int #if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\ (__STDC_VERSION__ >= 201112L) &&\ !defined(__STDC_NO_ATOMICS__)) #include #elif CYTHON_ATOMICS && (defined(__cplusplus) && (\ (__cplusplus >= 201103L) ||\ (defined(_MSC_VER) && _MSC_VER >= 1700))) #include #endif #if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\ (__STDC_VERSION__ >= 201112L) &&\ !defined(__STDC_NO_ATOMICS__) &&\ ATOMIC_INT_LOCK_FREE == 2) #undef __pyx_atomic_int_type #define __pyx_atomic_int_type atomic_int #define __pyx_atomic_ptr_type atomic_uintptr_t #define __pyx_nonatomic_ptr_type uintptr_t #define __pyx_atomic_incr_relaxed(value) atomic_fetch_add_explicit(value, 1, memory_order_relaxed) #define __pyx_atomic_incr_acq_rel(value) atomic_fetch_add_explicit(value, 1, memory_order_acq_rel) #define __pyx_atomic_decr_acq_rel(value) atomic_fetch_sub_explicit(value, 1, memory_order_acq_rel) #define __pyx_atomic_sub(value, arg) atomic_fetch_sub(value, arg) #define __pyx_atomic_int_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired) #define __pyx_atomic_load(value) atomic_load(value) #define __pyx_atomic_store(value, new_value) atomic_store(value, new_value) #define __pyx_atomic_pointer_load_relaxed(value) atomic_load_explicit(value, memory_order_relaxed) #define __pyx_atomic_pointer_load_acquire(value) atomic_load_explicit(value, memory_order_acquire) #define __pyx_atomic_pointer_exchange(value, new_value) atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value) #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired) #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER) #pragma message ("Using standard C atomics") #elif defined(__PYX_DEBUG_ATOMICS) #warning "Using standard C atomics" #endif #elif CYTHON_ATOMICS && (defined(__cplusplus) && (\ (__cplusplus >= 201103L) ||\ \ (defined(_MSC_VER) && _MSC_VER >= 1700)) &&\ ATOMIC_INT_LOCK_FREE == 2) #undef __pyx_atomic_int_type #define __pyx_atomic_int_type std::atomic_int #define __pyx_atomic_ptr_type std::atomic_uintptr_t #define __pyx_nonatomic_ptr_type uintptr_t #define __pyx_atomic_incr_relaxed(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_relaxed) #define __pyx_atomic_incr_acq_rel(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_acq_rel) #define __pyx_atomic_decr_acq_rel(value) std::atomic_fetch_sub_explicit(value, 1, std::memory_order_acq_rel) #define __pyx_atomic_sub(value, arg) std::atomic_fetch_sub(value, arg) #define __pyx_atomic_int_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired) #define __pyx_atomic_load(value) std::atomic_load(value) #define __pyx_atomic_store(value, new_value) std::atomic_store(value, new_value) #define __pyx_atomic_pointer_load_relaxed(value) std::atomic_load_explicit(value, std::memory_order_relaxed) #define __pyx_atomic_pointer_load_acquire(value) std::atomic_load_explicit(value, std::memory_order_acquire) #define __pyx_atomic_pointer_exchange(value, new_value) std::atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value) #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired) #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER) #pragma message ("Using standard C++ atomics") #elif defined(__PYX_DEBUG_ATOMICS) #warning "Using standard C++ atomics" #endif #elif CYTHON_ATOMICS && (__GNUC__ >= 5 || (__GNUC__ == 4 &&\ (__GNUC_MINOR__ > 1 ||\ (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ >= 2)))) #define __pyx_atomic_ptr_type void* #define __pyx_nonatomic_ptr_type void* #define __pyx_atomic_incr_relaxed(value) __sync_fetch_and_add(value, 1) #define __pyx_atomic_incr_acq_rel(value) __sync_fetch_and_add(value, 1) #define __pyx_atomic_decr_acq_rel(value) __sync_fetch_and_sub(value, 1) #define __pyx_atomic_sub(value, arg) __sync_fetch_and_sub(value, arg) static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) { __pyx_nonatomic_int_type old = __sync_val_compare_and_swap(value, *expected, desired); int result = old == *expected; *expected = old; return result; } #define __pyx_atomic_load(value) __sync_fetch_and_add(value, 0) #define __pyx_atomic_store(value, new_value) __sync_lock_test_and_set(value, new_value) #define __pyx_atomic_pointer_load_relaxed(value) __sync_fetch_and_add(value, 0) #define __pyx_atomic_pointer_load_acquire(value) __sync_fetch_and_add(value, 0) #define __pyx_atomic_pointer_exchange(value, new_value) __sync_lock_test_and_set(value, (__pyx_atomic_ptr_type)new_value) static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) { __pyx_nonatomic_ptr_type old = __sync_val_compare_and_swap(value, *expected, desired); int result = old == *expected; *expected = old; return result; } #ifdef __PYX_DEBUG_ATOMICS #warning "Using GNU atomics" #endif #elif CYTHON_ATOMICS && defined(_MSC_VER) #include #undef __pyx_atomic_int_type #define __pyx_atomic_int_type long #define __pyx_atomic_ptr_type void* #undef __pyx_nonatomic_int_type #define __pyx_nonatomic_int_type long #define __pyx_nonatomic_ptr_type void* #pragma intrinsic (_InterlockedExchangeAdd, _InterlockedExchange, _InterlockedCompareExchange, _InterlockedCompareExchangePointer, _InterlockedExchangePointer) #define __pyx_atomic_incr_relaxed(value) _InterlockedExchangeAdd(value, 1) #define __pyx_atomic_incr_acq_rel(value) _InterlockedExchangeAdd(value, 1) #define __pyx_atomic_decr_acq_rel(value) _InterlockedExchangeAdd(value, -1) #define __pyx_atomic_sub(value, arg) _InterlockedExchangeAdd(value, -arg) static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) { __pyx_nonatomic_int_type old = _InterlockedCompareExchange(value, desired, *expected); int result = old == *expected; *expected = old; return result; } #define __pyx_atomic_load(value) _InterlockedExchangeAdd(value, 0) #define __pyx_atomic_store(value, new_value) _InterlockedExchange(value, new_value) #define __pyx_atomic_pointer_load_relaxed(value) *(void * volatile *)value #define __pyx_atomic_pointer_load_acquire(value) _InterlockedCompareExchangePointer(value, 0, 0) #define __pyx_atomic_pointer_exchange(value, new_value) _InterlockedExchangePointer(value, (__pyx_atomic_ptr_type)new_value) static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) { __pyx_atomic_ptr_type old = _InterlockedCompareExchangePointer(value, desired, *expected); int result = old == *expected; *expected = old; return result; } #ifdef __PYX_DEBUG_ATOMICS #pragma message ("Using MSVC atomics") #endif #else #undef CYTHON_ATOMICS #define CYTHON_ATOMICS 0 #ifdef __PYX_DEBUG_ATOMICS #warning "Not using atomics" #endif #endif /* CriticalSectionsDefinition.proto */ #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #define __Pyx_PyCriticalSection void* #define __Pyx_PyCriticalSection2 void* #define __Pyx_PyCriticalSection_End(cs) #define __Pyx_PyCriticalSection2_End(cs) #else #define __Pyx_PyCriticalSection PyCriticalSection #define __Pyx_PyCriticalSection2 PyCriticalSection2 #define __Pyx_PyCriticalSection_End PyCriticalSection_End #define __Pyx_PyCriticalSection2_End PyCriticalSection2_End #endif /* CriticalSections.proto */ #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #define __Pyx_PyCriticalSection_Begin(cs, arg) (void)(cs) #define __Pyx_PyCriticalSection2_Begin(cs, arg1, arg2) (void)(cs) #else #define __Pyx_PyCriticalSection_Begin PyCriticalSection_Begin #define __Pyx_PyCriticalSection2_Begin PyCriticalSection2_Begin #endif #if PY_VERSION_HEX < 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_BEGIN_CRITICAL_SECTION(o) { #define __Pyx_END_CRITICAL_SECTION() } #else #define __Pyx_BEGIN_CRITICAL_SECTION Py_BEGIN_CRITICAL_SECTION #define __Pyx_END_CRITICAL_SECTION Py_END_CRITICAL_SECTION #endif /* IncludeStructmemberH.proto */ #include /* #### Code section: numeric_typedefs ### */ /* #### Code section: complex_type_declarations ### */ /* #### Code section: type_declarations ### */ /*--- Type declarations ---*/ struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter; struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter; struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter; struct __pyx_opt_args_7cpython_11contextvars_get_value; struct __pyx_opt_args_7cpython_11contextvars_get_value_no_default; /* "cpython/contextvars.pxd":116 * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline object get_value(var, default_value=None): # <<<<<<<<<<<<<< * """Return a new reference to the value of the context variable, * or the default value of the context variable, */ struct __pyx_opt_args_7cpython_11contextvars_get_value { int __pyx_n; PyObject *default_value; }; /* "cpython/contextvars.pxd":134 * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline object get_value_no_default(var, default_value=None): # <<<<<<<<<<<<<< * """Return a new reference to the value of the context variable, * or the provided default value if no such value was found. */ struct __pyx_opt_args_7cpython_11contextvars_get_value_no_default { int __pyx_n; PyObject *default_value; }; /* "clickhouse_driver/bufferedwriter.pyx":10 * * * cdef class BufferedWriter(object): # <<<<<<<<<<<<<< * cdef char* buffer * cdef unsigned long long position, buffer_size */ struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter { PyObject_HEAD struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_vtab; char *buffer; unsigned PY_LONG_LONG position; unsigned PY_LONG_LONG buffer_size; }; /* "clickhouse_driver/bufferedwriter.pyx":119 * * * cdef class BufferedSocketWriter(BufferedWriter): # <<<<<<<<<<<<<< * cdef object sock * */ struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter { struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter __pyx_base; PyObject *sock; }; /* "clickhouse_driver/bufferedwriter.pyx":133 * * * cdef class CompressedBufferedWriter(BufferedWriter): # <<<<<<<<<<<<<< * cdef object compressor * */ struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter { struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter __pyx_base; PyObject *compressor; }; /* "clickhouse_driver/bufferedwriter.pyx":10 * * * cdef class BufferedWriter(object): # <<<<<<<<<<<<<< * cdef char* buffer * cdef unsigned long long position, buffer_size */ struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter { PyObject *(*write_into_stream)(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *, int __pyx_skip_dispatch); PyObject *(*write)(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *, PyObject *, int __pyx_skip_dispatch); }; static struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedWriter; /* "clickhouse_driver/bufferedwriter.pyx":119 * * * cdef class BufferedSocketWriter(BufferedWriter): # <<<<<<<<<<<<<< * cdef object sock * */ struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter { struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter __pyx_base; }; static struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *__pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter; /* "clickhouse_driver/bufferedwriter.pyx":133 * * * cdef class CompressedBufferedWriter(BufferedWriter): # <<<<<<<<<<<<<< * cdef object compressor * */ struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter { struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter __pyx_base; }; static struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *__pyx_vtabptr_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter; /* #### Code section: utility_code_proto ### */ /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, Py_ssize_t); void (*DECREF)(void*, PyObject*, Py_ssize_t); void (*GOTREF)(void*, PyObject*, Py_ssize_t); void (*GIVEREF)(void*, PyObject*, Py_ssize_t); void* (*SetupContext)(const char*, Py_ssize_t, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\ } #define __Pyx_RefNannyFinishContextNogil() {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __Pyx_RefNannyFinishContext();\ PyGILState_Release(__pyx_gilstate_save);\ } #define __Pyx_RefNannyFinishContextNogil() {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __Pyx_RefNannyFinishContext();\ PyGILState_Release(__pyx_gilstate_save);\ } #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_XINCREF(r) do { if((r) == NULL); else {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) == NULL); else {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) == NULL); else {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) == NULL); else {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContextNogil() #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_Py_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; Py_XDECREF(tmp);\ } while (0) #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) /* PyErrExceptionMatches.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); #else #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) #endif /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; #if PY_VERSION_HEX >= 0x030C00A6 #define __Pyx_PyErr_Occurred() (__pyx_tstate->current_exception != NULL) #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->current_exception ? (PyObject*) Py_TYPE(__pyx_tstate->current_exception) : (PyObject*) NULL) #else #define __Pyx_PyErr_Occurred() (__pyx_tstate->curexc_type != NULL) #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->curexc_type) #endif #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign #define __Pyx_PyErr_Occurred() (PyErr_Occurred() != NULL) #define __Pyx_PyErr_CurrentExceptionType() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A6 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) #else #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #endif #else #define __Pyx_PyErr_Clear() PyErr_Clear() #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) #endif /* PyObjectGetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif /* PyObjectGetAttrStrNoError.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name); /* GetBuiltinName.proto */ static PyObject *__Pyx_GetBuiltinName(PyObject *name); /* TupleAndListFromArray.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n); #endif #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_METH_FASTCALL static CYTHON_INLINE PyObject* __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n); #endif /* IncludeStringH.proto */ #include /* BytesEquals.proto */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /* UnicodeEquals.proto */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /* fastcall.proto */ #if CYTHON_AVOID_BORROWED_REFS #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_PySequence_ITEM(args, i) #elif CYTHON_ASSUME_SAFE_MACROS #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_NewRef(__Pyx_PyTuple_GET_ITEM(args, i)) #else #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_XNewRef(PyTuple_GetItem(args, i)) #endif #define __Pyx_NumKwargs_VARARGS(kwds) PyDict_Size(kwds) #define __Pyx_KwValues_VARARGS(args, nargs) NULL #define __Pyx_GetKwValue_VARARGS(kw, kwvalues, s) __Pyx_PyDict_GetItemStrWithError(kw, s) #define __Pyx_KwargsAsDict_VARARGS(kw, kwvalues) PyDict_Copy(kw) #if CYTHON_METH_FASTCALL #define __Pyx_ArgRef_FASTCALL(args, i) __Pyx_NewRef(args[i]) #define __Pyx_NumKwargs_FASTCALL(kwds) __Pyx_PyTuple_GET_SIZE(kwds) #define __Pyx_KwValues_FASTCALL(args, nargs) ((args) + (nargs)) static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues); #else #define __Pyx_KwargsAsDict_FASTCALL(kw, kwvalues) _PyStack_AsDict(kwvalues, kw) #endif #else #define __Pyx_ArgRef_FASTCALL __Pyx_ArgRef_VARARGS #define __Pyx_NumKwargs_FASTCALL __Pyx_NumKwargs_VARARGS #define __Pyx_KwValues_FASTCALL __Pyx_KwValues_VARARGS #define __Pyx_GetKwValue_FASTCALL __Pyx_GetKwValue_VARARGS #define __Pyx_KwargsAsDict_FASTCALL __Pyx_KwargsAsDict_VARARGS #endif #define __Pyx_ArgsSlice_VARARGS(args, start, stop) PyTuple_GetSlice(args, start, stop) #if CYTHON_METH_FASTCALL || (CYTHON_COMPILING_IN_CPYTHON && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) __Pyx_PyTuple_FromArray(args + start, stop - start) #else #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) PyTuple_GetSlice(args, start, stop) #endif /* py_dict_items.proto */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d); /* CallCFunction.proto */ #define __Pyx_CallCFunction(cfunc, self, args)\ ((PyCFunction)(void(*)(void))(cfunc)->func)(self, args) #define __Pyx_CallCFunctionWithKeywords(cfunc, self, args, kwargs)\ ((PyCFunctionWithKeywords)(void(*)(void))(cfunc)->func)(self, args, kwargs) #define __Pyx_CallCFunctionFast(cfunc, self, args, nargs)\ ((__Pyx_PyCFunctionFast)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs) #define __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, nargs, kwnames)\ ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs, kwnames) /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif /* PyObjectCallMethO.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); #endif /* PyObjectFastCall.proto */ #define __Pyx_PyObject_FastCall(func, args, nargs) __Pyx_PyObject_FastCallDict(func, args, (size_t)(nargs), NULL) static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs); /* PyObjectCallOneArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); /* UnpackUnboundCMethod.proto */ typedef struct { PyObject *type; PyObject **method_name; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && CYTHON_ATOMICS __pyx_atomic_int_type initialized; #endif PyCFunction func; PyObject *method; int flag; } __Pyx_CachedCFunction; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING static CYTHON_INLINE int __Pyx_CachedCFunction_GetAndSetInitializing(__Pyx_CachedCFunction *cfunc) { #if !CYTHON_ATOMICS return 1; #else __pyx_nonatomic_int_type expected = 0; if (__pyx_atomic_int_cmp_exchange(&cfunc->initialized, &expected, 1)) { return 0; } return expected; #endif } static CYTHON_INLINE void __Pyx_CachedCFunction_SetFinishedInitializing(__Pyx_CachedCFunction *cfunc) { #if CYTHON_ATOMICS __pyx_atomic_store(&cfunc->initialized, 2); #endif } #else #define __Pyx_CachedCFunction_GetAndSetInitializing(cfunc) 2 #define __Pyx_CachedCFunction_SetFinishedInitializing(cfunc) #endif /* CallUnboundCMethod0.proto */ CYTHON_UNUSED static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self); #else #define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self) #endif /* py_dict_values.proto */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d); /* OwnedDictNext.proto */ #if CYTHON_AVOID_BORROWED_REFS static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue); #else CYTHON_INLINE static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue); #endif /* RaiseDoubleKeywords.proto */ static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /* ParseKeywordsImpl.export */ static int __Pyx_ParseKeywordsTuple( PyObject *kwds, PyObject * const *kwvalues, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs ); static int __Pyx_ParseKeywordDictToDict( PyObject *kwds, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name ); static int __Pyx_ParseKeywordDict( PyObject *kwds, PyObject ** const argnames[], PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs ); /* CallUnboundCMethod2.proto */ CYTHON_UNUSED static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2); #else #define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2) __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2) #endif /* ParseKeywords.proto */ static CYTHON_INLINE int __Pyx_ParseKeywords( PyObject *kwds, PyObject *const *kwvalues, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs ); /* RaiseArgTupleInvalid.proto */ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /* PyObjectFastCallMethod.proto */ #if CYTHON_VECTORCALL && PY_VERSION_HEX >= 0x03090000 #define __Pyx_PyObject_FastCallMethod(name, args, nargsf) PyObject_VectorcallMethod(name, args, nargsf, NULL) #else static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const *args, size_t nargsf); #endif /* PyDictVersioning.proto */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ (version_var) = __PYX_GET_DICT_VERSION(dict);\ (cache_var) = (value); #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ (VAR) = __Pyx_XNewRef(__pyx_dict_cached_value);\ } else {\ (VAR) = __pyx_dict_cached_value = (LOOKUP);\ __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ }\ } static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); #else #define __PYX_GET_DICT_VERSION(dict) (0) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); #endif /* PyNotImplementedError_Check.proto */ #define __Pyx_PyExc_NotImplementedError_Check(obj) __Pyx_TypeCheck(obj, PyExc_NotImplementedError) /* RaiseException.export */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /* RejectKeywords.export */ static void __Pyx_RejectKeywords(const char* function_name, PyObject *kwds); /* PyValueError_Check.proto */ #define __Pyx_PyExc_ValueError_Check(obj) __Pyx_TypeCheck(obj, PyExc_ValueError) /* GetModuleGlobalName.proto */ #if CYTHON_USE_DICT_VERSIONS #define __Pyx_GetModuleGlobalName(var, name) do {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_mstate_global->__pyx_d))) ?\ (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } while(0) #define __Pyx_GetModuleGlobalNameUncached(var, name) do {\ PY_UINT64_T __pyx_dict_version;\ PyObject *__pyx_dict_cached_value;\ (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } while(0) static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); #else #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); #endif /* GetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); #endif /* SwapException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); #endif /* GetTopmostException.proto */ #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); #endif /* SaveResetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); #else #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) #endif /* GetAttr3.proto */ static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); /* RaiseUnexpectedTypeError.proto */ static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj); /* ArgTypeTestFunc.export */ static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /* ArgTypeTest.proto */ #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ ((likely(__Pyx_IS_TYPE(obj, type) | (none_allowed && (obj == Py_None)))) ? 1 :\ __Pyx__ArgTypeTest(obj, type, name, exact)) /* GetItemInt.proto */ #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck, unsafe_shared) :\ (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ __Pyx_GetItemInt_Generic(o, to_py_func(i)))) #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) :\ (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck, int unsafe_shared); #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) :\ (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck, int unsafe_shared); static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck, int unsafe_shared); /* AllocateExtensionType.proto */ static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final); /* CallNextTpTraverse.proto */ static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse); /* CallTypeTraverse.proto */ #if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000) #define __Pyx_call_type_traverse(o, always_call, visit, arg) 0 #else static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg); #endif /* CallNextTpClear.proto */ static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear); /* LimitedApiGetTypeDict.proto */ #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp); #endif /* SetItemOnTypeDict.proto */ static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v); #define __Pyx_SetItemOnTypeDict(tp, k, v) __Pyx__SetItemOnTypeDict((PyTypeObject*)tp, k, v) /* FixUpExtensionType.proto */ static CYTHON_INLINE int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type); /* PyObjectCallNoArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); /* PyObjectGetMethod.proto */ #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))) static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method); #endif /* PyObjectCallMethod0.proto */ static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name); /* ValidateBasesTuple.proto */ #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases); #endif /* PyType_Ready.proto */ CYTHON_UNUSED static int __Pyx_PyType_Ready(PyTypeObject *t); /* SetVTable.proto */ static int __Pyx_SetVtable(PyTypeObject* typeptr , void* vtable); /* GetVTable.proto */ static void* __Pyx_GetVtable(PyTypeObject *type); /* MergeVTables.proto */ static int __Pyx_MergeVtables(PyTypeObject *type); /* DelItemOnTypeDict.proto */ static int __Pyx__DelItemOnTypeDict(PyTypeObject *tp, PyObject *k); #define __Pyx_DelItemOnTypeDict(tp, k) __Pyx__DelItemOnTypeDict((PyTypeObject*)tp, k) /* SetupReduce.proto */ static int __Pyx_setup_reduce(PyObject* type_obj); /* TypeImport.proto */ #ifndef __PYX_HAVE_RT_ImportType_proto_3_2_0 #define __PYX_HAVE_RT_ImportType_proto_3_2_0 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #include #endif #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || __cplusplus >= 201103L #define __PYX_GET_STRUCT_ALIGNMENT_3_2_0(s) alignof(s) #else #define __PYX_GET_STRUCT_ALIGNMENT_3_2_0(s) sizeof(void*) #endif enum __Pyx_ImportType_CheckSize_3_2_0 { __Pyx_ImportType_CheckSize_Error_3_2_0 = 0, __Pyx_ImportType_CheckSize_Warn_3_2_0 = 1, __Pyx_ImportType_CheckSize_Ignore_3_2_0 = 2 }; static PyTypeObject *__Pyx_ImportType_3_2_0(PyObject* module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_2_0 check_size); #endif /* HasAttr.proto */ #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_HasAttr(o, n) PyObject_HasAttrWithError(o, n) #else static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *); #endif /* Import.export */ static PyObject *__Pyx_Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, int level); /* ImportFrom.proto */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /* dict_setdefault.proto */ static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value); /* AddModuleRef.proto */ #if ((CYTHON_COMPILING_IN_CPYTHON_FREETHREADING ) ||\ __PYX_LIMITED_VERSION_HEX < 0x030d0000) static PyObject *__Pyx_PyImport_AddModuleRef(const char *name); #else #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name) #endif /* FetchSharedCythonModule.proto */ static PyObject *__Pyx_FetchSharedCythonABIModule(void); /* FetchCommonType.proto */ static PyTypeObject* __Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases); /* CommonTypesMetaclass.proto */ static int __pyx_CommonTypesMetaclass_init(PyObject *module); #define __Pyx_CommonTypesMetaclass_USED /* PyMethodNew.proto */ static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ); /* PyVectorcallFastCallDict.proto */ #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw); #endif /* CythonFunctionShared.proto */ #define __Pyx_CyFunction_USED #define __Pyx_CYFUNCTION_STATICMETHOD 0x01 #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 #define __Pyx_CYFUNCTION_CCLASS 0x04 #define __Pyx_CYFUNCTION_COROUTINE 0x08 #define __Pyx_CyFunction_GetClosure(f)\ (((__pyx_CyFunctionObject *) (f))->func_closure) #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_GetClassObj(f)\ (((__pyx_CyFunctionObject *) (f))->func_classobj) #else #define __Pyx_CyFunction_GetClassObj(f)\ ((PyObject*) ((PyCMethodObject *) (f))->mm_class) #endif #define __Pyx_CyFunction_SetClassObj(f, classobj)\ __Pyx__CyFunction_SetClassObj((__pyx_CyFunctionObject *) (f), (classobj)) #define __Pyx_CyFunction_Defaults(type, f)\ ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) typedef struct { #if CYTHON_COMPILING_IN_LIMITED_API PyObject_HEAD PyObject *func; #elif PY_VERSION_HEX < 0x030900B1 PyCFunctionObject func; #else PyCMethodObject func; #endif #if CYTHON_COMPILING_IN_LIMITED_API && CYTHON_METH_FASTCALL __pyx_vectorcallfunc func_vectorcall; #endif #if CYTHON_COMPILING_IN_LIMITED_API PyObject *func_weakreflist; #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API PyObject *func_dict; #endif PyObject *func_name; PyObject *func_qualname; PyObject *func_doc; PyObject *func_globals; PyObject *func_code; PyObject *func_closure; #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API PyObject *func_classobj; #endif PyObject *defaults; int flags; PyObject *defaults_tuple; PyObject *defaults_kwdict; PyObject *(*defaults_getter)(PyObject *); PyObject *func_annotations; PyObject *func_is_coroutine; } __pyx_CyFunctionObject; #undef __Pyx_CyOrPyCFunction_Check #define __Pyx_CyFunction_Check(obj) __Pyx_TypeCheck(obj, __pyx_mstate_global->__pyx_CyFunctionType) #define __Pyx_CyOrPyCFunction_Check(obj) __Pyx_TypeCheck2(obj, __pyx_mstate_global->__pyx_CyFunctionType, &PyCFunction_Type) #define __Pyx_CyFunction_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_mstate_global->__pyx_CyFunctionType) static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)); #undef __Pyx_IsSameCFunction #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCyOrCFunction(func, cfunc) static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject *globals, PyObject* code); static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj); static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, PyObject *tuple); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, PyObject *dict); static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, PyObject *dict); static int __pyx_CyFunction_init(PyObject *module); #if CYTHON_METH_FASTCALL static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_func_vectorcall(f) (((__pyx_CyFunctionObject*)f)->func_vectorcall) #else #define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall) #endif #endif /* CythonFunction.proto */ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject *globals, PyObject* code); /* CLineInTraceback.proto */ #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); #else #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) #endif /* CodeObjectCache.proto */ #if CYTHON_COMPILING_IN_LIMITED_API typedef PyObject __Pyx_CachedCodeObjectType; #else typedef PyCodeObject __Pyx_CachedCodeObjectType; #endif typedef struct { __Pyx_CachedCodeObjectType* code_object; int code_line; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_atomic_int_type accessor_count; #endif }; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object); /* AddTraceback.proto */ static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); /* GCCDiagnostics.proto */ #if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #define __Pyx_HAS_GCC_DIAGNOSTIC #endif /* CheckUnpickleChecksum.proto */ static CYTHON_INLINE int __Pyx_CheckUnpickleChecksum(long checksum, long checksum1, long checksum2, long checksum3, const char *members); /* PyObjectVectorCallKwBuilder.proto */ CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n); #if CYTHON_VECTORCALL #if PY_VERSION_HEX >= 0x03090000 #define __Pyx_Object_Vectorcall_CallFromBuilder PyObject_Vectorcall #else #define __Pyx_Object_Vectorcall_CallFromBuilder _PyObject_Vectorcall #endif #define __Pyx_MakeVectorcallBuilderKwds(n) PyTuple_New(n) static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n); static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n); #else #define __Pyx_Object_Vectorcall_CallFromBuilder __Pyx_PyObject_FastCallDict #define __Pyx_MakeVectorcallBuilderKwds(n) __Pyx_PyDict_NewPresized(n) #define __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n) PyDict_SetItem(builder, key, value) #define __Pyx_VectorcallBuilder_AddArgStr(key, value, builder, args, n) PyDict_SetItemString(builder, key, value) #endif /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value); /* CIntFromPy.proto */ static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyLong_As_unsigned_PY_LONG_LONG(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value); /* PyObjectCall2Args.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); /* PyObjectCallMethod1.proto */ static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); /* UpdateUnpickledDict.proto */ static int __Pyx_UpdateUnpickledDict(PyObject *obj, PyObject *state, Py_ssize_t index); /* FormatTypeName.proto */ #if CYTHON_COMPILING_IN_LIMITED_API typedef PyObject *__Pyx_TypeName; #define __Pyx_FMT_TYPENAME "%U" #define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj) #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyType_GetFullyQualifiedName PyType_GetFullyQualifiedName #else static __Pyx_TypeName __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp); #endif #else // !LIMITED_API typedef const char *__Pyx_TypeName; #define __Pyx_FMT_TYPENAME "%.200s" #define __Pyx_PyType_GetFullyQualifiedName(tp) ((tp)->tp_name) #define __Pyx_DECREF_TypeName(obj) #endif /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *); /* FastTypeChecks.proto */ #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) #define __Pyx_TypeCheck2(obj, type1, type2) __Pyx_IsAnySubtype2(Py_TYPE(obj), (PyTypeObject *)type1, (PyTypeObject *)type2) static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); #else #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_TypeCheck2(obj, type1, type2) (PyObject_TypeCheck(obj, (PyTypeObject *)type1) || PyObject_TypeCheck(obj, (PyTypeObject *)type2)) #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2) { return PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2); } #endif #define __Pyx_PyErr_ExceptionMatches2(err1, err2) __Pyx_PyErr_GivenExceptionMatches2(__Pyx_PyErr_CurrentExceptionType(), err1, err2) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #ifdef PyExceptionInstance_Check #define __Pyx_PyBaseException_Check(obj) PyExceptionInstance_Check(obj) #else #define __Pyx_PyBaseException_Check(obj) __Pyx_TypeCheck(obj, PyExc_BaseException) #endif /* GetRuntimeVersion.proto */ #if __PYX_LIMITED_VERSION_HEX < 0x030b0000 static unsigned long __Pyx_cached_runtime_version = 0; static void __Pyx_init_runtime_version(void); #else #define __Pyx_init_runtime_version() #endif static unsigned long __Pyx_get_runtime_version(void); /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer); /* DecompressString.proto */ static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo); /* MultiPhaseInitModuleState.proto */ #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE static PyObject *__Pyx_State_FindModule(void*); static int __Pyx_State_AddModule(PyObject* module, void*); static int __Pyx_State_RemoveModule(void*); #elif CYTHON_USE_MODULE_STATE #define __Pyx_State_FindModule PyState_FindModule #define __Pyx_State_AddModule PyState_AddModule #define __Pyx_State_RemoveModule PyState_RemoveModule #endif /* #### Code section: module_declarations ### */ /* CythonABIVersion.proto */ #if CYTHON_COMPILING_IN_LIMITED_API #if CYTHON_METH_FASTCALL #define __PYX_FASTCALL_ABI_SUFFIX "_fastcall" #else #define __PYX_FASTCALL_ABI_SUFFIX #endif #define __PYX_LIMITED_ABI_SUFFIX "limited" __PYX_FASTCALL_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX #else #define __PYX_LIMITED_ABI_SUFFIX #endif #if __PYX_HAS_PY_AM_SEND == 1 #define __PYX_AM_SEND_ABI_SUFFIX #elif __PYX_HAS_PY_AM_SEND == 2 #define __PYX_AM_SEND_ABI_SUFFIX "amsendbackport" #else #define __PYX_AM_SEND_ABI_SUFFIX "noamsend" #endif #ifndef __PYX_MONITORING_ABI_SUFFIX #define __PYX_MONITORING_ABI_SUFFIX #endif #if CYTHON_USE_TP_FINALIZE #define __PYX_TP_FINALIZE_ABI_SUFFIX #else #define __PYX_TP_FINALIZE_ABI_SUFFIX "nofinalize" #endif #if CYTHON_USE_FREELISTS || !defined(__Pyx_AsyncGen_USED) #define __PYX_FREELISTS_ABI_SUFFIX #else #define __PYX_FREELISTS_ABI_SUFFIX "nofreelists" #endif #define CYTHON_ABI __PYX_ABI_VERSION __PYX_LIMITED_ABI_SUFFIX __PYX_MONITORING_ABI_SUFFIX __PYX_TP_FINALIZE_ABI_SUFFIX __PYX_FREELISTS_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX #define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI #define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "." #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4real_real(PyComplexObject *__pyx_v_self); /* proto*/ #endif #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4imag_imag(PyComplexObject *__pyx_v_self); /* proto*/ #endif static PyObject *__pyx_f_17clickhouse_driver_14bufferedwriter_14BufferedWriter_write_into_stream(CYTHON_UNUSED struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ static PyObject *__pyx_f_17clickhouse_driver_14bufferedwriter_14BufferedWriter_write(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_data, int __pyx_skip_dispatch); /* proto*/ static PyObject *__pyx_f_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_write_into_stream(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ static PyObject *__pyx_f_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_write_into_stream(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ /* Module declarations from "cpython.version" */ /* Module declarations from "__builtin__" */ /* Module declarations from "cpython.type" */ /* Module declarations from "libc.string" */ /* Module declarations from "libc.stdio" */ /* Module declarations from "cpython.object" */ /* Module declarations from "cpython.ref" */ /* Module declarations from "cpython.exc" */ /* Module declarations from "cpython.module" */ /* Module declarations from "cpython.mem" */ /* Module declarations from "cpython.tuple" */ /* Module declarations from "cpython.list" */ /* Module declarations from "cpython.sequence" */ /* Module declarations from "cpython.mapping" */ /* Module declarations from "cpython.iterator" */ /* Module declarations from "cpython.number" */ /* Module declarations from "__builtin__" */ /* Module declarations from "cpython.bool" */ /* Module declarations from "cpython.long" */ /* Module declarations from "cpython.float" */ /* Module declarations from "cython" */ /* Module declarations from "__builtin__" */ /* Module declarations from "cpython.complex" */ /* Module declarations from "libc.stddef" */ /* Module declarations from "cpython.unicode" */ /* Module declarations from "cpython.pyport" */ /* Module declarations from "cpython.dict" */ /* Module declarations from "cpython.instance" */ /* Module declarations from "cpython.function" */ /* Module declarations from "cpython.method" */ /* Module declarations from "cpython.weakref" */ /* Module declarations from "cpython.getargs" */ /* Module declarations from "cpython.pythread" */ /* Module declarations from "cpython.pystate" */ /* Module declarations from "cpython.set" */ /* Module declarations from "cpython.buffer" */ /* Module declarations from "cpython.bytes" */ /* Module declarations from "cpython.pycapsule" */ /* Module declarations from "cpython.contextvars" */ /* Module declarations from "cpython" */ /* Module declarations from "clickhouse_driver.bufferedwriter" */ static PyObject *__pyx_f_17clickhouse_driver_14bufferedwriter___pyx_unpickle_BufferedWriter__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *, PyObject *); /*proto*/ static PyObject *__pyx_f_17clickhouse_driver_14bufferedwriter___pyx_unpickle_BufferedSocketWriter__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *, PyObject *); /*proto*/ static PyObject *__pyx_f_17clickhouse_driver_14bufferedwriter___pyx_unpickle_CompressedBufferedWriter__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *, PyObject *); /*proto*/ /* #### Code section: typeinfo ### */ /* #### Code section: before_global_var ### */ #define __Pyx_MODULE_NAME "clickhouse_driver.bufferedwriter" extern int __pyx_module_is_main_clickhouse_driver__bufferedwriter; int __pyx_module_is_main_clickhouse_driver__bufferedwriter = 0; /* Implementation of "clickhouse_driver.bufferedwriter" */ /* #### Code section: global_var ### */ static PyObject *__pyx_builtin_super; /* #### Code section: string_decls ### */ /* #### Code section: decls ### */ static int __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter___init__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, unsigned PY_LONG_LONG __pyx_v_bufsize); /* proto */ static void __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_2__dealloc__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_4write_into_stream(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_6write(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_data); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_8flush(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_10write_strings(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_encoding); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_12write_fixed_strings_as_bytes(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_items, Py_ssize_t __pyx_v_length); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_14write_fixed_strings(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_items, Py_ssize_t __pyx_v_length, PyObject *__pyx_v_encoding); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_16__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_18__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */ static int __pyx_pf_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter___init__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *__pyx_v_self, PyObject *__pyx_v_sock, PyObject *__pyx_v_bufsize); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_2write_into_stream(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_4__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_6__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */ static int __pyx_pf_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter___init__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *__pyx_v_self, PyObject *__pyx_v_compressor, PyObject *__pyx_v_bufsize); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_2write_into_stream(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_4flush(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_6__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_8__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter___pyx_unpickle_BufferedWriter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_2__pyx_unpickle_BufferedSocketWriter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_4__pyx_unpickle_CompressedBufferedWriter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */ static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedwriter_BufferedWriter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ /* #### Code section: late_includes ### */ /* #### Code section: module_state ### */ /* SmallCodeConfig */ #ifndef CYTHON_SMALL_CODE #if defined(__clang__) #define CYTHON_SMALL_CODE #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) #define CYTHON_SMALL_CODE __attribute__((cold)) #else #define CYTHON_SMALL_CODE #endif #endif typedef struct { PyObject *__pyx_d; PyObject *__pyx_b; PyObject *__pyx_cython_runtime; PyObject *__pyx_empty_tuple; PyObject *__pyx_empty_bytes; PyObject *__pyx_empty_unicode; PyTypeObject *__pyx_ptype_7cpython_4type_type; PyTypeObject *__pyx_ptype_7cpython_4bool_bool; PyTypeObject *__pyx_ptype_7cpython_7complex_complex; PyObject *__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter; PyObject *__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter; PyObject *__pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter; PyTypeObject *__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter; PyTypeObject *__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter; PyTypeObject *__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_values; PyObject *__pyx_tuple[4]; PyObject *__pyx_codeobj_tab[18]; PyObject *__pyx_string_tab[116]; PyObject *__pyx_number_tab[3]; /* #### Code section: module_state_contents ### */ /* CommonTypesMetaclass.module_state_decls */ PyTypeObject *__pyx_CommonTypesMetaclassType; /* CachedMethodType.module_state_decls */ #if CYTHON_COMPILING_IN_LIMITED_API PyObject *__Pyx_CachedMethodType; #endif /* CythonFunctionShared.module_state_decls */ PyTypeObject *__pyx_CyFunctionType; /* CodeObjectCache.module_state_decls */ struct __Pyx_CodeObjectCache __pyx_code_cache; /* #### Code section: module_state_end ### */ } __pyx_mstatetype; #if CYTHON_USE_MODULE_STATE #ifdef __cplusplus namespace { extern struct PyModuleDef __pyx_moduledef; } /* anonymous namespace */ #else static struct PyModuleDef __pyx_moduledef; #endif #define __pyx_mstate_global (__Pyx_PyModule_GetState(__Pyx_State_FindModule(&__pyx_moduledef))) #define __pyx_m (__Pyx_State_FindModule(&__pyx_moduledef)) #else static __pyx_mstatetype __pyx_mstate_global_static = #ifdef __cplusplus {}; #else {0}; #endif static __pyx_mstatetype * const __pyx_mstate_global = &__pyx_mstate_global_static; #endif /* #### Code section: constant_name_defines ### */ #define __pyx_kp_u_Note_that_Cython_is_deliberately __pyx_string_tab[0] #define __pyx_kp_u__2 __pyx_string_tab[1] #define __pyx_kp_u__3 __pyx_string_tab[2] #define __pyx_kp_u_add_note __pyx_string_tab[3] #define __pyx_kp_u_bytes_object_expected __pyx_string_tab[4] #define __pyx_kp_u_clickhouse_driver __pyx_string_tab[5] #define __pyx_kp_u_clickhouse_driver_bufferedwriter_2 __pyx_string_tab[6] #define __pyx_kp_u_clickhouse_driver_varint __pyx_string_tab[7] #define __pyx_kp_u_disable __pyx_string_tab[8] #define __pyx_kp_u_enable __pyx_string_tab[9] #define __pyx_kp_u_gc __pyx_string_tab[10] #define __pyx_kp_u_isenabled __pyx_string_tab[11] #define __pyx_kp_u_self_compressor_is_not_None __pyx_string_tab[12] #define __pyx_kp_u_self_sock_is_not_None __pyx_string_tab[13] #define __pyx_kp_u_stringsource __pyx_string_tab[14] #define __pyx_n_u_ __pyx_string_tab[15] #define __pyx_n_u_BufferedSocketWriter __pyx_string_tab[16] #define __pyx_n_u_BufferedSocketWriter___reduce_cy __pyx_string_tab[17] #define __pyx_n_u_BufferedSocketWriter___setstate __pyx_string_tab[18] #define __pyx_n_u_BufferedSocketWriter_write_into __pyx_string_tab[19] #define __pyx_n_u_BufferedWriter __pyx_string_tab[20] #define __pyx_n_u_BufferedWriter___reduce_cython __pyx_string_tab[21] #define __pyx_n_u_BufferedWriter___setstate_cython __pyx_string_tab[22] #define __pyx_n_u_BufferedWriter_flush __pyx_string_tab[23] #define __pyx_n_u_BufferedWriter_write __pyx_string_tab[24] #define __pyx_n_u_BufferedWriter_write_fixed_strin __pyx_string_tab[25] #define __pyx_n_u_BufferedWriter_write_fixed_strin_2 __pyx_string_tab[26] #define __pyx_n_u_BufferedWriter_write_into_stream __pyx_string_tab[27] #define __pyx_n_u_BufferedWriter_write_strings __pyx_string_tab[28] #define __pyx_n_u_CompressedBufferedWriter __pyx_string_tab[29] #define __pyx_n_u_CompressedBufferedWriter___reduc __pyx_string_tab[30] #define __pyx_n_u_CompressedBufferedWriter___setst __pyx_string_tab[31] #define __pyx_n_u_CompressedBufferedWriter_flush __pyx_string_tab[32] #define __pyx_n_u_CompressedBufferedWriter_write_i __pyx_string_tab[33] #define __pyx_n_u_False __pyx_string_tab[34] #define __pyx_n_u_Pyx_PyDict_NextRef __pyx_string_tab[35] #define __pyx_n_u_TooLargeStringSize __pyx_string_tab[36] #define __pyx_n_u_asyncio_coroutines __pyx_string_tab[37] #define __pyx_n_u_buf_pos __pyx_string_tab[38] #define __pyx_n_u_bufsize __pyx_string_tab[39] #define __pyx_n_u_c_value __pyx_string_tab[40] #define __pyx_n_u_clickhouse_driver_bufferedwriter __pyx_string_tab[41] #define __pyx_n_u_cline_in_traceback __pyx_string_tab[42] #define __pyx_n_u_compressor __pyx_string_tab[43] #define __pyx_n_u_data __pyx_string_tab[44] #define __pyx_n_u_dict __pyx_string_tab[45] #define __pyx_n_u_dict_2 __pyx_string_tab[46] #define __pyx_n_u_do_encode __pyx_string_tab[47] #define __pyx_n_u_encode __pyx_string_tab[48] #define __pyx_n_u_encoding __pyx_string_tab[49] #define __pyx_n_u_errors __pyx_string_tab[50] #define __pyx_n_u_flush __pyx_string_tab[51] #define __pyx_n_u_func __pyx_string_tab[52] #define __pyx_n_u_getstate __pyx_string_tab[53] #define __pyx_n_u_init __pyx_string_tab[54] #define __pyx_n_u_is_coroutine __pyx_string_tab[55] #define __pyx_n_u_items __pyx_string_tab[56] #define __pyx_n_u_items_buf __pyx_string_tab[57] #define __pyx_n_u_items_buf_size __pyx_string_tab[58] #define __pyx_n_u_length __pyx_string_tab[59] #define __pyx_n_u_main __pyx_string_tab[60] #define __pyx_n_u_make_varint __pyx_string_tab[61] #define __pyx_n_u_module __pyx_string_tab[62] #define __pyx_n_u_name __pyx_string_tab[63] #define __pyx_n_u_new __pyx_string_tab[64] #define __pyx_n_u_pop __pyx_string_tab[65] #define __pyx_n_u_pyx_checksum __pyx_string_tab[66] #define __pyx_n_u_pyx_result __pyx_string_tab[67] #define __pyx_n_u_pyx_state __pyx_string_tab[68] #define __pyx_n_u_pyx_type __pyx_string_tab[69] #define __pyx_n_u_pyx_unpickle_BufferedSocketWri __pyx_string_tab[70] #define __pyx_n_u_pyx_unpickle_BufferedWriter __pyx_string_tab[71] #define __pyx_n_u_pyx_unpickle_CompressedBuffere __pyx_string_tab[72] #define __pyx_n_u_pyx_vtable __pyx_string_tab[73] #define __pyx_n_u_qualname __pyx_string_tab[74] #define __pyx_n_u_reduce __pyx_string_tab[75] #define __pyx_n_u_reduce_cython __pyx_string_tab[76] #define __pyx_n_u_reduce_ex __pyx_string_tab[77] #define __pyx_n_u_self __pyx_string_tab[78] #define __pyx_n_u_sendall __pyx_string_tab[79] #define __pyx_n_u_set_name __pyx_string_tab[80] #define __pyx_n_u_setdefault __pyx_string_tab[81] #define __pyx_n_u_setstate __pyx_string_tab[82] #define __pyx_n_u_setstate_cython __pyx_string_tab[83] #define __pyx_n_u_sock __pyx_string_tab[84] #define __pyx_n_u_state __pyx_string_tab[85] #define __pyx_n_u_super __pyx_string_tab[86] #define __pyx_n_u_test __pyx_string_tab[87] #define __pyx_n_u_update __pyx_string_tab[88] #define __pyx_n_u_use_setstate __pyx_string_tab[89] #define __pyx_n_u_value __pyx_string_tab[90] #define __pyx_n_u_value_len __pyx_string_tab[91] #define __pyx_n_u_values __pyx_string_tab[92] #define __pyx_n_u_varint __pyx_string_tab[93] #define __pyx_n_u_write __pyx_string_tab[94] #define __pyx_n_u_write_fixed_strings __pyx_string_tab[95] #define __pyx_n_u_write_fixed_strings_as_bytes __pyx_string_tab[96] #define __pyx_n_u_write_into_stream __pyx_string_tab[97] #define __pyx_n_u_write_strings __pyx_string_tab[98] #define __pyx_kp_b_iso88591_2_6 __pyx_string_tab[99] #define __pyx_kp_b_iso88591_6avQ __pyx_string_tab[100] #define __pyx_kp_b_iso88591_AV1 __pyx_string_tab[101] #define __pyx_kp_b_iso88591_A_0_1A_Qa_hb_ay_4_Bd_1D_q_L_q_t __pyx_string_tab[102] #define __pyx_kp_b_iso88591_A_E_Qd_4q_L __pyx_string_tab[103] #define __pyx_kp_b_iso88591_A_KvQ_Qd_4q_L __pyx_string_tab[104] #define __pyx_kp_b_iso88591_A_Qa_x_1A_4q_a_Q_IQ_1A_wb_f_q_aq __pyx_string_tab[105] #define __pyx_kp_b_iso88591_A_YgQ_IQ_t_1_E_AQ_a_31A_aq __pyx_string_tab[106] #define __pyx_kp_b_iso88591_A_a __pyx_string_tab[107] #define __pyx_kp_b_iso88591_A_a_2 __pyx_string_tab[108] #define __pyx_kp_b_iso88591_EQ_9Cq_QgQ_Qa_x_1A_4q_a_Q_IQ_t __pyx_string_tab[109] #define __pyx_kp_b_iso88591_T_nD_4q_G1F_a_vWE_Q_q_q_5T_GST __pyx_string_tab[110] #define __pyx_kp_b_iso88591_T_nD_G1F_a_vWE_Q_q_q_t1G_gQ_t1G __pyx_string_tab[111] #define __pyx_kp_b_iso88591_T_nD_T_G1F_a_vWE_Q_q_q_9_Qg_PWW __pyx_string_tab[112] #define __pyx_kp_b_iso88591_q_0_kQR_7_0_1B_PQ_1 __pyx_string_tab[113] #define __pyx_kp_b_iso88591_q_0_kQR_81A_7_VVdde_1 __pyx_string_tab[114] #define __pyx_kp_b_iso88591_q_0_kQR_xq_7_6a7Nn_1 __pyx_string_tab[115] #define __pyx_int_29629619 __pyx_number_tab[0] #define __pyx_int_137744089 __pyx_number_tab[1] #define __pyx_int_211840719 __pyx_number_tab[2] /* #### Code section: module_state_clear ### */ #if CYTHON_USE_MODULE_STATE static CYTHON_SMALL_CODE int __pyx_m_clear(PyObject *m) { __pyx_mstatetype *clear_module_state = __Pyx_PyModule_GetState(m); if (!clear_module_state) return 0; Py_CLEAR(clear_module_state->__pyx_d); Py_CLEAR(clear_module_state->__pyx_b); Py_CLEAR(clear_module_state->__pyx_cython_runtime); Py_CLEAR(clear_module_state->__pyx_empty_tuple); Py_CLEAR(clear_module_state->__pyx_empty_bytes); Py_CLEAR(clear_module_state->__pyx_empty_unicode); #if CYTHON_PEP489_MULTI_PHASE_INIT __Pyx_State_RemoveModule(NULL); #endif Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_4type_type); Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_4bool_bool); Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_7complex_complex); Py_CLEAR(clear_module_state->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter); Py_CLEAR(clear_module_state->__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter); Py_CLEAR(clear_module_state->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter); Py_CLEAR(clear_module_state->__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter); Py_CLEAR(clear_module_state->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter); Py_CLEAR(clear_module_state->__pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter); for (int i=0; i<4; ++i) { Py_CLEAR(clear_module_state->__pyx_tuple[i]); } for (int i=0; i<18; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); } for (int i=0; i<116; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); } for (int i=0; i<3; ++i) { Py_CLEAR(clear_module_state->__pyx_number_tab[i]); } /* #### Code section: module_state_clear_contents ### */ /* CommonTypesMetaclass.module_state_clear */ Py_CLEAR(clear_module_state->__pyx_CommonTypesMetaclassType); /* CythonFunctionShared.module_state_clear */ Py_CLEAR(clear_module_state->__pyx_CyFunctionType); /* #### Code section: module_state_clear_end ### */ return 0; } #endif /* #### Code section: module_state_traverse ### */ #if CYTHON_USE_MODULE_STATE static CYTHON_SMALL_CODE int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) { __pyx_mstatetype *traverse_module_state = __Pyx_PyModule_GetState(m); if (!traverse_module_state) return 0; Py_VISIT(traverse_module_state->__pyx_d); Py_VISIT(traverse_module_state->__pyx_b); Py_VISIT(traverse_module_state->__pyx_cython_runtime); __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_tuple); __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_bytes); __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_unicode); Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_4type_type); Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_4bool_bool); Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_7complex_complex); Py_VISIT(traverse_module_state->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter); Py_VISIT(traverse_module_state->__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter); Py_VISIT(traverse_module_state->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter); Py_VISIT(traverse_module_state->__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter); Py_VISIT(traverse_module_state->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter); Py_VISIT(traverse_module_state->__pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter); for (int i=0; i<4; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_tuple[i]); } for (int i=0; i<18; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); } for (int i=0; i<116; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); } for (int i=0; i<3; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_number_tab[i]); } /* #### Code section: module_state_traverse_contents ### */ /* CommonTypesMetaclass.module_state_traverse */ Py_VISIT(traverse_module_state->__pyx_CommonTypesMetaclassType); /* CythonFunctionShared.module_state_traverse */ Py_VISIT(traverse_module_state->__pyx_CyFunctionType); /* #### Code section: module_state_traverse_end ### */ return 0; } #endif /* #### Code section: module_code ### */ /* "cpython/complex.pxd":20 * * # unavailable in limited API * @property # <<<<<<<<<<<<<< * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double real(self) noexcept: */ #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4real_real(PyComplexObject *__pyx_v_self) { double __pyx_r; /* "cpython/complex.pxd":23 * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double real(self) noexcept: * return self.cval.real # <<<<<<<<<<<<<< * * # unavailable in limited API */ __pyx_r = __pyx_v_self->cval.real; goto __pyx_L0; /* "cpython/complex.pxd":20 * * # unavailable in limited API * @property # <<<<<<<<<<<<<< * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double real(self) noexcept: */ /* function exit code */ __pyx_L0:; return __pyx_r; } #endif /*!(#if !CYTHON_COMPILING_IN_LIMITED_API)*/ /* "cpython/complex.pxd":26 * * # unavailable in limited API * @property # <<<<<<<<<<<<<< * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double imag(self) noexcept: */ #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4imag_imag(PyComplexObject *__pyx_v_self) { double __pyx_r; /* "cpython/complex.pxd":29 * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double imag(self) noexcept: * return self.cval.imag # <<<<<<<<<<<<<< * * # PyTypeObject PyComplex_Type */ __pyx_r = __pyx_v_self->cval.imag; goto __pyx_L0; /* "cpython/complex.pxd":26 * * # unavailable in limited API * @property # <<<<<<<<<<<<<< * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double imag(self) noexcept: */ /* function exit code */ __pyx_L0:; return __pyx_r; } #endif /*!(#if !CYTHON_COMPILING_IN_LIMITED_API)*/ /* "cpython/contextvars.pxd":115 * * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") # <<<<<<<<<<<<<< * cdef inline object get_value(var, default_value=None): * """Return a new reference to the value of the context variable, */ #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE PyObject *__pyx_f_7cpython_11contextvars_get_value(PyObject *__pyx_v_var, struct __pyx_opt_args_7cpython_11contextvars_get_value *__pyx_optional_args) { /* "cpython/contextvars.pxd":116 * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline object get_value(var, default_value=None): # <<<<<<<<<<<<<< * """Return a new reference to the value of the context variable, * or the default value of the context variable, */ PyObject *__pyx_v_default_value = ((PyObject *)Py_None); PyObject *__pyx_v_value; PyObject *__pyx_v_pyvalue = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_value", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_default_value = __pyx_optional_args->default_value; } } /* "cpython/contextvars.pxd":121 * or None if no such value or default was found. * """ * cdef PyObject *value = NULL # <<<<<<<<<<<<<< * PyContextVar_Get(var, NULL, &value) * if value is NULL: */ __pyx_v_value = NULL; /* "cpython/contextvars.pxd":122 * """ * cdef PyObject *value = NULL * PyContextVar_Get(var, NULL, &value) # <<<<<<<<<<<<<< * if value is NULL: * # context variable does not have a default */ __pyx_t_1 = PyContextVar_Get(__pyx_v_var, NULL, (&__pyx_v_value)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(1, 122, __pyx_L1_error) /* "cpython/contextvars.pxd":123 * cdef PyObject *value = NULL * PyContextVar_Get(var, NULL, &value) * if value is NULL: # <<<<<<<<<<<<<< * # context variable does not have a default * pyvalue = default_value */ __pyx_t_2 = (__pyx_v_value == NULL); if (__pyx_t_2) { /* "cpython/contextvars.pxd":125 * if value is NULL: * # context variable does not have a default * pyvalue = default_value # <<<<<<<<<<<<<< * else: * # value or default value of context variable */ __Pyx_INCREF(__pyx_v_default_value); __pyx_v_pyvalue = __pyx_v_default_value; /* "cpython/contextvars.pxd":123 * cdef PyObject *value = NULL * PyContextVar_Get(var, NULL, &value) * if value is NULL: # <<<<<<<<<<<<<< * # context variable does not have a default * pyvalue = default_value */ goto __pyx_L3; } /* "cpython/contextvars.pxd":128 * else: * # value or default value of context variable * pyvalue = value # <<<<<<<<<<<<<< * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' * return pyvalue */ /*else*/ { __pyx_t_3 = ((PyObject *)__pyx_v_value); __Pyx_INCREF(__pyx_t_3); __pyx_v_pyvalue = __pyx_t_3; __pyx_t_3 = 0; /* "cpython/contextvars.pxd":129 * # value or default value of context variable * pyvalue = value * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' # <<<<<<<<<<<<<< * return pyvalue * */ Py_XDECREF(__pyx_v_value); } __pyx_L3:; /* "cpython/contextvars.pxd":130 * pyvalue = value * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' * return pyvalue # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_pyvalue); __pyx_r = __pyx_v_pyvalue; goto __pyx_L0; /* "cpython/contextvars.pxd":115 * * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") # <<<<<<<<<<<<<< * cdef inline object get_value(var, default_value=None): * """Return a new reference to the value of the context variable, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("cpython.contextvars.get_value", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_pyvalue); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /*!(#if !CYTHON_COMPILING_IN_LIMITED_API)*/ /* "cpython/contextvars.pxd":133 * * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") # <<<<<<<<<<<<<< * cdef inline object get_value_no_default(var, default_value=None): * """Return a new reference to the value of the context variable, */ #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE PyObject *__pyx_f_7cpython_11contextvars_get_value_no_default(PyObject *__pyx_v_var, struct __pyx_opt_args_7cpython_11contextvars_get_value_no_default *__pyx_optional_args) { /* "cpython/contextvars.pxd":134 * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline object get_value_no_default(var, default_value=None): # <<<<<<<<<<<<<< * """Return a new reference to the value of the context variable, * or the provided default value if no such value was found. */ PyObject *__pyx_v_default_value = ((PyObject *)Py_None); PyObject *__pyx_v_value; PyObject *__pyx_v_pyvalue = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_value_no_default", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_default_value = __pyx_optional_args->default_value; } } /* "cpython/contextvars.pxd":140 * Ignores the default value of the context variable, if any. * """ * cdef PyObject *value = NULL # <<<<<<<<<<<<<< * PyContextVar_Get(var, default_value, &value) * # value of context variable or 'default_value' */ __pyx_v_value = NULL; /* "cpython/contextvars.pxd":141 * """ * cdef PyObject *value = NULL * PyContextVar_Get(var, default_value, &value) # <<<<<<<<<<<<<< * # value of context variable or 'default_value' * pyvalue = value */ __pyx_t_1 = PyContextVar_Get(__pyx_v_var, ((PyObject *)__pyx_v_default_value), (&__pyx_v_value)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(1, 141, __pyx_L1_error) /* "cpython/contextvars.pxd":143 * PyContextVar_Get(var, default_value, &value) * # value of context variable or 'default_value' * pyvalue = value # <<<<<<<<<<<<<< * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' * return pyvalue */ __pyx_t_2 = ((PyObject *)__pyx_v_value); __Pyx_INCREF(__pyx_t_2); __pyx_v_pyvalue = __pyx_t_2; __pyx_t_2 = 0; /* "cpython/contextvars.pxd":144 * # value of context variable or 'default_value' * pyvalue = value * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' # <<<<<<<<<<<<<< * return pyvalue */ Py_XDECREF(__pyx_v_value); /* "cpython/contextvars.pxd":145 * pyvalue = value * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' * return pyvalue # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_pyvalue); __pyx_r = __pyx_v_pyvalue; goto __pyx_L0; /* "cpython/contextvars.pxd":133 * * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") # <<<<<<<<<<<<<< * cdef inline object get_value_no_default(var, default_value=None): * """Return a new reference to the value of the context variable, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("cpython.contextvars.get_value_no_default", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_pyvalue); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /*!(#if !CYTHON_COMPILING_IN_LIMITED_API)*/ /* "clickhouse_driver/bufferedwriter.pyx":14 * cdef unsigned long long position, buffer_size * * def __init__(self, unsigned long long bufsize): # <<<<<<<<<<<<<< * self.buffer = PyMem_Malloc(bufsize) * if not self.buffer: */ /* Python wrapper */ static int __pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { unsigned PY_LONG_LONG __pyx_v_bufsize; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_bufsize,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_VARARGS(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 14, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 14, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__init__", 0) < (0)) __PYX_ERR(0, 14, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, i); __PYX_ERR(0, 14, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 14, __pyx_L3_error) } __pyx_v_bufsize = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(values[0]); if (unlikely((__pyx_v_bufsize == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 14, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 14, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter___init__(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self), __pyx_v_bufsize); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter___init__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, unsigned PY_LONG_LONG __pyx_v_bufsize) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; size_t __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "clickhouse_driver/bufferedwriter.pyx":15 * * def __init__(self, unsigned long long bufsize): * self.buffer = PyMem_Malloc(bufsize) # <<<<<<<<<<<<<< * if not self.buffer: * raise MemoryError() */ __pyx_v_self->buffer = ((char *)PyMem_Malloc(__pyx_v_bufsize)); /* "clickhouse_driver/bufferedwriter.pyx":16 * def __init__(self, unsigned long long bufsize): * self.buffer = PyMem_Malloc(bufsize) * if not self.buffer: # <<<<<<<<<<<<<< * raise MemoryError() * */ __pyx_t_1 = (!(__pyx_v_self->buffer != 0)); if (unlikely(__pyx_t_1)) { /* "clickhouse_driver/bufferedwriter.pyx":17 * self.buffer = PyMem_Malloc(bufsize) * if not self.buffer: * raise MemoryError() # <<<<<<<<<<<<<< * * self.position = 0 */ PyErr_NoMemory(); __PYX_ERR(0, 17, __pyx_L1_error) /* "clickhouse_driver/bufferedwriter.pyx":16 * def __init__(self, unsigned long long bufsize): * self.buffer = PyMem_Malloc(bufsize) * if not self.buffer: # <<<<<<<<<<<<<< * raise MemoryError() * */ } /* "clickhouse_driver/bufferedwriter.pyx":19 * raise MemoryError() * * self.position = 0 # <<<<<<<<<<<<<< * self.buffer_size = bufsize * */ __pyx_v_self->position = 0; /* "clickhouse_driver/bufferedwriter.pyx":20 * * self.position = 0 * self.buffer_size = bufsize # <<<<<<<<<<<<<< * * super(BufferedWriter, self).__init__() */ __pyx_v_self->buffer_size = __pyx_v_bufsize; /* "clickhouse_driver/bufferedwriter.pyx":22 * self.buffer_size = bufsize * * super(BufferedWriter, self).__init__() # <<<<<<<<<<<<<< * * def __dealloc__(self): */ __pyx_t_5 = NULL; __pyx_t_6 = 1; { PyObject *__pyx_callargs[3] = {__pyx_t_5, ((PyObject *)__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter), ((PyObject *)__pyx_v_self)}; __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_super, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); } __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_init, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedwriter.pyx":14 * cdef unsigned long long position, buffer_size * * def __init__(self, unsigned long long bufsize): # <<<<<<<<<<<<<< * self.buffer = PyMem_Malloc(bufsize) * if not self.buffer: */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedwriter.pyx":24 * super(BufferedWriter, self).__init__() * * def __dealloc__(self): # <<<<<<<<<<<<<< * PyMem_Free(self.buffer) * */ /* Python wrapper */ static void __pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_3__dealloc__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_2__dealloc__(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); } static void __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_2__dealloc__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self) { /* "clickhouse_driver/bufferedwriter.pyx":25 * * def __dealloc__(self): * PyMem_Free(self.buffer) # <<<<<<<<<<<<<< * * cpdef write_into_stream(self): */ PyMem_Free(__pyx_v_self->buffer); /* "clickhouse_driver/bufferedwriter.pyx":24 * super(BufferedWriter, self).__init__() * * def __dealloc__(self): # <<<<<<<<<<<<<< * PyMem_Free(self.buffer) * */ /* function exit code */ } /* "clickhouse_driver/bufferedwriter.pyx":27 * PyMem_Free(self.buffer) * * cpdef write_into_stream(self): # <<<<<<<<<<<<<< * raise NotImplementedError * */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_5write_into_stream(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_17clickhouse_driver_14bufferedwriter_14BufferedWriter_write_into_stream(CYTHON_UNUSED struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; size_t __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write_into_stream", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if ( #if !CYTHON_USE_TYPE_SLOTS unlikely(Py_TYPE(((PyObject *)__pyx_v_self)) != __pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter && __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), Py_TPFLAGS_HAVE_GC)) #else unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0 || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE))) #endif ) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_write_into_stream); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!__Pyx_IsSameCFunction(__pyx_t_1, (void(*)(void)) __pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_5write_into_stream)) { __Pyx_XDECREF(__pyx_r); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = __pyx_t_1; __pyx_t_5 = 1; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); assert(__pyx_t_3); PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx__function); __Pyx_DECREF_SET(__pyx_t_4, __pyx__function); __pyx_t_5 = 0; } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* "clickhouse_driver/bufferedwriter.pyx":28 * * cpdef write_into_stream(self): * raise NotImplementedError # <<<<<<<<<<<<<< * * cpdef write(self, data): */ __Pyx_Raise(((PyObject *)(((PyTypeObject*)PyExc_NotImplementedError))), 0, 0, 0); __PYX_ERR(0, 28, __pyx_L1_error) /* "clickhouse_driver/bufferedwriter.pyx":27 * PyMem_Free(self.buffer) * * cpdef write_into_stream(self): # <<<<<<<<<<<<<< * raise NotImplementedError * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write_into_stream", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_5write_into_stream(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_14BufferedWriter_5write_into_stream = {"write_into_stream", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_5write_into_stream, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_5write_into_stream(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_into_stream (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("write_into_stream", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("write_into_stream", __pyx_kwds); return NULL;} __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_4write_into_stream(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_4write_into_stream(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write_into_stream", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_17clickhouse_driver_14bufferedwriter_14BufferedWriter_write_into_stream(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write_into_stream", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedwriter.pyx":30 * raise NotImplementedError * * cpdef write(self, data): # <<<<<<<<<<<<<< * cdef unsigned long long size, written = 0 * cdef unsigned long long data_len = PyBytes_GET_SIZE(data) */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_7write(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_17clickhouse_driver_14bufferedwriter_14BufferedWriter_write(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_data, int __pyx_skip_dispatch) { unsigned PY_LONG_LONG __pyx_v_size; unsigned PY_LONG_LONG __pyx_v_written; unsigned PY_LONG_LONG __pyx_v_data_len; char *__pyx_v_c_data; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; size_t __pyx_t_5; int __pyx_t_6; unsigned PY_LONG_LONG __pyx_t_7; unsigned PY_LONG_LONG __pyx_t_8; unsigned PY_LONG_LONG __pyx_t_9; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if ( #if !CYTHON_USE_TYPE_SLOTS unlikely(Py_TYPE(((PyObject *)__pyx_v_self)) != __pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter && __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), Py_TPFLAGS_HAVE_GC)) #else unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0 || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE))) #endif ) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_write); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!__Pyx_IsSameCFunction(__pyx_t_1, (void(*)(void)) __pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_7write)) { __Pyx_XDECREF(__pyx_r); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = __pyx_t_1; __pyx_t_5 = 1; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); assert(__pyx_t_3); PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx__function); __Pyx_DECREF_SET(__pyx_t_4, __pyx__function); __pyx_t_5 = 0; } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_data}; __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* "clickhouse_driver/bufferedwriter.pyx":31 * * cpdef write(self, data): * cdef unsigned long long size, written = 0 # <<<<<<<<<<<<<< * cdef unsigned long long data_len = PyBytes_GET_SIZE(data) * cdef char* c_data = PyBytes_AS_STRING(data) */ __pyx_v_written = 0; /* "clickhouse_driver/bufferedwriter.pyx":32 * cpdef write(self, data): * cdef unsigned long long size, written = 0 * cdef unsigned long long data_len = PyBytes_GET_SIZE(data) # <<<<<<<<<<<<<< * cdef char* c_data = PyBytes_AS_STRING(data) * */ __pyx_v_data_len = PyBytes_GET_SIZE(__pyx_v_data); /* "clickhouse_driver/bufferedwriter.pyx":33 * cdef unsigned long long size, written = 0 * cdef unsigned long long data_len = PyBytes_GET_SIZE(data) * cdef char* c_data = PyBytes_AS_STRING(data) # <<<<<<<<<<<<<< * * while written < data_len: */ __pyx_v_c_data = PyBytes_AS_STRING(__pyx_v_data); /* "clickhouse_driver/bufferedwriter.pyx":35 * cdef char* c_data = PyBytes_AS_STRING(data) * * while written < data_len: # <<<<<<<<<<<<<< * size = min(data_len - written, self.buffer_size - self.position) * memcpy(&self.buffer[self.position], &c_data[written], size) */ while (1) { __pyx_t_6 = (__pyx_v_written < __pyx_v_data_len); if (!__pyx_t_6) break; /* "clickhouse_driver/bufferedwriter.pyx":36 * * while written < data_len: * size = min(data_len - written, self.buffer_size - self.position) # <<<<<<<<<<<<<< * memcpy(&self.buffer[self.position], &c_data[written], size) * */ __pyx_t_7 = (__pyx_v_self->buffer_size - __pyx_v_self->position); __pyx_t_8 = (__pyx_v_data_len - __pyx_v_written); __pyx_t_6 = (__pyx_t_7 < __pyx_t_8); if (__pyx_t_6) { __pyx_t_9 = __pyx_t_7; } else { __pyx_t_9 = __pyx_t_8; } __pyx_v_size = __pyx_t_9; /* "clickhouse_driver/bufferedwriter.pyx":37 * while written < data_len: * size = min(data_len - written, self.buffer_size - self.position) * memcpy(&self.buffer[self.position], &c_data[written], size) # <<<<<<<<<<<<<< * * if self.position == self.buffer_size: */ (void)(memcpy((&(__pyx_v_self->buffer[__pyx_v_self->position])), (&(__pyx_v_c_data[__pyx_v_written])), __pyx_v_size)); /* "clickhouse_driver/bufferedwriter.pyx":39 * memcpy(&self.buffer[self.position], &c_data[written], size) * * if self.position == self.buffer_size: # <<<<<<<<<<<<<< * self.write_into_stream() * */ __pyx_t_6 = (__pyx_v_self->position == __pyx_v_self->buffer_size); if (__pyx_t_6) { /* "clickhouse_driver/bufferedwriter.pyx":40 * * if self.position == self.buffer_size: * self.write_into_stream() # <<<<<<<<<<<<<< * * self.position += size */ __pyx_t_1 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self->__pyx_vtab)->write_into_stream(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedwriter.pyx":39 * memcpy(&self.buffer[self.position], &c_data[written], size) * * if self.position == self.buffer_size: # <<<<<<<<<<<<<< * self.write_into_stream() * */ } /* "clickhouse_driver/bufferedwriter.pyx":42 * self.write_into_stream() * * self.position += size # <<<<<<<<<<<<<< * written += size * */ __pyx_v_self->position = (__pyx_v_self->position + __pyx_v_size); /* "clickhouse_driver/bufferedwriter.pyx":43 * * self.position += size * written += size # <<<<<<<<<<<<<< * * def flush(self): */ __pyx_v_written = (__pyx_v_written + __pyx_v_size); } /* "clickhouse_driver/bufferedwriter.pyx":30 * raise NotImplementedError * * cpdef write(self, data): # <<<<<<<<<<<<<< * cdef unsigned long long size, written = 0 * cdef unsigned long long data_len = PyBytes_GET_SIZE(data) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_7write(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_14BufferedWriter_7write = {"write", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_7write, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_7write(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_data = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_data,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 30, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 30, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "write", 0) < (0)) __PYX_ERR(0, 30, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("write", 1, 1, 1, i); __PYX_ERR(0, 30, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 30, __pyx_L3_error) } __pyx_v_data = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("write", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 30, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_6write(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self), __pyx_v_data); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_6write(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_data) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_17clickhouse_driver_14bufferedwriter_14BufferedWriter_write(__pyx_v_self, __pyx_v_data, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedwriter.pyx":45 * written += size * * def flush(self): # <<<<<<<<<<<<<< * self.write_into_stream() * */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_9flush(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_14BufferedWriter_9flush = {"flush", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_9flush, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_9flush(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("flush (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("flush", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("flush", __pyx_kwds); return NULL;} __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_8flush(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_8flush(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("flush", 0); /* "clickhouse_driver/bufferedwriter.pyx":46 * * def flush(self): * self.write_into_stream() # <<<<<<<<<<<<<< * * def write_strings(self, items, encoding=None): */ __pyx_t_1 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self->__pyx_vtab)->write_into_stream(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedwriter.pyx":45 * written += size * * def flush(self): # <<<<<<<<<<<<<< * self.write_into_stream() * */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.flush", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedwriter.pyx":48 * self.write_into_stream() * * def write_strings(self, items, encoding=None): # <<<<<<<<<<<<<< * cdef int do_encode = encoding is not None * */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_11write_strings(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_14BufferedWriter_11write_strings = {"write_strings", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_11write_strings, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_11write_strings(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_items = 0; PyObject *__pyx_v_encoding = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[2] = {0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_strings (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_items,&__pyx_mstate_global->__pyx_n_u_encoding,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 48, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 48, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 48, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "write_strings", 0) < (0)) __PYX_ERR(0, 48, __pyx_L3_error) if (!values[1]) values[1] = __Pyx_NewRef(((PyObject *)Py_None)); for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("write_strings", 0, 1, 2, i); __PYX_ERR(0, 48, __pyx_L3_error) } } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 48, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 48, __pyx_L3_error) break; default: goto __pyx_L5_argtuple_error; } if (!values[1]) values[1] = __Pyx_NewRef(((PyObject *)Py_None)); } __pyx_v_items = values[0]; __pyx_v_encoding = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("write_strings", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 48, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write_strings", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_10write_strings(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self), __pyx_v_items, __pyx_v_encoding); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_10write_strings(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_encoding) { int __pyx_v_do_encode; PyObject *__pyx_v_value = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; Py_ssize_t __pyx_t_3; PyObject *(*__pyx_t_4)(PyObject *); PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; size_t __pyx_t_7; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write_strings", 0); /* "clickhouse_driver/bufferedwriter.pyx":49 * * def write_strings(self, items, encoding=None): * cdef int do_encode = encoding is not None # <<<<<<<<<<<<<< * * for value in items: */ __pyx_t_1 = (__pyx_v_encoding != Py_None); __pyx_v_do_encode = __pyx_t_1; /* "clickhouse_driver/bufferedwriter.pyx":51 * cdef int do_encode = encoding is not None * * for value in items: # <<<<<<<<<<<<<< * if not PyBytes_Check(value): * if do_encode: */ if (likely(PyList_CheckExact(__pyx_v_items)) || PyTuple_CheckExact(__pyx_v_items)) { __pyx_t_2 = __pyx_v_items; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_items); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 51, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_4)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 51, __pyx_L1_error) #endif if (__pyx_t_3 >= __pyx_temp) break; } __pyx_t_5 = __Pyx_PyList_GetItemRefFast(__pyx_t_2, __pyx_t_3, __Pyx_ReferenceSharing_OwnStrongReference); ++__pyx_t_3; } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 51, __pyx_L1_error) #endif if (__pyx_t_3 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3)); #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3); #endif ++__pyx_t_3; } if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 51, __pyx_L1_error) } else { __pyx_t_5 = __pyx_t_4(__pyx_t_2); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 51, __pyx_L1_error) PyErr_Clear(); } break; } } __Pyx_GOTREF(__pyx_t_5); __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_5); __pyx_t_5 = 0; /* "clickhouse_driver/bufferedwriter.pyx":52 * * for value in items: * if not PyBytes_Check(value): # <<<<<<<<<<<<<< * if do_encode: * value = value.encode(encoding) */ __pyx_t_1 = (!PyBytes_Check(__pyx_v_value)); if (__pyx_t_1) { /* "clickhouse_driver/bufferedwriter.pyx":53 * for value in items: * if not PyBytes_Check(value): * if do_encode: # <<<<<<<<<<<<<< * value = value.encode(encoding) * else: */ __pyx_t_1 = (__pyx_v_do_encode != 0); if (likely(__pyx_t_1)) { /* "clickhouse_driver/bufferedwriter.pyx":54 * if not PyBytes_Check(value): * if do_encode: * value = value.encode(encoding) # <<<<<<<<<<<<<< * else: * raise ValueError('bytes object expected') */ __pyx_t_6 = __pyx_v_value; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_encoding}; __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_encode, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); } __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_5); __pyx_t_5 = 0; /* "clickhouse_driver/bufferedwriter.pyx":53 * for value in items: * if not PyBytes_Check(value): * if do_encode: # <<<<<<<<<<<<<< * value = value.encode(encoding) * else: */ goto __pyx_L6; } /* "clickhouse_driver/bufferedwriter.pyx":56 * value = value.encode(encoding) * else: * raise ValueError('bytes object expected') # <<<<<<<<<<<<<< * * self.write(make_varint(PyBytes_GET_SIZE(value))) */ /*else*/ { __pyx_t_6 = NULL; __pyx_t_7 = 1; { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_bytes_object_expected}; __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_ValueError)), __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); } __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 56, __pyx_L1_error) } __pyx_L6:; /* "clickhouse_driver/bufferedwriter.pyx":52 * * for value in items: * if not PyBytes_Check(value): # <<<<<<<<<<<<<< * if do_encode: * value = value.encode(encoding) */ } /* "clickhouse_driver/bufferedwriter.pyx":58 * raise ValueError('bytes object expected') * * self.write(make_varint(PyBytes_GET_SIZE(value))) # <<<<<<<<<<<<<< * self.write(value) * */ __pyx_t_6 = NULL; __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_make_varint); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = PyLong_FromSsize_t(PyBytes_GET_SIZE(__pyx_v_value)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_7 = 1; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8); assert(__pyx_t_6); PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx__function); __Pyx_DECREF_SET(__pyx_t_8, __pyx__function); __pyx_t_7 = 0; } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_9}; __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); } __pyx_t_8 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self->__pyx_vtab)->write(__pyx_v_self, __pyx_t_5, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "clickhouse_driver/bufferedwriter.pyx":59 * * self.write(make_varint(PyBytes_GET_SIZE(value))) * self.write(value) # <<<<<<<<<<<<<< * * def write_fixed_strings_as_bytes(self, items, Py_ssize_t length): */ __pyx_t_8 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self->__pyx_vtab)->write(__pyx_v_self, __pyx_v_value, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "clickhouse_driver/bufferedwriter.pyx":51 * cdef int do_encode = encoding is not None * * for value in items: # <<<<<<<<<<<<<< * if not PyBytes_Check(value): * if do_encode: */ } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedwriter.pyx":48 * self.write_into_stream() * * def write_strings(self, items, encoding=None): # <<<<<<<<<<<<<< * cdef int do_encode = encoding is not None * */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write_strings", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_value); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedwriter.pyx":61 * self.write(value) * * def write_fixed_strings_as_bytes(self, items, Py_ssize_t length): # <<<<<<<<<<<<<< * cdef Py_ssize_t buf_pos = 0 * cdef Py_ssize_t items_buf_size = length * len(items) */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_13write_fixed_strings_as_bytes(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_14BufferedWriter_13write_fixed_strings_as_bytes = {"write_fixed_strings_as_bytes", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_13write_fixed_strings_as_bytes, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_13write_fixed_strings_as_bytes(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_items = 0; Py_ssize_t __pyx_v_length; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[2] = {0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_fixed_strings_as_bytes (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_items,&__pyx_mstate_global->__pyx_n_u_length,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 61, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 61, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 61, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "write_fixed_strings_as_bytes", 0) < (0)) __PYX_ERR(0, 61, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 2; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("write_fixed_strings_as_bytes", 1, 2, 2, i); __PYX_ERR(0, 61, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 61, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 61, __pyx_L3_error) } __pyx_v_items = values[0]; __pyx_v_length = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_length == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 61, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("write_fixed_strings_as_bytes", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 61, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write_fixed_strings_as_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_12write_fixed_strings_as_bytes(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self), __pyx_v_items, __pyx_v_length); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_12write_fixed_strings_as_bytes(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_items, Py_ssize_t __pyx_v_length) { Py_ssize_t __pyx_v_buf_pos; Py_ssize_t __pyx_v_items_buf_size; char *__pyx_v_c_value; char *__pyx_v_items_buf; PyObject *__pyx_v_value = NULL; Py_ssize_t __pyx_v_value_len; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations Py_ssize_t __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *(*__pyx_t_4)(PyObject *); PyObject *__pyx_t_5 = NULL; Py_ssize_t __pyx_t_6; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; size_t __pyx_t_10; char *__pyx_t_11; int __pyx_t_12; int __pyx_t_13; char const *__pyx_t_14; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; PyObject *__pyx_t_18 = NULL; PyObject *__pyx_t_19 = NULL; PyObject *__pyx_t_20 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write_fixed_strings_as_bytes", 0); /* "clickhouse_driver/bufferedwriter.pyx":62 * * def write_fixed_strings_as_bytes(self, items, Py_ssize_t length): * cdef Py_ssize_t buf_pos = 0 # <<<<<<<<<<<<<< * cdef Py_ssize_t items_buf_size = length * len(items) * */ __pyx_v_buf_pos = 0; /* "clickhouse_driver/bufferedwriter.pyx":63 * def write_fixed_strings_as_bytes(self, items, Py_ssize_t length): * cdef Py_ssize_t buf_pos = 0 * cdef Py_ssize_t items_buf_size = length * len(items) # <<<<<<<<<<<<<< * * cdef char* c_value */ __pyx_t_1 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 63, __pyx_L1_error) __pyx_v_items_buf_size = (__pyx_v_length * __pyx_t_1); /* "clickhouse_driver/bufferedwriter.pyx":66 * * cdef char* c_value * cdef char* items_buf = PyMem_Malloc(items_buf_size) # <<<<<<<<<<<<<< * if not items_buf: * raise MemoryError() */ __pyx_v_items_buf = ((char *)PyMem_Malloc(__pyx_v_items_buf_size)); /* "clickhouse_driver/bufferedwriter.pyx":67 * cdef char* c_value * cdef char* items_buf = PyMem_Malloc(items_buf_size) * if not items_buf: # <<<<<<<<<<<<<< * raise MemoryError() * */ __pyx_t_2 = (!(__pyx_v_items_buf != 0)); if (unlikely(__pyx_t_2)) { /* "clickhouse_driver/bufferedwriter.pyx":68 * cdef char* items_buf = PyMem_Malloc(items_buf_size) * if not items_buf: * raise MemoryError() # <<<<<<<<<<<<<< * * memset(items_buf, 0, items_buf_size) */ PyErr_NoMemory(); __PYX_ERR(0, 68, __pyx_L1_error) /* "clickhouse_driver/bufferedwriter.pyx":67 * cdef char* c_value * cdef char* items_buf = PyMem_Malloc(items_buf_size) * if not items_buf: # <<<<<<<<<<<<<< * raise MemoryError() * */ } /* "clickhouse_driver/bufferedwriter.pyx":70 * raise MemoryError() * * memset(items_buf, 0, items_buf_size) # <<<<<<<<<<<<<< * * for value in items: */ (void)(memset(__pyx_v_items_buf, 0, __pyx_v_items_buf_size)); /* "clickhouse_driver/bufferedwriter.pyx":72 * memset(items_buf, 0, items_buf_size) * * for value in items: # <<<<<<<<<<<<<< * value_len = len(value) * if length < value_len: */ if (likely(PyList_CheckExact(__pyx_v_items)) || PyTuple_CheckExact(__pyx_v_items)) { __pyx_t_3 = __pyx_v_items; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0; __pyx_t_4 = NULL; } else { __pyx_t_1 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_items); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 72, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_4)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 72, __pyx_L1_error) #endif if (__pyx_t_1 >= __pyx_temp) break; } __pyx_t_5 = __Pyx_PyList_GetItemRefFast(__pyx_t_3, __pyx_t_1, __Pyx_ReferenceSharing_OwnStrongReference); ++__pyx_t_1; } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 72, __pyx_L1_error) #endif if (__pyx_t_1 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1)); #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_1); #endif ++__pyx_t_1; } if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 72, __pyx_L1_error) } else { __pyx_t_5 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 72, __pyx_L1_error) PyErr_Clear(); } break; } } __Pyx_GOTREF(__pyx_t_5); __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_5); __pyx_t_5 = 0; /* "clickhouse_driver/bufferedwriter.pyx":73 * * for value in items: * value_len = len(value) # <<<<<<<<<<<<<< * if length < value_len: * raise errors.TooLargeStringSize() */ __pyx_t_6 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 73, __pyx_L1_error) __pyx_v_value_len = __pyx_t_6; /* "clickhouse_driver/bufferedwriter.pyx":74 * for value in items: * value_len = len(value) * if length < value_len: # <<<<<<<<<<<<<< * raise errors.TooLargeStringSize() * */ __pyx_t_2 = (__pyx_v_length < __pyx_v_value_len); if (unlikely(__pyx_t_2)) { /* "clickhouse_driver/bufferedwriter.pyx":75 * value_len = len(value) * if length < value_len: * raise errors.TooLargeStringSize() # <<<<<<<<<<<<<< * * c_value = PyBytes_AsString(value) */ __pyx_t_7 = NULL; __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_errors); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_TooLargeStringSize); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_10 = 1; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9); assert(__pyx_t_7); PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(__pyx__function); __Pyx_DECREF_SET(__pyx_t_9, __pyx__function); __pyx_t_10 = 0; } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL}; __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); } __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 75, __pyx_L1_error) /* "clickhouse_driver/bufferedwriter.pyx":74 * for value in items: * value_len = len(value) * if length < value_len: # <<<<<<<<<<<<<< * raise errors.TooLargeStringSize() * */ } /* "clickhouse_driver/bufferedwriter.pyx":77 * raise errors.TooLargeStringSize() * * c_value = PyBytes_AsString(value) # <<<<<<<<<<<<<< * * memcpy(&items_buf[buf_pos], c_value, value_len) */ __pyx_t_11 = PyBytes_AsString(__pyx_v_value); if (unlikely(__pyx_t_11 == ((void *)NULL))) __PYX_ERR(0, 77, __pyx_L1_error) __pyx_v_c_value = __pyx_t_11; /* "clickhouse_driver/bufferedwriter.pyx":79 * c_value = PyBytes_AsString(value) * * memcpy(&items_buf[buf_pos], c_value, value_len) # <<<<<<<<<<<<<< * buf_pos += length * try: */ (void)(memcpy((&(__pyx_v_items_buf[__pyx_v_buf_pos])), __pyx_v_c_value, __pyx_v_value_len)); /* "clickhouse_driver/bufferedwriter.pyx":80 * * memcpy(&items_buf[buf_pos], c_value, value_len) * buf_pos += length # <<<<<<<<<<<<<< * try: * self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size)) */ __pyx_v_buf_pos = (__pyx_v_buf_pos + __pyx_v_length); /* "clickhouse_driver/bufferedwriter.pyx":72 * memset(items_buf, 0, items_buf_size) * * for value in items: # <<<<<<<<<<<<<< * value_len = len(value) * if length < value_len: */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "clickhouse_driver/bufferedwriter.pyx":81 * memcpy(&items_buf[buf_pos], c_value, value_len) * buf_pos += length * try: # <<<<<<<<<<<<<< * self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size)) * finally: */ /*try:*/ { /* "clickhouse_driver/bufferedwriter.pyx":82 * buf_pos += length * try: * self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size)) # <<<<<<<<<<<<<< * finally: * PyMem_Free(items_buf) */ __pyx_t_3 = PyBytes_FromStringAndSize(__pyx_v_items_buf, __pyx_v_items_buf_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self->__pyx_vtab)->write(__pyx_v_self, __pyx_t_3, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 82, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } /* "clickhouse_driver/bufferedwriter.pyx":84 * self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size)) * finally: * PyMem_Free(items_buf) # <<<<<<<<<<<<<< * * def write_fixed_strings(self, items, Py_ssize_t length, encoding=None): */ /*finally:*/ { /*normal exit:*/{ PyMem_Free(__pyx_v_items_buf); goto __pyx_L10; } __pyx_L9_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20); if ( unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __pyx_t_12 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename; { PyMem_Free(__pyx_v_items_buf); } __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17); __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_lineno = __pyx_t_12; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14; goto __pyx_L1_error; } __pyx_L10:; } /* "clickhouse_driver/bufferedwriter.pyx":61 * self.write(value) * * def write_fixed_strings_as_bytes(self, items, Py_ssize_t length): # <<<<<<<<<<<<<< * cdef Py_ssize_t buf_pos = 0 * cdef Py_ssize_t items_buf_size = length * len(items) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write_fixed_strings_as_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_value); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedwriter.pyx":86 * PyMem_Free(items_buf) * * def write_fixed_strings(self, items, Py_ssize_t length, encoding=None): # <<<<<<<<<<<<<< * if encoding is None: * self.write_fixed_strings_as_bytes(items, length) */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_15write_fixed_strings(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_14BufferedWriter_15write_fixed_strings = {"write_fixed_strings", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_15write_fixed_strings, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_15write_fixed_strings(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_items = 0; Py_ssize_t __pyx_v_length; PyObject *__pyx_v_encoding = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_fixed_strings (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_items,&__pyx_mstate_global->__pyx_n_u_length,&__pyx_mstate_global->__pyx_n_u_encoding,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 86, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 86, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 86, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 86, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "write_fixed_strings", 0) < (0)) __PYX_ERR(0, 86, __pyx_L3_error) if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)Py_None)); for (Py_ssize_t i = __pyx_nargs; i < 2; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("write_fixed_strings", 0, 2, 3, i); __PYX_ERR(0, 86, __pyx_L3_error) } } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 86, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 86, __pyx_L3_error) values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 86, __pyx_L3_error) break; default: goto __pyx_L5_argtuple_error; } if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)Py_None)); } __pyx_v_items = values[0]; __pyx_v_length = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_length == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 86, __pyx_L3_error) __pyx_v_encoding = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("write_fixed_strings", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 86, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write_fixed_strings", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_14write_fixed_strings(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self), __pyx_v_items, __pyx_v_length, __pyx_v_encoding); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_14write_fixed_strings(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_items, Py_ssize_t __pyx_v_length, PyObject *__pyx_v_encoding) { Py_ssize_t __pyx_v_buf_pos; Py_ssize_t __pyx_v_items_buf_size; char *__pyx_v_c_value; char *__pyx_v_items_buf; PyObject *__pyx_v_value = NULL; Py_ssize_t __pyx_v_value_len; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; size_t __pyx_t_5; Py_ssize_t __pyx_t_6; PyObject *(*__pyx_t_7)(PyObject *); Py_ssize_t __pyx_t_8; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; char *__pyx_t_11; int __pyx_t_12; int __pyx_t_13; char const *__pyx_t_14; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; PyObject *__pyx_t_18 = NULL; PyObject *__pyx_t_19 = NULL; PyObject *__pyx_t_20 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write_fixed_strings", 0); /* "clickhouse_driver/bufferedwriter.pyx":87 * * def write_fixed_strings(self, items, Py_ssize_t length, encoding=None): * if encoding is None: # <<<<<<<<<<<<<< * self.write_fixed_strings_as_bytes(items, length) * return */ __pyx_t_1 = (__pyx_v_encoding == Py_None); if (__pyx_t_1) { /* "clickhouse_driver/bufferedwriter.pyx":88 * def write_fixed_strings(self, items, Py_ssize_t length, encoding=None): * if encoding is None: * self.write_fixed_strings_as_bytes(items, length) # <<<<<<<<<<<<<< * return * */ __pyx_t_3 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = PyLong_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = 0; { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_items, __pyx_t_4}; __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_write_fixed_strings_as_bytes, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedwriter.pyx":89 * if encoding is None: * self.write_fixed_strings_as_bytes(items, length) * return # <<<<<<<<<<<<<< * * cdef Py_ssize_t buf_pos = 0 */ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; /* "clickhouse_driver/bufferedwriter.pyx":87 * * def write_fixed_strings(self, items, Py_ssize_t length, encoding=None): * if encoding is None: # <<<<<<<<<<<<<< * self.write_fixed_strings_as_bytes(items, length) * return */ } /* "clickhouse_driver/bufferedwriter.pyx":91 * return * * cdef Py_ssize_t buf_pos = 0 # <<<<<<<<<<<<<< * cdef Py_ssize_t items_buf_size = length * len(items) * */ __pyx_v_buf_pos = 0; /* "clickhouse_driver/bufferedwriter.pyx":92 * * cdef Py_ssize_t buf_pos = 0 * cdef Py_ssize_t items_buf_size = length * len(items) # <<<<<<<<<<<<<< * * cdef char* c_value */ __pyx_t_6 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 92, __pyx_L1_error) __pyx_v_items_buf_size = (__pyx_v_length * __pyx_t_6); /* "clickhouse_driver/bufferedwriter.pyx":95 * * cdef char* c_value * cdef char* items_buf = PyMem_Malloc(items_buf_size) # <<<<<<<<<<<<<< * if not items_buf: * raise MemoryError() */ __pyx_v_items_buf = ((char *)PyMem_Malloc(__pyx_v_items_buf_size)); /* "clickhouse_driver/bufferedwriter.pyx":96 * cdef char* c_value * cdef char* items_buf = PyMem_Malloc(items_buf_size) * if not items_buf: # <<<<<<<<<<<<<< * raise MemoryError() * */ __pyx_t_1 = (!(__pyx_v_items_buf != 0)); if (unlikely(__pyx_t_1)) { /* "clickhouse_driver/bufferedwriter.pyx":97 * cdef char* items_buf = PyMem_Malloc(items_buf_size) * if not items_buf: * raise MemoryError() # <<<<<<<<<<<<<< * * memset(items_buf, 0, items_buf_size) */ PyErr_NoMemory(); __PYX_ERR(0, 97, __pyx_L1_error) /* "clickhouse_driver/bufferedwriter.pyx":96 * cdef char* c_value * cdef char* items_buf = PyMem_Malloc(items_buf_size) * if not items_buf: # <<<<<<<<<<<<<< * raise MemoryError() * */ } /* "clickhouse_driver/bufferedwriter.pyx":99 * raise MemoryError() * * memset(items_buf, 0, items_buf_size) # <<<<<<<<<<<<<< * * for value in items: */ (void)(memset(__pyx_v_items_buf, 0, __pyx_v_items_buf_size)); /* "clickhouse_driver/bufferedwriter.pyx":101 * memset(items_buf, 0, items_buf_size) * * for value in items: # <<<<<<<<<<<<<< * if not PyBytes_Check(value): * value = value.encode(encoding) */ if (likely(PyList_CheckExact(__pyx_v_items)) || PyTuple_CheckExact(__pyx_v_items)) { __pyx_t_2 = __pyx_v_items; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_items); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 101, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 101, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } __pyx_t_4 = __Pyx_PyList_GetItemRefFast(__pyx_t_2, __pyx_t_6, __Pyx_ReferenceSharing_OwnStrongReference); ++__pyx_t_6; } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 101, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6)); #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); #endif ++__pyx_t_6; } if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 101, __pyx_L1_error) } else { __pyx_t_4 = __pyx_t_7(__pyx_t_2); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 101, __pyx_L1_error) PyErr_Clear(); } break; } } __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_4); __pyx_t_4 = 0; /* "clickhouse_driver/bufferedwriter.pyx":102 * * for value in items: * if not PyBytes_Check(value): # <<<<<<<<<<<<<< * value = value.encode(encoding) * */ __pyx_t_1 = (!PyBytes_Check(__pyx_v_value)); if (__pyx_t_1) { /* "clickhouse_driver/bufferedwriter.pyx":103 * for value in items: * if not PyBytes_Check(value): * value = value.encode(encoding) # <<<<<<<<<<<<<< * * value_len = len(value) */ __pyx_t_3 = __pyx_v_value; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_encoding}; __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_encode, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); } __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_4); __pyx_t_4 = 0; /* "clickhouse_driver/bufferedwriter.pyx":102 * * for value in items: * if not PyBytes_Check(value): # <<<<<<<<<<<<<< * value = value.encode(encoding) * */ } /* "clickhouse_driver/bufferedwriter.pyx":105 * value = value.encode(encoding) * * value_len = len(value) # <<<<<<<<<<<<<< * if length < value_len: * raise errors.TooLargeStringSize() */ __pyx_t_8 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 105, __pyx_L1_error) __pyx_v_value_len = __pyx_t_8; /* "clickhouse_driver/bufferedwriter.pyx":106 * * value_len = len(value) * if length < value_len: # <<<<<<<<<<<<<< * raise errors.TooLargeStringSize() * */ __pyx_t_1 = (__pyx_v_length < __pyx_v_value_len); if (unlikely(__pyx_t_1)) { /* "clickhouse_driver/bufferedwriter.pyx":107 * value_len = len(value) * if length < value_len: * raise errors.TooLargeStringSize() # <<<<<<<<<<<<<< * * c_value = PyBytes_AsString(value) */ __pyx_t_3 = NULL; __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_errors); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_TooLargeStringSize); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_5 = 1; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10); assert(__pyx_t_3); PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx__function); __Pyx_DECREF_SET(__pyx_t_10, __pyx__function); __pyx_t_5 = 0; } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); } __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 107, __pyx_L1_error) /* "clickhouse_driver/bufferedwriter.pyx":106 * * value_len = len(value) * if length < value_len: # <<<<<<<<<<<<<< * raise errors.TooLargeStringSize() * */ } /* "clickhouse_driver/bufferedwriter.pyx":109 * raise errors.TooLargeStringSize() * * c_value = PyBytes_AsString(value) # <<<<<<<<<<<<<< * * memcpy(&items_buf[buf_pos], c_value, value_len) */ __pyx_t_11 = PyBytes_AsString(__pyx_v_value); if (unlikely(__pyx_t_11 == ((void *)NULL))) __PYX_ERR(0, 109, __pyx_L1_error) __pyx_v_c_value = __pyx_t_11; /* "clickhouse_driver/bufferedwriter.pyx":111 * c_value = PyBytes_AsString(value) * * memcpy(&items_buf[buf_pos], c_value, value_len) # <<<<<<<<<<<<<< * buf_pos += length * try: */ (void)(memcpy((&(__pyx_v_items_buf[__pyx_v_buf_pos])), __pyx_v_c_value, __pyx_v_value_len)); /* "clickhouse_driver/bufferedwriter.pyx":112 * * memcpy(&items_buf[buf_pos], c_value, value_len) * buf_pos += length # <<<<<<<<<<<<<< * try: * self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size)) */ __pyx_v_buf_pos = (__pyx_v_buf_pos + __pyx_v_length); /* "clickhouse_driver/bufferedwriter.pyx":101 * memset(items_buf, 0, items_buf_size) * * for value in items: # <<<<<<<<<<<<<< * if not PyBytes_Check(value): * value = value.encode(encoding) */ } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedwriter.pyx":113 * memcpy(&items_buf[buf_pos], c_value, value_len) * buf_pos += length * try: # <<<<<<<<<<<<<< * self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size)) * finally: */ /*try:*/ { /* "clickhouse_driver/bufferedwriter.pyx":114 * buf_pos += length * try: * self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size)) # <<<<<<<<<<<<<< * finally: * PyMem_Free(items_buf) */ __pyx_t_2 = PyBytes_FromStringAndSize(__pyx_v_items_buf, __pyx_v_items_buf_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self->__pyx_vtab)->write(__pyx_v_self, __pyx_t_2, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 114, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } /* "clickhouse_driver/bufferedwriter.pyx":116 * self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size)) * finally: * PyMem_Free(items_buf) # <<<<<<<<<<<<<< * * */ /*finally:*/ { /*normal exit:*/{ PyMem_Free(__pyx_v_items_buf); goto __pyx_L12; } __pyx_L11_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20); if ( unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __pyx_t_12 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename; { PyMem_Free(__pyx_v_items_buf); } __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17); __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_lineno = __pyx_t_12; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14; goto __pyx_L1_error; } __pyx_L12:; } /* "clickhouse_driver/bufferedwriter.pyx":86 * PyMem_Free(items_buf) * * def write_fixed_strings(self, items, Py_ssize_t length, encoding=None): # <<<<<<<<<<<<<< * if encoding is None: * self.write_fixed_strings_as_bytes(items, length) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write_fixed_strings", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_value); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_17__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_14BufferedWriter_17__reduce_cython__ = {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_17__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_17__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__reduce_cython__", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("__reduce_cython__", __pyx_kwds); return NULL;} __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_16__reduce_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_16__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self) { PyObject *__pyx_v_state = 0; PyObject *__pyx_v__dict = 0; int __pyx_v_use_setstate; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":5 * cdef object _dict * cdef bint use_setstate * state = (self.buffer, self.buffer_size, self.position) # <<<<<<<<<<<<<< * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: */ __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyLong_From_unsigned_PY_LONG_LONG(__pyx_v_self->buffer_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyLong_From_unsigned_PY_LONG_LONG(__pyx_v_self->position); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_v_state = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; /* "(tree fragment)":6 * cdef bint use_setstate * state = (self.buffer, self.buffer_size, self.position) * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<< * if _dict is not None and _dict: * state += (_dict,) */ __pyx_t_4 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_dict, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v__dict = __pyx_t_4; __pyx_t_4 = 0; /* "(tree fragment)":7 * state = (self.buffer, self.buffer_size, self.position) * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ __pyx_t_6 = (__pyx_v__dict != Py_None); if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L4_bool_binop_done; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v__dict); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(2, 7, __pyx_L1_error) __pyx_t_5 = __pyx_t_6; __pyx_L4_bool_binop_done:; if (__pyx_t_5) { /* "(tree fragment)":8 * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: * state += (_dict,) # <<<<<<<<<<<<<< * use_setstate = True * else: */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v__dict); __Pyx_GIVEREF(__pyx_v__dict); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v__dict) != (0)) __PYX_ERR(2, 8, __pyx_L1_error); __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; /* "(tree fragment)":9 * if _dict is not None and _dict: * state += (_dict,) * use_setstate = True # <<<<<<<<<<<<<< * else: * use_setstate = ('False',) */ __pyx_v_use_setstate = 1; /* "(tree fragment)":7 * state = (self.buffer, self.buffer_size, self.position) * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ goto __pyx_L3; } /* "(tree fragment)":11 * use_setstate = True * else: * use_setstate = ('False',) # <<<<<<<<<<<<<< * if use_setstate: * return __pyx_unpickle_BufferedWriter, (type(self), 0x1c41cb3, None), state */ /*else*/ { __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_mstate_global->__pyx_tuple[0]); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 11, __pyx_L1_error) __pyx_v_use_setstate = __pyx_t_5; } __pyx_L3:; /* "(tree fragment)":12 * else: * use_setstate = ('False',) * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle_BufferedWriter, (type(self), 0x1c41cb3, None), state * else: */ if (__pyx_v_use_setstate) { /* "(tree fragment)":13 * use_setstate = ('False',) * if use_setstate: * return __pyx_unpickle_BufferedWriter, (type(self), 0x1c41cb3, None), state # <<<<<<<<<<<<<< * else: * return __pyx_unpickle_BufferedWriter, (type(self), 0x1c41cb3, state) */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_BufferedWriter); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(__pyx_mstate_global->__pyx_int_29629619); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_29629619); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_mstate_global->__pyx_int_29629619) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, Py_None) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "(tree fragment)":12 * else: * use_setstate = ('False',) * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle_BufferedWriter, (type(self), 0x1c41cb3, None), state * else: */ } /* "(tree fragment)":15 * return __pyx_unpickle_BufferedWriter, (type(self), 0x1c41cb3, None), state * else: * return __pyx_unpickle_BufferedWriter, (type(self), 0x1c41cb3, state) # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle_BufferedWriter__set_state(self, __pyx_state) */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_BufferedWriter); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_INCREF(__pyx_mstate_global->__pyx_int_29629619); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_29629619); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_mstate_global->__pyx_int_29629619) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_state) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_4 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_state); __Pyx_XDECREF(__pyx_v__dict); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":16 * else: * return __pyx_unpickle_BufferedWriter, (type(self), 0x1c41cb3, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedWriter__set_state(self, __pyx_state) */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_19__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_14BufferedWriter_19__setstate_cython__ = {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_19__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_19__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v___pyx_state = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pyx_state,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(2, 16, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 16, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__setstate_cython__", 0) < (0)) __PYX_ERR(2, 16, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__setstate_cython__", 1, 1, 1, i); __PYX_ERR(2, 16, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 16, __pyx_L3_error) } __pyx_v___pyx_state = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__setstate_cython__", 1, 1, 1, __pyx_nargs); __PYX_ERR(2, 16, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_18__setstate_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self), __pyx_v___pyx_state); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_18__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":17 * return __pyx_unpickle_BufferedWriter, (type(self), 0x1c41cb3, state) * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle_BufferedWriter__set_state(self, __pyx_state) # <<<<<<<<<<<<<< */ __pyx_t_1 = __pyx_v___pyx_state; __Pyx_INCREF(__pyx_t_1); if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_t_1))) __PYX_ERR(2, 17, __pyx_L1_error) if (unlikely(__pyx_t_1 == Py_None)) { PyErr_SetString(PyExc_TypeError, "cannot pass None into a C function argument that is declared 'not None'"); __PYX_ERR(2, 17, __pyx_L1_error) } __pyx_t_2 = __pyx_f_17clickhouse_driver_14bufferedwriter___pyx_unpickle_BufferedWriter__set_state(__pyx_v_self, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":16 * else: * return __pyx_unpickle_BufferedWriter, (type(self), 0x1c41cb3, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedWriter__set_state(self, __pyx_state) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedwriter.pyx":122 * cdef object sock * * def __init__(self, sock, bufsize): # <<<<<<<<<<<<<< * self.sock = sock * super(BufferedSocketWriter, self).__init__(bufsize) */ /* Python wrapper */ static int __pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_sock = 0; PyObject *__pyx_v_bufsize = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[2] = {0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_sock,&__pyx_mstate_global->__pyx_n_u_bufsize,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_VARARGS(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 122, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 2: values[1] = __Pyx_ArgRef_VARARGS(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 122, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 122, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__init__", 0) < (0)) __PYX_ERR(0, 122, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 2; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, i); __PYX_ERR(0, 122, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 122, __pyx_L3_error) values[1] = __Pyx_ArgRef_VARARGS(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 122, __pyx_L3_error) } __pyx_v_sock = values[0]; __pyx_v_bufsize = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 122, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedSocketWriter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter___init__(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *)__pyx_v_self), __pyx_v_sock, __pyx_v_bufsize); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter___init__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *__pyx_v_self, PyObject *__pyx_v_sock, PyObject *__pyx_v_bufsize) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; size_t __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "clickhouse_driver/bufferedwriter.pyx":123 * * def __init__(self, sock, bufsize): * self.sock = sock # <<<<<<<<<<<<<< * super(BufferedSocketWriter, self).__init__(bufsize) * */ __Pyx_INCREF(__pyx_v_sock); __Pyx_GIVEREF(__pyx_v_sock); __Pyx_GOTREF(__pyx_v_self->sock); __Pyx_DECREF(__pyx_v_self->sock); __pyx_v_self->sock = __pyx_v_sock; /* "clickhouse_driver/bufferedwriter.pyx":124 * def __init__(self, sock, bufsize): * self.sock = sock * super(BufferedSocketWriter, self).__init__(bufsize) # <<<<<<<<<<<<<< * * cpdef write_into_stream(self): */ __pyx_t_4 = NULL; __pyx_t_5 = 1; { PyObject *__pyx_callargs[3] = {__pyx_t_4, ((PyObject *)__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter), ((PyObject *)__pyx_v_self)}; __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_super, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_bufsize}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_init, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedwriter.pyx":122 * cdef object sock * * def __init__(self, sock, bufsize): # <<<<<<<<<<<<<< * self.sock = sock * super(BufferedSocketWriter, self).__init__(bufsize) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedSocketWriter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedwriter.pyx":126 * super(BufferedSocketWriter, self).__init__(bufsize) * * cpdef write_into_stream(self): # <<<<<<<<<<<<<< * self.sock.sendall( * PyBytes_FromStringAndSize(self.buffer, self.position) */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_3write_into_stream(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_write_into_stream(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *__pyx_v_self, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; size_t __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write_into_stream", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if ( #if !CYTHON_USE_TYPE_SLOTS unlikely(Py_TYPE(((PyObject *)__pyx_v_self)) != __pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter && __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), Py_TPFLAGS_HAVE_GC)) #else unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0 || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE))) #endif ) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_write_into_stream); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!__Pyx_IsSameCFunction(__pyx_t_1, (void(*)(void)) __pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_3write_into_stream)) { __Pyx_XDECREF(__pyx_r); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = __pyx_t_1; __pyx_t_5 = 1; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); assert(__pyx_t_3); PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx__function); __Pyx_DECREF_SET(__pyx_t_4, __pyx__function); __pyx_t_5 = 0; } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* "clickhouse_driver/bufferedwriter.pyx":127 * * cpdef write_into_stream(self): * self.sock.sendall( # <<<<<<<<<<<<<< * PyBytes_FromStringAndSize(self.buffer, self.position) * ) */ __pyx_t_2 = __pyx_v_self->sock; __Pyx_INCREF(__pyx_t_2); /* "clickhouse_driver/bufferedwriter.pyx":128 * cpdef write_into_stream(self): * self.sock.sendall( * PyBytes_FromStringAndSize(self.buffer, self.position) # <<<<<<<<<<<<<< * ) * self.position = 0 */ __pyx_t_4 = PyBytes_FromStringAndSize(__pyx_v_self->__pyx_base.buffer, __pyx_v_self->__pyx_base.position); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_4}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_sendall, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedwriter.pyx":130 * PyBytes_FromStringAndSize(self.buffer, self.position) * ) * self.position = 0 # <<<<<<<<<<<<<< * * */ __pyx_v_self->__pyx_base.position = 0; /* "clickhouse_driver/bufferedwriter.pyx":126 * super(BufferedSocketWriter, self).__init__(bufsize) * * cpdef write_into_stream(self): # <<<<<<<<<<<<<< * self.sock.sendall( * PyBytes_FromStringAndSize(self.buffer, self.position) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedSocketWriter.write_into_stream", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_3write_into_stream(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_3write_into_stream = {"write_into_stream", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_3write_into_stream, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_3write_into_stream(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_into_stream (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("write_into_stream", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("write_into_stream", __pyx_kwds); return NULL;} __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_2write_into_stream(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_2write_into_stream(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write_into_stream", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_write_into_stream(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedSocketWriter.write_into_stream", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_5__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_5__reduce_cython__ = {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_5__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_5__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__reduce_cython__", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("__reduce_cython__", __pyx_kwds); return NULL;} __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_4__reduce_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_4__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *__pyx_v_self) { PyObject *__pyx_v_state = 0; PyObject *__pyx_v__dict = 0; int __pyx_v_use_setstate; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":5 * cdef object _dict * cdef bint use_setstate * state = (self.buffer, self.buffer_size, self.position, self.sock) # <<<<<<<<<<<<<< * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: */ __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->__pyx_base.buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyLong_From_unsigned_PY_LONG_LONG(__pyx_v_self->__pyx_base.buffer_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyLong_From_unsigned_PY_LONG_LONG(__pyx_v_self->__pyx_base.position); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __Pyx_INCREF(__pyx_v_self->sock); __Pyx_GIVEREF(__pyx_v_self->sock); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_self->sock) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_v_state = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; /* "(tree fragment)":6 * cdef bint use_setstate * state = (self.buffer, self.buffer_size, self.position, self.sock) * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<< * if _dict is not None and _dict: * state += (_dict,) */ __pyx_t_4 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_dict, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v__dict = __pyx_t_4; __pyx_t_4 = 0; /* "(tree fragment)":7 * state = (self.buffer, self.buffer_size, self.position, self.sock) * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ __pyx_t_6 = (__pyx_v__dict != Py_None); if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L4_bool_binop_done; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v__dict); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(2, 7, __pyx_L1_error) __pyx_t_5 = __pyx_t_6; __pyx_L4_bool_binop_done:; if (__pyx_t_5) { /* "(tree fragment)":8 * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: * state += (_dict,) # <<<<<<<<<<<<<< * use_setstate = True * else: */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v__dict); __Pyx_GIVEREF(__pyx_v__dict); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v__dict) != (0)) __PYX_ERR(2, 8, __pyx_L1_error); __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; /* "(tree fragment)":9 * if _dict is not None and _dict: * state += (_dict,) * use_setstate = True # <<<<<<<<<<<<<< * else: * use_setstate = ('self.sock is not None',) */ __pyx_v_use_setstate = 1; /* "(tree fragment)":7 * state = (self.buffer, self.buffer_size, self.position, self.sock) * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ goto __pyx_L3; } /* "(tree fragment)":11 * use_setstate = True * else: * use_setstate = ('self.sock is not None',) # <<<<<<<<<<<<<< * if use_setstate: * return __pyx_unpickle_BufferedSocketWriter, (type(self), 0xca06ecf, None), state */ /*else*/ { __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_mstate_global->__pyx_tuple[1]); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 11, __pyx_L1_error) __pyx_v_use_setstate = __pyx_t_5; } __pyx_L3:; /* "(tree fragment)":12 * else: * use_setstate = ('self.sock is not None',) * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle_BufferedSocketWriter, (type(self), 0xca06ecf, None), state * else: */ if (__pyx_v_use_setstate) { /* "(tree fragment)":13 * use_setstate = ('self.sock is not None',) * if use_setstate: * return __pyx_unpickle_BufferedSocketWriter, (type(self), 0xca06ecf, None), state # <<<<<<<<<<<<<< * else: * return __pyx_unpickle_BufferedSocketWriter, (type(self), 0xca06ecf, state) */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_BufferedSocketWri); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(__pyx_mstate_global->__pyx_int_211840719); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_211840719); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_mstate_global->__pyx_int_211840719) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, Py_None) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "(tree fragment)":12 * else: * use_setstate = ('self.sock is not None',) * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle_BufferedSocketWriter, (type(self), 0xca06ecf, None), state * else: */ } /* "(tree fragment)":15 * return __pyx_unpickle_BufferedSocketWriter, (type(self), 0xca06ecf, None), state * else: * return __pyx_unpickle_BufferedSocketWriter, (type(self), 0xca06ecf, state) # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle_BufferedSocketWriter__set_state(self, __pyx_state) */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_BufferedSocketWri); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_INCREF(__pyx_mstate_global->__pyx_int_211840719); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_211840719); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_mstate_global->__pyx_int_211840719) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_state) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_4 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedSocketWriter.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_state); __Pyx_XDECREF(__pyx_v__dict); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":16 * else: * return __pyx_unpickle_BufferedSocketWriter, (type(self), 0xca06ecf, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedSocketWriter__set_state(self, __pyx_state) */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_7__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_7__setstate_cython__ = {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_7__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_7__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v___pyx_state = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pyx_state,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(2, 16, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 16, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__setstate_cython__", 0) < (0)) __PYX_ERR(2, 16, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__setstate_cython__", 1, 1, 1, i); __PYX_ERR(2, 16, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 16, __pyx_L3_error) } __pyx_v___pyx_state = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__setstate_cython__", 1, 1, 1, __pyx_nargs); __PYX_ERR(2, 16, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedSocketWriter.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_6__setstate_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *)__pyx_v_self), __pyx_v___pyx_state); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_6__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":17 * return __pyx_unpickle_BufferedSocketWriter, (type(self), 0xca06ecf, state) * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle_BufferedSocketWriter__set_state(self, __pyx_state) # <<<<<<<<<<<<<< */ __pyx_t_1 = __pyx_v___pyx_state; __Pyx_INCREF(__pyx_t_1); if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_t_1))) __PYX_ERR(2, 17, __pyx_L1_error) if (unlikely(__pyx_t_1 == Py_None)) { PyErr_SetString(PyExc_TypeError, "cannot pass None into a C function argument that is declared 'not None'"); __PYX_ERR(2, 17, __pyx_L1_error) } __pyx_t_2 = __pyx_f_17clickhouse_driver_14bufferedwriter___pyx_unpickle_BufferedSocketWriter__set_state(__pyx_v_self, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":16 * else: * return __pyx_unpickle_BufferedSocketWriter, (type(self), 0xca06ecf, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedSocketWriter__set_state(self, __pyx_state) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedSocketWriter.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedwriter.pyx":136 * cdef object compressor * * def __init__(self, compressor, bufsize): # <<<<<<<<<<<<<< * self.compressor = compressor * super(CompressedBufferedWriter, self).__init__(bufsize) */ /* Python wrapper */ static int __pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_compressor = 0; PyObject *__pyx_v_bufsize = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[2] = {0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_compressor,&__pyx_mstate_global->__pyx_n_u_bufsize,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_VARARGS(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 136, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 2: values[1] = __Pyx_ArgRef_VARARGS(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 136, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 136, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__init__", 0) < (0)) __PYX_ERR(0, 136, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 2; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, i); __PYX_ERR(0, 136, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_VARARGS(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 136, __pyx_L3_error) values[1] = __Pyx_ArgRef_VARARGS(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 136, __pyx_L3_error) } __pyx_v_compressor = values[0]; __pyx_v_bufsize = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 136, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.CompressedBufferedWriter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter___init__(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *)__pyx_v_self), __pyx_v_compressor, __pyx_v_bufsize); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter___init__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *__pyx_v_self, PyObject *__pyx_v_compressor, PyObject *__pyx_v_bufsize) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; size_t __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); /* "clickhouse_driver/bufferedwriter.pyx":137 * * def __init__(self, compressor, bufsize): * self.compressor = compressor # <<<<<<<<<<<<<< * super(CompressedBufferedWriter, self).__init__(bufsize) * */ __Pyx_INCREF(__pyx_v_compressor); __Pyx_GIVEREF(__pyx_v_compressor); __Pyx_GOTREF(__pyx_v_self->compressor); __Pyx_DECREF(__pyx_v_self->compressor); __pyx_v_self->compressor = __pyx_v_compressor; /* "clickhouse_driver/bufferedwriter.pyx":138 * def __init__(self, compressor, bufsize): * self.compressor = compressor * super(CompressedBufferedWriter, self).__init__(bufsize) # <<<<<<<<<<<<<< * * cpdef write_into_stream(self): */ __pyx_t_4 = NULL; __pyx_t_5 = 1; { PyObject *__pyx_callargs[3] = {__pyx_t_4, ((PyObject *)__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter), ((PyObject *)__pyx_v_self)}; __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_super, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_bufsize}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_init, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedwriter.pyx":136 * cdef object compressor * * def __init__(self, compressor, bufsize): # <<<<<<<<<<<<<< * self.compressor = compressor * super(CompressedBufferedWriter, self).__init__(bufsize) */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.CompressedBufferedWriter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedwriter.pyx":140 * super(CompressedBufferedWriter, self).__init__(bufsize) * * cpdef write_into_stream(self): # <<<<<<<<<<<<<< * self.compressor.write( * PyBytes_FromStringAndSize(self.buffer, self.position) */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_3write_into_stream(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_write_into_stream(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *__pyx_v_self, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; size_t __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write_into_stream", 0); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if ( #if !CYTHON_USE_TYPE_SLOTS unlikely(Py_TYPE(((PyObject *)__pyx_v_self)) != __pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter && __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), Py_TPFLAGS_HAVE_GC)) #else unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0 || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE))) #endif ) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_write_into_stream); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!__Pyx_IsSameCFunction(__pyx_t_1, (void(*)(void)) __pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_3write_into_stream)) { __Pyx_XDECREF(__pyx_r); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = __pyx_t_1; __pyx_t_5 = 1; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); assert(__pyx_t_3); PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx__function); __Pyx_DECREF_SET(__pyx_t_4, __pyx__function); __pyx_t_5 = 0; } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* "clickhouse_driver/bufferedwriter.pyx":141 * * cpdef write_into_stream(self): * self.compressor.write( # <<<<<<<<<<<<<< * PyBytes_FromStringAndSize(self.buffer, self.position) * ) */ __pyx_t_2 = __pyx_v_self->compressor; __Pyx_INCREF(__pyx_t_2); /* "clickhouse_driver/bufferedwriter.pyx":142 * cpdef write_into_stream(self): * self.compressor.write( * PyBytes_FromStringAndSize(self.buffer, self.position) # <<<<<<<<<<<<<< * ) * self.position = 0 */ __pyx_t_4 = PyBytes_FromStringAndSize(__pyx_v_self->__pyx_base.buffer, __pyx_v_self->__pyx_base.position); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_4}; __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_write, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedwriter.pyx":144 * PyBytes_FromStringAndSize(self.buffer, self.position) * ) * self.position = 0 # <<<<<<<<<<<<<< * * def flush(self): */ __pyx_v_self->__pyx_base.position = 0; /* "clickhouse_driver/bufferedwriter.pyx":140 * super(CompressedBufferedWriter, self).__init__(bufsize) * * cpdef write_into_stream(self): # <<<<<<<<<<<<<< * self.compressor.write( * PyBytes_FromStringAndSize(self.buffer, self.position) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.CompressedBufferedWriter.write_into_stream", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_3write_into_stream(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_3write_into_stream = {"write_into_stream", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_3write_into_stream, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_3write_into_stream(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_into_stream (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("write_into_stream", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("write_into_stream", __pyx_kwds); return NULL;} __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_2write_into_stream(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_2write_into_stream(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write_into_stream", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_write_into_stream(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.CompressedBufferedWriter.write_into_stream", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/bufferedwriter.pyx":146 * self.position = 0 * * def flush(self): # <<<<<<<<<<<<<< * self.write_into_stream() */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_5flush(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_5flush = {"flush", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_5flush, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_5flush(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("flush (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("flush", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("flush", __pyx_kwds); return NULL;} __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_4flush(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_4flush(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("flush", 0); /* "clickhouse_driver/bufferedwriter.pyx":147 * * def flush(self): * self.write_into_stream() # <<<<<<<<<<<<<< */ __pyx_t_1 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.write_into_stream(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/bufferedwriter.pyx":146 * self.position = 0 * * def flush(self): # <<<<<<<<<<<<<< * self.write_into_stream() */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.CompressedBufferedWriter.flush", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_7__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_7__reduce_cython__ = {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_7__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_7__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__reduce_cython__", 1, 0, 0, __pyx_nargs); return NULL; } const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len < 0)) return NULL; if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("__reduce_cython__", __pyx_kwds); return NULL;} __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_6__reduce_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_6__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *__pyx_v_self) { PyObject *__pyx_v_state = 0; PyObject *__pyx_v__dict = 0; int __pyx_v_use_setstate; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__reduce_cython__", 0); /* "(tree fragment)":5 * cdef object _dict * cdef bint use_setstate * state = (self.buffer, self.buffer_size, self.compressor, self.position) # <<<<<<<<<<<<<< * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: */ __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->__pyx_base.buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyLong_From_unsigned_PY_LONG_LONG(__pyx_v_self->__pyx_base.buffer_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyLong_From_unsigned_PY_LONG_LONG(__pyx_v_self->__pyx_base.position); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __Pyx_INCREF(__pyx_v_self->compressor); __Pyx_GIVEREF(__pyx_v_self->compressor); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_self->compressor) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_3) != (0)) __PYX_ERR(2, 5, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_v_state = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; /* "(tree fragment)":6 * cdef bint use_setstate * state = (self.buffer, self.buffer_size, self.compressor, self.position) * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<< * if _dict is not None and _dict: * state += (_dict,) */ __pyx_t_4 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_dict, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v__dict = __pyx_t_4; __pyx_t_4 = 0; /* "(tree fragment)":7 * state = (self.buffer, self.buffer_size, self.compressor, self.position) * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ __pyx_t_6 = (__pyx_v__dict != Py_None); if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L4_bool_binop_done; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v__dict); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(2, 7, __pyx_L1_error) __pyx_t_5 = __pyx_t_6; __pyx_L4_bool_binop_done:; if (__pyx_t_5) { /* "(tree fragment)":8 * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: * state += (_dict,) # <<<<<<<<<<<<<< * use_setstate = True * else: */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v__dict); __Pyx_GIVEREF(__pyx_v__dict); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v__dict) != (0)) __PYX_ERR(2, 8, __pyx_L1_error); __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; /* "(tree fragment)":9 * if _dict is not None and _dict: * state += (_dict,) * use_setstate = True # <<<<<<<<<<<<<< * else: * use_setstate = ('self.compressor is not None',) */ __pyx_v_use_setstate = 1; /* "(tree fragment)":7 * state = (self.buffer, self.buffer_size, self.compressor, self.position) * _dict = getattr(self, '__dict__', None) * if _dict is not None and _dict: # <<<<<<<<<<<<<< * state += (_dict,) * use_setstate = True */ goto __pyx_L3; } /* "(tree fragment)":11 * use_setstate = True * else: * use_setstate = ('self.compressor is not None',) # <<<<<<<<<<<<<< * if use_setstate: * return __pyx_unpickle_CompressedBufferedWriter, (type(self), 0x835ced9, None), state */ /*else*/ { __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_mstate_global->__pyx_tuple[2]); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 11, __pyx_L1_error) __pyx_v_use_setstate = __pyx_t_5; } __pyx_L3:; /* "(tree fragment)":12 * else: * use_setstate = ('self.compressor is not None',) * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle_CompressedBufferedWriter, (type(self), 0x835ced9, None), state * else: */ if (__pyx_v_use_setstate) { /* "(tree fragment)":13 * use_setstate = ('self.compressor is not None',) * if use_setstate: * return __pyx_unpickle_CompressedBufferedWriter, (type(self), 0x835ced9, None), state # <<<<<<<<<<<<<< * else: * return __pyx_unpickle_CompressedBufferedWriter, (type(self), 0x835ced9, state) */ __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_CompressedBuffere); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(__pyx_mstate_global->__pyx_int_137744089); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_137744089); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_mstate_global->__pyx_int_137744089) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, Py_None) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state) != (0)) __PYX_ERR(2, 13, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "(tree fragment)":12 * else: * use_setstate = ('self.compressor is not None',) * if use_setstate: # <<<<<<<<<<<<<< * return __pyx_unpickle_CompressedBufferedWriter, (type(self), 0x835ced9, None), state * else: */ } /* "(tree fragment)":15 * return __pyx_unpickle_CompressedBufferedWriter, (type(self), 0x835ced9, None), state * else: * return __pyx_unpickle_CompressedBufferedWriter, (type(self), 0x835ced9, state) # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle_CompressedBufferedWriter__set_state(self, __pyx_state) */ /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_CompressedBuffere); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_INCREF(__pyx_mstate_global->__pyx_int_137744089); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_137744089); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_mstate_global->__pyx_int_137744089) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_INCREF(__pyx_v_state); __Pyx_GIVEREF(__pyx_v_state); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_state) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4) != (0)) __PYX_ERR(2, 15, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_4 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.CompressedBufferedWriter.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_state); __Pyx_XDECREF(__pyx_v__dict); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":16 * else: * return __pyx_unpickle_CompressedBufferedWriter, (type(self), 0x835ced9, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_CompressedBufferedWriter__set_state(self, __pyx_state) */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_9__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_9__setstate_cython__ = {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_9__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_9__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v___pyx_state = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pyx_state,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(2, 16, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 16, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__setstate_cython__", 0) < (0)) __PYX_ERR(2, 16, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__setstate_cython__", 1, 1, 1, i); __PYX_ERR(2, 16, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 16, __pyx_L3_error) } __pyx_v___pyx_state = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__setstate_cython__", 1, 1, 1, __pyx_nargs); __PYX_ERR(2, 16, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.CompressedBufferedWriter.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_8__setstate_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *)__pyx_v_self), __pyx_v___pyx_state); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_8__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setstate_cython__", 0); /* "(tree fragment)":17 * return __pyx_unpickle_CompressedBufferedWriter, (type(self), 0x835ced9, state) * def __setstate_cython__(self, __pyx_state): * __pyx_unpickle_CompressedBufferedWriter__set_state(self, __pyx_state) # <<<<<<<<<<<<<< */ __pyx_t_1 = __pyx_v___pyx_state; __Pyx_INCREF(__pyx_t_1); if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_t_1))) __PYX_ERR(2, 17, __pyx_L1_error) if (unlikely(__pyx_t_1 == Py_None)) { PyErr_SetString(PyExc_TypeError, "cannot pass None into a C function argument that is declared 'not None'"); __PYX_ERR(2, 17, __pyx_L1_error) } __pyx_t_2 = __pyx_f_17clickhouse_driver_14bufferedwriter___pyx_unpickle_CompressedBufferedWriter__set_state(__pyx_v_self, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":16 * else: * return __pyx_unpickle_CompressedBufferedWriter, (type(self), 0x835ced9, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_CompressedBufferedWriter__set_state(self, __pyx_state) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.CompressedBufferedWriter.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":4 * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 * def __pyx_unpickle_BufferedWriter(__pyx_type, long __pyx_checksum, tuple __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x1c41cb3, 0x253d0cc, 0x25d1d0c, b'buffer, buffer_size, position') */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_1__pyx_unpickle_BufferedWriter(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_1__pyx_unpickle_BufferedWriter = {"__pyx_unpickle_BufferedWriter", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_1__pyx_unpickle_BufferedWriter, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_1__pyx_unpickle_BufferedWriter(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v___pyx_type = 0; long __pyx_v___pyx_checksum; PyObject *__pyx_v___pyx_state = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedWriter (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pyx_type,&__pyx_mstate_global->__pyx_n_u_pyx_checksum,&__pyx_mstate_global->__pyx_n_u_pyx_state,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(2, 4, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__pyx_unpickle_BufferedWriter", 0) < (0)) __PYX_ERR(2, 4, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 3; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BufferedWriter", 1, 3, 3, i); __PYX_ERR(2, 4, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 4, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(2, 4, __pyx_L3_error) values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(2, 4, __pyx_L3_error) } __pyx_v___pyx_type = values[0]; __pyx_v___pyx_checksum = __Pyx_PyLong_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 4, __pyx_L3_error) __pyx_v___pyx_state = ((PyObject*)values[2]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BufferedWriter", 1, 3, 3, __pyx_nargs); __PYX_ERR(2, 4, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.__pyx_unpickle_BufferedWriter", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v___pyx_state), (&PyTuple_Type), 1, "__pyx_state", 1))) __PYX_ERR(2, 4, __pyx_L1_error) __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter___pyx_unpickle_BufferedWriter(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } goto __pyx_L7_cleaned_up; __pyx_L0:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __pyx_L7_cleaned_up:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter___pyx_unpickle_BufferedWriter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_v___pyx_result = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; size_t __pyx_t_4; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedWriter", 0); /* "(tree fragment)":6 * def __pyx_unpickle_BufferedWriter(__pyx_type, long __pyx_checksum, tuple __pyx_state): * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x1c41cb3, 0x253d0cc, 0x25d1d0c, b'buffer, buffer_size, position') # <<<<<<<<<<<<<< * __pyx_result = BufferedWriter.__new__(__pyx_type) * if __pyx_state is not None: */ __pyx_t_1 = __Pyx_CheckUnpickleChecksum(__pyx_v___pyx_checksum, 0x1c41cb3, 0x253d0cc, 0x25d1d0c, ((char const *)"buffer, buffer_size, position")); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(2, 6, __pyx_L1_error) /* "(tree fragment)":7 * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x1c41cb3, 0x253d0cc, 0x25d1d0c, b'buffer, buffer_size, position') * __pyx_result = BufferedWriter.__new__(__pyx_type) # <<<<<<<<<<<<<< * if __pyx_state is not None: * __pyx_unpickle_BufferedWriter__set_state( __pyx_result, __pyx_state) */ __pyx_t_3 = ((PyObject *)__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v___pyx_type}; __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_new, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __pyx_v___pyx_result = __pyx_t_2; __pyx_t_2 = 0; /* "(tree fragment)":8 * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x1c41cb3, 0x253d0cc, 0x25d1d0c, b'buffer, buffer_size, position') * __pyx_result = BufferedWriter.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedWriter__set_state( __pyx_result, __pyx_state) * return __pyx_result */ __pyx_t_5 = (__pyx_v___pyx_state != ((PyObject*)Py_None)); if (__pyx_t_5) { /* "(tree fragment)":9 * __pyx_result = BufferedWriter.__new__(__pyx_type) * if __pyx_state is not None: * __pyx_unpickle_BufferedWriter__set_state( __pyx_result, __pyx_state) # <<<<<<<<<<<<<< * return __pyx_result * cdef __pyx_unpickle_BufferedWriter__set_state(BufferedWriter __pyx_result, __pyx_state: tuple): */ if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "cannot pass None into a C function argument that is declared 'not None'"); __PYX_ERR(2, 9, __pyx_L1_error) } __pyx_t_2 = __pyx_f_17clickhouse_driver_14bufferedwriter___pyx_unpickle_BufferedWriter__set_state(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v___pyx_result), __pyx_v___pyx_state); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":8 * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x1c41cb3, 0x253d0cc, 0x25d1d0c, b'buffer, buffer_size, position') * __pyx_result = BufferedWriter.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedWriter__set_state( __pyx_result, __pyx_state) * return __pyx_result */ } /* "(tree fragment)":10 * if __pyx_state is not None: * __pyx_unpickle_BufferedWriter__set_state( __pyx_result, __pyx_state) * return __pyx_result # <<<<<<<<<<<<<< * cdef __pyx_unpickle_BufferedWriter__set_state(BufferedWriter __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2] */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v___pyx_result); __pyx_r = __pyx_v___pyx_result; goto __pyx_L0; /* "(tree fragment)":4 * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 * def __pyx_unpickle_BufferedWriter(__pyx_type, long __pyx_checksum, tuple __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x1c41cb3, 0x253d0cc, 0x25d1d0c, b'buffer, buffer_size, position') */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.__pyx_unpickle_BufferedWriter", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v___pyx_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":11 * __pyx_unpickle_BufferedWriter__set_state( __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle_BufferedWriter__set_state(BufferedWriter __pyx_result, __pyx_state: tuple): # <<<<<<<<<<<<<< * __pyx_result.buffer = __pyx_state[0]; __pyx_result.buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 3) */ static PyObject *__pyx_f_17clickhouse_driver_14bufferedwriter___pyx_unpickle_BufferedWriter__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; char *__pyx_t_2; unsigned PY_LONG_LONG __pyx_t_3; int __pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedWriter__set_state", 0); /* "(tree fragment)":12 * return __pyx_result * cdef __pyx_unpickle_BufferedWriter__set_state(BufferedWriter __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2] # <<<<<<<<<<<<<< * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 3) */ __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_t_1); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error) __pyx_v___pyx_result->buffer = __pyx_t_2; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_3 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->buffer_size = __pyx_t_3; __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_3 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->position = __pyx_t_3; /* "(tree fragment)":13 * cdef __pyx_unpickle_BufferedWriter__set_state(BufferedWriter __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 3) # <<<<<<<<<<<<<< */ __pyx_t_4 = __Pyx_UpdateUnpickledDict(((PyObject *)__pyx_v___pyx_result), __pyx_v___pyx_state, 3); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 13, __pyx_L1_error) /* "(tree fragment)":11 * __pyx_unpickle_BufferedWriter__set_state( __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle_BufferedWriter__set_state(BufferedWriter __pyx_result, __pyx_state: tuple): # <<<<<<<<<<<<<< * __pyx_result.buffer = __pyx_state[0]; __pyx_result.buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 3) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.__pyx_unpickle_BufferedWriter__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":4 * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 * def __pyx_unpickle_BufferedSocketWriter(__pyx_type, long __pyx_checksum, tuple __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0xca06ecf, 0x4e3cebf, 0x3baf4af, b'buffer, buffer_size, position, sock') */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_3__pyx_unpickle_BufferedSocketWriter(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_3__pyx_unpickle_BufferedSocketWriter = {"__pyx_unpickle_BufferedSocketWriter", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_3__pyx_unpickle_BufferedSocketWriter, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_3__pyx_unpickle_BufferedSocketWriter(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v___pyx_type = 0; long __pyx_v___pyx_checksum; PyObject *__pyx_v___pyx_state = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedSocketWriter (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pyx_type,&__pyx_mstate_global->__pyx_n_u_pyx_checksum,&__pyx_mstate_global->__pyx_n_u_pyx_state,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(2, 4, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__pyx_unpickle_BufferedSocketWriter", 0) < (0)) __PYX_ERR(2, 4, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 3; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BufferedSocketWriter", 1, 3, 3, i); __PYX_ERR(2, 4, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 4, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(2, 4, __pyx_L3_error) values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(2, 4, __pyx_L3_error) } __pyx_v___pyx_type = values[0]; __pyx_v___pyx_checksum = __Pyx_PyLong_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 4, __pyx_L3_error) __pyx_v___pyx_state = ((PyObject*)values[2]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BufferedSocketWriter", 1, 3, 3, __pyx_nargs); __PYX_ERR(2, 4, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.__pyx_unpickle_BufferedSocketWriter", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v___pyx_state), (&PyTuple_Type), 1, "__pyx_state", 1))) __PYX_ERR(2, 4, __pyx_L1_error) __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_2__pyx_unpickle_BufferedSocketWriter(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } goto __pyx_L7_cleaned_up; __pyx_L0:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __pyx_L7_cleaned_up:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_2__pyx_unpickle_BufferedSocketWriter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_v___pyx_result = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; size_t __pyx_t_4; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedSocketWriter", 0); /* "(tree fragment)":6 * def __pyx_unpickle_BufferedSocketWriter(__pyx_type, long __pyx_checksum, tuple __pyx_state): * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0xca06ecf, 0x4e3cebf, 0x3baf4af, b'buffer, buffer_size, position, sock') # <<<<<<<<<<<<<< * __pyx_result = BufferedSocketWriter.__new__(__pyx_type) * if __pyx_state is not None: */ __pyx_t_1 = __Pyx_CheckUnpickleChecksum(__pyx_v___pyx_checksum, 0xca06ecf, 0x4e3cebf, 0x3baf4af, ((char const *)"buffer, buffer_size, position, sock")); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(2, 6, __pyx_L1_error) /* "(tree fragment)":7 * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0xca06ecf, 0x4e3cebf, 0x3baf4af, b'buffer, buffer_size, position, sock') * __pyx_result = BufferedSocketWriter.__new__(__pyx_type) # <<<<<<<<<<<<<< * if __pyx_state is not None: * __pyx_unpickle_BufferedSocketWriter__set_state( __pyx_result, __pyx_state) */ __pyx_t_3 = ((PyObject *)__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v___pyx_type}; __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_new, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __pyx_v___pyx_result = __pyx_t_2; __pyx_t_2 = 0; /* "(tree fragment)":8 * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0xca06ecf, 0x4e3cebf, 0x3baf4af, b'buffer, buffer_size, position, sock') * __pyx_result = BufferedSocketWriter.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedSocketWriter__set_state( __pyx_result, __pyx_state) * return __pyx_result */ __pyx_t_5 = (__pyx_v___pyx_state != ((PyObject*)Py_None)); if (__pyx_t_5) { /* "(tree fragment)":9 * __pyx_result = BufferedSocketWriter.__new__(__pyx_type) * if __pyx_state is not None: * __pyx_unpickle_BufferedSocketWriter__set_state( __pyx_result, __pyx_state) # <<<<<<<<<<<<<< * return __pyx_result * cdef __pyx_unpickle_BufferedSocketWriter__set_state(BufferedSocketWriter __pyx_result, __pyx_state: tuple): */ if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "cannot pass None into a C function argument that is declared 'not None'"); __PYX_ERR(2, 9, __pyx_L1_error) } __pyx_t_2 = __pyx_f_17clickhouse_driver_14bufferedwriter___pyx_unpickle_BufferedSocketWriter__set_state(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *)__pyx_v___pyx_result), __pyx_v___pyx_state); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":8 * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0xca06ecf, 0x4e3cebf, 0x3baf4af, b'buffer, buffer_size, position, sock') * __pyx_result = BufferedSocketWriter.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedSocketWriter__set_state( __pyx_result, __pyx_state) * return __pyx_result */ } /* "(tree fragment)":10 * if __pyx_state is not None: * __pyx_unpickle_BufferedSocketWriter__set_state( __pyx_result, __pyx_state) * return __pyx_result # <<<<<<<<<<<<<< * cdef __pyx_unpickle_BufferedSocketWriter__set_state(BufferedSocketWriter __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3] */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v___pyx_result); __pyx_r = __pyx_v___pyx_result; goto __pyx_L0; /* "(tree fragment)":4 * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 * def __pyx_unpickle_BufferedSocketWriter(__pyx_type, long __pyx_checksum, tuple __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0xca06ecf, 0x4e3cebf, 0x3baf4af, b'buffer, buffer_size, position, sock') */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.__pyx_unpickle_BufferedSocketWriter", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v___pyx_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":11 * __pyx_unpickle_BufferedSocketWriter__set_state( __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle_BufferedSocketWriter__set_state(BufferedSocketWriter __pyx_result, __pyx_state: tuple): # <<<<<<<<<<<<<< * __pyx_result.buffer = __pyx_state[0]; __pyx_result.buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 4) */ static PyObject *__pyx_f_17clickhouse_driver_14bufferedwriter___pyx_unpickle_BufferedSocketWriter__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; char *__pyx_t_2; unsigned PY_LONG_LONG __pyx_t_3; int __pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedSocketWriter__set_state", 0); /* "(tree fragment)":12 * return __pyx_result * cdef __pyx_unpickle_BufferedSocketWriter__set_state(BufferedSocketWriter __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3] # <<<<<<<<<<<<<< * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 4) */ __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_t_1); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error) __pyx_v___pyx_result->__pyx_base.buffer = __pyx_t_2; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_3 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->__pyx_base.buffer_size = __pyx_t_3; __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_3 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->__pyx_base.position = __pyx_t_3; __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->sock); __Pyx_DECREF(__pyx_v___pyx_result->sock); __pyx_v___pyx_result->sock = __pyx_t_1; __pyx_t_1 = 0; /* "(tree fragment)":13 * cdef __pyx_unpickle_BufferedSocketWriter__set_state(BufferedSocketWriter __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 4) # <<<<<<<<<<<<<< */ __pyx_t_4 = __Pyx_UpdateUnpickledDict(((PyObject *)__pyx_v___pyx_result), __pyx_v___pyx_state, 4); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 13, __pyx_L1_error) /* "(tree fragment)":11 * __pyx_unpickle_BufferedSocketWriter__set_state( __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle_BufferedSocketWriter__set_state(BufferedSocketWriter __pyx_result, __pyx_state: tuple): # <<<<<<<<<<<<<< * __pyx_result.buffer = __pyx_state[0]; __pyx_result.buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 4) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.__pyx_unpickle_BufferedSocketWriter__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":4 * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 * def __pyx_unpickle_CompressedBufferedWriter(__pyx_type, long __pyx_checksum, tuple __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x835ced9, 0x96f6a9b, 0x108d208, b'buffer, buffer_size, compressor, position') */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_5__pyx_unpickle_CompressedBufferedWriter(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedwriter_5__pyx_unpickle_CompressedBufferedWriter = {"__pyx_unpickle_CompressedBufferedWriter", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_5__pyx_unpickle_CompressedBufferedWriter, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_5__pyx_unpickle_CompressedBufferedWriter(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v___pyx_type = 0; long __pyx_v___pyx_checksum; PyObject *__pyx_v___pyx_state = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__pyx_unpickle_CompressedBufferedWriter (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_pyx_type,&__pyx_mstate_global->__pyx_n_u_pyx_checksum,&__pyx_mstate_global->__pyx_n_u_pyx_state,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(2, 4, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__pyx_unpickle_CompressedBufferedWriter", 0) < (0)) __PYX_ERR(2, 4, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 3; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_CompressedBufferedWriter", 1, 3, 3, i); __PYX_ERR(2, 4, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(2, 4, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(2, 4, __pyx_L3_error) values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(2, 4, __pyx_L3_error) } __pyx_v___pyx_type = values[0]; __pyx_v___pyx_checksum = __Pyx_PyLong_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 4, __pyx_L3_error) __pyx_v___pyx_state = ((PyObject*)values[2]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_CompressedBufferedWriter", 1, 3, 3, __pyx_nargs); __PYX_ERR(2, 4, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.__pyx_unpickle_CompressedBufferedWriter", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v___pyx_state), (&PyTuple_Type), 1, "__pyx_state", 1))) __PYX_ERR(2, 4, __pyx_L1_error) __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_4__pyx_unpickle_CompressedBufferedWriter(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } goto __pyx_L7_cleaned_up; __pyx_L0:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __pyx_L7_cleaned_up:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_4__pyx_unpickle_CompressedBufferedWriter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_v___pyx_result = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; size_t __pyx_t_4; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle_CompressedBufferedWriter", 0); /* "(tree fragment)":6 * def __pyx_unpickle_CompressedBufferedWriter(__pyx_type, long __pyx_checksum, tuple __pyx_state): * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x835ced9, 0x96f6a9b, 0x108d208, b'buffer, buffer_size, compressor, position') # <<<<<<<<<<<<<< * __pyx_result = CompressedBufferedWriter.__new__(__pyx_type) * if __pyx_state is not None: */ __pyx_t_1 = __Pyx_CheckUnpickleChecksum(__pyx_v___pyx_checksum, 0x835ced9, 0x96f6a9b, 0x108d208, ((char const *)"buffer, buffer_size, compressor, position")); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(2, 6, __pyx_L1_error) /* "(tree fragment)":7 * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x835ced9, 0x96f6a9b, 0x108d208, b'buffer, buffer_size, compressor, position') * __pyx_result = CompressedBufferedWriter.__new__(__pyx_type) # <<<<<<<<<<<<<< * if __pyx_state is not None: * __pyx_unpickle_CompressedBufferedWriter__set_state( __pyx_result, __pyx_state) */ __pyx_t_3 = ((PyObject *)__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v___pyx_type}; __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_new, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __pyx_v___pyx_result = __pyx_t_2; __pyx_t_2 = 0; /* "(tree fragment)":8 * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x835ced9, 0x96f6a9b, 0x108d208, b'buffer, buffer_size, compressor, position') * __pyx_result = CompressedBufferedWriter.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle_CompressedBufferedWriter__set_state( __pyx_result, __pyx_state) * return __pyx_result */ __pyx_t_5 = (__pyx_v___pyx_state != ((PyObject*)Py_None)); if (__pyx_t_5) { /* "(tree fragment)":9 * __pyx_result = CompressedBufferedWriter.__new__(__pyx_type) * if __pyx_state is not None: * __pyx_unpickle_CompressedBufferedWriter__set_state( __pyx_result, __pyx_state) # <<<<<<<<<<<<<< * return __pyx_result * cdef __pyx_unpickle_CompressedBufferedWriter__set_state(CompressedBufferedWriter __pyx_result, __pyx_state: tuple): */ if (unlikely(__pyx_v___pyx_state == Py_None)) { PyErr_SetString(PyExc_TypeError, "cannot pass None into a C function argument that is declared 'not None'"); __PYX_ERR(2, 9, __pyx_L1_error) } __pyx_t_2 = __pyx_f_17clickhouse_driver_14bufferedwriter___pyx_unpickle_CompressedBufferedWriter__set_state(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *)__pyx_v___pyx_result), __pyx_v___pyx_state); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":8 * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x835ced9, 0x96f6a9b, 0x108d208, b'buffer, buffer_size, compressor, position') * __pyx_result = CompressedBufferedWriter.__new__(__pyx_type) * if __pyx_state is not None: # <<<<<<<<<<<<<< * __pyx_unpickle_CompressedBufferedWriter__set_state( __pyx_result, __pyx_state) * return __pyx_result */ } /* "(tree fragment)":10 * if __pyx_state is not None: * __pyx_unpickle_CompressedBufferedWriter__set_state( __pyx_result, __pyx_state) * return __pyx_result # <<<<<<<<<<<<<< * cdef __pyx_unpickle_CompressedBufferedWriter__set_state(CompressedBufferedWriter __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.buffer_size = __pyx_state[1]; __pyx_result.compressor = __pyx_state[2]; __pyx_result.position = __pyx_state[3] */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v___pyx_result); __pyx_r = __pyx_v___pyx_result; goto __pyx_L0; /* "(tree fragment)":4 * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 * def __pyx_unpickle_CompressedBufferedWriter(__pyx_type, long __pyx_checksum, tuple __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x835ced9, 0x96f6a9b, 0x108d208, b'buffer, buffer_size, compressor, position') */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.__pyx_unpickle_CompressedBufferedWriter", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v___pyx_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":11 * __pyx_unpickle_CompressedBufferedWriter__set_state( __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle_CompressedBufferedWriter__set_state(CompressedBufferedWriter __pyx_result, __pyx_state: tuple): # <<<<<<<<<<<<<< * __pyx_result.buffer = __pyx_state[0]; __pyx_result.buffer_size = __pyx_state[1]; __pyx_result.compressor = __pyx_state[2]; __pyx_result.position = __pyx_state[3] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 4) */ static PyObject *__pyx_f_17clickhouse_driver_14bufferedwriter___pyx_unpickle_CompressedBufferedWriter__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; char *__pyx_t_2; unsigned PY_LONG_LONG __pyx_t_3; int __pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__pyx_unpickle_CompressedBufferedWriter__set_state", 0); /* "(tree fragment)":12 * return __pyx_result * cdef __pyx_unpickle_CompressedBufferedWriter__set_state(CompressedBufferedWriter __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.buffer_size = __pyx_state[1]; __pyx_result.compressor = __pyx_state[2]; __pyx_result.position = __pyx_state[3] # <<<<<<<<<<<<<< * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 4) */ __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_AsWritableString(__pyx_t_1); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error) __pyx_v___pyx_result->__pyx_base.buffer = __pyx_t_2; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_3 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->__pyx_base.buffer_size = __pyx_t_3; __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v___pyx_result->compressor); __Pyx_DECREF(__pyx_v___pyx_result->compressor); __pyx_v___pyx_result->compressor = __pyx_t_1; __pyx_t_1 = 0; __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_3 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v___pyx_result->__pyx_base.position = __pyx_t_3; /* "(tree fragment)":13 * cdef __pyx_unpickle_CompressedBufferedWriter__set_state(CompressedBufferedWriter __pyx_result, __pyx_state: tuple): * __pyx_result.buffer = __pyx_state[0]; __pyx_result.buffer_size = __pyx_state[1]; __pyx_result.compressor = __pyx_state[2]; __pyx_result.position = __pyx_state[3] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 4) # <<<<<<<<<<<<<< */ __pyx_t_4 = __Pyx_UpdateUnpickledDict(((PyObject *)__pyx_v___pyx_result), __pyx_v___pyx_state, 4); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 13, __pyx_L1_error) /* "(tree fragment)":11 * __pyx_unpickle_CompressedBufferedWriter__set_state( __pyx_result, __pyx_state) * return __pyx_result * cdef __pyx_unpickle_CompressedBufferedWriter__set_state(CompressedBufferedWriter __pyx_result, __pyx_state: tuple): # <<<<<<<<<<<<<< * __pyx_result.buffer = __pyx_state[0]; __pyx_result.buffer_size = __pyx_state[1]; __pyx_result.compressor = __pyx_state[2]; __pyx_result.position = __pyx_state[3] * __Pyx_UpdateUnpickledDict(__pyx_result, __pyx_state, 4) */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.__pyx_unpickle_CompressedBufferedWriter__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* #### Code section: module_exttypes ### */ static struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter __pyx_vtable_17clickhouse_driver_14bufferedwriter_BufferedWriter; static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedwriter_BufferedWriter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *p; PyObject *o; o = __Pyx_AllocateExtensionType(t, 0); if (unlikely(!o)) return 0; p = ((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)o); p->__pyx_vtab = __pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedWriter; return o; } static void __pyx_tp_dealloc_17clickhouse_driver_14bufferedwriter_BufferedWriter(PyObject *o) { #if CYTHON_USE_TP_FINALIZE if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && (!PyType_IS_GC(Py_TYPE(o)) || !__Pyx_PyObject_GC_IsFinalized(o))) { if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_17clickhouse_driver_14bufferedwriter_BufferedWriter) { if (PyObject_CallFinalizerFromDealloc(o)) return; } } #endif { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); __pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_3__dealloc__(o); __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); PyErr_Restore(etype, eval, etb); } PyTypeObject *tp = Py_TYPE(o); #if CYTHON_USE_TYPE_SLOTS (*tp->tp_free)(o); #else { freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free); if (tp_free) tp_free(o); } #endif #if CYTHON_USE_TYPE_SPECS Py_DECREF(tp); #endif } static PyMethodDef __pyx_methods_17clickhouse_driver_14bufferedwriter_BufferedWriter[] = { {"flush", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_9flush, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"write_strings", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_11write_strings, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"write_fixed_strings_as_bytes", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_13write_fixed_strings_as_bytes, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"write_fixed_strings", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_15write_fixed_strings, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_17__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_19__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; #if CYTHON_USE_TYPE_SPECS static PyType_Slot __pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter_slots[] = { {Py_tp_dealloc, (void *)__pyx_tp_dealloc_17clickhouse_driver_14bufferedwriter_BufferedWriter}, {Py_tp_methods, (void *)__pyx_methods_17clickhouse_driver_14bufferedwriter_BufferedWriter}, {Py_tp_init, (void *)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_1__init__}, {Py_tp_new, (void *)__pyx_tp_new_17clickhouse_driver_14bufferedwriter_BufferedWriter}, {0, 0}, }; static PyType_Spec __pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter_spec = { "clickhouse_driver.bufferedwriter.BufferedWriter", sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter), 0, Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, __pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter_slots, }; #else static PyTypeObject __pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter = { PyVarObject_HEAD_INIT(0, 0) "clickhouse_driver.bufferedwriter.""BufferedWriter", /*tp_name*/ sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_17clickhouse_driver_14bufferedwriter_BufferedWriter, /*tp_dealloc*/ 0, /*tp_vectorcall_offset*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_as_async*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ 0, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_17clickhouse_driver_14bufferedwriter_BufferedWriter, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ #if !CYTHON_USE_TYPE_SPECS 0, /*tp_dictoffset*/ #endif __pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_17clickhouse_driver_14bufferedwriter_BufferedWriter, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if CYTHON_USE_TP_FINALIZE 0, /*tp_finalize*/ #else NULL, /*tp_finalize*/ #endif #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800 0, /*tp_vectorcall*/ #endif #if __PYX_NEED_TP_PRINT_SLOT == 1 0, /*tp_print*/ #endif #if PY_VERSION_HEX >= 0x030C0000 0, /*tp_watched*/ #endif #if PY_VERSION_HEX >= 0x030d00A4 0, /*tp_versions_used*/ #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000 0, /*tp_pypy_flags*/ #endif }; #endif static struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter __pyx_vtable_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter; static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *p; PyObject *o = __pyx_tp_new_17clickhouse_driver_14bufferedwriter_BufferedWriter(t, a, k); if (unlikely(!o)) return 0; p = ((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *)o); p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter*)__pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter; p->sock = Py_None; Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter(PyObject *o) { struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *p = (struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *)o; #if CYTHON_USE_TP_FINALIZE if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) { if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter) { if (PyObject_CallFinalizerFromDealloc(o)) return; } } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->sock); __pyx_tp_dealloc_17clickhouse_driver_14bufferedwriter_BufferedWriter(o); } static int __pyx_tp_traverse_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *p = (struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *)o; #if !CYTHON_USE_MODULE_STATE e = 0; if (likely(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter)) { traverseproc traverse = __Pyx_PyType_GetSlot(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter, tp_traverse, traverseproc); if (traverse) { e = traverse(o, v, a); } } else #endif { e = __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter); } if (e) return e; { e = __Pyx_call_type_traverse(o, 0, v, a); if (e) return e; } if (p->sock) { e = (*v)(p->sock, a); if (e) return e; } return 0; } static int __pyx_tp_clear_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter(PyObject *o) { PyObject* tmp; struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *p = (struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *)o; #if !CYTHON_USE_MODULE_STATE if (likely(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter)) { inquiry clear = __Pyx_PyType_GetSlot(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter, tp_clear, inquiry); if (clear) clear(o); } else #endif { __Pyx_call_next_tp_clear(o, __pyx_tp_clear_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter); } tmp = ((PyObject*)p->sock); p->sock = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyMethodDef __pyx_methods_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter[] = { {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_5__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_7__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; #if CYTHON_USE_TYPE_SPECS static PyType_Slot __pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter_slots[] = { {Py_tp_dealloc, (void *)__pyx_tp_dealloc_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter}, {Py_tp_traverse, (void *)__pyx_tp_traverse_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter}, {Py_tp_clear, (void *)__pyx_tp_clear_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter}, {Py_tp_methods, (void *)__pyx_methods_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter}, {Py_tp_init, (void *)__pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_1__init__}, {Py_tp_new, (void *)__pyx_tp_new_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter}, {0, 0}, }; static PyType_Spec __pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter_spec = { "clickhouse_driver.bufferedwriter.BufferedSocketWriter", sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter), 0, Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, __pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter_slots, }; #else static PyTypeObject __pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter = { PyVarObject_HEAD_INIT(0, 0) "clickhouse_driver.bufferedwriter.""BufferedSocketWriter", /*tp_name*/ sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter, /*tp_dealloc*/ 0, /*tp_vectorcall_offset*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_as_async*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter, /*tp_traverse*/ __pyx_tp_clear_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ #if !CYTHON_USE_TYPE_SPECS 0, /*tp_dictoffset*/ #endif __pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if CYTHON_USE_TP_FINALIZE 0, /*tp_finalize*/ #else NULL, /*tp_finalize*/ #endif #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800 0, /*tp_vectorcall*/ #endif #if __PYX_NEED_TP_PRINT_SLOT == 1 0, /*tp_print*/ #endif #if PY_VERSION_HEX >= 0x030C0000 0, /*tp_watched*/ #endif #if PY_VERSION_HEX >= 0x030d00A4 0, /*tp_versions_used*/ #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000 0, /*tp_pypy_flags*/ #endif }; #endif static struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter __pyx_vtable_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter; static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *p; PyObject *o = __pyx_tp_new_17clickhouse_driver_14bufferedwriter_BufferedWriter(t, a, k); if (unlikely(!o)) return 0; p = ((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *)o); p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter*)__pyx_vtabptr_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter; p->compressor = Py_None; Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter(PyObject *o) { struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *p = (struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *)o; #if CYTHON_USE_TP_FINALIZE if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) { if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter) { if (PyObject_CallFinalizerFromDealloc(o)) return; } } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->compressor); __pyx_tp_dealloc_17clickhouse_driver_14bufferedwriter_BufferedWriter(o); } static int __pyx_tp_traverse_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *p = (struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *)o; #if !CYTHON_USE_MODULE_STATE e = 0; if (likely(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter)) { traverseproc traverse = __Pyx_PyType_GetSlot(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter, tp_traverse, traverseproc); if (traverse) { e = traverse(o, v, a); } } else #endif { e = __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter); } if (e) return e; { e = __Pyx_call_type_traverse(o, 0, v, a); if (e) return e; } if (p->compressor) { e = (*v)(p->compressor, a); if (e) return e; } return 0; } static int __pyx_tp_clear_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter(PyObject *o) { PyObject* tmp; struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *p = (struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *)o; #if !CYTHON_USE_MODULE_STATE if (likely(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter)) { inquiry clear = __Pyx_PyType_GetSlot(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter, tp_clear, inquiry); if (clear) clear(o); } else #endif { __Pyx_call_next_tp_clear(o, __pyx_tp_clear_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter); } tmp = ((PyObject*)p->compressor); p->compressor = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyMethodDef __pyx_methods_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter[] = { {"flush", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_5flush, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"__reduce_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_7__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"__setstate_cython__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_9__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; #if CYTHON_USE_TYPE_SPECS static PyType_Slot __pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter_slots[] = { {Py_tp_dealloc, (void *)__pyx_tp_dealloc_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter}, {Py_tp_traverse, (void *)__pyx_tp_traverse_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter}, {Py_tp_clear, (void *)__pyx_tp_clear_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter}, {Py_tp_methods, (void *)__pyx_methods_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter}, {Py_tp_init, (void *)__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_1__init__}, {Py_tp_new, (void *)__pyx_tp_new_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter}, {0, 0}, }; static PyType_Spec __pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter_spec = { "clickhouse_driver.bufferedwriter.CompressedBufferedWriter", sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter), 0, Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, __pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter_slots, }; #else static PyTypeObject __pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter = { PyVarObject_HEAD_INIT(0, 0) "clickhouse_driver.bufferedwriter.""CompressedBufferedWriter", /*tp_name*/ sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter, /*tp_dealloc*/ 0, /*tp_vectorcall_offset*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_as_async*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter, /*tp_traverse*/ __pyx_tp_clear_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ #if !CYTHON_USE_TYPE_SPECS 0, /*tp_dictoffset*/ #endif __pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if CYTHON_USE_TP_FINALIZE 0, /*tp_finalize*/ #else NULL, /*tp_finalize*/ #endif #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800 0, /*tp_vectorcall*/ #endif #if __PYX_NEED_TP_PRINT_SLOT == 1 0, /*tp_print*/ #endif #if PY_VERSION_HEX >= 0x030C0000 0, /*tp_watched*/ #endif #if PY_VERSION_HEX >= 0x030d00A4 0, /*tp_versions_used*/ #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000 0, /*tp_pypy_flags*/ #endif }; #endif static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; /* #### Code section: initfunc_declarations ### */ static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate); /*proto*/ /* #### Code section: init_module ### */ static int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); /*--- Global init code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); /*--- Variable export code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); /*--- Function export code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); /*--- Type init code ---*/ __pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedWriter = &__pyx_vtable_17clickhouse_driver_14bufferedwriter_BufferedWriter; __pyx_vtable_17clickhouse_driver_14bufferedwriter_BufferedWriter.write_into_stream = (PyObject *(*)(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *, int __pyx_skip_dispatch))__pyx_f_17clickhouse_driver_14bufferedwriter_14BufferedWriter_write_into_stream; __pyx_vtable_17clickhouse_driver_14bufferedwriter_BufferedWriter.write = (PyObject *(*)(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *, PyObject *, int __pyx_skip_dispatch))__pyx_f_17clickhouse_driver_14bufferedwriter_14BufferedWriter_write; #if CYTHON_USE_TYPE_SPECS __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter)) __PYX_ERR(0, 10, __pyx_L1_error) if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter_spec, __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter) < (0)) __PYX_ERR(0, 10, __pyx_L1_error) #else __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter = &__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter; #endif #if !CYTHON_COMPILING_IN_LIMITED_API #endif #if !CYTHON_USE_TYPE_SPECS if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter) < (0)) __PYX_ERR(0, 10, __pyx_L1_error) #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter); #endif #if !CYTHON_COMPILING_IN_LIMITED_API if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter->tp_dictoffset && __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter->tp_getattro == PyObject_GenericGetAttr)) { __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter->tp_getattro = PyObject_GenericGetAttr; } #endif if (__Pyx_SetVtable(__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter, __pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedWriter) < (0)) __PYX_ERR(0, 10, __pyx_L1_error) if (__Pyx_MergeVtables(__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter) < (0)) __PYX_ERR(0, 10, __pyx_L1_error) if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_BufferedWriter, (PyObject *) __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter) < (0)) __PYX_ERR(0, 10, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject *) __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter) < (0)) __PYX_ERR(0, 10, __pyx_L1_error) __pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter = &__pyx_vtable_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter; __pyx_vtable_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter.__pyx_base = *__pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedWriter; __pyx_vtable_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter.__pyx_base.write_into_stream = (PyObject *(*)(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *, int __pyx_skip_dispatch))__pyx_f_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_write_into_stream; #if CYTHON_USE_TYPE_SPECS __pyx_t_1 = PyTuple_Pack(1, (PyObject *)__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter_spec, __pyx_t_1); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter)) __PYX_ERR(0, 119, __pyx_L1_error) if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter_spec, __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter) < (0)) __PYX_ERR(0, 119, __pyx_L1_error) #else __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter = &__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter; #endif #if !CYTHON_COMPILING_IN_LIMITED_API __pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter->tp_base = __pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter; #endif #if !CYTHON_USE_TYPE_SPECS if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter) < (0)) __PYX_ERR(0, 119, __pyx_L1_error) #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter); #endif #if !CYTHON_COMPILING_IN_LIMITED_API if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter->tp_dictoffset && __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter->tp_getattro == PyObject_GenericGetAttr)) { __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter->tp_getattro = PyObject_GenericGetAttr; } #endif if (__Pyx_SetVtable(__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter, __pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter) < (0)) __PYX_ERR(0, 119, __pyx_L1_error) if (__Pyx_MergeVtables(__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter) < (0)) __PYX_ERR(0, 119, __pyx_L1_error) if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_BufferedSocketWriter, (PyObject *) __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter) < (0)) __PYX_ERR(0, 119, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject *) __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter) < (0)) __PYX_ERR(0, 119, __pyx_L1_error) __pyx_vtabptr_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter = &__pyx_vtable_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter; __pyx_vtable_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter.__pyx_base = *__pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedWriter; __pyx_vtable_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter.__pyx_base.write_into_stream = (PyObject *(*)(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *, int __pyx_skip_dispatch))__pyx_f_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_write_into_stream; #if CYTHON_USE_TYPE_SPECS __pyx_t_1 = PyTuple_Pack(1, (PyObject *)__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter_spec, __pyx_t_1); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter)) __PYX_ERR(0, 133, __pyx_L1_error) if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter_spec, __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter) < (0)) __PYX_ERR(0, 133, __pyx_L1_error) #else __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter = &__pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter; #endif #if !CYTHON_COMPILING_IN_LIMITED_API __pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter->tp_base = __pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter; #endif #if !CYTHON_USE_TYPE_SPECS if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter) < (0)) __PYX_ERR(0, 133, __pyx_L1_error) #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter); #endif #if !CYTHON_COMPILING_IN_LIMITED_API if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter->tp_dictoffset && __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter->tp_getattro == PyObject_GenericGetAttr)) { __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter->tp_getattro = PyObject_GenericGetAttr; } #endif if (__Pyx_SetVtable(__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter, __pyx_vtabptr_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter) < (0)) __PYX_ERR(0, 133, __pyx_L1_error) if (__Pyx_MergeVtables(__pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter) < (0)) __PYX_ERR(0, 133, __pyx_L1_error) if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_CompressedBufferedWriter, (PyObject *) __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter) < (0)) __PYX_ERR(0, 133, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject *) __pyx_mstate->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter) < (0)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); /*--- Type import code ---*/ __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_mstate->__pyx_ptype_7cpython_4type_type = __Pyx_ImportType_3_2_0(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 sizeof(PyTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyTypeObject), #elif CYTHON_COMPILING_IN_LIMITED_API 0, 0, #else sizeof(PyHeapTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyHeapTypeObject), #endif __Pyx_ImportType_CheckSize_Warn_3_2_0); if (!__pyx_mstate->__pyx_ptype_7cpython_4type_type) __PYX_ERR(3, 9, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_mstate->__pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType_3_2_0(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "bool", #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 sizeof(PyLongObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyLongObject), #elif CYTHON_COMPILING_IN_LIMITED_API 0, 0, #else sizeof(PyLongObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyLongObject), #endif __Pyx_ImportType_CheckSize_Warn_3_2_0); if (!__pyx_mstate->__pyx_ptype_7cpython_4bool_bool) __PYX_ERR(4, 8, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_mstate->__pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType_3_2_0(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "complex", #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 sizeof(PyComplexObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyComplexObject), #elif CYTHON_COMPILING_IN_LIMITED_API 0, 0, #else sizeof(PyComplexObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyComplexObject), #endif __Pyx_ImportType_CheckSize_Warn_3_2_0); if (!__pyx_mstate->__pyx_ptype_7cpython_7complex_complex) __PYX_ERR(5, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); /*--- Variable import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); /*--- Function import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } #if CYTHON_PEP489_MULTI_PHASE_INIT static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ static int __pyx_pymod_exec_bufferedwriter(PyObject* module); /*proto*/ static PyModuleDef_Slot __pyx_moduledef_slots[] = { {Py_mod_create, (void*)__pyx_pymod_create}, {Py_mod_exec, (void*)__pyx_pymod_exec_bufferedwriter}, #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING {Py_mod_gil, Py_MOD_GIL_USED}, #endif #if PY_VERSION_HEX >= 0x030C0000 && CYTHON_USE_MODULE_STATE {Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED}, #endif {0, NULL} }; #endif #ifdef __cplusplus namespace { struct PyModuleDef __pyx_moduledef = #else static struct PyModuleDef __pyx_moduledef = #endif { PyModuleDef_HEAD_INIT, "bufferedwriter", 0, /* m_doc */ #if CYTHON_USE_MODULE_STATE sizeof(__pyx_mstatetype), /* m_size */ #else (CYTHON_PEP489_MULTI_PHASE_INIT) ? 0 : -1, /* m_size */ #endif __pyx_methods /* m_methods */, #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_moduledef_slots, /* m_slots */ #else NULL, /* m_reload */ #endif #if CYTHON_USE_MODULE_STATE __pyx_m_traverse, /* m_traverse */ __pyx_m_clear, /* m_clear */ NULL /* m_free */ #else NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ #endif }; #ifdef __cplusplus } /* anonymous namespace */ #endif /* PyModInitFuncType */ #ifndef CYTHON_NO_PYINIT_EXPORT #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC #else #ifdef __cplusplus #define __Pyx_PyMODINIT_FUNC extern "C" PyObject * #else #define __Pyx_PyMODINIT_FUNC PyObject * #endif #endif __Pyx_PyMODINIT_FUNC PyInit_bufferedwriter(void) CYTHON_SMALL_CODE; /*proto*/ __Pyx_PyMODINIT_FUNC PyInit_bufferedwriter(void) #if CYTHON_PEP489_MULTI_PHASE_INIT { return PyModuleDef_Init(&__pyx_moduledef); } /* ModuleCreationPEP489 */ #if CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\ || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000)) static PY_INT64_T __Pyx_GetCurrentInterpreterId(void) { { PyObject *module = PyImport_ImportModule("_interpreters"); // 3.13+ I think if (!module) { PyErr_Clear(); // just try the 3.8-3.12 version module = PyImport_ImportModule("_xxsubinterpreters"); if (!module) goto bad; } PyObject *current = PyObject_CallMethod(module, "get_current", NULL); Py_DECREF(module); if (!current) goto bad; if (PyTuple_Check(current)) { PyObject *new_current = PySequence_GetItem(current, 0); Py_DECREF(current); current = new_current; if (!new_current) goto bad; } long long as_c_int = PyLong_AsLongLong(current); Py_DECREF(current); return as_c_int; } bad: PySys_WriteStderr("__Pyx_GetCurrentInterpreterId failed. Try setting the C define CYTHON_PEP489_MULTI_PHASE_INIT=0\n"); return -1; } #endif #if !CYTHON_USE_MODULE_STATE static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { static PY_INT64_T main_interpreter_id = -1; #if CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000 PY_INT64_T current_id = GraalPyInterpreterState_GetIDFromThreadState(PyThreadState_Get()); #elif CYTHON_COMPILING_IN_GRAAL PY_INT64_T current_id = PyInterpreterState_GetIDFromThreadState(PyThreadState_Get()); #elif CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\ || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000)) PY_INT64_T current_id = __Pyx_GetCurrentInterpreterId(); #elif CYTHON_COMPILING_IN_LIMITED_API PY_INT64_T current_id = PyInterpreterState_GetID(PyInterpreterState_Get()); #else PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); #endif if (unlikely(current_id == -1)) { return -1; } if (main_interpreter_id == -1) { main_interpreter_id = current_id; return 0; } else if (unlikely(main_interpreter_id != current_id)) { PyErr_SetString( PyExc_ImportError, "Interpreter change detected - this module can only be loaded into one interpreter per process."); return -1; } return 0; } #endif static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { PyObject *value = PyObject_GetAttrString(spec, from_name); int result = 0; if (likely(value)) { if (allow_none || value != Py_None) { result = PyDict_SetItemString(moddict, to_name, value); } Py_DECREF(value); } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Clear(); } else { result = -1; } return result; } static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def) { PyObject *module = NULL, *moddict, *modname; CYTHON_UNUSED_VAR(def); #if !CYTHON_USE_MODULE_STATE if (__Pyx_check_single_interpreter()) return NULL; #endif if (__pyx_m) return __Pyx_NewRef(__pyx_m); modname = PyObject_GetAttrString(spec, "name"); if (unlikely(!modname)) goto bad; module = PyModule_NewObject(modname); Py_DECREF(modname); if (unlikely(!module)) goto bad; moddict = PyModule_GetDict(module); if (unlikely(!moddict)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; return module; bad: Py_XDECREF(module); return NULL; } static CYTHON_SMALL_CODE int __pyx_pymod_exec_bufferedwriter(PyObject *__pyx_pyinit_module) #endif { int stringtab_initialized = 0; #if CYTHON_USE_MODULE_STATE int pystate_addmodule_run = 0; #endif __pyx_mstatetype *__pyx_mstate = NULL; PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; Py_ssize_t __pyx_t_3; PyObject *__pyx_t_4 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #if CYTHON_PEP489_MULTI_PHASE_INIT if (__pyx_m) { if (__pyx_m == __pyx_pyinit_module) return 0; PyErr_SetString(PyExc_RuntimeError, "Module 'bufferedwriter' has already been imported. Re-initialisation is not supported."); return -1; } #else if (__pyx_m) return __Pyx_NewRef(__pyx_m); #endif /*--- Module creation code ---*/ #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_t_1 = __pyx_pyinit_module; Py_INCREF(__pyx_t_1); #else __pyx_t_1 = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) #endif #if CYTHON_USE_MODULE_STATE { int add_module_result = __Pyx_State_AddModule(__pyx_t_1, &__pyx_moduledef); __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to "bufferedwriter" pseudovariable */ if (unlikely((add_module_result < 0))) __PYX_ERR(0, 1, __pyx_L1_error) pystate_addmodule_run = 1; } #else __pyx_m = __pyx_t_1; #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING PyUnstable_Module_SetGIL(__pyx_m, Py_MOD_GIL_USED); #endif __pyx_mstate = __pyx_mstate_global; CYTHON_UNUSED_VAR(__pyx_t_1); __pyx_mstate->__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_mstate->__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_mstate->__pyx_d); __pyx_mstate->__pyx_b = __Pyx_PyImport_AddModuleRef(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_mstate->__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_mstate->__pyx_cython_runtime = __Pyx_PyImport_AddModuleRef("cython_runtime"); if (unlikely(!__pyx_mstate->__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_mstate->__pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error) /* ImportRefnannyAPI */ #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("PyInit_bufferedwriter", 0); __Pyx_init_runtime_version(); if (__Pyx_check_binary_version(__PYX_LIMITED_VERSION_HEX, __Pyx_get_runtime_version(), CYTHON_COMPILING_IN_LIMITED_API) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_mstate->__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_mstate->__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_mstate->__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_mstate->__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Library function declarations ---*/ /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) stringtab_initialized = 1; if (__Pyx_InitGlobals() < (0)) __PYX_ERR(0, 1, __pyx_L1_error) if (__pyx_module_is_main_clickhouse_driver__bufferedwriter) { if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_name, __pyx_mstate_global->__pyx_n_u_main) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) } { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) if (!PyDict_GetItemString(modules, "clickhouse_driver.bufferedwriter")) { if (unlikely((PyDict_SetItemString(modules, "clickhouse_driver.bufferedwriter", __pyx_m) < 0))) __PYX_ERR(0, 1, __pyx_L1_error) } } /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_CreateCodeObjects(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Global type/function init code ---*/ (void)__Pyx_modinit_global_init_code(__pyx_mstate); (void)__Pyx_modinit_variable_export_code(__pyx_mstate); (void)__Pyx_modinit_function_export_code(__pyx_mstate); if (unlikely((__Pyx_modinit_type_init_code(__pyx_mstate) < 0))) __PYX_ERR(0, 1, __pyx_L1_error) if (unlikely((__Pyx_modinit_type_import_code(__pyx_mstate) < 0))) __PYX_ERR(0, 1, __pyx_L1_error) (void)__Pyx_modinit_variable_import_code(__pyx_mstate); (void)__Pyx_modinit_function_import_code(__pyx_mstate); /*--- Execution code ---*/ /* "clickhouse_driver/bufferedwriter.pyx":6 * from libc.string cimport memcpy, memset * * from . import errors # <<<<<<<<<<<<<< * from .varint import make_varint * */ { PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_errors}; __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_, __pyx_imported_names, 1, __pyx_mstate_global->__pyx_kp_u_clickhouse_driver, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) } __pyx_t_2 = __pyx_t_1; __Pyx_GOTREF(__pyx_t_2); { PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_errors}; __pyx_t_3 = 0; { __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedwriter.pyx":7 * * from . import errors * from .varint import make_varint # <<<<<<<<<<<<<< * * */ { PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_make_varint}; __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_varint, __pyx_imported_names, 1, __pyx_mstate_global->__pyx_kp_u_clickhouse_driver_varint, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error) } __pyx_t_2 = __pyx_t_1; __Pyx_GOTREF(__pyx_t_2); { PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_make_varint}; __pyx_t_3 = 0; { __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedwriter.pyx":27 * PyMem_Free(self.buffer) * * cpdef write_into_stream(self): # <<<<<<<<<<<<<< * raise NotImplementedError * */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_14BufferedWriter_5write_into_stream, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedWriter_write_into_stream, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter, __pyx_mstate_global->__pyx_n_u_write_into_stream, __pyx_t_2) < (0)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedwriter.pyx":30 * raise NotImplementedError * * cpdef write(self, data): # <<<<<<<<<<<<<< * cdef unsigned long long size, written = 0 * cdef unsigned long long data_len = PyBytes_GET_SIZE(data) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_14BufferedWriter_7write, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedWriter_write, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter, __pyx_mstate_global->__pyx_n_u_write, __pyx_t_2) < (0)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedwriter.pyx":45 * written += size * * def flush(self): # <<<<<<<<<<<<<< * self.write_into_stream() * */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_14BufferedWriter_9flush, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedWriter_flush, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[2])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter, __pyx_mstate_global->__pyx_n_u_flush, __pyx_t_2) < (0)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedwriter.pyx":48 * self.write_into_stream() * * def write_strings(self, items, encoding=None): # <<<<<<<<<<<<<< * cdef int do_encode = encoding is not None * */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_14BufferedWriter_11write_strings, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedWriter_write_strings, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[3])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_mstate_global->__pyx_tuple[3]); if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter, __pyx_mstate_global->__pyx_n_u_write_strings, __pyx_t_2) < (0)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedwriter.pyx":61 * self.write(value) * * def write_fixed_strings_as_bytes(self, items, Py_ssize_t length): # <<<<<<<<<<<<<< * cdef Py_ssize_t buf_pos = 0 * cdef Py_ssize_t items_buf_size = length * len(items) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_14BufferedWriter_13write_fixed_strings_as_bytes, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedWriter_write_fixed_strin, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[4])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter, __pyx_mstate_global->__pyx_n_u_write_fixed_strings_as_bytes, __pyx_t_2) < (0)) __PYX_ERR(0, 61, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedwriter.pyx":86 * PyMem_Free(items_buf) * * def write_fixed_strings(self, items, Py_ssize_t length, encoding=None): # <<<<<<<<<<<<<< * if encoding is None: * self.write_fixed_strings_as_bytes(items, length) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_14BufferedWriter_15write_fixed_strings, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedWriter_write_fixed_strin_2, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[5])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_mstate_global->__pyx_tuple[3]); if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter, __pyx_mstate_global->__pyx_n_u_write_fixed_strings, __pyx_t_2) < (0)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_14BufferedWriter_17__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedWriter___reduce_cython, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[6])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter, __pyx_mstate_global->__pyx_n_u_reduce_cython, __pyx_t_2) < (0)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":16 * else: * return __pyx_unpickle_BufferedWriter, (type(self), 0x1c41cb3, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedWriter__set_state(self, __pyx_state) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_14BufferedWriter_19__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedWriter___setstate_cython, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[7])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter, __pyx_mstate_global->__pyx_n_u_setstate_cython, __pyx_t_2) < (0)) __PYX_ERR(2, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedwriter.pyx":126 * super(BufferedSocketWriter, self).__init__(bufsize) * * cpdef write_into_stream(self): # <<<<<<<<<<<<<< * self.sock.sendall( * PyBytes_FromStringAndSize(self.buffer, self.position) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_3write_into_stream, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedSocketWriter_write_into, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[8])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter, __pyx_mstate_global->__pyx_n_u_write_into_stream, __pyx_t_2) < (0)) __PYX_ERR(0, 126, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_5__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedSocketWriter___reduce_cy, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[9])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter, __pyx_mstate_global->__pyx_n_u_reduce_cython, __pyx_t_2) < (0)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":16 * else: * return __pyx_unpickle_BufferedSocketWriter, (type(self), 0xca06ecf, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_BufferedSocketWriter__set_state(self, __pyx_state) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_7__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_BufferedSocketWriter___setstate, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[10])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter, __pyx_mstate_global->__pyx_n_u_setstate_cython, __pyx_t_2) < (0)) __PYX_ERR(2, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedwriter.pyx":140 * super(CompressedBufferedWriter, self).__init__(bufsize) * * cpdef write_into_stream(self): # <<<<<<<<<<<<<< * self.compressor.write( * PyBytes_FromStringAndSize(self.buffer, self.position) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_3write_into_stream, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_CompressedBufferedWriter_write_i, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[11])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter, __pyx_mstate_global->__pyx_n_u_write_into_stream, __pyx_t_2) < (0)) __PYX_ERR(0, 140, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedwriter.pyx":146 * self.position = 0 * * def flush(self): # <<<<<<<<<<<<<< * self.write_into_stream() */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_5flush, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_CompressedBufferedWriter_flush, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[12])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter, __pyx_mstate_global->__pyx_n_u_flush, __pyx_t_2) < (0)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * cdef tuple state * cdef object _dict */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_7__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_CompressedBufferedWriter___reduc, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[13])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter, __pyx_mstate_global->__pyx_n_u_reduce_cython, __pyx_t_2) < (0)) __PYX_ERR(2, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":16 * else: * return __pyx_unpickle_CompressedBufferedWriter, (type(self), 0x835ced9, state) * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * __pyx_unpickle_CompressedBufferedWriter__set_state(self, __pyx_state) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_9__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_CompressedBufferedWriter___setst, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[14])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter, __pyx_mstate_global->__pyx_n_u_setstate_cython, __pyx_t_2) < (0)) __PYX_ERR(2, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":4 * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 * def __pyx_unpickle_BufferedWriter(__pyx_type, long __pyx_checksum, tuple __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x1c41cb3, 0x253d0cc, 0x25d1d0c, b'buffer, buffer_size, position') */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_1__pyx_unpickle_BufferedWriter, 0, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_BufferedWriter, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[15])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_BufferedWriter, __pyx_t_2) < (0)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":1 * cdef extern from *: # <<<<<<<<<<<<<< * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_3__pyx_unpickle_BufferedSocketWriter, 0, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_BufferedSocketWri, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[16])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_BufferedSocketWri, __pyx_t_2) < (0)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "(tree fragment)":4 * int __Pyx_CheckUnpickleChecksum(long, long, long, long, const char*) except -1 * int __Pyx_UpdateUnpickledDict(object, object, Py_ssize_t) except -1 * def __pyx_unpickle_CompressedBufferedWriter(__pyx_type, long __pyx_checksum, tuple __pyx_state): # <<<<<<<<<<<<<< * cdef object __pyx_result * __Pyx_CheckUnpickleChecksum(__pyx_checksum, 0x835ced9, 0x96f6a9b, 0x108d208, b'buffer, buffer_size, compressor, position') */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_14bufferedwriter_5__pyx_unpickle_CompressedBufferedWriter, 0, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_CompressedBuffere, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_bufferedwriter, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[17])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_pyx_unpickle_CompressedBuffere, __pyx_t_2) < (0)) __PYX_ERR(2, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/bufferedwriter.pyx":1 * from cpython cimport PyMem_Malloc, PyMem_Free, PyBytes_AsString, \ # <<<<<<<<<<<<<< * PyBytes_Check, PyBytes_FromStringAndSize, PyBytes_AS_STRING, \ * PyBytes_GET_SIZE */ __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_test, __pyx_t_2) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); if (__pyx_m) { if (__pyx_mstate->__pyx_d && stringtab_initialized) { __Pyx_AddTraceback("init clickhouse_driver.bufferedwriter", __pyx_clineno, __pyx_lineno, __pyx_filename); } #if !CYTHON_USE_MODULE_STATE Py_CLEAR(__pyx_m); #else Py_DECREF(__pyx_m); if (pystate_addmodule_run) { PyObject *tp, *value, *tb; PyErr_Fetch(&tp, &value, &tb); PyState_RemoveModule(&__pyx_moduledef); PyErr_Restore(tp, value, tb); } #endif } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init clickhouse_driver.bufferedwriter"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if CYTHON_PEP489_MULTI_PHASE_INIT return (__pyx_m != NULL) ? 0 : -1; #else return __pyx_m; #endif } /* #### Code section: pystring_table ### */ /* #### Code section: cached_builtins ### */ static int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate) { CYTHON_UNUSED_VAR(__pyx_mstate); __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_super); if (!__pyx_builtin_super) __PYX_ERR(0, 22, __pyx_L1_error) /* Cached unbound methods */ __pyx_mstate->__pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type; __pyx_mstate->__pyx_umethod_PyDict_Type_items.method_name = &__pyx_mstate->__pyx_n_u_items; __pyx_mstate->__pyx_umethod_PyDict_Type_pop.type = (PyObject*)&PyDict_Type; __pyx_mstate->__pyx_umethod_PyDict_Type_pop.method_name = &__pyx_mstate->__pyx_n_u_pop; __pyx_mstate->__pyx_umethod_PyDict_Type_values.type = (PyObject*)&PyDict_Type; __pyx_mstate->__pyx_umethod_PyDict_Type_values.method_name = &__pyx_mstate->__pyx_n_u_values; return 0; __pyx_L1_error:; return -1; } /* #### Code section: cached_constants ### */ static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "(tree fragment)":11 * use_setstate = True * else: * use_setstate = ('False',) # <<<<<<<<<<<<<< * if use_setstate: * return __pyx_unpickle_BufferedWriter, (type(self), 0x1c41cb3, None), state */ __pyx_mstate_global->__pyx_tuple[0] = PyTuple_Pack(1, __pyx_mstate_global->__pyx_n_u_False); if (unlikely(!__pyx_mstate_global->__pyx_tuple[0])) __PYX_ERR(2, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[0]); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[0]); __pyx_mstate_global->__pyx_tuple[1] = PyTuple_Pack(1, __pyx_mstate_global->__pyx_kp_u_self_sock_is_not_None); if (unlikely(!__pyx_mstate_global->__pyx_tuple[1])) __PYX_ERR(2, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[1]); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[1]); __pyx_mstate_global->__pyx_tuple[2] = PyTuple_Pack(1, __pyx_mstate_global->__pyx_kp_u_self_compressor_is_not_None); if (unlikely(!__pyx_mstate_global->__pyx_tuple[2])) __PYX_ERR(2, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[2]); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[2]); /* "clickhouse_driver/bufferedwriter.pyx":48 * self.write_into_stream() * * def write_strings(self, items, encoding=None): # <<<<<<<<<<<<<< * cdef int do_encode = encoding is not None * */ __pyx_mstate_global->__pyx_tuple[3] = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_mstate_global->__pyx_tuple[3])) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[3]); __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[3]); #if CYTHON_IMMORTAL_CONSTANTS { PyObject **table = __pyx_mstate->__pyx_tuple; for (Py_ssize_t i=0; i<4; ++i) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL); #else Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT); #endif } } #endif __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } /* #### Code section: init_constants ### */ static int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate) { CYTHON_UNUSED_VAR(__pyx_mstate); { const struct { const unsigned int length: 8; } index[] = {{179},{1},{1},{8},{21},{18},{36},{24},{7},{6},{2},{9},{27},{21},{14},{0},{20},{38},{40},{38},{14},{32},{34},{20},{20},{43},{34},{32},{28},{24},{42},{44},{30},{42},{5},{20},{18},{18},{7},{7},{7},{32},{18},{10},{4},{8},{5},{9},{6},{8},{6},{5},{8},{12},{8},{13},{5},{9},{14},{6},{8},{11},{10},{8},{7},{3},{14},{12},{11},{10},{35},{29},{39},{14},{12},{10},{17},{13},{4},{7},{12},{10},{12},{19},{4},{5},{5},{8},{6},{12},{5},{9},{6},{6},{5},{19},{28},{17},{13},{11},{11},{11},{117},{31},{31},{147},{84},{7},{10},{196},{104},{99},{106},{57},{59},{58}}; #if (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (1477 bytes) */ const char* const cstring = "BZh91AY&SYf-\353\333\000\001+\177\377\377\377\375\377\377\277\377\377\277\255}\356\277\377\377\376@@@@@@@@@@@@@\000@\000P\005Xl\265\354wa\331\255j.\003\004\224J=S\323S\323\324\237\2416\206\240\3112i\246\322d\320\3654\332\206&\203\324=M\003\3242hmM\014\321=L\322d\304\364'\250\031 \022`#*~\251\351\251\350\232oI4\320\000\001\240h\000\000\000\000\000\032\036\240\000\022\"&\204\321&\324\312z4j6\211\262\023@4\320\032\000\000\000\000\000\003@h\332M=\004A\200\000\000\000\000\000\000\000\004\300\000\000\000F\000\002`\000J\232SS\365O\"zOH\3201\r\006\200\000\000\000\000\000\000\000\000\000\000\002\365c\336A\3237\216\247\372\022\231\274\234(\025$\223\256 \354'\330c\251\231W\262u\203U\004\312\260\257M\214`\333m&\230\330\027\031\215\007^\365\013 \271Y\241\261\261\203cM\344\312U4\263]\302Z\312\201aJ VD\310\260\305\235\213\315\032\205nX+\315\254\353FT\301d]%\352\014\320H\206#\034aEa\3235\016\\\004\302\"\270\010L|\3158\364\267\312\032Z>\254{\326\267\341\217\350\340\"\356;j\340u\353\247\032\353\274\374RR\225\004\331\267\t\302\0254\230@\341\020b\230e\020\331\245\226\361\024\214\361\0263\267.,\003_\267>\\\271\360\201.\375\251\254\002\006D2\316\310\361%?mM\204W\202\201\261upz<\230\013\360\020\230BVI\031\325\302(\006=\334\213\204X\320\211g\373\010\216S\261\013\346\016\tJ\324\330\357\017\205\306\3546\372]\266\243\235\341\325\337\354\337B\373G\027O5\352\256\337\207&\356\007\316\302\323xV\325\226\004\314A\\\255\024\365|\013\300Z\020\327E\002!H\23446\327)\251Qh\214A\346\312\316U@\250\210\242+t\323\nt{\235\310;+v\000\210\002 \210\"\027\254t\364c\202[\370\327H\3401\261\343\277\"9\302\244 \377 R\352\177u\3447Zo\365x\363y\270\271k.\255+E\205\323\312\025\235\300d0\334h\206\206\332\256\304m4\2134\25317\005j\323\246\025mF\255&\362\270\306\260\225}9u\021\214b\317pk\213\021\215#J-`O\003\r^,\265/\"%\211N\005\327 7\034\334\371\030\204JJCR\022\314\271\344\270U\243\"\237p\266\311\002\260\t^\302-\305\234\2626uw1)4$.J\214""\355\016\343\247\332\333\215\302\324\334\246\306\332\254\307%\272\311\246f[m\272\204@Y\206\315 \341k\207Z\324\214\366\337\315h\323\210\245\010\342\006\032$\014\361\3037\234M3\336\253`\3178\35420*\227\004i\264\233\026\215\250\344\244\215x\261X\320h\002\033\322\353\254\206Y\212h\214Gbz\302\213\351\010\226~#\312R\205\200\247\0028\353\032j\200\2027\tyh\004\374\210\346t\206\2402\220\021`\031\324\021|\343\260Oz\030\252\202\304\034\364&\352\007\000\2229\271\005\252e\347\022,\242\265\200\014H\003\000\332\264avx\210P\200\232\315*\025\233\320\002\024 U\027\205NT\006uXT\270\204\366\200\242\222\"\350I\266\340\326\315u\274F\230#\341Z\005D\240C\021\255\025E\021i.\240\356+\014\217L\260.UY\tt\3473\030\247\304\205\003\372#\3323\203\010\317\241\251\2114\307\001\203\322\220\331N\265\266\244\231\036\001\000\266\375\247O\231\260Z\315\252\033\363\210)\241\016hx\247(\002p\245(\265\201\201d\021,\345\0105\270`S\215d\rs\2229\3406\204\315\260\331\310\305\344\240\277\213\013\230\027\304a\301\217\264RD\001\215\263?\023E,\006\352O\021\225\354\300\220\023\317 (\020\320*\303u\300ga\322d\025\253,\355\017I\310\246\333D\032v\365\315\025\277\233(0\245\327\315\366I\210\211\231P\322G\034\321Hd\345\240(\203-b\353\352b\030d\215\326\225s\245Z\334\370\313h\324\353`q\005\2409\206\362\020\3214\324{9\2020Bh\212\202\2312\225\220\352\310]\2472\327\274\275J*L\231\206MB\373\320\201 \n\031\243\023\371\261\246ER\226< ;\212\202E\332\274\033%]\227\335\307\276m\3178\247`\263M\255m\306\252\017\220\252\210\326X\311\201P\250\210\247\255\024\363\025aW\343L=\326\326\022o\024zI\210\357\257\205f\014Y\371\303\203\372\214\030c1Zp\363\233\013!1Sd\n\252\266W[UV\311$\255z}\026\326&\271kf\307\347\254YY;\2538\344<\032Th\220\375\341\3367\177t+\233\347t\3408S/NlskT\311\330(I\342<>\301\273\217\032\212\311\255\035\361\353\001O3\215N\314l\221\255L\337$/\346\t\271\301\343-S%\236JB\242A\310r\222\317\024\006\034\027:G\230\245\206p\325\364\014]\016S\375\241\242h\355\310#\336e\035^giL\037C\303\177PK\324\323\026\237\274\221~:T\260],.\325\007""\\\267\266\315\325?#C7\211\212\305c\036\037g\364\343\323\201\312\352)RX\253\010P\257R\231G\014\241E+\236M+[\r\267t\221\313\205Eq\272e;\235\232\252\343[\250b2q\241\202\377\305\334\221N\024$\031\213z\366\300"; PyObject *data = __Pyx_DecompressString(cstring, 1477, 2); if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error) const char* const bytes = __Pyx_PyBytes_AsString(data); #if !CYTHON_ASSUME_SAFE_MACROS if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } #endif #elif (CYTHON_COMPRESS_STRINGS) != 0 /* compression: zlib (1284 bytes) */ const char* const cstring = "x\332\265T\315s\323F\024\307\324\200)\006\342\222I\322\222\266ri\233\241\200\301m\312WZ:\006\002\303\224\311D$C\332i;;kim\213(\222\255]\031\273\320\231\034}\324q\217:\352\250\243\216>r\324QG\375\t\374\t}\273r \3016\231\241S\317x\365\364>\177\357\267\357i\315fDa-\314\224{}\326\262-\305\240\212NL\243N\034\314\210\331W(s\014\215\021G8Y\312\372\352\372\225\345\233\313\n\266t\305!\317\210\306\250B\335\272fbJ\tU\354\206Rw\r\223\031\226\302\372mB+\312\243\206\322\267]\305\"DW\230\255\264\301o\177\000k\021K\241\204\tAY\302\226e3\314\014\333B\020nX\315%E7\034(bt\211\210~\200MJ*\225_\260\256#\360$\365>\023E\353\002\207Bzmx\020]3\rm\273e\273\224 \335\201@\2472\246\271Zw\033\r\342\020\375\271c@k\225v\2777\036\325\305\216a1\335\240\270n\022b\211\263\251\0314\223tJ\314FE\263w\332\016\241\324v\004m\200HY\263-\"M\324\326\266\367+\177\022\310\005\245t\3663\376\235_\363\3254\313\347\275\360\313\361\205\037$\370\221F\222\004\350%\031q\361\013\216\343\374\352P\025\275\335\362\356\001\230\342L<#\356\251\031\252\262\323\377@\311>\234\013\374\030\337\312\220\375\037D\355\346^\027\216\034;3\330\364>\345_s+\270\037\236\212\226\243N\222/\016\036B\232\007\374\262\217\223\374\211\335\356`\313[\345\2630\000\005(\220\024 iZX\000\014`\203\364g\343\263?\206\233Q)Z\032\236\177\3650\336\330L\017\252j\343ur\037P\343j\300\200\274\207\321\312\260\371JM\017j\360x\211\323\321\346\260\364\001enE\263\221\0325\207\177\304\353[\361\326o\351;:X\3274\377%\357\304\3125`ke\270\035\253O\222\3749\357\216\277\020\224\202\262\310\363\322\273\301\313r\221\343\352\335a\005b\222\374\251Aur`|\356RpS\016\305\333\310\333Q9^y\032?\325c\235\2747t\311\357\005\2350\267/\024\276)\361\215\265WV\374\347_2\362_O\331h\352"; PyObject *data = __Pyx_DecompressString(cstring, 1284, 1); if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error) const char* const bytes = __Pyx_PyBytes_AsString(data); #if !CYTHON_ASSUME_SAFE_MACROS if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } #endif #else /* compression: none (2831 bytes) */ const char* const bytes = "Note that Cython is deliberately stricter than PEP-484 and rejects subclasses of builtin types. If you need to pass subclasses then set the 'annotation_typing' directive to False..?add_notebytes object expectedclickhouse_driver.clickhouse_driver/bufferedwriter.pyxclickhouse_driver.varintdisableenablegcisenabledself.compressor is not Noneself.sock is not NoneBufferedSocketWriterBufferedSocketWriter.__reduce_cython__BufferedSocketWriter.__setstate_cython__BufferedSocketWriter.write_into_streamBufferedWriterBufferedWriter.__reduce_cython__BufferedWriter.__setstate_cython__BufferedWriter.flushBufferedWriter.writeBufferedWriter.write_fixed_strings_as_bytesBufferedWriter.write_fixed_stringsBufferedWriter.write_into_streamBufferedWriter.write_stringsCompressedBufferedWriterCompressedBufferedWriter.__reduce_cython__CompressedBufferedWriter.__setstate_cython__CompressedBufferedWriter.flushCompressedBufferedWriter.write_into_streamFalse__Pyx_PyDict_NextRefTooLargeStringSizeasyncio.coroutinesbuf_posbufsizec_valueclickhouse_driver.bufferedwritercline_in_tracebackcompressordata__dict___dictdo_encodeencodeencodingerrorsflush__func____getstate____init___is_coroutineitemsitems_bufitems_buf_sizelength__main__make_varint__module____name____new__pop__pyx_checksum__pyx_result__pyx_state__pyx_type__pyx_unpickle_BufferedSocketWriter__pyx_unpickle_BufferedWriter__pyx_unpickle_CompressedBufferedWriter__pyx_vtable____qualname____reduce____reduce_cython____reduce_ex__selfsendall__set_name__setdefault__setstate____setstate_cython__sockstatesuper__test__updateuse_setstatevaluevalue_lenvaluesvarintwritewrite_fixed_stringswrite_fixed_strings_as_byteswrite_into_streamwrite_strings\200\001\330\0042\260!\2606\270\021\200\001\330\0046\260a\260v\270Q\200\001\330\004,\250A\250V\2601\200A\330\0100\260\001\330\010+\320+;\2701\270A\330\010\034\320\034-\250Q\250a\340\010\016\210h\220b\230\001\330\014\026\220a\220y\240\002\240)\2504\250}\270B\270d\300!\330\014\022\220!\2201\220D\230\007\230q""\240\004\240L\260\001\260\026\260q\270\n\300!\340\014\017\210t\220:\230S\240\004\240A\330\020\024\320\024&\240a\340\014\020\220\r\230Q\330\014\027\220q\200A\330\010\014\210E\220\030\230\021\330\014%\240Q\240d\250)\2604\260q\340\010\014\210L\230\001\200A\330\010\014\210K\220v\230Q\330\014%\240Q\240d\250)\2604\260q\340\010\014\210L\230\001\200A\330\010\"\240!\330\010)\250\027\260\002\260#\260Q\260a\360\006\000\t \230x\240|\2601\260A\330\010\013\2104\210q\330\014\r\340\010\016\210a\210{\230#\230Q\340\010\014\210I\220Q\330\014\030\230\003\2301\230A\330\014\017\210w\220b\230\001\330\020\026\220f\320\034/\250q\340\014\026\320\026&\240a\240q\340\014\022\220!\2201\220I\230Q\230j\250\t\260\021\330\014\027\220q\330\010\t\330\014\020\220\006\220a\320\0270\260\001\260\033\270A\340\014\026\220a\220q\320\004,\250A\330\010\035\230Y\240g\250Q\340\010\014\210I\220Q\330\014\017\210t\220=\240\001\240\021\330\020\023\2201\330\024\034\230E\240\027\250\001\250\021\340\024\032\230*\240A\240Q\340\014\020\220\006\220a\220{\240!\320#3\2601\260A\330\014\020\220\006\220a\220q\200A\330\010\016\210a\200A\330\010\014\320\014\036\230a\320\004E\300Q\330\010\013\2109\220C\220q\330\014\020\320\020-\250Q\250g\260Q\330\014\r\340\010\"\240!\330\010)\250\027\260\002\260#\260Q\260a\360\006\000\t \230x\240|\2601\260A\330\010\013\2104\210q\330\014\r\340\010\016\210a\210{\230#\230Q\340\010\014\210I\220Q\330\014\017\210t\220=\240\001\240\021\330\020\030\230\005\230W\240A\240Q\340\014\030\230\003\2301\230A\330\014\017\210w\220b\230\001\330\020\026\220f\320\034/\250q\340\014\026\320\026&\240a\240q\340\014\022\220!\2201\220I\230Q\230j\250\t\260\021\330\014\027\220q\330\010\t\330\014\020\220\006\220a\320\0270\260\001\260\033\270A\340\014\026\220a\220q\200\001\360\010\000\005\016\210T\220\031\230$\230n\250D\260\013\2704\270q\330\004\014\210G\2201\220F\230,\240a\330\004\007\200v\210W\220E\230\024\230Q\330\010\022\220!\330\010\027\220q\340\010\030\230\001\330\004\007\200q\330\010\017\320\0175\260T\270\021\270'\300""\033\310G\320ST\340\010\017\320\0175\260T\270\021\270'\300\033\310A\200\001\360\010\000\005\016\210T\220\031\230$\230n\250D\260\001\330\004\014\210G\2201\220F\230,\240a\330\004\007\200v\210W\220E\230\024\230Q\330\010\022\220!\330\010\027\220q\340\010\030\230\001\330\004\007\200q\330\010\017\320\017/\250t\2601\260G\270;\300g\310Q\340\010\017\320\017/\250t\2601\260G\270;\300a\200\001\360\010\000\005\016\210T\220\031\230$\230n\250D\260\r\270T\300\021\330\004\014\210G\2201\220F\230,\240a\330\004\007\200v\210W\220E\230\024\230Q\330\010\022\220!\330\010\027\220q\340\010\030\230\001\330\004\007\200q\330\010\017\320\0179\270\024\270Q\270g\300[\320PW\320WX\340\010\017\320\0179\270\024\270Q\270g\300[\320PQ\200\001\340\004\037\230q\320 0\260\013\270;\300k\320QR\330\004\023\220>\240\030\250\021\250!\330\004\007\200|\2207\230!\330\0100\260\001\3201B\300.\320PQ\330\004\013\2101\200\001\340\004\037\230q\320 0\260\013\270;\300k\320QR\330\004\023\320\023+\2508\2601\260A\330\004\007\200|\2207\230!\330\010:\270!\320;V\320Vd\320de\330\004\013\2101\200\001\340\004\037\230q\320 0\260\013\270;\300k\320QR\330\004\023\320\023'\240x\250q\260\001\330\004\007\200|\2207\230!\330\0106\260a\3207N\310n\320\\]\330\004\013\2101"; PyObject *data = NULL; CYTHON_UNUSED_VAR(__Pyx_DecompressString); #endif PyObject **stringtab = __pyx_mstate->__pyx_string_tab; Py_ssize_t pos = 0; for (int i = 0; i < 99; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyUnicode_DecodeUTF8(bytes + pos, bytes_length, NULL); if (likely(string) && i >= 15) PyUnicode_InternInPlace(&string); if (unlikely(!string)) { Py_XDECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } stringtab[i] = string; pos += bytes_length; } for (int i = 99; i < 116; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyBytes_FromStringAndSize(bytes + pos, bytes_length); stringtab[i] = string; pos += bytes_length; if (unlikely(!string)) { Py_XDECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } } Py_XDECREF(data); for (Py_ssize_t i = 0; i < 116; i++) { if (unlikely(PyObject_Hash(stringtab[i]) == -1)) { __PYX_ERR(0, 1, __pyx_L1_error) } } #if CYTHON_IMMORTAL_CONSTANTS { PyObject **table = stringtab + 99; for (Py_ssize_t i=0; i<17; ++i) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL); #else Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT); #endif } } #endif } { PyObject **numbertab = __pyx_mstate->__pyx_number_tab + 0; int32_t const cint_constants_4[] = {29629619L,137744089L,211840719L}; for (int i = 0; i < 3; i++) { numbertab[i] = PyLong_FromLong(cint_constants_4[i - 0]); if (unlikely(!numbertab[i])) __PYX_ERR(0, 1, __pyx_L1_error) } } #if CYTHON_IMMORTAL_CONSTANTS { PyObject **table = __pyx_mstate->__pyx_number_tab; for (Py_ssize_t i=0; i<3; ++i) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL); #else Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT); #endif } } #endif return 0; __pyx_L1_error:; return -1; } /* #### Code section: init_codeobjects ### */ typedef struct { unsigned int argcount : 3; unsigned int num_posonly_args : 1; unsigned int num_kwonly_args : 1; unsigned int nlocals : 4; unsigned int flags : 10; unsigned int first_line : 8; } __Pyx_PyCode_New_function_description; /* NewCodeObj.proto */ static PyObject* __Pyx_PyCode_New( const __Pyx_PyCode_New_function_description descr, PyObject * const *varnames, PyObject *filename, PyObject *funcname, PyObject *line_table, PyObject *tuple_dedup_map ); static int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate) { PyObject* tuple_dedup_map = PyDict_New(); if (unlikely(!tuple_dedup_map)) return -1; { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 27}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; __pyx_mstate_global->__pyx_codeobj_tab[0] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedwriter_2, __pyx_mstate->__pyx_n_u_write_into_stream, __pyx_mstate->__pyx_kp_b_iso88591_A_a, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[0])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 30}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_data}; __pyx_mstate_global->__pyx_codeobj_tab[1] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedwriter_2, __pyx_mstate->__pyx_n_u_write, __pyx_mstate->__pyx_kp_b_iso88591_A_0_1A_Qa_hb_ay_4_Bd_1D_q_L_q_t, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[1])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 45}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; __pyx_mstate_global->__pyx_codeobj_tab[2] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedwriter_2, __pyx_mstate->__pyx_n_u_flush, __pyx_mstate->__pyx_kp_b_iso88591_A_a_2, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[2])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 5, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 48}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_items, __pyx_mstate->__pyx_n_u_encoding, __pyx_mstate->__pyx_n_u_do_encode, __pyx_mstate->__pyx_n_u_value}; __pyx_mstate_global->__pyx_codeobj_tab[3] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedwriter_2, __pyx_mstate->__pyx_n_u_write_strings, __pyx_mstate->__pyx_kp_b_iso88591_A_YgQ_IQ_t_1_E_AQ_a_31A_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[3])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 9, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 61}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_items, __pyx_mstate->__pyx_n_u_length, __pyx_mstate->__pyx_n_u_buf_pos, __pyx_mstate->__pyx_n_u_items_buf_size, __pyx_mstate->__pyx_n_u_c_value, __pyx_mstate->__pyx_n_u_items_buf, __pyx_mstate->__pyx_n_u_value, __pyx_mstate->__pyx_n_u_value_len}; __pyx_mstate_global->__pyx_codeobj_tab[4] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedwriter_2, __pyx_mstate->__pyx_n_u_write_fixed_strings_as_bytes, __pyx_mstate->__pyx_kp_b_iso88591_A_Qa_x_1A_4q_a_Q_IQ_1A_wb_f_q_aq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[4])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {4, 0, 0, 10, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 86}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_items, __pyx_mstate->__pyx_n_u_length, __pyx_mstate->__pyx_n_u_encoding, __pyx_mstate->__pyx_n_u_buf_pos, __pyx_mstate->__pyx_n_u_items_buf_size, __pyx_mstate->__pyx_n_u_c_value, __pyx_mstate->__pyx_n_u_items_buf, __pyx_mstate->__pyx_n_u_value, __pyx_mstate->__pyx_n_u_value_len}; __pyx_mstate_global->__pyx_codeobj_tab[5] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedwriter_2, __pyx_mstate->__pyx_n_u_write_fixed_strings, __pyx_mstate->__pyx_kp_b_iso88591_EQ_9Cq_QgQ_Qa_x_1A_4q_a_Q_IQ_t, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[5])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 1}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_state, __pyx_mstate->__pyx_n_u_dict_2, __pyx_mstate->__pyx_n_u_use_setstate}; __pyx_mstate_global->__pyx_codeobj_tab[6] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_reduce_cython, __pyx_mstate->__pyx_kp_b_iso88591_T_nD_G1F_a_vWE_Q_q_q_t1G_gQ_t1G, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[6])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 16}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_pyx_state}; __pyx_mstate_global->__pyx_codeobj_tab[7] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_setstate_cython, __pyx_mstate->__pyx_kp_b_iso88591_AV1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[7])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 126}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; __pyx_mstate_global->__pyx_codeobj_tab[8] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedwriter_2, __pyx_mstate->__pyx_n_u_write_into_stream, __pyx_mstate->__pyx_kp_b_iso88591_A_E_Qd_4q_L, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[8])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 1}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_state, __pyx_mstate->__pyx_n_u_dict_2, __pyx_mstate->__pyx_n_u_use_setstate}; __pyx_mstate_global->__pyx_codeobj_tab[9] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_reduce_cython, __pyx_mstate->__pyx_kp_b_iso88591_T_nD_4q_G1F_a_vWE_Q_q_q_5T_GST, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[9])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 16}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_pyx_state}; __pyx_mstate_global->__pyx_codeobj_tab[10] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_setstate_cython, __pyx_mstate->__pyx_kp_b_iso88591_2_6, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[10])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 140}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; __pyx_mstate_global->__pyx_codeobj_tab[11] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedwriter_2, __pyx_mstate->__pyx_n_u_write_into_stream, __pyx_mstate->__pyx_kp_b_iso88591_A_KvQ_Qd_4q_L, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[11])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 146}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self}; __pyx_mstate_global->__pyx_codeobj_tab[12] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_bufferedwriter_2, __pyx_mstate->__pyx_n_u_flush, __pyx_mstate->__pyx_kp_b_iso88591_A_a_2, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[12])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 1}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_state, __pyx_mstate->__pyx_n_u_dict_2, __pyx_mstate->__pyx_n_u_use_setstate}; __pyx_mstate_global->__pyx_codeobj_tab[13] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_reduce_cython, __pyx_mstate->__pyx_kp_b_iso88591_T_nD_T_G1F_a_vWE_Q_q_q_9_Qg_PWW, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[13])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 16}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_pyx_state}; __pyx_mstate_global->__pyx_codeobj_tab[14] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_setstate_cython, __pyx_mstate->__pyx_kp_b_iso88591_6avQ, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[14])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 4}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_pyx_type, __pyx_mstate->__pyx_n_u_pyx_checksum, __pyx_mstate->__pyx_n_u_pyx_state, __pyx_mstate->__pyx_n_u_pyx_result}; __pyx_mstate_global->__pyx_codeobj_tab[15] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_pyx_unpickle_BufferedWriter, __pyx_mstate->__pyx_kp_b_iso88591_q_0_kQR_7_0_1B_PQ_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[15])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 4}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_pyx_type, __pyx_mstate->__pyx_n_u_pyx_checksum, __pyx_mstate->__pyx_n_u_pyx_state, __pyx_mstate->__pyx_n_u_pyx_result}; __pyx_mstate_global->__pyx_codeobj_tab[16] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_pyx_unpickle_BufferedSocketWri, __pyx_mstate->__pyx_kp_b_iso88591_q_0_kQR_xq_7_6a7Nn_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[16])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 4}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_pyx_type, __pyx_mstate->__pyx_n_u_pyx_checksum, __pyx_mstate->__pyx_n_u_pyx_state, __pyx_mstate->__pyx_n_u_pyx_result}; __pyx_mstate_global->__pyx_codeobj_tab[17] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_stringsource, __pyx_mstate->__pyx_n_u_pyx_unpickle_CompressedBuffere, __pyx_mstate->__pyx_kp_b_iso88591_q_0_kQR_81A_7_VVdde_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[17])) goto bad; } Py_DECREF(tuple_dedup_map); return 0; bad: Py_DECREF(tuple_dedup_map); return -1; } /* #### Code section: init_globals ### */ static int __Pyx_InitGlobals(void) { /* PythonCompatibility.init */ if (likely(__Pyx_init_co_variables() == 0)); else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) /* CommonTypesMetaclass.init */ if (likely(__pyx_CommonTypesMetaclass_init(__pyx_m) == 0)); else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) /* CachedMethodType.init */ #if CYTHON_COMPILING_IN_LIMITED_API { PyObject *typesModule=NULL; typesModule = PyImport_ImportModule("types"); if (typesModule) { __pyx_mstate_global->__Pyx_CachedMethodType = PyObject_GetAttrString(typesModule, "MethodType"); Py_DECREF(typesModule); } } // error handling follows #endif if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) /* CythonFunctionShared.init */ if (likely(__pyx_CyFunction_init(__pyx_m) == 0)); else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } /* #### Code section: cleanup_globals ### */ /* #### Code section: cleanup_module ### */ /* #### Code section: main_method ### */ /* #### Code section: utility_code_pragmas ### */ #ifdef _MSC_VER #pragma warning( push ) /* Warning 4127: conditional expression is constant * Cython uses constant conditional expressions to allow in inline functions to be optimized at * compile-time, so this warning is not useful */ #pragma warning( disable : 4127 ) #endif /* #### Code section: utility_code_def ### */ /* --- Runtime support code --- */ /* Refnanny */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule(modname); if (!m) goto end; p = PyObject_GetAttrString(m, "RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif /* PyErrExceptionMatches */ #if CYTHON_FAST_THREAD_STATE static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(tuple); for (i=0; i= 0x030C00A6 PyObject *current_exception = tstate->current_exception; if (unlikely(!current_exception)) return 0; exc_type = (PyObject*) Py_TYPE(current_exception); if (exc_type == err) return 1; #else exc_type = tstate->curexc_type; if (exc_type == err) return 1; if (unlikely(!exc_type)) return 0; #endif #if CYTHON_AVOID_BORROWED_REFS Py_INCREF(exc_type); #endif if (unlikely(PyTuple_Check(err))) { result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); } else { result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err); } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(exc_type); #endif return result; } #endif /* PyErrFetchRestore */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyObject *tmp_value; assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value))); if (value) { #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb)) #endif PyException_SetTraceback(value, tb); } tmp_value = tstate->current_exception; tstate->current_exception = value; Py_XDECREF(tmp_value); Py_XDECREF(type); Py_XDECREF(tb); #else PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #endif } static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyObject* exc_value; exc_value = tstate->current_exception; tstate->current_exception = 0; *value = exc_value; *type = NULL; *tb = NULL; if (exc_value) { *type = (PyObject*) Py_TYPE(exc_value); Py_INCREF(*type); #if CYTHON_COMPILING_IN_CPYTHON *tb = ((PyBaseExceptionObject*) exc_value)->traceback; Py_XINCREF(*tb); #else *tb = PyException_GetTraceback(exc_value); #endif } #else *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #endif } #endif /* PyObjectGetAttrStr */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); return PyObject_GetAttr(obj, attr_name); } #endif /* PyObjectGetAttrStrNoError */ #if __PYX_LIMITED_VERSION_HEX < 0x030d0000 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) __Pyx_PyErr_Clear(); } #endif static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { PyObject *result; #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 (void) PyObject_GetOptionalAttr(obj, attr_name, &result); return result; #else #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); } #endif result = __Pyx_PyObject_GetAttrStr(obj, attr_name); if (unlikely(!result)) { __Pyx_PyObject_GetAttrStr_ClearAttributeError(); } return result; #endif } /* GetBuiltinName */ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStrNoError(__pyx_mstate_global->__pyx_b, name); if (unlikely(!result) && !PyErr_Occurred()) { PyErr_Format(PyExc_NameError, "name '%U' is not defined", name); } return result; } /* TupleAndListFromArray */ #if !CYTHON_COMPILING_IN_CPYTHON && CYTHON_METH_FASTCALL static CYTHON_INLINE PyObject * __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n) { PyObject *res; Py_ssize_t i; if (n <= 0) { return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple); } res = PyTuple_New(n); if (unlikely(res == NULL)) return NULL; for (i = 0; i < n; i++) { if (unlikely(__Pyx_PyTuple_SET_ITEM(res, i, src[i]) < (0))) { Py_DECREF(res); return NULL; } Py_INCREF(src[i]); } return res; } #elif CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE void __Pyx_copy_object_array(PyObject *const *CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) { PyObject *v; Py_ssize_t i; for (i = 0; i < length; i++) { v = dest[i] = src[i]; Py_INCREF(v); } } static CYTHON_INLINE PyObject * __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n) { PyObject *res; if (n <= 0) { return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple); } res = PyTuple_New(n); if (unlikely(res == NULL)) return NULL; __Pyx_copy_object_array(src, ((PyTupleObject*)res)->ob_item, n); return res; } static CYTHON_INLINE PyObject * __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n) { PyObject *res; if (n <= 0) { return PyList_New(0); } res = PyList_New(n); if (unlikely(res == NULL)) return NULL; __Pyx_copy_object_array(src, ((PyListObject*)res)->ob_item, n); return res; } #endif /* BytesEquals */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL ||\ !(CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS) return PyObject_RichCompareBool(s1, s2, equals); #else if (s1 == s2) { return (equals == Py_EQ); } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { const char *ps1, *ps2; Py_ssize_t length = PyBytes_GET_SIZE(s1); if (length != PyBytes_GET_SIZE(s2)) return (equals == Py_NE); ps1 = PyBytes_AS_STRING(s1); ps2 = PyBytes_AS_STRING(s2); if (ps1[0] != ps2[0]) { return (equals == Py_NE); } else if (length == 1) { return (equals == Py_EQ); } else { int result; #if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000) Py_hash_t hash1, hash2; hash1 = ((PyBytesObject*)s1)->ob_shash; hash2 = ((PyBytesObject*)s2)->ob_shash; if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { return (equals == Py_NE); } #endif result = memcmp(ps1, ps2, (size_t)length); return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { return (equals == Py_NE); } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { return (equals == Py_NE); } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } #endif } /* UnicodeEquals */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL return PyObject_RichCompareBool(s1, s2, equals); #else int s1_is_unicode, s2_is_unicode; if (s1 == s2) { goto return_eq; } s1_is_unicode = PyUnicode_CheckExact(s1); s2_is_unicode = PyUnicode_CheckExact(s2); if (s1_is_unicode & s2_is_unicode) { Py_ssize_t length, length2; int kind; void *data1, *data2; #if !CYTHON_COMPILING_IN_LIMITED_API if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0)) return -1; #endif length = __Pyx_PyUnicode_GET_LENGTH(s1); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(length < 0)) return -1; #endif length2 = __Pyx_PyUnicode_GET_LENGTH(s2); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(length2 < 0)) return -1; #endif if (length != length2) { goto return_ne; } #if CYTHON_USE_UNICODE_INTERNALS { Py_hash_t hash1, hash2; hash1 = ((PyASCIIObject*)s1)->hash; hash2 = ((PyASCIIObject*)s2)->hash; if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { goto return_ne; } } #endif kind = __Pyx_PyUnicode_KIND(s1); if (kind != __Pyx_PyUnicode_KIND(s2)) { goto return_ne; } data1 = __Pyx_PyUnicode_DATA(s1); data2 = __Pyx_PyUnicode_DATA(s2); if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) { goto return_ne; } else if (length == 1) { goto return_eq; } else { int result = memcmp(data1, data2, (size_t)(length * kind)); return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & s2_is_unicode) { goto return_ne; } else if ((s2 == Py_None) & s1_is_unicode) { goto return_ne; } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } return_eq: return (equals == Py_EQ); return_ne: return (equals == Py_NE); #endif } /* fastcall */ #if CYTHON_METH_FASTCALL static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s) { Py_ssize_t i, n = __Pyx_PyTuple_GET_SIZE(kwnames); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(n == -1)) return NULL; #endif for (i = 0; i < n; i++) { PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely(!namei)) return NULL; #endif if (s == namei) return kwvalues[i]; } for (i = 0; i < n; i++) { PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely(!namei)) return NULL; #endif int eq = __Pyx_PyUnicode_Equals(s, namei, Py_EQ); if (unlikely(eq != 0)) { if (unlikely(eq < 0)) return NULL; return kwvalues[i]; } } return NULL; } #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues) { Py_ssize_t i, nkwargs; PyObject *dict; #if !CYTHON_ASSUME_SAFE_SIZE nkwargs = PyTuple_Size(kwnames); if (unlikely(nkwargs < 0)) return NULL; #else nkwargs = PyTuple_GET_SIZE(kwnames); #endif dict = PyDict_New(); if (unlikely(!dict)) return NULL; for (i=0; itp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) return NULL; result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectCallMethO */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { PyObject *self, *result; PyCFunction cfunc; cfunc = __Pyx_CyOrPyCFunction_GET_FUNCTION(func); self = __Pyx_CyOrPyCFunction_GET_SELF(func); if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) return NULL; result = cfunc(self, arg); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectFastCall */ #if PY_VERSION_HEX < 0x03090000 || CYTHON_COMPILING_IN_LIMITED_API static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs) { PyObject *argstuple; PyObject *result = 0; size_t i; argstuple = PyTuple_New((Py_ssize_t)nargs); if (unlikely(!argstuple)) return NULL; for (i = 0; i < nargs; i++) { Py_INCREF(args[i]); if (__Pyx_PyTuple_SET_ITEM(argstuple, (Py_ssize_t)i, args[i]) != (0)) goto bad; } result = __Pyx_PyObject_Call(func, argstuple, kwargs); bad: Py_DECREF(argstuple); return result; } #endif #if CYTHON_VECTORCALL && !CYTHON_COMPILING_IN_LIMITED_API #if PY_VERSION_HEX < 0x03090000 #define __Pyx_PyVectorcall_Function(callable) _PyVectorcall_Function(callable) #elif CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE vectorcallfunc __Pyx_PyVectorcall_Function(PyObject *callable) { PyTypeObject *tp = Py_TYPE(callable); #if defined(__Pyx_CyFunction_USED) if (__Pyx_CyFunction_CheckExact(callable)) { return __Pyx_CyFunction_func_vectorcall(callable); } #endif if (!PyType_HasFeature(tp, Py_TPFLAGS_HAVE_VECTORCALL)) { return NULL; } assert(PyCallable_Check(callable)); Py_ssize_t offset = tp->tp_vectorcall_offset; assert(offset > 0); vectorcallfunc ptr; memcpy(&ptr, (char *) callable + offset, sizeof(ptr)); return ptr; } #else #define __Pyx_PyVectorcall_Function(callable) PyVectorcall_Function(callable) #endif #endif static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject *const *args, size_t _nargs, PyObject *kwargs) { Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs); #if CYTHON_COMPILING_IN_CPYTHON if (nargs == 0 && kwargs == NULL) { if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_NOARGS)) return __Pyx_PyObject_CallMethO(func, NULL); } else if (nargs == 1 && kwargs == NULL) { if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_O)) return __Pyx_PyObject_CallMethO(func, args[0]); } #endif if (kwargs == NULL) { #if CYTHON_VECTORCALL #if CYTHON_COMPILING_IN_LIMITED_API return PyObject_Vectorcall(func, args, _nargs, NULL); #else vectorcallfunc f = __Pyx_PyVectorcall_Function(func); if (f) { return f(func, args, _nargs, NULL); } #endif #endif } if (nargs == 0) { return __Pyx_PyObject_Call(func, __pyx_mstate_global->__pyx_empty_tuple, kwargs); } #if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API return PyObject_VectorcallDict(func, args, (size_t)nargs, kwargs); #else return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs); #endif } /* PyObjectCallOneArg */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *args[2] = {NULL, arg}; return __Pyx_PyObject_FastCall(func, args+1, 1 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } /* UnpackUnboundCMethod */ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000 static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *args, PyObject *kwargs) { PyObject *result; PyObject *selfless_args = PyTuple_GetSlice(args, 1, PyTuple_Size(args)); if (unlikely(!selfless_args)) return NULL; result = PyObject_Call(method, selfless_args, kwargs); Py_DECREF(selfless_args); return result; } #elif CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03090000 static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { return _PyObject_Vectorcall (method, args ? args+1 : NULL, nargs ? nargs-1 : 0, kwnames); } #else static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { return #if PY_VERSION_HEX < 0x03090000 _PyObject_Vectorcall #else PyObject_Vectorcall #endif (method, args ? args+1 : NULL, nargs ? (size_t) nargs-1 : 0, kwnames); } #endif static PyMethodDef __Pyx_UnboundCMethod_Def = { "CythonUnboundCMethod", __PYX_REINTERPRET_FUNCION(PyCFunction, __Pyx_SelflessCall), #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000 METH_VARARGS | METH_KEYWORDS, #else METH_FASTCALL | METH_KEYWORDS, #endif NULL }; static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) { PyObject *method, *result=NULL; method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name); if (unlikely(!method)) return -1; result = method; #if CYTHON_COMPILING_IN_CPYTHON if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type))) { PyMethodDescrObject *descr = (PyMethodDescrObject*) method; target->func = descr->d_method->ml_meth; target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS); } else #endif #if CYTHON_COMPILING_IN_PYPY #else if (PyCFunction_Check(method)) #endif { PyObject *self; int self_found; #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY self = PyObject_GetAttrString(method, "__self__"); if (!self) { PyErr_Clear(); } #else self = PyCFunction_GET_SELF(method); #endif self_found = (self && self != Py_None); #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY Py_XDECREF(self); #endif if (self_found) { PyObject *unbound_method = PyCFunction_New(&__Pyx_UnboundCMethod_Def, method); if (unlikely(!unbound_method)) return -1; Py_DECREF(method); result = unbound_method; } } #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING if (unlikely(target->method)) { Py_DECREF(result); } else #endif target->method = result; return 0; } /* CallUnboundCMethod0 */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) { int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc); if (likely(was_initialized == 2 && cfunc->func)) { if (likely(cfunc->flag == METH_NOARGS)) return __Pyx_CallCFunction(cfunc, self, NULL); if (likely(cfunc->flag == METH_FASTCALL)) return __Pyx_CallCFunctionFast(cfunc, self, NULL, 0); if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS)) return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, NULL, 0, NULL); if (likely(cfunc->flag == (METH_VARARGS | METH_KEYWORDS))) return __Pyx_CallCFunctionWithKeywords(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple, NULL); if (cfunc->flag == METH_VARARGS) return __Pyx_CallCFunction(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple); return __Pyx__CallUnboundCMethod0(cfunc, self); } #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING else if (unlikely(was_initialized == 1)) { __Pyx_CachedCFunction tmp_cfunc = { #ifndef __cplusplus 0 #endif }; tmp_cfunc.type = cfunc->type; tmp_cfunc.method_name = cfunc->method_name; return __Pyx__CallUnboundCMethod0(&tmp_cfunc, self); } #endif PyObject *result = __Pyx__CallUnboundCMethod0(cfunc, self); __Pyx_CachedCFunction_SetFinishedInitializing(cfunc); return result; } #endif static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) { PyObject *result; if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; result = __Pyx_PyObject_CallOneArg(cfunc->method, self); return result; } /* py_dict_items */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) { return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_items, d); } /* py_dict_values */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d) { return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_values, d); } /* OwnedDictNext */ #if CYTHON_AVOID_BORROWED_REFS static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue) { PyObject *next = NULL; if (!*ppos) { if (pvalue) { PyObject *dictview = pkey ? __Pyx_PyDict_Items(p) : __Pyx_PyDict_Values(p); if (unlikely(!dictview)) goto bad; *ppos = PyObject_GetIter(dictview); Py_DECREF(dictview); } else { *ppos = PyObject_GetIter(p); } if (unlikely(!*ppos)) goto bad; } next = PyIter_Next(*ppos); if (!next) { if (PyErr_Occurred()) goto bad; return 0; } if (pkey && pvalue) { *pkey = __Pyx_PySequence_ITEM(next, 0); if (unlikely(*pkey)) goto bad; *pvalue = __Pyx_PySequence_ITEM(next, 1); if (unlikely(*pvalue)) goto bad; Py_DECREF(next); } else if (pkey) { *pkey = next; } else { assert(pvalue); *pvalue = next; } return 1; bad: Py_XDECREF(next); #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000 PyErr_FormatUnraisable("Exception ignored in __Pyx_PyDict_NextRef"); #else PyErr_WriteUnraisable(__pyx_mstate_global->__pyx_n_u_Pyx_PyDict_NextRef); #endif if (pkey) *pkey = NULL; if (pvalue) *pvalue = NULL; return 0; } #else // !CYTHON_AVOID_BORROWED_REFS static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue) { int result = PyDict_Next(p, ppos, pkey, pvalue); if (likely(result == 1)) { if (pkey) Py_INCREF(*pkey); if (pvalue) Py_INCREF(*pvalue); } return result; } #endif /* RaiseDoubleKeywords */ static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { PyErr_Format(PyExc_TypeError, "%s() got multiple values for keyword argument '%U'", func_name, kw_name); } /* CallUnboundCMethod2 */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) { int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc); if (likely(was_initialized == 2 && cfunc->func)) { PyObject *args[2] = {arg1, arg2}; if (cfunc->flag == METH_FASTCALL) { return __Pyx_CallCFunctionFast(cfunc, self, args, 2); } if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS)) return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, 2, NULL); } #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING else if (unlikely(was_initialized == 1)) { __Pyx_CachedCFunction tmp_cfunc = { #ifndef __cplusplus 0 #endif }; tmp_cfunc.type = cfunc->type; tmp_cfunc.method_name = cfunc->method_name; return __Pyx__CallUnboundCMethod2(&tmp_cfunc, self, arg1, arg2); } #endif PyObject *result = __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2); __Pyx_CachedCFunction_SetFinishedInitializing(cfunc); return result; } #endif static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){ if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; #if CYTHON_COMPILING_IN_CPYTHON if (cfunc->func && (cfunc->flag & METH_VARARGS)) { PyObject *result = NULL; PyObject *args = PyTuple_New(2); if (unlikely(!args)) return NULL; Py_INCREF(arg1); PyTuple_SET_ITEM(args, 0, arg1); Py_INCREF(arg2); PyTuple_SET_ITEM(args, 1, arg2); if (cfunc->flag & METH_KEYWORDS) result = __Pyx_CallCFunctionWithKeywords(cfunc, self, args, NULL); else result = __Pyx_CallCFunction(cfunc, self, args); Py_DECREF(args); return result; } #endif { PyObject *args[4] = {NULL, self, arg1, arg2}; return __Pyx_PyObject_FastCall(cfunc->method, args+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } } /* ParseKeywordsImpl */ static int __Pyx_ValidateDuplicatePosArgs( PyObject *kwds, PyObject ** const argnames[], PyObject ** const *first_kw_arg, const char* function_name) { PyObject ** const *name = argnames; while (name != first_kw_arg) { PyObject *key = **name; int found = PyDict_Contains(kwds, key); if (unlikely(found)) { if (found == 1) __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; } name++; } return 0; bad: return -1; } #if CYTHON_USE_UNICODE_INTERNALS static CYTHON_INLINE int __Pyx_UnicodeKeywordsEqual(PyObject *s1, PyObject *s2) { int kind; Py_ssize_t len = PyUnicode_GET_LENGTH(s1); if (len != PyUnicode_GET_LENGTH(s2)) return 0; kind = PyUnicode_KIND(s1); if (kind != PyUnicode_KIND(s2)) return 0; const void *data1 = PyUnicode_DATA(s1); const void *data2 = PyUnicode_DATA(s2); return (memcmp(data1, data2, (size_t) len * (size_t) kind) == 0); } #endif static int __Pyx_MatchKeywordArg_str( PyObject *key, PyObject ** const argnames[], PyObject ** const *first_kw_arg, size_t *index_found, const char *function_name) { PyObject ** const *name; #if CYTHON_USE_UNICODE_INTERNALS Py_hash_t key_hash = ((PyASCIIObject*)key)->hash; if (unlikely(key_hash == -1)) { key_hash = PyObject_Hash(key); if (unlikely(key_hash == -1)) goto bad; } #endif name = first_kw_arg; while (*name) { PyObject *name_str = **name; #if CYTHON_USE_UNICODE_INTERNALS if (key_hash == ((PyASCIIObject*)name_str)->hash && __Pyx_UnicodeKeywordsEqual(name_str, key)) { *index_found = (size_t) (name - argnames); return 1; } #else #if CYTHON_ASSUME_SAFE_SIZE if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key)) #endif { int cmp = PyUnicode_Compare(name_str, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { *index_found = (size_t) (name - argnames); return 1; } } #endif name++; } name = argnames; while (name != first_kw_arg) { PyObject *name_str = **name; #if CYTHON_USE_UNICODE_INTERNALS if (unlikely(key_hash == ((PyASCIIObject*)name_str)->hash)) { if (__Pyx_UnicodeKeywordsEqual(name_str, key)) goto arg_passed_twice; } #else #if CYTHON_ASSUME_SAFE_SIZE if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key)) #endif { if (unlikely(name_str == key)) goto arg_passed_twice; int cmp = PyUnicode_Compare(name_str, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) goto arg_passed_twice; } #endif name++; } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; bad: return -1; } static int __Pyx_MatchKeywordArg_nostr( PyObject *key, PyObject ** const argnames[], PyObject ** const *first_kw_arg, size_t *index_found, const char *function_name) { PyObject ** const *name; if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type; name = first_kw_arg; while (*name) { int cmp = PyObject_RichCompareBool(**name, key, Py_EQ); if (cmp == 1) { *index_found = (size_t) (name - argnames); return 1; } if (unlikely(cmp == -1)) goto bad; name++; } name = argnames; while (name != first_kw_arg) { int cmp = PyObject_RichCompareBool(**name, key, Py_EQ); if (unlikely(cmp != 0)) { if (cmp == 1) goto arg_passed_twice; else goto bad; } name++; } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); goto bad; bad: return -1; } static CYTHON_INLINE int __Pyx_MatchKeywordArg( PyObject *key, PyObject ** const argnames[], PyObject ** const *first_kw_arg, size_t *index_found, const char *function_name) { return likely(PyUnicode_CheckExact(key)) ? __Pyx_MatchKeywordArg_str(key, argnames, first_kw_arg, index_found, function_name) : __Pyx_MatchKeywordArg_nostr(key, argnames, first_kw_arg, index_found, function_name); } static void __Pyx_RejectUnknownKeyword( PyObject *kwds, PyObject ** const argnames[], PyObject ** const *first_kw_arg, const char *function_name) { #if CYTHON_AVOID_BORROWED_REFS PyObject *pos = NULL; #else Py_ssize_t pos = 0; #endif PyObject *key = NULL; __Pyx_BEGIN_CRITICAL_SECTION(kwds); while ( #if CYTHON_AVOID_BORROWED_REFS __Pyx_PyDict_NextRef(kwds, &pos, &key, NULL) #else PyDict_Next(kwds, &pos, &key, NULL) #endif ) { PyObject** const *name = first_kw_arg; while (*name && (**name != key)) name++; if (!*name) { size_t index_found = 0; int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name); if (cmp != 1) { if (cmp == 0) { PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%U'", function_name, key); } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(key); #endif break; } } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(key); #endif } __Pyx_END_CRITICAL_SECTION(); #if CYTHON_AVOID_BORROWED_REFS Py_XDECREF(pos); #endif assert(PyErr_Occurred()); } static int __Pyx_ParseKeywordDict( PyObject *kwds, PyObject ** const argnames[], PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs) { PyObject** const *name; PyObject** const *first_kw_arg = argnames + num_pos_args; Py_ssize_t extracted = 0; #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments) if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1; #endif name = first_kw_arg; while (*name && num_kwargs > extracted) { PyObject * key = **name; PyObject *value; int found = 0; #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 found = PyDict_GetItemRef(kwds, key, &value); #else value = PyDict_GetItemWithError(kwds, key); if (value) { Py_INCREF(value); found = 1; } else { if (unlikely(PyErr_Occurred())) goto bad; } #endif if (found) { if (unlikely(found < 0)) goto bad; values[name-argnames] = value; extracted++; } name++; } if (num_kwargs > extracted) { if (ignore_unknown_kwargs) { if (unlikely(__Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name) == -1)) goto bad; } else { __Pyx_RejectUnknownKeyword(kwds, argnames, first_kw_arg, function_name); goto bad; } } return 0; bad: return -1; } static int __Pyx_ParseKeywordDictToDict( PyObject *kwds, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject** const *name; PyObject** const *first_kw_arg = argnames + num_pos_args; Py_ssize_t len; #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments) if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1; #endif if (PyDict_Update(kwds2, kwds) < 0) goto bad; name = first_kw_arg; while (*name) { PyObject *key = **name; PyObject *value; #if !CYTHON_COMPILING_IN_LIMITED_API && (PY_VERSION_HEX >= 0x030d00A2 || defined(PyDict_Pop)) int found = PyDict_Pop(kwds2, key, &value); if (found) { if (unlikely(found < 0)) goto bad; values[name-argnames] = value; } #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000 int found = PyDict_GetItemRef(kwds2, key, &value); if (found) { if (unlikely(found < 0)) goto bad; values[name-argnames] = value; if (unlikely(PyDict_DelItem(kwds2, key) < 0)) goto bad; } #else #if CYTHON_COMPILING_IN_CPYTHON value = _PyDict_Pop(kwds2, key, kwds2); #else value = __Pyx_CallUnboundCMethod2(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_pop, kwds2, key, kwds2); #endif if (value == kwds2) { Py_DECREF(value); } else { if (unlikely(!value)) goto bad; values[name-argnames] = value; } #endif name++; } len = PyDict_Size(kwds2); if (len > 0) { return __Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name); } else if (unlikely(len == -1)) { goto bad; } return 0; bad: return -1; } static int __Pyx_ParseKeywordsTuple( PyObject *kwds, PyObject * const *kwvalues, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs) { PyObject *key = NULL; PyObject** const * name; PyObject** const *first_kw_arg = argnames + num_pos_args; for (Py_ssize_t pos = 0; pos < num_kwargs; pos++) { #if CYTHON_AVOID_BORROWED_REFS key = __Pyx_PySequence_ITEM(kwds, pos); #else key = __Pyx_PyTuple_GET_ITEM(kwds, pos); #endif #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely(!key)) goto bad; #endif name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { PyObject *value = kwvalues[pos]; values[name-argnames] = __Pyx_NewRef(value); } else { size_t index_found = 0; int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name); if (cmp == 1) { PyObject *value = kwvalues[pos]; values[index_found] = __Pyx_NewRef(value); } else { if (unlikely(cmp == -1)) goto bad; if (kwds2) { PyObject *value = kwvalues[pos]; if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else if (!ignore_unknown_kwargs) { goto invalid_keyword; } } } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(key); key = NULL; #endif } return 0; invalid_keyword: PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%U'", function_name, key); goto bad; bad: #if CYTHON_AVOID_BORROWED_REFS Py_XDECREF(key); #endif return -1; } /* ParseKeywords */ static int __Pyx_ParseKeywords( PyObject *kwds, PyObject * const *kwvalues, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs) { if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds))) return __Pyx_ParseKeywordsTuple(kwds, kwvalues, argnames, kwds2, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs); else if (kwds2) return __Pyx_ParseKeywordDictToDict(kwds, argnames, kwds2, values, num_pos_args, function_name); else return __Pyx_ParseKeywordDict(kwds, argnames, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs); } /* RaiseArgTupleInvalid */ static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found) { Py_ssize_t num_expected; const char *more_or_less; if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; } else { num_expected = num_max; more_or_less = "at most"; } if (exact) { more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } /* PyObjectFastCallMethod */ #if !CYTHON_VECTORCALL || PY_VERSION_HEX < 0x03090000 static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const *args, size_t nargsf) { PyObject *result; PyObject *attr = PyObject_GetAttr(args[0], name); if (unlikely(!attr)) return NULL; result = __Pyx_PyObject_FastCall(attr, args+1, nargsf - 1); Py_DECREF(attr); return result; } #endif /* PyDictVersioning */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { PyObject *dict = Py_TYPE(obj)->tp_dict; return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; } static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { PyObject **dictptr = NULL; Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; if (offset) { #if CYTHON_COMPILING_IN_CPYTHON dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); #else dictptr = _PyObject_GetDictPtr(obj); #endif } return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; } static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { PyObject *dict = Py_TYPE(obj)->tp_dict; if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) return 0; return obj_dict_version == __Pyx_get_object_dict_version(obj); } #endif /* RaiseException */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto bad; } if (value == Py_None) value = 0; if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto bad; } value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { PyObject *instance_class = NULL; if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { int is_subclass = PyObject_IsSubclass(instance_class, type); if (!is_subclass) { instance_class = NULL; } else if (unlikely(is_subclass == -1)) { goto bad; } else { type = instance_class; } } } if (!instance_class) { PyObject *args; if (!value) args = PyTuple_New(0); else if (PyTuple_Check(value)) { Py_INCREF(value); args = value; } else args = PyTuple_Pack(1, value); if (!args) goto bad; owned_instance = PyObject_Call(type, args, NULL); Py_DECREF(args); if (!owned_instance) goto bad; value = owned_instance; if (!PyExceptionInstance_Check(value)) { PyErr_Format(PyExc_TypeError, "calling %R should have returned an instance of " "BaseException, not %R", type, Py_TYPE(value)); goto bad; } } } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } if (cause) { PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyException_SetTraceback(value, tb); #elif CYTHON_FAST_THREAD_STATE PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #else PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #endif } bad: Py_XDECREF(owned_instance); return; } /* RejectKeywords */ static void __Pyx_RejectKeywords(const char* function_name, PyObject *kwds) { PyObject *key = NULL; if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds))) { key = __Pyx_PySequence_ITEM(kwds, 0); } else { #if CYTHON_AVOID_BORROWED_REFS PyObject *pos = NULL; #else Py_ssize_t pos = 0; #endif #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments) if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return; #endif __Pyx_PyDict_NextRef(kwds, &pos, &key, NULL); #if CYTHON_AVOID_BORROWED_REFS Py_XDECREF(pos); #endif } if (likely(key)) { PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%U'", function_name, key); Py_DECREF(key); } } /* GetModuleGlobalName */ #if CYTHON_USE_DICT_VERSIONS static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) #else static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) #endif { PyObject *result; #if CYTHON_COMPILING_IN_LIMITED_API if (unlikely(!__pyx_m)) { if (!PyErr_Occurred()) PyErr_SetNone(PyExc_NameError); return NULL; } result = PyObject_GetAttr(__pyx_m, name); if (likely(result)) { return result; } PyErr_Clear(); #elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS if (unlikely(__Pyx_PyDict_GetItemRef(__pyx_mstate_global->__pyx_d, name, &result) == -1)) PyErr_Clear(); __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return result; } #else result = _PyDict_GetItem_KnownHash(__pyx_mstate_global->__pyx_d, name, ((PyASCIIObject *) name)->hash); __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } PyErr_Clear(); #endif return __Pyx_GetBuiltinName(name); } /* GetException */ #if CYTHON_FAST_THREAD_STATE static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) #endif { PyObject *local_type = NULL, *local_value, *local_tb = NULL; #if CYTHON_FAST_THREAD_STATE PyObject *tmp_type, *tmp_value, *tmp_tb; #if PY_VERSION_HEX >= 0x030C0000 local_value = tstate->current_exception; tstate->current_exception = 0; #else local_type = tstate->curexc_type; local_value = tstate->curexc_value; local_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #endif #elif __PYX_LIMITED_VERSION_HEX > 0x030C0000 local_value = PyErr_GetRaisedException(); #else PyErr_Fetch(&local_type, &local_value, &local_tb); #endif #if __PYX_LIMITED_VERSION_HEX > 0x030C0000 if (likely(local_value)) { local_type = (PyObject*) Py_TYPE(local_value); Py_INCREF(local_type); local_tb = PyException_GetTraceback(local_value); } #else PyErr_NormalizeException(&local_type, &local_value, &local_tb); #if CYTHON_FAST_THREAD_STATE if (unlikely(tstate->curexc_type)) #else if (unlikely(PyErr_Occurred())) #endif goto bad; if (local_tb) { if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) goto bad; } #endif // __PYX_LIMITED_VERSION_HEX > 0x030C0000 Py_XINCREF(local_tb); Py_XINCREF(local_type); Py_XINCREF(local_value); *type = local_type; *value = local_value; *tb = local_tb; #if CYTHON_FAST_THREAD_STATE #if CYTHON_USE_EXC_INFO_STACK { _PyErr_StackItem *exc_info = tstate->exc_info; #if PY_VERSION_HEX >= 0x030B00a4 tmp_value = exc_info->exc_value; exc_info->exc_value = local_value; tmp_type = NULL; tmp_tb = NULL; Py_XDECREF(local_type); Py_XDECREF(local_tb); #else tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = local_type; exc_info->exc_value = local_value; exc_info->exc_traceback = local_tb; #endif } #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = local_type; tstate->exc_value = local_value; tstate->exc_traceback = local_tb; #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #elif __PYX_LIMITED_VERSION_HEX >= 0x030b0000 PyErr_SetHandledException(local_value); Py_XDECREF(local_value); Py_XDECREF(local_type); Py_XDECREF(local_tb); #else PyErr_SetExcInfo(local_type, local_value, local_tb); #endif return 0; #if __PYX_LIMITED_VERSION_HEX <= 0x030C0000 bad: *type = 0; *value = 0; *tb = 0; Py_XDECREF(local_type); Py_XDECREF(local_value); Py_XDECREF(local_tb); return -1; #endif } /* SwapException */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4 _PyErr_StackItem *exc_info = tstate->exc_info; tmp_value = exc_info->exc_value; exc_info->exc_value = *value; if (tmp_value == NULL || tmp_value == Py_None) { Py_XDECREF(tmp_value); tmp_value = NULL; tmp_type = NULL; tmp_tb = NULL; } else { tmp_type = (PyObject*) Py_TYPE(tmp_value); Py_INCREF(tmp_type); #if CYTHON_COMPILING_IN_CPYTHON tmp_tb = ((PyBaseExceptionObject*) tmp_value)->traceback; Py_XINCREF(tmp_tb); #else tmp_tb = PyException_GetTraceback(tmp_value); #endif } #elif CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = tstate->exc_info; tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = *type; exc_info->exc_value = *value; exc_info->exc_traceback = *tb; #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = *type; tstate->exc_value = *value; tstate->exc_traceback = *tb; #endif *type = tmp_type; *value = tmp_value; *tb = tmp_tb; } #else static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); PyErr_SetExcInfo(*type, *value, *tb); *type = tmp_type; *value = tmp_value; *tb = tmp_tb; } #endif /* GetTopmostException */ #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate) { _PyErr_StackItem *exc_info = tstate->exc_info; while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) && exc_info->previous_item != NULL) { exc_info = exc_info->previous_item; } return exc_info; } #endif /* SaveResetException */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4 _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); PyObject *exc_value = exc_info->exc_value; if (exc_value == NULL || exc_value == Py_None) { *value = NULL; *type = NULL; *tb = NULL; } else { *value = exc_value; Py_INCREF(*value); *type = (PyObject*) Py_TYPE(exc_value); Py_INCREF(*type); *tb = PyException_GetTraceback(exc_value); } #elif CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); *type = exc_info->exc_type; *value = exc_info->exc_value; *tb = exc_info->exc_traceback; Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); #else *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); #endif } static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4 _PyErr_StackItem *exc_info = tstate->exc_info; PyObject *tmp_value = exc_info->exc_value; exc_info->exc_value = value; Py_XDECREF(tmp_value); Py_XDECREF(type); Py_XDECREF(tb); #else PyObject *tmp_type, *tmp_value, *tmp_tb; #if CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = tstate->exc_info; tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = type; exc_info->exc_value = value; exc_info->exc_traceback = tb; #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = type; tstate->exc_value = value; tstate->exc_traceback = tb; #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #endif } #endif /* GetAttr3 */ #if __PYX_LIMITED_VERSION_HEX < 0x030d0000 static PyObject *__Pyx_GetAttr3Default(PyObject *d) { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) return NULL; __Pyx_PyErr_Clear(); Py_INCREF(d); return d; } #endif static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) { PyObject *r; #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 int res = PyObject_GetOptionalAttr(o, n, &r); return (res != 0) ? r : __Pyx_NewRef(d); #else #if CYTHON_USE_TYPE_SLOTS if (likely(PyUnicode_Check(n))) { r = __Pyx_PyObject_GetAttrStrNoError(o, n); if (unlikely(!r) && likely(!PyErr_Occurred())) { r = __Pyx_NewRef(d); } return r; } #endif r = PyObject_GetAttr(o, n); return (likely(r)) ? r : __Pyx_GetAttr3Default(d); #endif } /* RaiseUnexpectedTypeError */ static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj) { __Pyx_TypeName obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj)); PyErr_Format(PyExc_TypeError, "Expected %s, got " __Pyx_FMT_TYPENAME, expected, obj_type_name); __Pyx_DECREF_TypeName(obj_type_name); return 0; } /* ArgTypeTestFunc */ static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { __Pyx_TypeName type_name; __Pyx_TypeName obj_type_name; PyObject *extra_info = __pyx_mstate_global->__pyx_empty_unicode; int from_annotation_subclass = 0; if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } else if (!exact) { if (likely(__Pyx_TypeCheck(obj, type))) return 1; } else if (exact == 2) { if (__Pyx_TypeCheck(obj, type)) { from_annotation_subclass = 1; extra_info = __pyx_mstate_global->__pyx_kp_u_Note_that_Cython_is_deliberately; } } type_name = __Pyx_PyType_GetFullyQualifiedName(type); obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj)); PyErr_Format(PyExc_TypeError, "Argument '%.200s' has incorrect type (expected " __Pyx_FMT_TYPENAME ", got " __Pyx_FMT_TYPENAME ")" #if __PYX_LIMITED_VERSION_HEX < 0x030C0000 "%s%U" #endif , name, type_name, obj_type_name #if __PYX_LIMITED_VERSION_HEX < 0x030C0000 , (from_annotation_subclass ? ". " : ""), extra_info #endif ); #if __PYX_LIMITED_VERSION_HEX >= 0x030C0000 if (exact == 2 && from_annotation_subclass) { PyObject *res; PyObject *vargs[2]; vargs[0] = PyErr_GetRaisedException(); vargs[1] = extra_info; res = PyObject_VectorcallMethod(__pyx_mstate_global->__pyx_kp_u_add_note, vargs, 2, NULL); Py_XDECREF(res); PyErr_SetRaisedException(vargs[0]); } #endif __Pyx_DECREF_TypeName(type_name); __Pyx_DECREF_TypeName(obj_type_name); return 0; } /* GetItemInt */ static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; if (unlikely(!j)) return NULL; r = PyObject_GetItem(o, j); Py_DECREF(j); return r; } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck, int unsafe_shared) { CYTHON_MAYBE_UNUSED_VAR(unsafe_shared); #if CYTHON_ASSUME_SAFE_SIZE Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyList_GET_SIZE(o); } if ((CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS || !CYTHON_ASSUME_SAFE_MACROS)) { return __Pyx_PyList_GetItemRefFast(o, wrapped_i, unsafe_shared); } else if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { return __Pyx_NewRef(PyList_GET_ITEM(o, wrapped_i)); } return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i)); #else (void)wraparound; (void)boundscheck; return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck, int unsafe_shared) { CYTHON_MAYBE_UNUSED_VAR(unsafe_shared); #if CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyTuple_GET_SIZE(o); } if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { return __Pyx_NewRef(PyTuple_GET_ITEM(o, wrapped_i)); } return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i)); #else (void)wraparound; (void)boundscheck; return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck, int unsafe_shared) { CYTHON_MAYBE_UNUSED_VAR(unsafe_shared); #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); if ((CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)) { return __Pyx_PyList_GetItemRefFast(o, n, unsafe_shared); } else if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { return __Pyx_NewRef(PyList_GET_ITEM(o, n)); } } else #if !CYTHON_AVOID_BORROWED_REFS if (PyTuple_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { return __Pyx_NewRef(PyTuple_GET_ITEM(o, n)); } } else #endif #endif #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY { PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping; PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence; if (!is_list && mm && mm->mp_subscript) { PyObject *r, *key = PyLong_FromSsize_t(i); if (unlikely(!key)) return NULL; r = mm->mp_subscript(o, key); Py_DECREF(key); return r; } if (is_list || likely(sm && sm->sq_item)) { if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) { Py_ssize_t l = sm->sq_length(o); if (likely(l >= 0)) { i += l; } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) return NULL; PyErr_Clear(); } } return sm->sq_item(o, i); } } #else if (is_list || !PyMapping_Check(o)) { return PySequence_GetItem(o, i); } #endif (void)wraparound; (void)boundscheck; return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i)); } /* AllocateExtensionType */ static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final) { if (is_final || likely(!__Pyx_PyType_HasFeature(t, Py_TPFLAGS_IS_ABSTRACT))) { allocfunc alloc_func = __Pyx_PyType_GetSlot(t, tp_alloc, allocfunc); return alloc_func(t, 0); } else { newfunc tp_new = __Pyx_PyType_TryGetSlot(&PyBaseObject_Type, tp_new, newfunc); #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 if (!tp_new) { PyObject *new_str = PyUnicode_FromString("__new__"); if (likely(new_str)) { PyObject *o = PyObject_CallMethodObjArgs((PyObject *)&PyBaseObject_Type, new_str, t, NULL); Py_DECREF(new_str); return o; } else return NULL; } else #endif return tp_new(t, __pyx_mstate_global->__pyx_empty_tuple, 0); } } /* CallNextTpTraverse */ static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) { PyTypeObject* type = Py_TYPE(obj); traverseproc tp_traverse = NULL; while (type && __Pyx_PyType_GetSlot(type, tp_traverse, traverseproc) != current_tp_traverse) type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*); while (type && (tp_traverse = __Pyx_PyType_GetSlot(type, tp_traverse, traverseproc)) == current_tp_traverse) type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*); if (type && tp_traverse) return tp_traverse(obj, v, a); return 0; } /* CallTypeTraverse */ #if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000) #else static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg) { #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x03090000 if (__Pyx_get_runtime_version() < 0x03090000) return 0; #endif if (!always_call) { PyTypeObject *base = __Pyx_PyObject_GetSlot(o, tp_base, PyTypeObject*); unsigned long flags = PyType_GetFlags(base); if (flags & Py_TPFLAGS_HEAPTYPE) { return 0; } } Py_VISIT((PyObject*)Py_TYPE(o)); return 0; } #endif /* CallNextTpClear */ static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) { PyTypeObject* type = Py_TYPE(obj); inquiry tp_clear = NULL; while (type && __Pyx_PyType_GetSlot(type, tp_clear, inquiry) != current_tp_clear) type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*); while (type && (tp_clear = __Pyx_PyType_GetSlot(type, tp_clear, inquiry)) == current_tp_clear) type = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*); if (type && tp_clear) tp_clear(obj); } /* LimitedApiGetTypeDict */ #if CYTHON_COMPILING_IN_LIMITED_API static Py_ssize_t __Pyx_GetTypeDictOffset(void) { PyObject *tp_dictoffset_o; Py_ssize_t tp_dictoffset; tp_dictoffset_o = PyObject_GetAttrString((PyObject*)(&PyType_Type), "__dictoffset__"); if (unlikely(!tp_dictoffset_o)) return -1; tp_dictoffset = PyLong_AsSsize_t(tp_dictoffset_o); Py_DECREF(tp_dictoffset_o); if (unlikely(tp_dictoffset == 0)) { PyErr_SetString( PyExc_TypeError, "'type' doesn't have a dictoffset"); return -1; } else if (unlikely(tp_dictoffset < 0)) { PyErr_SetString( PyExc_TypeError, "'type' has an unexpected negative dictoffset. " "Please report this as Cython bug"); return -1; } return tp_dictoffset; } static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp) { static Py_ssize_t tp_dictoffset = 0; if (unlikely(tp_dictoffset == 0)) { tp_dictoffset = __Pyx_GetTypeDictOffset(); if (unlikely(tp_dictoffset == -1 && PyErr_Occurred())) { tp_dictoffset = 0; // try again next time? return NULL; } } return *(PyObject**)((char*)tp + tp_dictoffset); } #endif /* SetItemOnTypeDict */ static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v) { int result; PyObject *tp_dict; #if CYTHON_COMPILING_IN_LIMITED_API tp_dict = __Pyx_GetTypeDict(tp); if (unlikely(!tp_dict)) return -1; #else tp_dict = tp->tp_dict; #endif result = PyDict_SetItem(tp_dict, k, v); if (likely(!result)) { PyType_Modified(tp); if (unlikely(PyObject_HasAttr(v, __pyx_mstate_global->__pyx_n_u_set_name))) { PyObject *setNameResult = PyObject_CallMethodObjArgs(v, __pyx_mstate_global->__pyx_n_u_set_name, (PyObject *) tp, k, NULL); if (!setNameResult) return -1; Py_DECREF(setNameResult); } } return result; } /* FixUpExtensionType */ static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type) { #if __PYX_LIMITED_VERSION_HEX > 0x030900B1 CYTHON_UNUSED_VAR(spec); CYTHON_UNUSED_VAR(type); CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict); #else const PyType_Slot *slot = spec->slots; int changed = 0; #if !CYTHON_COMPILING_IN_LIMITED_API while (slot && slot->slot && slot->slot != Py_tp_members) slot++; if (slot && slot->slot == Py_tp_members) { #if !CYTHON_COMPILING_IN_CPYTHON const #endif // !CYTHON_COMPILING_IN_CPYTHON) PyMemberDef *memb = (PyMemberDef*) slot->pfunc; while (memb && memb->name) { if (memb->name[0] == '_' && memb->name[1] == '_') { if (strcmp(memb->name, "__weaklistoffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); type->tp_weaklistoffset = memb->offset; changed = 1; } else if (strcmp(memb->name, "__dictoffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); type->tp_dictoffset = memb->offset; changed = 1; } #if CYTHON_METH_FASTCALL else if (strcmp(memb->name, "__vectorcalloffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); type->tp_vectorcall_offset = memb->offset; changed = 1; } #endif // CYTHON_METH_FASTCALL #if !CYTHON_COMPILING_IN_PYPY else if (strcmp(memb->name, "__module__") == 0) { PyObject *descr; assert(memb->type == T_OBJECT); assert(memb->flags == 0 || memb->flags == READONLY); descr = PyDescr_NewMember(type, memb); if (unlikely(!descr)) return -1; int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr); Py_DECREF(descr); if (unlikely(set_item_result < 0)) { return -1; } changed = 1; } #endif // !CYTHON_COMPILING_IN_PYPY } memb++; } } #endif // !CYTHON_COMPILING_IN_LIMITED_API #if !CYTHON_COMPILING_IN_PYPY slot = spec->slots; while (slot && slot->slot && slot->slot != Py_tp_getset) slot++; if (slot && slot->slot == Py_tp_getset) { PyGetSetDef *getset = (PyGetSetDef*) slot->pfunc; while (getset && getset->name) { if (getset->name[0] == '_' && getset->name[1] == '_' && strcmp(getset->name, "__module__") == 0) { PyObject *descr = PyDescr_NewGetSet(type, getset); if (unlikely(!descr)) return -1; #if CYTHON_COMPILING_IN_LIMITED_API PyObject *pyname = PyUnicode_FromString(getset->name); if (unlikely(!pyname)) { Py_DECREF(descr); return -1; } int set_item_result = __Pyx_SetItemOnTypeDict(type, pyname, descr); Py_DECREF(pyname); #else CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict); int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr); #endif Py_DECREF(descr); if (unlikely(set_item_result < 0)) { return -1; } changed = 1; } ++getset; } } #else CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict); #endif // !CYTHON_COMPILING_IN_PYPY if (changed) PyType_Modified(type); #endif // PY_VERSION_HEX > 0x030900B1 return 0; } /* PyObjectCallNoArg */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { PyObject *arg[2] = {NULL, NULL}; return __Pyx_PyObject_FastCall(func, arg + 1, 0 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } /* PyObjectGetMethod */ #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))) static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) { PyObject *attr; #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP __Pyx_TypeName type_name; PyTypeObject *tp = Py_TYPE(obj); PyObject *descr; descrgetfunc f = NULL; PyObject **dictptr, *dict; int meth_found = 0; assert (*method == NULL); if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) { attr = __Pyx_PyObject_GetAttrStr(obj, name); goto try_unpack; } if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) { return 0; } descr = _PyType_Lookup(tp, name); if (likely(descr != NULL)) { Py_INCREF(descr); #if defined(Py_TPFLAGS_METHOD_DESCRIPTOR) && Py_TPFLAGS_METHOD_DESCRIPTOR if (__Pyx_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR)) #else #ifdef __Pyx_CyFunction_USED if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr))) #else if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type))) #endif #endif { meth_found = 1; } else { f = Py_TYPE(descr)->tp_descr_get; if (f != NULL && PyDescr_IsData(descr)) { attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); Py_DECREF(descr); goto try_unpack; } } } dictptr = _PyObject_GetDictPtr(obj); if (dictptr != NULL && (dict = *dictptr) != NULL) { Py_INCREF(dict); attr = __Pyx_PyDict_GetItemStr(dict, name); if (attr != NULL) { Py_INCREF(attr); Py_DECREF(dict); Py_XDECREF(descr); goto try_unpack; } Py_DECREF(dict); } if (meth_found) { *method = descr; return 1; } if (f != NULL) { attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); Py_DECREF(descr); goto try_unpack; } if (likely(descr != NULL)) { *method = descr; return 0; } type_name = __Pyx_PyType_GetFullyQualifiedName(tp); PyErr_Format(PyExc_AttributeError, "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'", type_name, name); __Pyx_DECREF_TypeName(type_name); return 0; #else attr = __Pyx_PyObject_GetAttrStr(obj, name); goto try_unpack; #endif try_unpack: #if CYTHON_UNPACK_METHODS if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) { PyObject *function = PyMethod_GET_FUNCTION(attr); Py_INCREF(function); Py_DECREF(attr); *method = function; return 1; } #endif *method = attr; return 0; } #endif /* PyObjectCallMethod0 */ static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) { #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)) PyObject *args[1] = {obj}; (void) __Pyx_PyObject_CallOneArg; (void) __Pyx_PyObject_CallNoArg; return PyObject_VectorcallMethod(method_name, args, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); #else PyObject *method = NULL, *result = NULL; int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); if (likely(is_method)) { result = __Pyx_PyObject_CallOneArg(method, obj); Py_DECREF(method); return result; } if (unlikely(!method)) goto bad; result = __Pyx_PyObject_CallNoArg(method); Py_DECREF(method); bad: return result; #endif } /* ValidateBasesTuple */ #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases) { Py_ssize_t i, n; #if CYTHON_ASSUME_SAFE_SIZE n = PyTuple_GET_SIZE(bases); #else n = PyTuple_Size(bases); if (unlikely(n < 0)) return -1; #endif for (i = 1; i < n; i++) { PyTypeObject *b; #if CYTHON_AVOID_BORROWED_REFS PyObject *b0 = PySequence_GetItem(bases, i); if (!b0) return -1; #elif CYTHON_ASSUME_SAFE_MACROS PyObject *b0 = PyTuple_GET_ITEM(bases, i); #else PyObject *b0 = PyTuple_GetItem(bases, i); if (!b0) return -1; #endif b = (PyTypeObject*) b0; if (!__Pyx_PyType_HasFeature(b, Py_TPFLAGS_HEAPTYPE)) { __Pyx_TypeName b_name = __Pyx_PyType_GetFullyQualifiedName(b); PyErr_Format(PyExc_TypeError, "base class '" __Pyx_FMT_TYPENAME "' is not a heap type", b_name); __Pyx_DECREF_TypeName(b_name); #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(b0); #endif return -1; } if (dictoffset == 0) { Py_ssize_t b_dictoffset = 0; #if CYTHON_USE_TYPE_SLOTS b_dictoffset = b->tp_dictoffset; #else PyObject *py_b_dictoffset = PyObject_GetAttrString((PyObject*)b, "__dictoffset__"); if (!py_b_dictoffset) goto dictoffset_return; b_dictoffset = PyLong_AsSsize_t(py_b_dictoffset); Py_DECREF(py_b_dictoffset); if (b_dictoffset == -1 && PyErr_Occurred()) goto dictoffset_return; #endif if (b_dictoffset) { { __Pyx_TypeName b_name = __Pyx_PyType_GetFullyQualifiedName(b); PyErr_Format(PyExc_TypeError, "extension type '%.200s' has no __dict__ slot, " "but base type '" __Pyx_FMT_TYPENAME "' has: " "either add 'cdef dict __dict__' to the extension type " "or add '__slots__ = [...]' to the base type", type_name, b_name); __Pyx_DECREF_TypeName(b_name); } #if !CYTHON_USE_TYPE_SLOTS dictoffset_return: #endif #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(b0); #endif return -1; } } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(b0); #endif } return 0; } #endif /* PyType_Ready */ CYTHON_UNUSED static int __Pyx_PyType_HasMultipleInheritance(PyTypeObject *t) { while (t) { PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*); if (bases) { return 1; } t = __Pyx_PyType_GetSlot(t, tp_base, PyTypeObject*); } return 0; } static int __Pyx_PyType_Ready(PyTypeObject *t) { #if CYTHON_USE_TYPE_SPECS || !CYTHON_COMPILING_IN_CPYTHON || defined(PYSTON_MAJOR_VERSION) (void)__Pyx_PyObject_CallMethod0; #if CYTHON_USE_TYPE_SPECS (void)__Pyx_validate_bases_tuple; #endif return PyType_Ready(t); #else int r; if (!__Pyx_PyType_HasMultipleInheritance(t)) { return PyType_Ready(t); } PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*); if (bases && unlikely(__Pyx_validate_bases_tuple(t->tp_name, t->tp_dictoffset, bases) == -1)) return -1; #if !defined(PYSTON_MAJOR_VERSION) { int gc_was_enabled; #if PY_VERSION_HEX >= 0x030A00b1 gc_was_enabled = PyGC_Disable(); (void)__Pyx_PyObject_CallMethod0; #else PyObject *ret, *py_status; PyObject *gc = NULL; #if (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM+0 >= 0x07030400) &&\ !CYTHON_COMPILING_IN_GRAAL gc = PyImport_GetModule(__pyx_mstate_global->__pyx_kp_u_gc); #endif if (unlikely(!gc)) gc = PyImport_Import(__pyx_mstate_global->__pyx_kp_u_gc); if (unlikely(!gc)) return -1; py_status = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_isenabled); if (unlikely(!py_status)) { Py_DECREF(gc); return -1; } gc_was_enabled = __Pyx_PyObject_IsTrue(py_status); Py_DECREF(py_status); if (gc_was_enabled > 0) { ret = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_disable); if (unlikely(!ret)) { Py_DECREF(gc); return -1; } Py_DECREF(ret); } else if (unlikely(gc_was_enabled == -1)) { Py_DECREF(gc); return -1; } #endif t->tp_flags |= Py_TPFLAGS_HEAPTYPE; #if PY_VERSION_HEX >= 0x030A0000 t->tp_flags |= Py_TPFLAGS_IMMUTABLETYPE; #endif #else (void)__Pyx_PyObject_CallMethod0; #endif r = PyType_Ready(t); #if !defined(PYSTON_MAJOR_VERSION) t->tp_flags &= ~Py_TPFLAGS_HEAPTYPE; #if PY_VERSION_HEX >= 0x030A00b1 if (gc_was_enabled) PyGC_Enable(); #else if (gc_was_enabled) { PyObject *tp, *v, *tb; PyErr_Fetch(&tp, &v, &tb); ret = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_enable); if (likely(ret || r == -1)) { Py_XDECREF(ret); PyErr_Restore(tp, v, tb); } else { Py_XDECREF(tp); Py_XDECREF(v); Py_XDECREF(tb); r = -1; } } Py_DECREF(gc); #endif } #endif return r; #endif } /* SetVTable */ static int __Pyx_SetVtable(PyTypeObject *type, void *vtable) { PyObject *ob = PyCapsule_New(vtable, 0, 0); if (unlikely(!ob)) goto bad; #if CYTHON_COMPILING_IN_LIMITED_API if (unlikely(PyObject_SetAttr((PyObject *) type, __pyx_mstate_global->__pyx_n_u_pyx_vtable, ob) < 0)) #else if (unlikely(PyDict_SetItem(type->tp_dict, __pyx_mstate_global->__pyx_n_u_pyx_vtable, ob) < 0)) #endif goto bad; Py_DECREF(ob); return 0; bad: Py_XDECREF(ob); return -1; } /* GetVTable */ static void* __Pyx_GetVtable(PyTypeObject *type) { void* ptr; #if CYTHON_COMPILING_IN_LIMITED_API PyObject *ob = PyObject_GetAttr((PyObject *)type, __pyx_mstate_global->__pyx_n_u_pyx_vtable); #else PyObject *ob = PyObject_GetItem(type->tp_dict, __pyx_mstate_global->__pyx_n_u_pyx_vtable); #endif if (!ob) goto bad; ptr = PyCapsule_GetPointer(ob, 0); if (!ptr && !PyErr_Occurred()) PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type"); Py_DECREF(ob); return ptr; bad: Py_XDECREF(ob); return NULL; } /* MergeVTables */ static int __Pyx_MergeVtables(PyTypeObject *type) { int i=0; Py_ssize_t size; void** base_vtables; __Pyx_TypeName tp_base_name = NULL; __Pyx_TypeName base_name = NULL; void* unknown = (void*)-1; PyObject* bases = __Pyx_PyType_GetSlot(type, tp_bases, PyObject*); int base_depth = 0; { PyTypeObject* base = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*); while (base) { base_depth += 1; base = __Pyx_PyType_GetSlot(base, tp_base, PyTypeObject*); } } base_vtables = (void**) PyMem_Malloc(sizeof(void*) * (size_t)(base_depth + 1)); base_vtables[0] = unknown; #if CYTHON_COMPILING_IN_LIMITED_API size = PyTuple_Size(bases); if (size < 0) goto other_failure; #else size = PyTuple_GET_SIZE(bases); #endif for (i = 1; i < size; i++) { PyObject *basei; void* base_vtable; #if CYTHON_AVOID_BORROWED_REFS basei = PySequence_GetItem(bases, i); if (unlikely(!basei)) goto other_failure; #elif !CYTHON_ASSUME_SAFE_MACROS basei = PyTuple_GetItem(bases, i); if (unlikely(!basei)) goto other_failure; #else basei = PyTuple_GET_ITEM(bases, i); #endif base_vtable = __Pyx_GetVtable((PyTypeObject*)basei); #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(basei); #endif if (base_vtable != NULL) { int j; PyTypeObject* base = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*); for (j = 0; j < base_depth; j++) { if (base_vtables[j] == unknown) { base_vtables[j] = __Pyx_GetVtable(base); base_vtables[j + 1] = unknown; } if (base_vtables[j] == base_vtable) { break; } else if (base_vtables[j] == NULL) { goto bad; } base = __Pyx_PyType_GetSlot(base, tp_base, PyTypeObject*); } } } PyErr_Clear(); PyMem_Free(base_vtables); return 0; bad: { PyTypeObject* basei = NULL; PyTypeObject* tp_base = __Pyx_PyType_GetSlot(type, tp_base, PyTypeObject*); tp_base_name = __Pyx_PyType_GetFullyQualifiedName(tp_base); #if CYTHON_AVOID_BORROWED_REFS basei = (PyTypeObject*)PySequence_GetItem(bases, i); if (unlikely(!basei)) goto really_bad; #elif !CYTHON_ASSUME_SAFE_MACROS basei = (PyTypeObject*)PyTuple_GetItem(bases, i); if (unlikely(!basei)) goto really_bad; #else basei = (PyTypeObject*)PyTuple_GET_ITEM(bases, i); #endif base_name = __Pyx_PyType_GetFullyQualifiedName(basei); #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(basei); #endif } PyErr_Format(PyExc_TypeError, "multiple bases have vtable conflict: '" __Pyx_FMT_TYPENAME "' and '" __Pyx_FMT_TYPENAME "'", tp_base_name, base_name); #if CYTHON_AVOID_BORROWED_REFS || !CYTHON_ASSUME_SAFE_MACROS really_bad: // bad has failed! #endif __Pyx_DECREF_TypeName(tp_base_name); __Pyx_DECREF_TypeName(base_name); #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_AVOID_BORROWED_REFS || !CYTHON_ASSUME_SAFE_MACROS other_failure: #endif PyMem_Free(base_vtables); return -1; } /* DelItemOnTypeDict */ static int __Pyx__DelItemOnTypeDict(PyTypeObject *tp, PyObject *k) { int result; PyObject *tp_dict; #if CYTHON_COMPILING_IN_LIMITED_API tp_dict = __Pyx_GetTypeDict(tp); if (unlikely(!tp_dict)) return -1; #else tp_dict = tp->tp_dict; #endif result = PyDict_DelItem(tp_dict, k); if (likely(!result)) PyType_Modified(tp); return result; } /* SetupReduce */ static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { int ret; PyObject *name_attr; name_attr = __Pyx_PyObject_GetAttrStrNoError(meth, __pyx_mstate_global->__pyx_n_u_name); if (likely(name_attr)) { ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); } else { ret = -1; } if (unlikely(ret < 0)) { PyErr_Clear(); ret = 0; } Py_XDECREF(name_attr); return ret; } static int __Pyx_setup_reduce(PyObject* type_obj) { int ret = 0; PyObject *object_reduce = NULL; PyObject *object_getstate = NULL; PyObject *object_reduce_ex = NULL; PyObject *reduce = NULL; PyObject *reduce_ex = NULL; PyObject *reduce_cython = NULL; PyObject *setstate = NULL; PyObject *setstate_cython = NULL; PyObject *getstate = NULL; #if CYTHON_USE_PYTYPE_LOOKUP getstate = _PyType_Lookup((PyTypeObject*)type_obj, __pyx_mstate_global->__pyx_n_u_getstate); #else getstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_mstate_global->__pyx_n_u_getstate); if (!getstate && PyErr_Occurred()) { goto __PYX_BAD; } #endif if (getstate) { #if CYTHON_USE_PYTYPE_LOOKUP object_getstate = _PyType_Lookup(&PyBaseObject_Type, __pyx_mstate_global->__pyx_n_u_getstate); #else object_getstate = __Pyx_PyObject_GetAttrStrNoError((PyObject*)&PyBaseObject_Type, __pyx_mstate_global->__pyx_n_u_getstate); if (!object_getstate && PyErr_Occurred()) { goto __PYX_BAD; } #endif if (object_getstate != getstate) { goto __PYX_GOOD; } } #if CYTHON_USE_PYTYPE_LOOKUP object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_mstate_global->__pyx_n_u_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD; #else object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_mstate_global->__pyx_n_u_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD; #endif reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_mstate_global->__pyx_n_u_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD; if (reduce_ex == object_reduce_ex) { #if CYTHON_USE_PYTYPE_LOOKUP object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_mstate_global->__pyx_n_u_reduce); if (!object_reduce) goto __PYX_BAD; #else object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_mstate_global->__pyx_n_u_reduce); if (!object_reduce) goto __PYX_BAD; #endif reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_mstate_global->__pyx_n_u_reduce); if (unlikely(!reduce)) goto __PYX_BAD; if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_mstate_global->__pyx_n_u_reduce_cython)) { reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_mstate_global->__pyx_n_u_reduce_cython); if (likely(reduce_cython)) { ret = __Pyx_SetItemOnTypeDict((PyTypeObject*)type_obj, __pyx_mstate_global->__pyx_n_u_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD; ret = __Pyx_DelItemOnTypeDict((PyTypeObject*)type_obj, __pyx_mstate_global->__pyx_n_u_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD; } else if (reduce == object_reduce || PyErr_Occurred()) { goto __PYX_BAD; } setstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_mstate_global->__pyx_n_u_setstate); if (!setstate) PyErr_Clear(); if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_mstate_global->__pyx_n_u_setstate_cython)) { setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_mstate_global->__pyx_n_u_setstate_cython); if (likely(setstate_cython)) { ret = __Pyx_SetItemOnTypeDict((PyTypeObject*)type_obj, __pyx_mstate_global->__pyx_n_u_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD; ret = __Pyx_DelItemOnTypeDict((PyTypeObject*)type_obj, __pyx_mstate_global->__pyx_n_u_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD; } else if (!setstate || PyErr_Occurred()) { goto __PYX_BAD; } } PyType_Modified((PyTypeObject*)type_obj); } } goto __PYX_GOOD; __PYX_BAD: if (!PyErr_Occurred()) { __Pyx_TypeName type_obj_name = __Pyx_PyType_GetFullyQualifiedName((PyTypeObject*)type_obj); PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for " __Pyx_FMT_TYPENAME, type_obj_name); __Pyx_DECREF_TypeName(type_obj_name); } ret = -1; __PYX_GOOD: #if !CYTHON_USE_PYTYPE_LOOKUP Py_XDECREF(object_reduce); Py_XDECREF(object_reduce_ex); Py_XDECREF(object_getstate); Py_XDECREF(getstate); #endif Py_XDECREF(reduce); Py_XDECREF(reduce_ex); Py_XDECREF(reduce_cython); Py_XDECREF(setstate); Py_XDECREF(setstate_cython); return ret; } /* TypeImport */ #ifndef __PYX_HAVE_RT_ImportType_3_2_0 #define __PYX_HAVE_RT_ImportType_3_2_0 static PyTypeObject *__Pyx_ImportType_3_2_0(PyObject *module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_2_0 check_size) { PyObject *result = 0; Py_ssize_t basicsize; Py_ssize_t itemsize; #if defined(Py_LIMITED_API) || (defined(CYTHON_COMPILING_IN_LIMITED_API) && CYTHON_COMPILING_IN_LIMITED_API) PyObject *py_basicsize; PyObject *py_itemsize; #endif result = PyObject_GetAttrString(module, class_name); if (!result) goto bad; if (!PyType_Check(result)) { PyErr_Format(PyExc_TypeError, "%.200s.%.200s is not a type object", module_name, class_name); goto bad; } #if !( defined(Py_LIMITED_API) || (defined(CYTHON_COMPILING_IN_LIMITED_API) && CYTHON_COMPILING_IN_LIMITED_API) ) basicsize = ((PyTypeObject *)result)->tp_basicsize; itemsize = ((PyTypeObject *)result)->tp_itemsize; #else if (size == 0) { return (PyTypeObject *)result; } py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); if (!py_basicsize) goto bad; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = 0; if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; py_itemsize = PyObject_GetAttrString(result, "__itemsize__"); if (!py_itemsize) goto bad; itemsize = PyLong_AsSsize_t(py_itemsize); Py_DECREF(py_itemsize); py_itemsize = 0; if (itemsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; #endif if (itemsize) { if (size % alignment) { alignment = size % alignment; } if (itemsize < (Py_ssize_t)alignment) itemsize = (Py_ssize_t)alignment; } if ((size_t)(basicsize + itemsize) < size) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", module_name, class_name, size, basicsize+itemsize); goto bad; } if (check_size == __Pyx_ImportType_CheckSize_Error_3_2_0 && ((size_t)basicsize > size || (size_t)(basicsize + itemsize) < size)) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd-%zd from PyObject", module_name, class_name, size, basicsize, basicsize+itemsize); goto bad; } else if (check_size == __Pyx_ImportType_CheckSize_Warn_3_2_0 && (size_t)basicsize > size) { if (PyErr_WarnFormat(NULL, 0, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", module_name, class_name, size, basicsize) < 0) { goto bad; } } return (PyTypeObject *)result; bad: Py_XDECREF(result); return NULL; } #endif /* HasAttr */ #if __PYX_LIMITED_VERSION_HEX < 0x030d0000 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) { PyObject *r; if (unlikely(!PyUnicode_Check(n))) { PyErr_SetString(PyExc_TypeError, "hasattr(): attribute name must be string"); return -1; } r = __Pyx_PyObject_GetAttrStrNoError(o, n); if (!r) { return (unlikely(PyErr_Occurred())) ? -1 : 0; } else { Py_DECREF(r); return 1; } } #endif /* Import */ static int __Pyx__Import_GetModule(PyObject *qualname, PyObject **module) { PyObject *imported_module = PyImport_GetModule(qualname); if (unlikely(!imported_module)) { *module = NULL; if (PyErr_Occurred()) { return -1; } return 0; } *module = imported_module; return 1; } static int __Pyx__Import_Lookup(PyObject *qualname, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject **module) { PyObject *imported_module; PyObject *top_level_package_name; Py_ssize_t i; int status, module_found; Py_ssize_t dot_index; module_found = __Pyx__Import_GetModule(qualname, &imported_module); if (unlikely(!module_found || module_found == -1)) { *module = NULL; return module_found; } if (imported_names) { for (i = 0; i < len_imported_names; i++) { PyObject *imported_name = imported_names[i]; #if __PYX_LIMITED_VERSION_HEX < 0x030d0000 int has_imported_attribute = PyObject_HasAttr(imported_module, imported_name); #else int has_imported_attribute = PyObject_HasAttrWithError(imported_module, imported_name); if (unlikely(has_imported_attribute == -1)) goto error; #endif if (!has_imported_attribute) { goto not_found; } } *module = imported_module; return 1; } dot_index = PyUnicode_FindChar(qualname, '.', 0, PY_SSIZE_T_MAX, 1); if (dot_index == -1) { *module = imported_module; return 1; } if (unlikely(dot_index == -2)) goto error; top_level_package_name = PyUnicode_Substring(qualname, 0, dot_index); if (unlikely(!top_level_package_name)) goto error; Py_DECREF(imported_module); status = __Pyx__Import_GetModule(top_level_package_name, module); Py_DECREF(top_level_package_name); return status; error: Py_DECREF(imported_module); *module = NULL; return -1; not_found: Py_DECREF(imported_module); *module = NULL; return 0; } static PyObject *__Pyx_Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, int level) { PyObject *module = 0; PyObject *empty_dict = 0; PyObject *from_list = 0; int module_found; if (!qualname) { qualname = name; } module_found = __Pyx__Import_Lookup(qualname, imported_names, len_imported_names, &module); if (likely(module_found == 1)) { return module; } else if (unlikely(module_found == -1)) { return NULL; } empty_dict = PyDict_New(); if (unlikely(!empty_dict)) goto bad; if (imported_names) { #if CYTHON_COMPILING_IN_CPYTHON from_list = __Pyx_PyList_FromArray(imported_names, len_imported_names); if (unlikely(!from_list)) goto bad; #else from_list = PyList_New(len_imported_names); if (unlikely(!from_list)) goto bad; for (Py_ssize_t i=0; i__pyx_d, empty_dict, from_list, 1); if (unlikely(!module)) { if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError))) goto bad; PyErr_Clear(); } } level = 0; } if (!module) { module = PyImport_ImportModuleLevelObject( name, __pyx_mstate_global->__pyx_d, empty_dict, from_list, level); } bad: Py_XDECREF(from_list); Py_XDECREF(empty_dict); return module; } /* ImportFrom */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { const char* module_name_str = 0; PyObject* module_name = 0; PyObject* module_dot = 0; PyObject* full_name = 0; PyErr_Clear(); module_name_str = PyModule_GetName(module); if (unlikely(!module_name_str)) { goto modbad; } module_name = PyUnicode_FromString(module_name_str); if (unlikely(!module_name)) { goto modbad; } module_dot = PyUnicode_Concat(module_name, __pyx_mstate_global->__pyx_kp_u__2); if (unlikely(!module_dot)) { goto modbad; } full_name = PyUnicode_Concat(module_dot, name); if (unlikely(!full_name)) { goto modbad; } #if (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) ||\ CYTHON_COMPILING_IN_GRAAL { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) goto modbad; value = PyObject_GetItem(modules, full_name); } #else value = PyImport_GetModule(full_name); #endif modbad: Py_XDECREF(full_name); Py_XDECREF(module_dot); Py_XDECREF(module_name); } if (unlikely(!value)) { PyErr_Format(PyExc_ImportError, "cannot import name %S", name); } return value; } /* dict_setdefault */ static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value) { PyObject* value; #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX >= 0x030C0000 PyObject *args[] = {d, key, default_value}; value = PyObject_VectorcallMethod(__pyx_mstate_global->__pyx_n_u_setdefault, args, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); #elif CYTHON_COMPILING_IN_LIMITED_API value = PyObject_CallMethodObjArgs(d, __pyx_mstate_global->__pyx_n_u_setdefault, key, default_value, NULL); #elif PY_VERSION_HEX >= 0x030d0000 PyDict_SetDefaultRef(d, key, default_value, &value); #else value = PyDict_SetDefault(d, key, default_value); if (unlikely(!value)) return NULL; Py_INCREF(value); #endif return value; } /* AddModuleRef */ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING static PyObject *__Pyx_PyImport_AddModuleObjectRef(PyObject *name) { PyObject *module_dict = PyImport_GetModuleDict(); PyObject *m; if (PyMapping_GetOptionalItem(module_dict, name, &m) < 0) { return NULL; } if (m != NULL && PyModule_Check(m)) { return m; } Py_XDECREF(m); m = PyModule_NewObject(name); if (m == NULL) return NULL; if (PyDict_CheckExact(module_dict)) { PyObject *new_m; (void)PyDict_SetDefaultRef(module_dict, name, m, &new_m); Py_DECREF(m); return new_m; } else { if (PyObject_SetItem(module_dict, name, m) != 0) { Py_DECREF(m); return NULL; } return m; } } static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) { PyObject *py_name = PyUnicode_FromString(name); if (!py_name) return NULL; PyObject *module = __Pyx_PyImport_AddModuleObjectRef(py_name); Py_DECREF(py_name); return module; } #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name) #else static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) { PyObject *module = PyImport_AddModule(name); Py_XINCREF(module); return module; } #endif /* FetchSharedCythonModule */ static PyObject *__Pyx_FetchSharedCythonABIModule(void) { return __Pyx_PyImport_AddModuleRef(__PYX_ABI_MODULE_NAME); } /* FetchCommonType */ #if __PYX_LIMITED_VERSION_HEX < 0x030C0000 static PyObject* __Pyx_PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) { PyObject *result = __Pyx_PyType_FromModuleAndSpec(module, spec, bases); if (result && metaclass) { PyObject *old_tp = (PyObject*)Py_TYPE(result); Py_INCREF((PyObject*)metaclass); #if __PYX_LIMITED_VERSION_HEX >= 0x03090000 Py_SET_TYPE(result, metaclass); #else result->ob_type = metaclass; #endif Py_DECREF(old_tp); } return result; } #else #define __Pyx_PyType_FromMetaclass(me, mo, s, b) PyType_FromMetaclass(me, mo, s, b) #endif static int __Pyx_VerifyCachedType(PyObject *cached_type, const char *name, Py_ssize_t expected_basicsize) { Py_ssize_t basicsize; if (!PyType_Check(cached_type)) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s is not a type object", name); return -1; } if (expected_basicsize == 0) { return 0; // size is inherited, nothing useful to check } #if CYTHON_COMPILING_IN_LIMITED_API PyObject *py_basicsize; py_basicsize = PyObject_GetAttrString(cached_type, "__basicsize__"); if (unlikely(!py_basicsize)) return -1; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = NULL; if (unlikely(basicsize == (Py_ssize_t)-1) && PyErr_Occurred()) return -1; #else basicsize = ((PyTypeObject*) cached_type)->tp_basicsize; #endif if (basicsize != expected_basicsize) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s has the wrong size, try recompiling", name); return -1; } return 0; } static PyTypeObject *__Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) { PyObject *abi_module = NULL, *cached_type = NULL, *abi_module_dict, *new_cached_type, *py_object_name; int get_item_ref_result; const char* object_name = strrchr(spec->name, '.'); object_name = object_name ? object_name+1 : spec->name; py_object_name = PyUnicode_FromString(object_name); if (!py_object_name) return NULL; abi_module = __Pyx_FetchSharedCythonABIModule(); if (!abi_module) goto done; abi_module_dict = PyModule_GetDict(abi_module); if (!abi_module_dict) goto done; get_item_ref_result = __Pyx_PyDict_GetItemRef(abi_module_dict, py_object_name, &cached_type); if (get_item_ref_result == 1) { if (__Pyx_VerifyCachedType( cached_type, object_name, spec->basicsize) < 0) { goto bad; } goto done; } else if (unlikely(get_item_ref_result == -1)) { goto bad; } cached_type = __Pyx_PyType_FromMetaclass( metaclass, CYTHON_USE_MODULE_STATE ? module : abi_module, spec, bases); if (unlikely(!cached_type)) goto bad; if (unlikely(__Pyx_fix_up_extension_type_from_spec(spec, (PyTypeObject *) cached_type) < 0)) goto bad; new_cached_type = __Pyx_PyDict_SetDefault(abi_module_dict, py_object_name, cached_type); if (unlikely(new_cached_type != cached_type)) { if (unlikely(!new_cached_type)) goto bad; Py_DECREF(cached_type); cached_type = new_cached_type; if (__Pyx_VerifyCachedType( cached_type, object_name, spec->basicsize) < 0) { goto bad; } goto done; } else { Py_DECREF(new_cached_type); } done: Py_XDECREF(abi_module); Py_DECREF(py_object_name); assert(cached_type == NULL || PyType_Check(cached_type)); return (PyTypeObject *) cached_type; bad: Py_XDECREF(cached_type); cached_type = NULL; goto done; } /* CommonTypesMetaclass */ static PyObject* __pyx_CommonTypesMetaclass_get_module(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED void* context) { return PyUnicode_FromString(__PYX_ABI_MODULE_NAME); } #if __PYX_LIMITED_VERSION_HEX < 0x030A0000 static PyObject* __pyx_CommonTypesMetaclass_call(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *args, CYTHON_UNUSED PyObject *kwds) { PyErr_SetString(PyExc_TypeError, "Cannot instantiate Cython internal types"); return NULL; } static int __pyx_CommonTypesMetaclass_setattr(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *attr, CYTHON_UNUSED PyObject *value) { PyErr_SetString(PyExc_TypeError, "Cython internal types are immutable"); return -1; } #endif static PyGetSetDef __pyx_CommonTypesMetaclass_getset[] = { {"__module__", __pyx_CommonTypesMetaclass_get_module, NULL, NULL, NULL}, {0, 0, 0, 0, 0} }; static PyType_Slot __pyx_CommonTypesMetaclass_slots[] = { {Py_tp_getset, (void *)__pyx_CommonTypesMetaclass_getset}, #if __PYX_LIMITED_VERSION_HEX < 0x030A0000 {Py_tp_call, (void*)__pyx_CommonTypesMetaclass_call}, {Py_tp_new, (void*)__pyx_CommonTypesMetaclass_call}, {Py_tp_setattro, (void*)__pyx_CommonTypesMetaclass_setattr}, #endif {0, 0} }; static PyType_Spec __pyx_CommonTypesMetaclass_spec = { __PYX_TYPE_MODULE_PREFIX "_common_types_metatype", 0, 0, Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_DEFAULT, __pyx_CommonTypesMetaclass_slots }; static int __pyx_CommonTypesMetaclass_init(PyObject *module) { __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module); PyObject *bases = PyTuple_Pack(1, &PyType_Type); if (unlikely(!bases)) { return -1; } mstate->__pyx_CommonTypesMetaclassType = __Pyx_FetchCommonTypeFromSpec(NULL, module, &__pyx_CommonTypesMetaclass_spec, bases); Py_DECREF(bases); if (unlikely(mstate->__pyx_CommonTypesMetaclassType == NULL)) { return -1; } return 0; } /* PyMethodNew */ #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) { PyObject *result; CYTHON_UNUSED_VAR(typ); if (!self) return __Pyx_NewRef(func); #if __PYX_LIMITED_VERSION_HEX >= 0x030C0000 { PyObject *args[] = {func, self}; result = PyObject_Vectorcall(__pyx_mstate_global->__Pyx_CachedMethodType, args, 2, NULL); } #else result = PyObject_CallFunctionObjArgs(__pyx_mstate_global->__Pyx_CachedMethodType, func, self, NULL); #endif return result; } #else static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) { CYTHON_UNUSED_VAR(typ); if (!self) return __Pyx_NewRef(func); return PyMethod_New(func, self); } #endif /* PyVectorcallFastCallDict */ #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL static PyObject *__Pyx_PyVectorcall_FastCallDict_kw(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw) { PyObject *res = NULL; PyObject *kwnames; PyObject **newargs; PyObject **kwvalues; Py_ssize_t i; #if CYTHON_AVOID_BORROWED_REFS PyObject *pos; #else Py_ssize_t pos; #endif size_t j; PyObject *key, *value; unsigned long keys_are_strings; #if !CYTHON_ASSUME_SAFE_SIZE Py_ssize_t nkw = PyDict_Size(kw); if (unlikely(nkw == -1)) return NULL; #else Py_ssize_t nkw = PyDict_GET_SIZE(kw); #endif newargs = (PyObject **)PyMem_Malloc((nargs + (size_t)nkw) * sizeof(args[0])); if (unlikely(newargs == NULL)) { PyErr_NoMemory(); return NULL; } for (j = 0; j < nargs; j++) newargs[j] = args[j]; kwnames = PyTuple_New(nkw); if (unlikely(kwnames == NULL)) { PyMem_Free(newargs); return NULL; } kwvalues = newargs + nargs; pos = 0; i = 0; keys_are_strings = Py_TPFLAGS_UNICODE_SUBCLASS; while (__Pyx_PyDict_NextRef(kw, &pos, &key, &value)) { keys_are_strings &= #if CYTHON_COMPILING_IN_LIMITED_API PyType_GetFlags(Py_TYPE(key)); #else Py_TYPE(key)->tp_flags; #endif #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely(PyTuple_SetItem(kwnames, i, key) < 0)) goto cleanup; #else PyTuple_SET_ITEM(kwnames, i, key); #endif kwvalues[i] = value; i++; } if (unlikely(!keys_are_strings)) { PyErr_SetString(PyExc_TypeError, "keywords must be strings"); goto cleanup; } res = vc(func, newargs, nargs, kwnames); cleanup: #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(pos); #endif Py_DECREF(kwnames); for (i = 0; i < nkw; i++) Py_DECREF(kwvalues[i]); PyMem_Free(newargs); return res; } static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw) { Py_ssize_t kw_size = likely(kw == NULL) ? 0 : #if !CYTHON_ASSUME_SAFE_SIZE PyDict_Size(kw); #else PyDict_GET_SIZE(kw); #endif if (kw_size == 0) { return vc(func, args, nargs, NULL); } #if !CYTHON_ASSUME_SAFE_SIZE else if (unlikely(kw_size == -1)) { return NULL; } #endif return __Pyx_PyVectorcall_FastCallDict_kw(func, vc, args, nargs, kw); } #endif /* CythonFunctionShared */ #if CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE int __Pyx__IsSameCyOrCFunctionNoMethod(PyObject *func, void (*cfunc)(void)) { if (__Pyx_CyFunction_Check(func)) { return PyCFunction_GetFunction(((__pyx_CyFunctionObject*)func)->func) == (PyCFunction) cfunc; } else if (PyCFunction_Check(func)) { return PyCFunction_GetFunction(func) == (PyCFunction) cfunc; } return 0; } static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) { if ((PyObject*)Py_TYPE(func) == __pyx_mstate_global->__Pyx_CachedMethodType) { int result; PyObject *newFunc = PyObject_GetAttr(func, __pyx_mstate_global->__pyx_n_u_func); if (unlikely(!newFunc)) { PyErr_Clear(); // It's only an optimization, so don't throw an error return 0; } result = __Pyx__IsSameCyOrCFunctionNoMethod(newFunc, cfunc); Py_DECREF(newFunc); return result; } return __Pyx__IsSameCyOrCFunctionNoMethod(func, cfunc); } #else static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) { if (PyMethod_Check(func)) { func = PyMethod_GET_FUNCTION(func); } return __Pyx_CyOrPyCFunction_Check(func) && __Pyx_CyOrPyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; } #endif static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) { #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API __Pyx_Py_XDECREF_SET( __Pyx_CyFunction_GetClassObj(f), ((classobj) ? __Pyx_NewRef(classobj) : NULL)); #else __Pyx_Py_XDECREF_SET( ((PyCMethodObject *) (f))->mm_class, (PyTypeObject*)((classobj) ? __Pyx_NewRef(classobj) : NULL)); #endif } static PyObject * __Pyx_CyFunction_get_doc_locked(__pyx_CyFunctionObject *op) { if (unlikely(op->func_doc == NULL)) { #if CYTHON_COMPILING_IN_LIMITED_API op->func_doc = PyObject_GetAttrString(op->func, "__doc__"); if (unlikely(!op->func_doc)) return NULL; #else if (((PyCFunctionObject*)op)->m_ml->ml_doc) { op->func_doc = PyUnicode_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc); if (unlikely(op->func_doc == NULL)) return NULL; } else { Py_INCREF(Py_None); return Py_None; } #endif } Py_INCREF(op->func_doc); return op->func_doc; } static PyObject * __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, void *closure) { PyObject *result; CYTHON_UNUSED_VAR(closure); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_doc_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); if (value == NULL) { value = Py_None; } Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->func_doc, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_name_locked(__pyx_CyFunctionObject *op) { if (unlikely(op->func_name == NULL)) { #if CYTHON_COMPILING_IN_LIMITED_API op->func_name = PyObject_GetAttrString(op->func, "__name__"); #else op->func_name = PyUnicode_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name); #endif if (unlikely(op->func_name == NULL)) return NULL; } Py_INCREF(op->func_name); return op->func_name; } static PyObject * __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, void *context) { PyObject *result = NULL; CYTHON_UNUSED_VAR(context); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_name_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(value == NULL || !PyUnicode_Check(value))) { PyErr_SetString(PyExc_TypeError, "__name__ must be set to a string object"); return -1; } Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->func_name, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); PyObject *result; __Pyx_BEGIN_CRITICAL_SECTION(op); Py_INCREF(op->func_qualname); result = op->func_qualname; __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(value == NULL || !PyUnicode_Check(value))) { PyErr_SetString(PyExc_TypeError, "__qualname__ must be set to a string object"); return -1; } Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->func_qualname, value); __Pyx_END_CRITICAL_SECTION(); return 0; } #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 static PyObject * __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(op->func_dict == NULL)) { op->func_dict = PyDict_New(); if (unlikely(op->func_dict == NULL)) return NULL; } Py_INCREF(op->func_dict); return op->func_dict; } #endif static PyObject * __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); Py_INCREF(op->func_globals); return op->func_globals; } static PyObject * __Pyx_CyFunction_get_closure(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(op); CYTHON_UNUSED_VAR(context); Py_INCREF(Py_None); return Py_None; } static PyObject * __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, void *context) { PyObject* result = (op->func_code) ? op->func_code : Py_None; CYTHON_UNUSED_VAR(context); Py_INCREF(result); return result; } static int __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { int result = 0; PyObject *res = op->defaults_getter((PyObject *) op); if (unlikely(!res)) return -1; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS op->defaults_tuple = PyTuple_GET_ITEM(res, 0); Py_INCREF(op->defaults_tuple); op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); Py_INCREF(op->defaults_kwdict); #else op->defaults_tuple = __Pyx_PySequence_ITEM(res, 0); if (unlikely(!op->defaults_tuple)) result = -1; else { op->defaults_kwdict = __Pyx_PySequence_ITEM(res, 1); if (unlikely(!op->defaults_kwdict)) result = -1; } #endif Py_DECREF(res); return result; } static int __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value) { value = Py_None; } else if (unlikely(value != Py_None && !PyTuple_Check(value))) { PyErr_SetString(PyExc_TypeError, "__defaults__ must be set to a tuple object"); return -1; } PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__defaults__ will not " "currently affect the values used in function calls", 1); Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->defaults_tuple, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_defaults_locked(__pyx_CyFunctionObject *op) { PyObject* result = op->defaults_tuple; if (unlikely(!result)) { if (op->defaults_getter) { if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL; result = op->defaults_tuple; } else { result = Py_None; } } Py_INCREF(result); return result; } static PyObject * __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, void *context) { PyObject* result = NULL; CYTHON_UNUSED_VAR(context); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_defaults_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value) { value = Py_None; } else if (unlikely(value != Py_None && !PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "__kwdefaults__ must be set to a dict object"); return -1; } PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__kwdefaults__ will not " "currently affect the values used in function calls", 1); Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->defaults_kwdict, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_kwdefaults_locked(__pyx_CyFunctionObject *op) { PyObject* result = op->defaults_kwdict; if (unlikely(!result)) { if (op->defaults_getter) { if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL; result = op->defaults_kwdict; } else { result = Py_None; } } Py_INCREF(result); return result; } static PyObject * __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, void *context) { PyObject* result; CYTHON_UNUSED_VAR(context); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_kwdefaults_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value || value == Py_None) { value = NULL; } else if (unlikely(!PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "__annotations__ must be set to a dict object"); return -1; } Py_XINCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->func_annotations, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_annotations_locked(__pyx_CyFunctionObject *op) { PyObject* result = op->func_annotations; if (unlikely(!result)) { result = PyDict_New(); if (unlikely(!result)) return NULL; op->func_annotations = result; } Py_INCREF(result); return result; } static PyObject * __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, void *context) { PyObject *result; CYTHON_UNUSED_VAR(context); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_annotations_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static PyObject * __Pyx_CyFunction_get_is_coroutine_value(__pyx_CyFunctionObject *op) { int is_coroutine = op->flags & __Pyx_CYFUNCTION_COROUTINE; if (is_coroutine) { PyObject *is_coroutine_value, *module, *fromlist, *marker = __pyx_mstate_global->__pyx_n_u_is_coroutine; fromlist = PyList_New(1); if (unlikely(!fromlist)) return NULL; Py_INCREF(marker); #if CYTHON_ASSUME_SAFE_MACROS PyList_SET_ITEM(fromlist, 0, marker); #else if (unlikely(PyList_SetItem(fromlist, 0, marker) < 0)) { Py_DECREF(marker); Py_DECREF(fromlist); return NULL; } #endif module = PyImport_ImportModuleLevelObject(__pyx_mstate_global->__pyx_n_u_asyncio_coroutines, NULL, NULL, fromlist, 0); Py_DECREF(fromlist); if (unlikely(!module)) goto ignore; is_coroutine_value = __Pyx_PyObject_GetAttrStr(module, marker); Py_DECREF(module); if (likely(is_coroutine_value)) { return is_coroutine_value; } ignore: PyErr_Clear(); } return __Pyx_PyBool_FromLong(is_coroutine); } static PyObject * __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) { PyObject *result; CYTHON_UNUSED_VAR(context); if (op->func_is_coroutine) { return __Pyx_NewRef(op->func_is_coroutine); } result = __Pyx_CyFunction_get_is_coroutine_value(op); if (unlikely(!result)) return NULL; __Pyx_BEGIN_CRITICAL_SECTION(op); if (op->func_is_coroutine) { Py_DECREF(result); result = __Pyx_NewRef(op->func_is_coroutine); } else { op->func_is_coroutine = __Pyx_NewRef(result); } __Pyx_END_CRITICAL_SECTION(); return result; } static void __Pyx_CyFunction_raise_argument_count_error(__pyx_CyFunctionObject *func, const char* message, Py_ssize_t size) { #if CYTHON_COMPILING_IN_LIMITED_API PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL); if (!py_name) return; PyErr_Format(PyExc_TypeError, "%.200S() %s (%" CYTHON_FORMAT_SSIZE_T "d given)", py_name, message, size); Py_DECREF(py_name); #else const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name; PyErr_Format(PyExc_TypeError, "%.200s() %s (%" CYTHON_FORMAT_SSIZE_T "d given)", name, message, size); #endif } static void __Pyx_CyFunction_raise_type_error(__pyx_CyFunctionObject *func, const char* message) { #if CYTHON_COMPILING_IN_LIMITED_API PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL); if (!py_name) return; PyErr_Format(PyExc_TypeError, "%.200S() %s", py_name, message); Py_DECREF(py_name); #else const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name; PyErr_Format(PyExc_TypeError, "%.200s() %s", name, message); #endif } #if CYTHON_COMPILING_IN_LIMITED_API static PyObject * __Pyx_CyFunction_get_module(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); return PyObject_GetAttrString(op->func, "__module__"); } static int __Pyx_CyFunction_set_module(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); return PyObject_SetAttrString(op->func, "__module__", value); } #endif static PyGetSetDef __pyx_CyFunction_getsets[] = { {"func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {"__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {"func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {"__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {"__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 {"func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0}, {"__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0}, #else {"func_dict", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0}, {"__dict__", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0}, #endif {"func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {"__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {"func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {"__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {"func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {"__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {"func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {"__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {"__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, {"__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, {"_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0}, #if CYTHON_COMPILING_IN_LIMITED_API {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0}, #endif {0, 0, 0, 0, 0} }; static PyMemberDef __pyx_CyFunction_members[] = { #if !CYTHON_COMPILING_IN_LIMITED_API {"__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0}, #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API {"__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict), READONLY, 0}, #endif #if CYTHON_METH_FASTCALL #if CYTHON_COMPILING_IN_LIMITED_API {"__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall), READONLY, 0}, #else {"__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0}, #endif #if CYTHON_COMPILING_IN_LIMITED_API {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist), READONLY, 0}, #else {"__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0}, #endif #endif {0, 0, 0, 0, 0} }; static PyObject * __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, PyObject *args) { PyObject *result = NULL; CYTHON_UNUSED_VAR(args); __Pyx_BEGIN_CRITICAL_SECTION(m); Py_INCREF(m->func_qualname); result = m->func_qualname; __Pyx_END_CRITICAL_SECTION(); return result; } static PyMethodDef __pyx_CyFunction_methods[] = { {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, {0, 0, 0, 0} }; #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) #else #define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist) #endif static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { #if !CYTHON_COMPILING_IN_LIMITED_API PyCFunctionObject *cf = (PyCFunctionObject*) op; #endif if (unlikely(op == NULL)) return NULL; #if CYTHON_COMPILING_IN_LIMITED_API op->func = PyCFunction_NewEx(ml, (PyObject*)op, module); if (unlikely(!op->func)) return NULL; #endif op->flags = flags; __Pyx_CyFunction_weakreflist(op) = NULL; #if !CYTHON_COMPILING_IN_LIMITED_API cf->m_ml = ml; cf->m_self = (PyObject *) op; #endif Py_XINCREF(closure); op->func_closure = closure; #if !CYTHON_COMPILING_IN_LIMITED_API Py_XINCREF(module); cf->m_module = module; #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API op->func_dict = NULL; #endif op->func_name = NULL; Py_INCREF(qualname); op->func_qualname = qualname; op->func_doc = NULL; #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API op->func_classobj = NULL; #else ((PyCMethodObject*)op)->mm_class = NULL; #endif op->func_globals = globals; Py_INCREF(op->func_globals); Py_XINCREF(code); op->func_code = code; op->defaults = NULL; op->defaults_tuple = NULL; op->defaults_kwdict = NULL; op->defaults_getter = NULL; op->func_annotations = NULL; op->func_is_coroutine = NULL; #if CYTHON_METH_FASTCALL switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) { case METH_NOARGS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_NOARGS; break; case METH_O: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_O; break; case METH_METHOD | METH_FASTCALL | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD; break; case METH_FASTCALL | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS; break; case METH_VARARGS | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = NULL; break; default: PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction"); Py_DECREF(op); return NULL; } #endif return (PyObject *) op; } static int __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) { Py_CLEAR(m->func_closure); #if CYTHON_COMPILING_IN_LIMITED_API Py_CLEAR(m->func); #else Py_CLEAR(((PyCFunctionObject*)m)->m_module); #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API Py_CLEAR(m->func_dict); #elif PY_VERSION_HEX < 0x030d0000 _PyObject_ClearManagedDict((PyObject*)m); #else PyObject_ClearManagedDict((PyObject*)m); #endif Py_CLEAR(m->func_name); Py_CLEAR(m->func_qualname); Py_CLEAR(m->func_doc); Py_CLEAR(m->func_globals); Py_CLEAR(m->func_code); #if !CYTHON_COMPILING_IN_LIMITED_API #if PY_VERSION_HEX < 0x030900B1 Py_CLEAR(__Pyx_CyFunction_GetClassObj(m)); #else { PyObject *cls = (PyObject*) ((PyCMethodObject *) (m))->mm_class; ((PyCMethodObject *) (m))->mm_class = NULL; Py_XDECREF(cls); } #endif #endif Py_CLEAR(m->defaults_tuple); Py_CLEAR(m->defaults_kwdict); Py_CLEAR(m->func_annotations); Py_CLEAR(m->func_is_coroutine); Py_CLEAR(m->defaults); return 0; } static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m) { if (__Pyx_CyFunction_weakreflist(m) != NULL) PyObject_ClearWeakRefs((PyObject *) m); __Pyx_CyFunction_clear(m); __Pyx_PyHeapTypeObject_GC_Del(m); } static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) { PyObject_GC_UnTrack(m); __Pyx__CyFunction_dealloc(m); } static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) { { int e = __Pyx_call_type_traverse((PyObject*)m, 1, visit, arg); if (e) return e; } Py_VISIT(m->func_closure); #if CYTHON_COMPILING_IN_LIMITED_API Py_VISIT(m->func); #else Py_VISIT(((PyCFunctionObject*)m)->m_module); #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API Py_VISIT(m->func_dict); #else { int e = #if PY_VERSION_HEX < 0x030d0000 _PyObject_VisitManagedDict #else PyObject_VisitManagedDict #endif ((PyObject*)m, visit, arg); if (e != 0) return e; } #endif __Pyx_VISIT_CONST(m->func_name); __Pyx_VISIT_CONST(m->func_qualname); Py_VISIT(m->func_doc); Py_VISIT(m->func_globals); __Pyx_VISIT_CONST(m->func_code); #if !CYTHON_COMPILING_IN_LIMITED_API Py_VISIT(__Pyx_CyFunction_GetClassObj(m)); #endif Py_VISIT(m->defaults_tuple); Py_VISIT(m->defaults_kwdict); Py_VISIT(m->func_is_coroutine); Py_VISIT(m->defaults); return 0; } static PyObject* __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) { PyObject *repr; __Pyx_BEGIN_CRITICAL_SECTION(op); repr = PyUnicode_FromFormat("", op->func_qualname, (void *)op); __Pyx_END_CRITICAL_SECTION(); return repr; } static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { #if CYTHON_COMPILING_IN_LIMITED_API PyObject *f = ((__pyx_CyFunctionObject*)func)->func; PyCFunction meth; int flags; meth = PyCFunction_GetFunction(f); if (unlikely(!meth)) return NULL; flags = PyCFunction_GetFlags(f); if (unlikely(flags < 0)) return NULL; #else PyCFunctionObject* f = (PyCFunctionObject*)func; PyCFunction meth = f->m_ml->ml_meth; int flags = f->m_ml->ml_flags; #endif Py_ssize_t size; switch (flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { case METH_VARARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) return (*meth)(self, arg); break; case METH_VARARGS | METH_KEYWORDS: return (*(PyCFunctionWithKeywords)(void(*)(void))meth)(self, arg, kw); case METH_NOARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { #if CYTHON_ASSUME_SAFE_SIZE size = PyTuple_GET_SIZE(arg); #else size = PyTuple_Size(arg); if (unlikely(size < 0)) return NULL; #endif if (likely(size == 0)) return (*meth)(self, NULL); __Pyx_CyFunction_raise_argument_count_error( (__pyx_CyFunctionObject*)func, "takes no arguments", size); return NULL; } break; case METH_O: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { #if CYTHON_ASSUME_SAFE_SIZE size = PyTuple_GET_SIZE(arg); #else size = PyTuple_Size(arg); if (unlikely(size < 0)) return NULL; #endif if (likely(size == 1)) { PyObject *result, *arg0; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS arg0 = PyTuple_GET_ITEM(arg, 0); #else arg0 = __Pyx_PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; #endif result = (*meth)(self, arg0); #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) Py_DECREF(arg0); #endif return result; } __Pyx_CyFunction_raise_argument_count_error( (__pyx_CyFunctionObject*)func, "takes exactly one argument", size); return NULL; } break; default: PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction"); return NULL; } __Pyx_CyFunction_raise_type_error( (__pyx_CyFunctionObject*)func, "takes no keyword arguments"); return NULL; } static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *self, *result; #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)func)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)func)->m_self; #endif result = __Pyx_CyFunction_CallMethod(func, self, arg, kw); return result; } static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { PyObject *result; __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc); if (vc) { #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw); #else (void) &__Pyx_PyVectorcall_FastCallDict; return PyVectorcall_Call(func, args, kw); #endif } #endif if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { Py_ssize_t argc; PyObject *new_args; PyObject *self; #if CYTHON_ASSUME_SAFE_SIZE argc = PyTuple_GET_SIZE(args); #else argc = PyTuple_Size(args); if (unlikely(argc < 0)) return NULL; #endif new_args = PyTuple_GetSlice(args, 1, argc); if (unlikely(!new_args)) return NULL; self = PyTuple_GetItem(args, 0); if (unlikely(!self)) { Py_DECREF(new_args); PyErr_Format(PyExc_TypeError, "unbound method %.200S() needs an argument", cyfunc->func_qualname); return NULL; } result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); Py_DECREF(new_args); } else { result = __Pyx_CyFunction_Call(func, args, kw); } return result; } #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(__pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames) { int ret = 0; if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { if (unlikely(nargs < 1)) { __Pyx_CyFunction_raise_type_error( cyfunc, "needs an argument"); return -1; } ret = 1; } if (unlikely(kwnames) && unlikely(__Pyx_PyTuple_GET_SIZE(kwnames))) { __Pyx_CyFunction_raise_type_error( cyfunc, "takes no keyword arguments"); return -1; } return ret; } static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); PyObject *self; #if CYTHON_COMPILING_IN_LIMITED_API PyCFunction meth = PyCFunction_GetFunction(cyfunc->func); if (unlikely(!meth)) return NULL; #else PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth; #endif switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)cyfunc)->m_self; #endif break; default: return NULL; } if (unlikely(nargs != 0)) { __Pyx_CyFunction_raise_argument_count_error( cyfunc, "takes no arguments", nargs); return NULL; } return meth(self, NULL); } static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); PyObject *self; #if CYTHON_COMPILING_IN_LIMITED_API PyCFunction meth = PyCFunction_GetFunction(cyfunc->func); if (unlikely(!meth)) return NULL; #else PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth; #endif switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)cyfunc)->m_self; #endif break; default: return NULL; } if (unlikely(nargs != 1)) { __Pyx_CyFunction_raise_argument_count_error( cyfunc, "takes exactly one argument", nargs); return NULL; } return meth(self, args[0]); } static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); PyObject *self; #if CYTHON_COMPILING_IN_LIMITED_API PyCFunction meth = PyCFunction_GetFunction(cyfunc->func); if (unlikely(!meth)) return NULL; #else PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth; #endif switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)cyfunc)->m_self; #endif break; default: return NULL; } return ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))meth)(self, args, nargs, kwnames); } static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; PyTypeObject *cls = (PyTypeObject *) __Pyx_CyFunction_GetClassObj(cyfunc); Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); PyObject *self; #if CYTHON_COMPILING_IN_LIMITED_API PyCFunction meth = PyCFunction_GetFunction(cyfunc->func); if (unlikely(!meth)) return NULL; #else PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth; #endif switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)cyfunc)->m_self; #endif break; default: return NULL; } #if PY_VERSION_HEX < 0x030e00A6 size_t nargs_value = (size_t) nargs; #else Py_ssize_t nargs_value = nargs; #endif return ((__Pyx_PyCMethod)(void(*)(void))meth)(self, cls, args, nargs_value, kwnames); } #endif static PyType_Slot __pyx_CyFunctionType_slots[] = { {Py_tp_dealloc, (void *)__Pyx_CyFunction_dealloc}, {Py_tp_repr, (void *)__Pyx_CyFunction_repr}, {Py_tp_call, (void *)__Pyx_CyFunction_CallAsMethod}, {Py_tp_traverse, (void *)__Pyx_CyFunction_traverse}, {Py_tp_clear, (void *)__Pyx_CyFunction_clear}, {Py_tp_methods, (void *)__pyx_CyFunction_methods}, {Py_tp_members, (void *)__pyx_CyFunction_members}, {Py_tp_getset, (void *)__pyx_CyFunction_getsets}, {Py_tp_descr_get, (void *)__Pyx_PyMethod_New}, {0, 0}, }; static PyType_Spec __pyx_CyFunctionType_spec = { __PYX_TYPE_MODULE_PREFIX "cython_function_or_method", sizeof(__pyx_CyFunctionObject), 0, #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR Py_TPFLAGS_METHOD_DESCRIPTOR | #endif #if CYTHON_METH_FASTCALL #if defined(Py_TPFLAGS_HAVE_VECTORCALL) Py_TPFLAGS_HAVE_VECTORCALL | #elif defined(_Py_TPFLAGS_HAVE_VECTORCALL) _Py_TPFLAGS_HAVE_VECTORCALL | #endif #endif // CYTHON_METH_FASTCALL #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API Py_TPFLAGS_MANAGED_DICT | #endif Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, __pyx_CyFunctionType_slots }; static int __pyx_CyFunction_init(PyObject *module) { __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module); mstate->__pyx_CyFunctionType = __Pyx_FetchCommonTypeFromSpec( mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_CyFunctionType_spec, NULL); if (unlikely(mstate->__pyx_CyFunctionType == NULL)) { return -1; } return 0; } static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults = PyObject_CallObject((PyObject*)defaults_type, NULL); // _PyObject_New(defaults_type); if (unlikely(!m->defaults)) return NULL; return m->defaults; } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_tuple = tuple; Py_INCREF(tuple); } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_kwdict = dict; Py_INCREF(dict); } static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->func_annotations = dict; Py_INCREF(dict); } /* CythonFunction */ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { PyObject *op = __Pyx_CyFunction_Init( PyObject_GC_New(__pyx_CyFunctionObject, __pyx_mstate_global->__pyx_CyFunctionType), ml, flags, qualname, closure, module, globals, code ); if (likely(op)) { PyObject_GC_Track(op); } return op; } /* CLineInTraceback */ #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 #define __Pyx_PyProbablyModule_GetDict(o) __Pyx_XNewRef(PyModule_GetDict(o)) #elif !CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #define __Pyx_PyProbablyModule_GetDict(o) PyObject_GenericGetDict(o, NULL); #else PyObject* __Pyx_PyProbablyModule_GetDict(PyObject *o) { PyObject **dict_ptr = _PyObject_GetDictPtr(o); return dict_ptr ? __Pyx_XNewRef(*dict_ptr) : NULL; } #endif static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) { PyObject *use_cline = NULL; PyObject *ptype, *pvalue, *ptraceback; PyObject *cython_runtime_dict; CYTHON_MAYBE_UNUSED_VAR(tstate); if (unlikely(!__pyx_mstate_global->__pyx_cython_runtime)) { return c_line; } __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); cython_runtime_dict = __Pyx_PyProbablyModule_GetDict(__pyx_mstate_global->__pyx_cython_runtime); if (likely(cython_runtime_dict)) { __PYX_PY_DICT_LOOKUP_IF_MODIFIED( use_cline, cython_runtime_dict, __Pyx_PyDict_SetDefault(cython_runtime_dict, __pyx_mstate_global->__pyx_n_u_cline_in_traceback, Py_False)) } if (use_cline == NULL || use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { c_line = 0; } Py_XDECREF(use_cline); Py_XDECREF(cython_runtime_dict); __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); return c_line; } #endif /* CodeObjectCache */ static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static __Pyx_CachedCodeObjectType *__pyx__find_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line) { __Pyx_CachedCodeObjectType* code_object; int pos; if (unlikely(!code_line) || unlikely(!code_cache->entries)) { return NULL; } pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line); if (unlikely(pos >= code_cache->count) || unlikely(code_cache->entries[pos].code_line != code_line)) { return NULL; } code_object = code_cache->entries[pos].code_object; Py_INCREF(code_object); return code_object; } static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS (void)__pyx__find_code_object; return NULL; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just miss. #else struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_nonatomic_int_type old_count = __pyx_atomic_incr_acq_rel(&code_cache->accessor_count); if (old_count < 0) { __pyx_atomic_decr_acq_rel(&code_cache->accessor_count); return NULL; } #endif __Pyx_CachedCodeObjectType *result = __pyx__find_code_object(code_cache, code_line); #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_atomic_decr_acq_rel(&code_cache->accessor_count); #endif return result; #endif } static void __pyx__insert_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line, __Pyx_CachedCodeObjectType* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = code_cache->entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { code_cache->entries = entries; code_cache->max_count = 64; code_cache->count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line); if ((pos < code_cache->count) && unlikely(code_cache->entries[pos].code_line == code_line)) { __Pyx_CachedCodeObjectType* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_INCREF(code_object); Py_DECREF(tmp); return; } if (code_cache->count == code_cache->max_count) { int new_max = code_cache->max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( code_cache->entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } code_cache->entries = entries; code_cache->max_count = new_max; } for (i=code_cache->count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; code_cache->count++; Py_INCREF(code_object); } static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS (void)__pyx__insert_code_object; return; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just fail. #else struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_nonatomic_int_type expected = 0; if (!__pyx_atomic_int_cmp_exchange(&code_cache->accessor_count, &expected, INT_MIN)) { return; } #endif __pyx__insert_code_object(code_cache, code_line, code_object); #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_atomic_sub(&code_cache->accessor_count, INT_MIN); #endif #endif } /* AddTraceback */ #include "compile.h" #include "frameobject.h" #include "traceback.h" #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION) #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif #include "internal/pycore_frame.h" #endif #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict, PyObject *firstlineno, PyObject *name) { PyObject *replace = NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL; replace = PyObject_GetAttrString(code, "replace"); if (likely(replace)) { PyObject *result = PyObject_Call(replace, __pyx_mstate_global->__pyx_empty_tuple, scratch_dict); Py_DECREF(replace); return result; } PyErr_Clear(); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL; PyObject *replace = NULL, *getframe = NULL, *frame = NULL; PyObject *exc_type, *exc_value, *exc_traceback; int success = 0; if (c_line) { c_line = __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line); } PyErr_Fetch(&exc_type, &exc_value, &exc_traceback); code_object = __pyx_find_code_object(c_line ? -c_line : py_line); if (!code_object) { code_object = Py_CompileString("_getframe()", filename, Py_eval_input); if (unlikely(!code_object)) goto bad; py_py_line = PyLong_FromLong(py_line); if (unlikely(!py_py_line)) goto bad; if (c_line) { py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); } else { py_funcname = PyUnicode_FromString(funcname); } if (unlikely(!py_funcname)) goto bad; dict = PyDict_New(); if (unlikely(!dict)) goto bad; { PyObject *old_code_object = code_object; code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname); Py_DECREF(old_code_object); } if (unlikely(!code_object)) goto bad; __pyx_insert_code_object(c_line ? -c_line : py_line, code_object); } else { dict = PyDict_New(); } getframe = PySys_GetObject("_getframe"); if (unlikely(!getframe)) goto bad; if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad; frame = PyEval_EvalCode(code_object, dict, dict); if (unlikely(!frame) || frame == Py_None) goto bad; success = 1; bad: PyErr_Restore(exc_type, exc_value, exc_traceback); Py_XDECREF(code_object); Py_XDECREF(py_py_line); Py_XDECREF(py_funcname); Py_XDECREF(dict); Py_XDECREF(replace); if (success) { PyTraceBack_Here( (struct _frame*)frame); } Py_XDECREF(frame); } #else static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = NULL; PyObject *py_funcname = NULL; if (c_line) { py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); if (!py_funcname) goto bad; funcname = PyUnicode_AsUTF8(py_funcname); if (!funcname) goto bad; } py_code = PyCode_NewEmpty(filename, funcname, py_line); Py_XDECREF(py_funcname); return py_code; bad: Py_XDECREF(py_funcname); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject *ptype, *pvalue, *ptraceback; if (c_line) { c_line = __Pyx_CLineForTraceback(tstate, c_line); } py_code = __pyx_find_code_object(c_line ? -c_line : py_line); if (!py_code) { __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) { /* If the code object creation fails, then we should clear the fetched exception references and propagate the new exception */ Py_XDECREF(ptype); Py_XDECREF(pvalue); Py_XDECREF(ptraceback); goto bad; } __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); } py_frame = PyFrame_New( tstate, /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_mstate_global->__pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } #endif /* CIntFromPyVerify */ #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } /* CheckUnpickleChecksum */ static void __Pyx_RaiseUnpickleChecksumError(long checksum, long checksum1, long checksum2, long checksum3, const char *members) { PyObject *pickle_module = PyImport_ImportModule("pickle"); if (unlikely(!pickle_module)) return; PyObject *pickle_error = PyObject_GetAttrString(pickle_module, "PickleError"); Py_DECREF(pickle_module); if (unlikely(!pickle_error)) return; if (checksum2 == checksum1) { PyErr_Format(pickle_error, "Incompatible checksums (0x%x vs (0x%x) = (%s))", checksum, checksum1, members); } else if (checksum3 == checksum2) { PyErr_Format(pickle_error, "Incompatible checksums (0x%x vs (0x%x, 0x%x) = (%s))", checksum, checksum1, checksum2, members); } else { PyErr_Format(pickle_error, "Incompatible checksums (0x%x vs (0x%x, 0x%x, 0x%x) = (%s))", checksum, checksum1, checksum2, checksum3, members); } Py_DECREF(pickle_error); } static int __Pyx_CheckUnpickleChecksum(long checksum, long checksum1, long checksum2, long checksum3, const char *members) { int found = 0; found |= checksum1 == checksum; found |= checksum2 == checksum; found |= checksum3 == checksum; if (likely(found)) return 0; __Pyx_RaiseUnpickleChecksumError(checksum, checksum1, checksum2, checksum3, members); return -1; } /* PyObjectVectorCallKwBuilder */ #if CYTHON_VECTORCALL static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) { (void)__Pyx_PyObject_FastCallDict; if (__Pyx_PyTuple_SET_ITEM(builder, n, key) != (0)) return -1; Py_INCREF(key); args[n] = value; return 0; } CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) { (void)__Pyx_VectorcallBuilder_AddArgStr; if (unlikely(!PyUnicode_Check(key))) { PyErr_SetString(PyExc_TypeError, "keywords must be strings"); return -1; } return __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n); } static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n) { PyObject *pyKey = PyUnicode_FromString(key); if (!pyKey) return -1; return __Pyx_VectorcallBuilder_AddArg(pyKey, value, builder, args, n); } #else // CYTHON_VECTORCALL CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, CYTHON_UNUSED PyObject **args, CYTHON_UNUSED int n) { if (unlikely(!PyUnicode_Check(key))) { PyErr_SetString(PyExc_TypeError, "keywords must be strings"); return -1; } return PyDict_SetItem(builder, key, value); } #endif /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) -1, const_zero = (unsigned PY_LONG_LONG) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(unsigned PY_LONG_LONG) < sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #if !CYTHON_COMPILING_IN_PYPY } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(unsigned PY_LONG_LONG) <= sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4 if (is_unsigned) { return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1); } else { return PyLong_FromNativeBytes(bytes, sizeof(value), -1); } #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 int one = 1; int little = (int)*(unsigned char *)&one; return _PyLong_FromByteArray(bytes, sizeof(unsigned PY_LONG_LONG), little, !is_unsigned); #else int one = 1; int little = (int)*(unsigned char *)&one; PyObject *from_bytes, *result = NULL, *kwds = NULL; PyObject *py_bytes = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(unsigned PY_LONG_LONG)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; { PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str }; if (!is_unsigned) { kwds = __Pyx_MakeVectorcallBuilderKwds(1); if (!kwds) goto limited_bad; if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad; } result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds); } limited_bad: Py_XDECREF(kwds); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* CIntFromPy */ static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyLong_As_unsigned_PY_LONG_LONG(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) -1, const_zero = (unsigned PY_LONG_LONG) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (unlikely(!PyLong_Check(x))) { unsigned PY_LONG_LONG val; PyObject *tmp = __Pyx_PyNumber_Long(x); if (!tmp) return (unsigned PY_LONG_LONG) -1; val = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(tmp); Py_DECREF(tmp); return val; } if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) >= 2 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); } } break; case 3: if ((8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) >= 3 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); } } break; case 4: if ((8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) >= 4 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (unsigned PY_LONG_LONG) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned long, PyLong_AsUnsignedLong(x)) } else if ((sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case 2: if ((8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) ((((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case -3: if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case 3: if ((8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) ((((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case -4: if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case 4: if ((8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) ((((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; } } #endif if ((sizeof(unsigned PY_LONG_LONG) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, long, PyLong_AsLong(x)) } else if ((sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { unsigned PY_LONG_LONG val; int ret = -1; #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API Py_ssize_t bytes_copied = PyLong_AsNativeBytes( x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0)); if (unlikely(bytes_copied == -1)) { } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) { goto raise_overflow; } else { ret = 0; } #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)x, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *v; PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (likely(PyLong_CheckExact(x))) { v = __Pyx_NewRef(x); } else { v = PyNumber_Long(x); if (unlikely(!v)) return (unsigned PY_LONG_LONG) -1; assert(PyLong_CheckExact(v)); } { int result = PyObject_RichCompareBool(v, Py_False, Py_LT); if (unlikely(result < 0)) { Py_DECREF(v); return (unsigned PY_LONG_LONG) -1; } is_negative = result == 1; } if (is_unsigned && unlikely(is_negative)) { Py_DECREF(v); goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); Py_DECREF(v); if (unlikely(!stepval)) return (unsigned PY_LONG_LONG) -1; } else { stepval = v; } v = NULL; val = (unsigned PY_LONG_LONG) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(unsigned PY_LONG_LONG) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; long idigit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; val |= ((unsigned PY_LONG_LONG) idigit) << bits; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; } Py_DECREF(shift); shift = NULL; Py_DECREF(mask); mask = NULL; { long idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(unsigned PY_LONG_LONG) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((unsigned PY_LONG_LONG) idigit) << bits; } if (!is_unsigned) { if (unlikely(val & (((unsigned PY_LONG_LONG) 1) << (sizeof(unsigned PY_LONG_LONG) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif if (unlikely(ret)) return (unsigned PY_LONG_LONG) -1; return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned PY_LONG_LONG"); return (unsigned PY_LONG_LONG) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to unsigned PY_LONG_LONG"); return (unsigned PY_LONG_LONG) -1; } /* CIntFromPy */ static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (unlikely(!PyLong_Check(x))) { long val; PyObject *tmp = __Pyx_PyNumber_Long(x); if (!tmp) return (long) -1; val = __Pyx_PyLong_As_long(tmp); Py_DECREF(tmp); return val; } if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(long) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } } #endif if ((sizeof(long) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { long val; int ret = -1; #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API Py_ssize_t bytes_copied = PyLong_AsNativeBytes( x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0)); if (unlikely(bytes_copied == -1)) { } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) { goto raise_overflow; } else { ret = 0; } #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)x, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *v; PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (likely(PyLong_CheckExact(x))) { v = __Pyx_NewRef(x); } else { v = PyNumber_Long(x); if (unlikely(!v)) return (long) -1; assert(PyLong_CheckExact(v)); } { int result = PyObject_RichCompareBool(v, Py_False, Py_LT); if (unlikely(result < 0)) { Py_DECREF(v); return (long) -1; } is_negative = result == 1; } if (is_unsigned && unlikely(is_negative)) { Py_DECREF(v); goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); Py_DECREF(v); if (unlikely(!stepval)) return (long) -1; } else { stepval = v; } v = NULL; val = (long) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; long idigit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; val |= ((long) idigit) << bits; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; } Py_DECREF(shift); shift = NULL; Py_DECREF(mask); mask = NULL; { long idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((long) idigit) << bits; } if (!is_unsigned) { if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif if (unlikely(ret)) return (long) -1; return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #if !CYTHON_COMPILING_IN_PYPY } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(long) <= sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4 if (is_unsigned) { return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1); } else { return PyLong_FromNativeBytes(bytes, sizeof(value), -1); } #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 int one = 1; int little = (int)*(unsigned char *)&one; return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); #else int one = 1; int little = (int)*(unsigned char *)&one; PyObject *from_bytes, *result = NULL, *kwds = NULL; PyObject *py_bytes = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(long)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; { PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str }; if (!is_unsigned) { kwds = __Pyx_MakeVectorcallBuilderKwds(1); if (!kwds) goto limited_bad; if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad; } result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds); } limited_bad: Py_XDECREF(kwds); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* PyObjectCall2Args */ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { PyObject *args[3] = {NULL, arg1, arg2}; return __Pyx_PyObject_FastCall(function, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } /* PyObjectCallMethod1 */ #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))) static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) { PyObject *result = __Pyx_PyObject_CallOneArg(method, arg); Py_DECREF(method); return result; } #endif static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)) PyObject *args[2] = {obj, arg}; (void) __Pyx_PyObject_CallOneArg; (void) __Pyx_PyObject_Call2Args; return PyObject_VectorcallMethod(method_name, args, 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); #else PyObject *method = NULL, *result; int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); if (likely(is_method)) { result = __Pyx_PyObject_Call2Args(method, obj, arg); Py_DECREF(method); return result; } if (unlikely(!method)) return NULL; return __Pyx__PyObject_CallMethod1(method, arg); #endif } /* UpdateUnpickledDict */ static int __Pyx__UpdateUnpickledDict(PyObject *obj, PyObject *state, Py_ssize_t index) { PyObject *state_dict = __Pyx_PySequence_ITEM(state, index); if (unlikely(!state_dict)) { return -1; } int non_empty = PyObject_IsTrue(state_dict); if (non_empty == 0) { Py_DECREF(state_dict); return 0; } else if (unlikely(non_empty == -1)) { return -1; } PyObject *dict; #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 dict = PyObject_GetAttrString(obj, "__dict__"); #else dict = PyObject_GenericGetDict(obj, NULL); #endif if (unlikely(!dict)) { Py_DECREF(state_dict); return -1; } int result; if (likely(PyDict_CheckExact(dict))) { result = PyDict_Update(dict, state_dict); } else { PyObject *obj_result = __Pyx_PyObject_CallMethod1(dict, __pyx_mstate_global->__pyx_n_u_update, state_dict); if (likely(obj_result)) { Py_DECREF(obj_result); result = 0; } else { result = -1; } } Py_DECREF(state_dict); Py_DECREF(dict); return result; } static int __Pyx_UpdateUnpickledDict(PyObject *obj, PyObject *state, Py_ssize_t index) { Py_ssize_t state_size = __Pyx_PyTuple_GET_SIZE(state); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(state_size == -1)) return -1; #endif if (state_size <= index) { return 0; } return __Pyx__UpdateUnpickledDict(obj, state, index); } /* FormatTypeName */ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000 static __Pyx_TypeName __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp) { PyObject *module = NULL, *name = NULL, *result = NULL; #if __PYX_LIMITED_VERSION_HEX < 0x030b0000 name = __Pyx_PyObject_GetAttrStr((PyObject *)tp, __pyx_mstate_global->__pyx_n_u_qualname); #else name = PyType_GetQualName(tp); #endif if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) goto bad; module = __Pyx_PyObject_GetAttrStr((PyObject *)tp, __pyx_mstate_global->__pyx_n_u_module); if (unlikely(module == NULL) || unlikely(!PyUnicode_Check(module))) goto bad; if (PyUnicode_CompareWithASCIIString(module, "builtins") == 0) { result = name; name = NULL; goto done; } result = PyUnicode_FromFormat("%U.%U", module, name); if (unlikely(result == NULL)) goto bad; done: Py_XDECREF(name); Py_XDECREF(module); return result; bad: PyErr_Clear(); if (name) { result = name; name = NULL; } else { result = __Pyx_NewRef(__pyx_mstate_global->__pyx_kp_u__3); } goto done; } #endif /* CIntFromPy */ static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const int neg_one = (int) -1, const_zero = (int) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (unlikely(!PyLong_Check(x))) { int val; PyObject *tmp = __Pyx_PyNumber_Long(x); if (!tmp) return (int) -1; val = __Pyx_PyLong_As_int(tmp); Py_DECREF(tmp); return val; } if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(int) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } } #endif if ((sizeof(int) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { int val; int ret = -1; #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API Py_ssize_t bytes_copied = PyLong_AsNativeBytes( x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0)); if (unlikely(bytes_copied == -1)) { } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) { goto raise_overflow; } else { ret = 0; } #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)x, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *v; PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (likely(PyLong_CheckExact(x))) { v = __Pyx_NewRef(x); } else { v = PyNumber_Long(x); if (unlikely(!v)) return (int) -1; assert(PyLong_CheckExact(v)); } { int result = PyObject_RichCompareBool(v, Py_False, Py_LT); if (unlikely(result < 0)) { Py_DECREF(v); return (int) -1; } is_negative = result == 1; } if (is_unsigned && unlikely(is_negative)) { Py_DECREF(v); goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); Py_DECREF(v); if (unlikely(!stepval)) return (int) -1; } else { stepval = v; } v = NULL; val = (int) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; long idigit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; val |= ((int) idigit) << bits; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; } Py_DECREF(shift); shift = NULL; Py_DECREF(mask); mask = NULL; { long idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((int) idigit) << bits; } if (!is_unsigned) { if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif if (unlikely(ret)) return (int) -1; return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } /* FastTypeChecks */ #if CYTHON_COMPILING_IN_CPYTHON static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { while (a) { a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*); if (a == b) return 1; } return b == &PyBaseObject_Type; } static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (a == b) return 1; mro = a->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(a, b); } static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (cls == a || cls == b) return 1; mro = cls->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { PyObject *base = PyTuple_GET_ITEM(mro, i); if (base == (PyObject *)a || base == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b); } static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { if (exc_type1) { return __Pyx_IsAnySubtype2((PyTypeObject*)err, (PyTypeObject*)exc_type1, (PyTypeObject*)exc_type2); } else { return __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); } } static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; assert(PyExceptionClass_Check(exc_type)); n = PyTuple_GET_SIZE(tuple); for (i=0; i>= 8; ++i; } __Pyx_cached_runtime_version = version; } } #endif static unsigned long __Pyx_get_runtime_version(void) { #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000 return Py_Version & ~0xFFUL; #else return __Pyx_cached_runtime_version; #endif } /* CheckBinaryVersion */ static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) { const unsigned long MAJOR_MINOR = 0xFFFF0000UL; if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR)) return 0; if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR))) return 1; { char message[200]; PyOS_snprintf(message, sizeof(message), "compile time Python version %d.%d " "of module '%.100s' " "%s " "runtime version %d.%d", (int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF), __Pyx_MODULE_NAME, (allow_newer) ? "was newer than" : "does not match", (int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF) ); return PyErr_WarnEx(NULL, message, 1); } } /* NewCodeObj */ #if CYTHON_COMPILING_IN_LIMITED_API static PyObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f, PyObject *code, PyObject *c, PyObject* n, PyObject *v, PyObject *fv, PyObject *cell, PyObject* fn, PyObject *name, int fline, PyObject *lnos) { PyObject *exception_table = NULL; PyObject *types_module=NULL, *code_type=NULL, *result=NULL; #if __PYX_LIMITED_VERSION_HEX < 0x030b0000 PyObject *version_info; PyObject *py_minor_version = NULL; #endif long minor_version = 0; PyObject *type, *value, *traceback; PyErr_Fetch(&type, &value, &traceback); #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000 minor_version = 11; #else if (!(version_info = PySys_GetObject("version_info"))) goto end; if (!(py_minor_version = PySequence_GetItem(version_info, 1))) goto end; minor_version = PyLong_AsLong(py_minor_version); Py_DECREF(py_minor_version); if (minor_version == -1 && PyErr_Occurred()) goto end; #endif if (!(types_module = PyImport_ImportModule("types"))) goto end; if (!(code_type = PyObject_GetAttrString(types_module, "CodeType"))) goto end; if (minor_version <= 7) { (void)p; result = PyObject_CallFunction(code_type, "iiiiiOOOOOOiOOO", a, k, l, s, f, code, c, n, v, fn, name, fline, lnos, fv, cell); } else if (minor_version <= 10) { result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOiOOO", a,p, k, l, s, f, code, c, n, v, fn, name, fline, lnos, fv, cell); } else { if (!(exception_table = PyBytes_FromStringAndSize(NULL, 0))) goto end; result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOOiOOOO", a,p, k, l, s, f, code, c, n, v, fn, name, name, fline, lnos, exception_table, fv, cell); } end: Py_XDECREF(code_type); Py_XDECREF(exception_table); Py_XDECREF(types_module); if (type) { PyErr_Restore(type, value, traceback); } return result; } #elif PY_VERSION_HEX >= 0x030B0000 static PyCodeObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f, PyObject *code, PyObject *c, PyObject* n, PyObject *v, PyObject *fv, PyObject *cell, PyObject* fn, PyObject *name, int fline, PyObject *lnos) { PyCodeObject *result; result = #if PY_VERSION_HEX >= 0x030C0000 PyUnstable_Code_NewWithPosOnlyArgs #else PyCode_NewWithPosOnlyArgs #endif (a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, name, fline, lnos, __pyx_mstate_global->__pyx_empty_bytes); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030c00A1 if (likely(result)) result->_co_firsttraceable = 0; #endif return result; } #elif !CYTHON_COMPILING_IN_PYPY #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #else #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #endif static PyObject* __Pyx_PyCode_New( const __Pyx_PyCode_New_function_description descr, PyObject * const *varnames, PyObject *filename, PyObject *funcname, PyObject *line_table, PyObject *tuple_dedup_map ) { PyObject *code_obj = NULL, *varnames_tuple_dedup = NULL, *code_bytes = NULL; Py_ssize_t var_count = (Py_ssize_t) descr.nlocals; PyObject *varnames_tuple = PyTuple_New(var_count); if (unlikely(!varnames_tuple)) return NULL; for (Py_ssize_t i=0; i < var_count; i++) { Py_INCREF(varnames[i]); if (__Pyx_PyTuple_SET_ITEM(varnames_tuple, i, varnames[i]) != (0)) goto done; } #if CYTHON_COMPILING_IN_LIMITED_API varnames_tuple_dedup = PyDict_GetItem(tuple_dedup_map, varnames_tuple); if (!varnames_tuple_dedup) { if (unlikely(PyDict_SetItem(tuple_dedup_map, varnames_tuple, varnames_tuple) < 0)) goto done; varnames_tuple_dedup = varnames_tuple; } #else varnames_tuple_dedup = PyDict_SetDefault(tuple_dedup_map, varnames_tuple, varnames_tuple); if (unlikely(!varnames_tuple_dedup)) goto done; #endif #if CYTHON_AVOID_BORROWED_REFS Py_INCREF(varnames_tuple_dedup); #endif if (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table != NULL && !CYTHON_COMPILING_IN_GRAAL) { Py_ssize_t line_table_length = __Pyx_PyBytes_GET_SIZE(line_table); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(line_table_length == -1)) goto done; #endif Py_ssize_t code_len = (line_table_length * 2 + 4) & ~3LL; code_bytes = PyBytes_FromStringAndSize(NULL, code_len); if (unlikely(!code_bytes)) goto done; char* c_code_bytes = PyBytes_AsString(code_bytes); if (unlikely(!c_code_bytes)) goto done; memset(c_code_bytes, 0, (size_t) code_len); } code_obj = (PyObject*) __Pyx__PyCode_New( (int) descr.argcount, (int) descr.num_posonly_args, (int) descr.num_kwonly_args, (int) descr.nlocals, 0, (int) descr.flags, code_bytes ? code_bytes : __pyx_mstate_global->__pyx_empty_bytes, __pyx_mstate_global->__pyx_empty_tuple, __pyx_mstate_global->__pyx_empty_tuple, varnames_tuple_dedup, __pyx_mstate_global->__pyx_empty_tuple, __pyx_mstate_global->__pyx_empty_tuple, filename, funcname, (int) descr.first_line, (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table) ? line_table : __pyx_mstate_global->__pyx_empty_bytes ); done: Py_XDECREF(code_bytes); #if CYTHON_AVOID_BORROWED_REFS Py_XDECREF(varnames_tuple_dedup); #endif Py_DECREF(varnames_tuple); return code_obj; } /* DecompressString */ static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo) { PyObject *module, *decompress, *compressed_bytes, *decompressed; const char* module_name = algo == 3 ? "compression.zstd" : algo == 2 ? "bz2" : "zlib"; PyObject *methodname = PyUnicode_FromString("decompress"); if (unlikely(!methodname)) return NULL; #if __PYX_LIMITED_VERSION_HEX >= 0x030e0000 if (algo == 3) { PyObject *fromlist = Py_BuildValue("[O]", methodname); if (unlikely(!fromlist)) return NULL; module = PyImport_ImportModuleLevel("compression.zstd", NULL, NULL, fromlist, 0); Py_DECREF(fromlist); } else #endif module = PyImport_ImportModule(module_name); if (unlikely(!module)) goto import_failed; decompress = PyObject_GetAttr(module, methodname); if (unlikely(!decompress)) goto import_failed; { #ifdef __cplusplus char *memview_bytes = const_cast(s); #else #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wcast-qual" #elif !defined(__INTEL_COMPILER) && defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-qual" #endif char *memview_bytes = (char*) s; #if defined(__clang__) #pragma clang diagnostic pop #elif !defined(__INTEL_COMPILER) && defined(__GNUC__) #pragma GCC diagnostic pop #endif #endif #if CYTHON_COMPILING_IN_LIMITED_API && !defined(PyBUF_READ) int memview_flags = 0x100; #else int memview_flags = PyBUF_READ; #endif compressed_bytes = PyMemoryView_FromMemory(memview_bytes, length, memview_flags); } if (unlikely(!compressed_bytes)) { Py_DECREF(decompress); goto bad; } decompressed = PyObject_CallFunctionObjArgs(decompress, compressed_bytes, NULL); Py_DECREF(compressed_bytes); Py_DECREF(decompress); Py_DECREF(module); Py_DECREF(methodname); return decompressed; import_failed: PyErr_Format(PyExc_ImportError, "Failed to import '%.20s.decompress' - cannot initialise module strings. " "String compression was configured with the C macro 'CYTHON_COMPRESS_STRINGS=%d'.", module_name, algo); bad: Py_XDECREF(module); Py_DECREF(methodname); return NULL; } #include static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s) { size_t len = strlen(s); if (unlikely(len > (size_t) PY_SSIZE_T_MAX)) { PyErr_SetString(PyExc_OverflowError, "byte string is too long"); return -1; } return (Py_ssize_t) len; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { Py_ssize_t len = __Pyx_ssize_strlen(c_str); if (unlikely(len < 0)) return NULL; return __Pyx_PyUnicode_FromStringAndSize(c_str, len); } static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char* c_str) { Py_ssize_t len = __Pyx_ssize_strlen(c_str); if (unlikely(len < 0)) return NULL; return PyByteArray_FromStringAndSize(c_str, len); } static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if CYTHON_COMPILING_IN_LIMITED_API { const char* result; Py_ssize_t unicode_length; CYTHON_MAYBE_UNUSED_VAR(unicode_length); // only for __PYX_DEFAULT_STRING_ENCODING_IS_ASCII #if __PYX_LIMITED_VERSION_HEX < 0x030A0000 if (unlikely(PyArg_Parse(o, "s#", &result, length) < 0)) return NULL; #else result = PyUnicode_AsUTF8AndSize(o, length); #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII unicode_length = PyUnicode_GetLength(o); if (unlikely(unicode_length < 0)) return NULL; if (unlikely(unicode_length != *length)) { PyUnicode_AsASCIIString(o); return NULL; } #endif return result; } #else #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (likely(PyUnicode_IS_ASCII(o))) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif #endif } #endif static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 if (PyUnicode_Check(o)) { return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif if (PyByteArray_Check(o)) { #if (CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS) || (CYTHON_COMPILING_IN_PYPY && (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))) *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); #else *length = PyByteArray_Size(o); if (*length == -1) return NULL; return PyByteArray_AsString(o); #endif } else { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { int retval; if (unlikely(!x)) return -1; retval = __Pyx_PyObject_IsTrue(x); Py_DECREF(x); return retval; } static PyObject* __Pyx_PyNumber_LongWrongResultType(PyObject* result) { __Pyx_TypeName result_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(result)); if (PyLong_Check(result)) { if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, "__int__ returned non-int (type " __Pyx_FMT_TYPENAME "). " "The ability to return an instance of a strict subclass of int is deprecated, " "and may be removed in a future version of Python.", result_type_name)) { __Pyx_DECREF_TypeName(result_type_name); Py_DECREF(result); return NULL; } __Pyx_DECREF_TypeName(result_type_name); return result; } PyErr_Format(PyExc_TypeError, "__int__ returned non-int (type " __Pyx_FMT_TYPENAME ")", result_type_name); __Pyx_DECREF_TypeName(result_type_name); Py_DECREF(result); return NULL; } static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; #endif PyObject *res = NULL; if (likely(PyLong_Check(x))) return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS m = Py_TYPE(x)->tp_as_number; if (likely(m && m->nb_int)) { res = m->nb_int(x); } #else if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { res = PyNumber_Long(x); } #endif if (likely(res)) { if (unlikely(!PyLong_CheckExact(res))) { return __Pyx_PyNumber_LongWrongResultType(res); } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS if (likely(__Pyx_PyLong_IsCompact(b))) { return __Pyx_PyLong_CompactValue(b); } else { const digit* digits = __Pyx_PyLong_Digits(b); const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(b); switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyLong_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) { if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) { return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o); } else { Py_ssize_t ival; PyObject *x; x = PyNumber_Index(o); if (!x) return -1; ival = PyLong_AsLong(x); Py_DECREF(x); return ival; } } static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b) { CYTHON_UNUSED_VAR(b); return __Pyx_NewRef(Py_None); } static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { return __Pyx_NewRef(b ? Py_True: Py_False); } static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t ival) { return PyLong_FromSize_t(ival); } /* MultiPhaseInitModuleState */ #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE #ifndef CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE #if (CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX >= 0x030C0000) #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 1 #else #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 0 #endif #endif #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE && !CYTHON_ATOMICS #error "Module state with PEP489 requires atomics. Currently that's one of\ C11, C++11, gcc atomic intrinsics or MSVC atomic intrinsics" #endif #if !CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE #define __Pyx_ModuleStateLookup_Lock() #define __Pyx_ModuleStateLookup_Unlock() #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000 static PyMutex __Pyx_ModuleStateLookup_mutex = {0}; #define __Pyx_ModuleStateLookup_Lock() PyMutex_Lock(&__Pyx_ModuleStateLookup_mutex) #define __Pyx_ModuleStateLookup_Unlock() PyMutex_Unlock(&__Pyx_ModuleStateLookup_mutex) #elif defined(__cplusplus) && __cplusplus >= 201103L #include static std::mutex __Pyx_ModuleStateLookup_mutex; #define __Pyx_ModuleStateLookup_Lock() __Pyx_ModuleStateLookup_mutex.lock() #define __Pyx_ModuleStateLookup_Unlock() __Pyx_ModuleStateLookup_mutex.unlock() #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201112L) && !defined(__STDC_NO_THREADS__) #include static mtx_t __Pyx_ModuleStateLookup_mutex; static once_flag __Pyx_ModuleStateLookup_mutex_once_flag = ONCE_FLAG_INIT; static void __Pyx_ModuleStateLookup_initialize_mutex(void) { mtx_init(&__Pyx_ModuleStateLookup_mutex, mtx_plain); } #define __Pyx_ModuleStateLookup_Lock()\ call_once(&__Pyx_ModuleStateLookup_mutex_once_flag, __Pyx_ModuleStateLookup_initialize_mutex);\ mtx_lock(&__Pyx_ModuleStateLookup_mutex) #define __Pyx_ModuleStateLookup_Unlock() mtx_unlock(&__Pyx_ModuleStateLookup_mutex) #elif defined(HAVE_PTHREAD_H) #include static pthread_mutex_t __Pyx_ModuleStateLookup_mutex = PTHREAD_MUTEX_INITIALIZER; #define __Pyx_ModuleStateLookup_Lock() pthread_mutex_lock(&__Pyx_ModuleStateLookup_mutex) #define __Pyx_ModuleStateLookup_Unlock() pthread_mutex_unlock(&__Pyx_ModuleStateLookup_mutex) #elif defined(_WIN32) #include // synchapi.h on its own doesn't work static SRWLOCK __Pyx_ModuleStateLookup_mutex = SRWLOCK_INIT; #define __Pyx_ModuleStateLookup_Lock() AcquireSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex) #define __Pyx_ModuleStateLookup_Unlock() ReleaseSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex) #else #error "No suitable lock available for CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE.\ Requires C standard >= C11, or C++ standard >= C++11,\ or pthreads, or the Windows 32 API, or Python >= 3.13." #endif typedef struct { int64_t id; PyObject *module; } __Pyx_InterpreterIdAndModule; typedef struct { char interpreter_id_as_index; Py_ssize_t count; Py_ssize_t allocated; __Pyx_InterpreterIdAndModule table[1]; } __Pyx_ModuleStateLookupData; #define __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE 32 #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE static __pyx_atomic_int_type __Pyx_ModuleStateLookup_read_counter = 0; #endif #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE static __pyx_atomic_ptr_type __Pyx_ModuleStateLookup_data = 0; #else static __Pyx_ModuleStateLookupData* __Pyx_ModuleStateLookup_data = NULL; #endif static __Pyx_InterpreterIdAndModule* __Pyx_State_FindModuleStateLookupTableLowerBound( __Pyx_InterpreterIdAndModule* table, Py_ssize_t count, int64_t interpreterId) { __Pyx_InterpreterIdAndModule* begin = table; __Pyx_InterpreterIdAndModule* end = begin + count; if (begin->id == interpreterId) { return begin; } while ((end - begin) > __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) { __Pyx_InterpreterIdAndModule* halfway = begin + (end - begin)/2; if (halfway->id == interpreterId) { return halfway; } if (halfway->id < interpreterId) { begin = halfway; } else { end = halfway; } } for (; begin < end; ++begin) { if (begin->id >= interpreterId) return begin; } return begin; } static PyObject *__Pyx_State_FindModule(CYTHON_UNUSED void* dummy) { int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get()); if (interpreter_id == -1) return NULL; #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __Pyx_ModuleStateLookupData* data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data); { __pyx_atomic_incr_acq_rel(&__Pyx_ModuleStateLookup_read_counter); if (likely(data)) { __Pyx_ModuleStateLookupData* new_data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_acquire(&__Pyx_ModuleStateLookup_data); if (likely(data == new_data)) { goto read_finished; } } __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter); __Pyx_ModuleStateLookup_Lock(); __pyx_atomic_incr_relaxed(&__Pyx_ModuleStateLookup_read_counter); data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data); __Pyx_ModuleStateLookup_Unlock(); } read_finished:; #else __Pyx_ModuleStateLookupData* data = __Pyx_ModuleStateLookup_data; #endif __Pyx_InterpreterIdAndModule* found = NULL; if (unlikely(!data)) goto end; if (data->interpreter_id_as_index) { if (interpreter_id < data->count) { found = data->table+interpreter_id; } } else { found = __Pyx_State_FindModuleStateLookupTableLowerBound( data->table, data->count, interpreter_id); } end: { PyObject *result=NULL; if (found && found->id == interpreter_id) { result = found->module; } #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter); #endif return result; } } #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE static void __Pyx_ModuleStateLookup_wait_until_no_readers(void) { while (__pyx_atomic_load(&__Pyx_ModuleStateLookup_read_counter) != 0); } #else #define __Pyx_ModuleStateLookup_wait_until_no_readers() #endif static int __Pyx_State_AddModuleInterpIdAsIndex(__Pyx_ModuleStateLookupData **old_data, PyObject* module, int64_t interpreter_id) { Py_ssize_t to_allocate = (*old_data)->allocated; while (to_allocate <= interpreter_id) { if (to_allocate == 0) to_allocate = 1; else to_allocate *= 2; } __Pyx_ModuleStateLookupData *new_data = *old_data; if (to_allocate != (*old_data)->allocated) { new_data = (__Pyx_ModuleStateLookupData *)realloc( *old_data, sizeof(__Pyx_ModuleStateLookupData)+(to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule)); if (!new_data) { PyErr_NoMemory(); return -1; } for (Py_ssize_t i = new_data->allocated; i < to_allocate; ++i) { new_data->table[i].id = i; new_data->table[i].module = NULL; } new_data->allocated = to_allocate; } new_data->table[interpreter_id].module = module; if (new_data->count < interpreter_id+1) { new_data->count = interpreter_id+1; } *old_data = new_data; return 0; } static void __Pyx_State_ConvertFromInterpIdAsIndex(__Pyx_ModuleStateLookupData *data) { __Pyx_InterpreterIdAndModule *read = data->table; __Pyx_InterpreterIdAndModule *write = data->table; __Pyx_InterpreterIdAndModule *end = read + data->count; for (; readmodule) { write->id = read->id; write->module = read->module; ++write; } } data->count = write - data->table; for (; writeid = 0; write->module = NULL; } data->interpreter_id_as_index = 0; } static int __Pyx_State_AddModule(PyObject* module, CYTHON_UNUSED void* dummy) { int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get()); if (interpreter_id == -1) return -1; int result = 0; __Pyx_ModuleStateLookup_Lock(); #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __Pyx_ModuleStateLookupData *old_data = (__Pyx_ModuleStateLookupData *) __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0); #else __Pyx_ModuleStateLookupData *old_data = __Pyx_ModuleStateLookup_data; #endif __Pyx_ModuleStateLookupData *new_data = old_data; if (!new_data) { new_data = (__Pyx_ModuleStateLookupData *)calloc(1, sizeof(__Pyx_ModuleStateLookupData)); if (!new_data) { result = -1; PyErr_NoMemory(); goto end; } new_data->allocated = 1; new_data->interpreter_id_as_index = 1; } __Pyx_ModuleStateLookup_wait_until_no_readers(); if (new_data->interpreter_id_as_index) { if (interpreter_id < __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) { result = __Pyx_State_AddModuleInterpIdAsIndex(&new_data, module, interpreter_id); goto end; } __Pyx_State_ConvertFromInterpIdAsIndex(new_data); } { Py_ssize_t insert_at = 0; { __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound( new_data->table, new_data->count, interpreter_id); assert(lower_bound); insert_at = lower_bound - new_data->table; if (unlikely(insert_at < new_data->count && lower_bound->id == interpreter_id)) { lower_bound->module = module; goto end; // already in table, nothing more to do } } if (new_data->count+1 >= new_data->allocated) { Py_ssize_t to_allocate = (new_data->count+1)*2; new_data = (__Pyx_ModuleStateLookupData*)realloc( new_data, sizeof(__Pyx_ModuleStateLookupData) + (to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule)); if (!new_data) { result = -1; new_data = old_data; PyErr_NoMemory(); goto end; } new_data->allocated = to_allocate; } ++new_data->count; int64_t last_id = interpreter_id; PyObject *last_module = module; for (Py_ssize_t i=insert_at; icount; ++i) { int64_t current_id = new_data->table[i].id; new_data->table[i].id = last_id; last_id = current_id; PyObject *current_module = new_data->table[i].module; new_data->table[i].module = last_module; last_module = current_module; } } end: #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, new_data); #else __Pyx_ModuleStateLookup_data = new_data; #endif __Pyx_ModuleStateLookup_Unlock(); return result; } static int __Pyx_State_RemoveModule(CYTHON_UNUSED void* dummy) { int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get()); if (interpreter_id == -1) return -1; __Pyx_ModuleStateLookup_Lock(); #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __Pyx_ModuleStateLookupData *data = (__Pyx_ModuleStateLookupData *) __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0); #else __Pyx_ModuleStateLookupData *data = __Pyx_ModuleStateLookup_data; #endif if (data->interpreter_id_as_index) { if (interpreter_id < data->count) { data->table[interpreter_id].module = NULL; } goto done; } { __Pyx_ModuleStateLookup_wait_until_no_readers(); __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound( data->table, data->count, interpreter_id); if (!lower_bound) goto done; if (lower_bound->id != interpreter_id) goto done; __Pyx_InterpreterIdAndModule *end = data->table+data->count; for (;lower_boundid = (lower_bound+1)->id; lower_bound->module = (lower_bound+1)->module; } } --data->count; if (data->count == 0) { free(data); data = NULL; } done: #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, data); #else __Pyx_ModuleStateLookup_data = data; #endif __Pyx_ModuleStateLookup_Unlock(); return 0; } #endif /* #### Code section: utility_code_pragmas_end ### */ #ifdef _MSC_VER #pragma warning( pop ) #endif /* #### Code section: end ### */ #endif /* Py_PYTHON_H */ clickhouse-driver-0.2.11/clickhouse_driver/bufferedwriter.pyx000066400000000000000000000104551522645447600245260ustar00rootroot00000000000000from cpython cimport PyMem_Malloc, PyMem_Free, PyBytes_AsString, \ PyBytes_Check, PyBytes_FromStringAndSize, PyBytes_AS_STRING, \ PyBytes_GET_SIZE from libc.string cimport memcpy, memset from . import errors from .varint import make_varint cdef class BufferedWriter(object): cdef char* buffer cdef unsigned long long position, buffer_size def __init__(self, unsigned long long bufsize): self.buffer = PyMem_Malloc(bufsize) if not self.buffer: raise MemoryError() self.position = 0 self.buffer_size = bufsize super(BufferedWriter, self).__init__() def __dealloc__(self): PyMem_Free(self.buffer) cpdef write_into_stream(self): raise NotImplementedError cpdef write(self, data): cdef unsigned long long size, written = 0 cdef unsigned long long data_len = PyBytes_GET_SIZE(data) cdef char* c_data = PyBytes_AS_STRING(data) while written < data_len: size = min(data_len - written, self.buffer_size - self.position) memcpy(&self.buffer[self.position], &c_data[written], size) if self.position == self.buffer_size: self.write_into_stream() self.position += size written += size def flush(self): self.write_into_stream() def write_strings(self, items, encoding=None): cdef int do_encode = encoding is not None for value in items: if not PyBytes_Check(value): if do_encode: value = value.encode(encoding) else: raise ValueError('bytes object expected') self.write(make_varint(PyBytes_GET_SIZE(value))) self.write(value) def write_fixed_strings_as_bytes(self, items, Py_ssize_t length): cdef Py_ssize_t buf_pos = 0 cdef Py_ssize_t items_buf_size = length * len(items) cdef char* c_value cdef char* items_buf = PyMem_Malloc(items_buf_size) if not items_buf: raise MemoryError() memset(items_buf, 0, items_buf_size) for value in items: value_len = len(value) if length < value_len: raise errors.TooLargeStringSize() c_value = PyBytes_AsString(value) memcpy(&items_buf[buf_pos], c_value, value_len) buf_pos += length try: self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size)) finally: PyMem_Free(items_buf) def write_fixed_strings(self, items, Py_ssize_t length, encoding=None): if encoding is None: self.write_fixed_strings_as_bytes(items, length) return cdef Py_ssize_t buf_pos = 0 cdef Py_ssize_t items_buf_size = length * len(items) cdef char* c_value cdef char* items_buf = PyMem_Malloc(items_buf_size) if not items_buf: raise MemoryError() memset(items_buf, 0, items_buf_size) for value in items: if not PyBytes_Check(value): value = value.encode(encoding) value_len = len(value) if length < value_len: raise errors.TooLargeStringSize() c_value = PyBytes_AsString(value) memcpy(&items_buf[buf_pos], c_value, value_len) buf_pos += length try: self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size)) finally: PyMem_Free(items_buf) cdef class BufferedSocketWriter(BufferedWriter): cdef object sock def __init__(self, sock, bufsize): self.sock = sock super(BufferedSocketWriter, self).__init__(bufsize) cpdef write_into_stream(self): self.sock.sendall( PyBytes_FromStringAndSize(self.buffer, self.position) ) self.position = 0 cdef class CompressedBufferedWriter(BufferedWriter): cdef object compressor def __init__(self, compressor, bufsize): self.compressor = compressor super(CompressedBufferedWriter, self).__init__(bufsize) cpdef write_into_stream(self): self.compressor.write( PyBytes_FromStringAndSize(self.buffer, self.position) ) self.position = 0 def flush(self): self.write_into_stream() clickhouse-driver-0.2.11/clickhouse_driver/client.py000066400000000000000000001154471522645447600226040ustar00rootroot00000000000000import re from collections import deque from contextlib import contextmanager from time import time import types from urllib.parse import urlparse from . import errors, defines from .block import ColumnOrientedBlock, RowOrientedBlock from .connection import Connection from .log import log_block from .protocol import ServerPacketTypes from .result import ( IterQueryResult, ProgressQueryResult, QueryResult, QueryInfo ) from .util.escape import escape_params from .util.helpers import column_chunks, chunks, parse_url class Client(object): """ Client for communication with the ClickHouse server. Single connection is established per each connected instance of the client. :param settings: Dictionary of settings that passed to every query (except for the client settings, see below). Defaults to ``None`` (no additional settings). See all available settings in `ClickHouse docs `_. :param \\**kwargs: All other args are passed to the :py:class:`~clickhouse_driver.connection.Connection` constructor. The following keys when passed in ``settings`` are used for configuring the client itself: * ``insert_block_size`` -- chunk size to split rows for ``INSERT``. Defaults to ``1048576``. * ``strings_as_bytes`` -- turns off string column encoding/decoding. * ``strings_encoding`` -- specifies string encoding. UTF-8 by default. * ``use_numpy`` -- Use NumPy for columns reading. New in version *0.2.0*. * ``opentelemetry_traceparent`` -- OpenTelemetry traceparent header as described by W3C Trace Context recommendation. New in version *0.2.2*. * ``opentelemetry_tracestate`` -- OpenTelemetry tracestate header as described by W3C Trace Context recommendation. New in version *0.2.2*. * ``quota_key`` -- A string to differentiate quotas when the user have keyed quotas configured on server. New in version *0.2.3*. * ``input_format_null_as_default`` -- Initialize null fields with default values if data type of this field is not nullable. Does not work for NumPy. Default: False. New in version *0.2.4*. * ``round_robin`` -- If ``alt_hosts`` are provided the query will be executed on host picked with round-robin algorithm. New in version *0.2.5*. * ``namedtuple_as_json`` -- Controls named tuple and nested types deserialization. To interpret these column alongside with ``allow_experimental_object_type=1`` as Python tuple set ``namedtuple_as_json`` to ``False``. Default: True. New in version *0.2.6*. * ``server_side_params`` -- Species on which side query parameters should be rendered into placeholders. Default: False. Means that parameters are rendered on driver's side. New in version *0.2.7*. """ available_client_settings = ( 'insert_block_size', # TODO: rename to max_insert_block_size 'strings_as_bytes', 'strings_encoding', 'use_numpy', 'opentelemetry_traceparent', 'opentelemetry_tracestate', 'quota_key', 'input_format_null_as_default', 'namedtuple_as_json', 'server_side_params' ) def __init__(self, *args, **kwargs): self.settings = (kwargs.pop('settings', None) or {}).copy() self.client_settings = { 'insert_block_size': int(self.settings.pop( 'insert_block_size', defines.DEFAULT_INSERT_BLOCK_SIZE, )), 'strings_as_bytes': self.settings.pop( 'strings_as_bytes', False ), 'strings_encoding': self.settings.pop( 'strings_encoding', defines.STRINGS_ENCODING ), 'use_numpy': self.settings.pop( 'use_numpy', False ), 'opentelemetry_traceparent': self.settings.pop( 'opentelemetry_traceparent', None ), 'opentelemetry_tracestate': self.settings.pop( 'opentelemetry_tracestate', '' ), 'quota_key': self.settings.pop( 'quota_key', '' ), 'input_format_null_as_default': self.settings.pop( 'input_format_null_as_default', False ), 'namedtuple_as_json': self.settings.pop( 'namedtuple_as_json', True ), 'server_side_params': self.settings.pop( 'server_side_params', False ) } if self.client_settings['use_numpy']: try: from .numpy.result import ( NumpyIterQueryResult, NumpyProgressQueryResult, NumpyQueryResult ) self.query_result_cls = NumpyQueryResult self.iter_query_result_cls = NumpyIterQueryResult self.progress_query_result_cls = NumpyProgressQueryResult except ImportError: raise RuntimeError('Extras for NumPy must be installed') else: self.query_result_cls = QueryResult self.iter_query_result_cls = IterQueryResult self.progress_query_result_cls = ProgressQueryResult round_robin = kwargs.pop('round_robin', False) self.connections = deque([Connection(*args, **kwargs)]) self._pending_arrow_stream = None if round_robin and 'alt_hosts' in kwargs: alt_hosts = kwargs.pop('alt_hosts') for host in alt_hosts.split(','): url = urlparse('clickhouse://' + host) connection_kwargs = kwargs.copy() num_args = len(args) if num_args >= 2: # host and port as positional arguments connection_args = (url.hostname, url.port) + args[2:] elif num_args >= 1: # host as positional and port as keyword argument connection_args = (url.hostname, ) + args[1:] connection_kwargs['port'] = url.port else: # host and port as keyword arguments connection_args = tuple() connection_kwargs['host'] = url.hostname connection_kwargs['port'] = url.port connection = Connection(*connection_args, **connection_kwargs) self.connections.append(connection) self.connection = self.get_connection() self.reset_last_query() super(Client, self).__init__() def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): self.disconnect() def get_connection(self): if hasattr(self, 'connection'): self.connections.append(self.connection) connection = self.connections.popleft() connection.context.settings = self.settings connection.context.client_settings = self.client_settings return connection def disconnect(self): self.disconnect_connection() for connection in self.connections: connection.disconnect() def disconnect_connection(self): """ Disconnects from the server. """ self.connection.disconnect() self.reset_last_query() def reset_last_query(self): self.last_query = None def receive_result(self, with_column_types=False, progress=False, columnar=False): gen = self.packet_generator() if progress: return self.progress_query_result_cls( gen, with_column_types=with_column_types, columnar=columnar ) else: result = self.query_result_cls( gen, with_column_types=with_column_types, columnar=columnar ) return result.get_result() def iter_receive_result(self, with_column_types=False): gen = self.packet_generator() result = self.iter_query_result_cls( gen, with_column_types=with_column_types ) for rows in result: for row in rows: yield row def packet_generator(self): while True: try: packet = self.receive_packet() if not packet: break if packet is True: continue yield packet except (Exception, KeyboardInterrupt): self.disconnect() raise def receive_packet(self): packet = self.connection.receive_packet() if packet.type == ServerPacketTypes.EXCEPTION: raise packet.exception elif packet.type == ServerPacketTypes.PROGRESS: self.last_query.store_progress(packet.progress) return packet elif packet.type == ServerPacketTypes.END_OF_STREAM: return False elif packet.type == ServerPacketTypes.DATA: return packet elif packet.type == ServerPacketTypes.TOTALS: return packet elif packet.type == ServerPacketTypes.EXTREMES: return packet elif packet.type == ServerPacketTypes.PROFILE_INFO: self.last_query.store_profile(packet.profile_info) return True else: return True def make_query_settings(self, settings): settings = dict(settings or {}) # Pick client-related settings. client_settings = self.client_settings.copy() for key in self.available_client_settings: if key in settings: client_settings[key] = settings.pop(key) self.connection.context.client_settings = client_settings # The rest of settings are ClickHouse-related. query_settings = self.settings.copy() query_settings.update(settings) self.connection.context.settings = query_settings def track_current_database(self, query): query = query.strip('; ') if query.lower().startswith('use '): self.connection.database = query[4:].strip() def establish_connection(self, settings): num_connections = len(self.connections) if hasattr(self, 'connection'): num_connections += 1 for i in range(num_connections): try: self.connection = self.get_connection() self.make_query_settings(settings) self.connection.force_connect() self.last_query = QueryInfo() except (errors.SocketTimeoutError, errors.NetworkError): if i < num_connections - 1: continue raise return def _reset_pending_arrow_stream(self): """ Cancels the previous streamed Arrow query if it wasn't consumed to the end. RecordBatchReader.close() doesn't reach the underlying generator, so cleanup happens on the next query: drain the stream through END_OF_STREAM after Cancel, or reset the connection. """ state = self._pending_arrow_stream self._pending_arrow_stream = None if state is None or state.finished: return state.cancelled = True connection = state.connection if not connection.connected or not connection.is_query_executing: return try: connection.send_cancel() terminal_packets = ( ServerPacketTypes.END_OF_STREAM, ServerPacketTypes.EXCEPTION ) while True: packet = connection.receive_packet() if packet.type in terminal_packets: break # Exception packet leaves the query marked as executing. if connection.is_query_executing: connection.disconnect() except (Exception, KeyboardInterrupt): connection.disconnect() @contextmanager def disconnect_on_error(self, query, settings): try: self._reset_pending_arrow_stream() self.establish_connection(settings) self.connection.server_info.session_timezone = None yield self.track_current_database(query) except (Exception, KeyboardInterrupt): self.disconnect() raise def execute(self, query, params=None, with_column_types=False, external_tables=None, query_id=None, settings=None, types_check=False, columnar=False): """ Executes query. Establishes new connection if it wasn't established yet. After query execution connection remains intact for next queries. If connection can't be reused it will be closed and new connection will be created. :param query: query that will be send to server. :param params: substitution parameters for SELECT queries and data for INSERT queries. Data for INSERT can be `list`, `tuple` or :data:`~types.GeneratorType`. Defaults to ``None`` (no parameters or data). :param with_column_types: if specified column names and types will be returned alongside with result. Defaults to ``False``. :param external_tables: external tables to send. Defaults to ``None`` (no external tables). :param query_id: the query identifier. If no query id specified ClickHouse server will generate it. :param settings: dictionary of query settings. Defaults to ``None`` (no additional settings). :param types_check: enables type checking of data for INSERT queries. Causes additional overhead. Defaults to ``False``. :param columnar: if specified the result of the SELECT query will be returned in column-oriented form. It also allows to INSERT data in columnar form. Defaults to ``False`` (row-like form). :return: * number of inserted rows for INSERT queries with data. Returning rows count from INSERT FROM SELECT is not supported. * if `with_column_types=False`: `list` of `tuples` with rows/columns. * if `with_column_types=True`: `tuple` of 2 elements: * The first element is `list` of `tuples` with rows/columns. * The second element information is about columns: names and types. """ start_time = time() with self.disconnect_on_error(query, settings): # INSERT queries can use list/tuple/generator of list/tuples/dicts. # For SELECT parameters can be passed in only in dict right now. is_insert = isinstance(params, (list, tuple, types.GeneratorType)) if is_insert: rv = self.process_insert_query( query, params, external_tables=external_tables, query_id=query_id, types_check=types_check, columnar=columnar ) else: rv = self.process_ordinary_query( query, params=params, with_column_types=with_column_types, external_tables=external_tables, query_id=query_id, types_check=types_check, columnar=columnar ) self.last_query.store_elapsed(time() - start_time) return rv def execute_with_progress( self, query, params=None, with_column_types=False, external_tables=None, query_id=None, settings=None, types_check=False, columnar=False): """ Executes SELECT query with progress information. See, :ref:`execute-with-progress`. :param query: query that will be send to server. :param params: substitution parameters for SELECT queries and data for INSERT queries. Data for INSERT can be `list`, `tuple` or :data:`~types.GeneratorType`. Defaults to ``None`` (no parameters or data). :param with_column_types: if specified column names and types will be returned alongside with result. Defaults to ``False``. :param external_tables: external tables to send. Defaults to ``None`` (no external tables). :param query_id: the query identifier. If no query id specified ClickHouse server will generate it. :param settings: dictionary of query settings. Defaults to ``None`` (no additional settings). :param types_check: enables type checking of data for INSERT queries. Causes additional overhead. Defaults to ``False``. :param columnar: if specified the result will be returned in column-oriented form. Defaults to ``False`` (row-like form). :return: :ref:`progress-query-result` proxy. """ with self.disconnect_on_error(query, settings): return self.process_ordinary_query_with_progress( query, params=params, with_column_types=with_column_types, external_tables=external_tables, query_id=query_id, types_check=types_check, columnar=columnar ) def execute_iter( self, query, params=None, with_column_types=False, external_tables=None, query_id=None, settings=None, types_check=False, chunk_size=1): """ *New in version 0.0.14.* Executes SELECT query with results streaming. See, :ref:`execute-iter`. :param query: query that will be send to server. :param params: substitution parameters for SELECT queries and data for INSERT queries. Data for INSERT can be `list`, `tuple` or :data:`~types.GeneratorType`. Defaults to ``None`` (no parameters or data). :param with_column_types: if specified column names and types will be returned alongside with result. Defaults to ``False``. :param external_tables: external tables to send. Defaults to ``None`` (no external tables). :param query_id: the query identifier. If no query id specified ClickHouse server will generate it. :param settings: dictionary of query settings. Defaults to ``None`` (no additional settings). :param types_check: enables type checking of data for INSERT queries. Causes additional overhead. Defaults to ``False``. :param chunk_size: chunk query results. :return: :ref:`iter-query-result` proxy. """ with self.disconnect_on_error(query, settings): rv = self.iter_process_ordinary_query( query, params=params, with_column_types=with_column_types, external_tables=external_tables, query_id=query_id, types_check=types_check ) return chunks(rv, chunk_size) if chunk_size > 1 else rv def query_dataframe( self, query, params=None, external_tables=None, query_id=None, settings=None, replace_nonwords=True): """ *New in version 0.2.0.* Queries DataFrame with specified SELECT query. :param query: query that will be send to server. :param params: substitution parameters. Defaults to ``None`` (no parameters or data). :param external_tables: external tables to send. Defaults to ``None`` (no external tables). :param query_id: the query identifier. If no query id specified ClickHouse server will generate it. :param settings: dictionary of query settings. Defaults to ``None`` (no additional settings). :param replace_nonwords: boolean to replace non-words in column names to underscores. Defaults to ``True``. :return: pandas DataFrame. """ try: import pandas as pd except ImportError: raise RuntimeError('Extras for NumPy must be installed') data, columns = self.execute( query, columnar=True, with_column_types=True, params=params, external_tables=external_tables, query_id=query_id, settings=settings ) columns = [name for name, type_ in columns] if replace_nonwords: columns = [re.sub(r'\W', '_', x) for x in columns] return pd.DataFrame( {col: d for d, col in zip(data, columns)}, columns=columns ) def insert_dataframe( self, query, dataframe, external_tables=None, query_id=None, settings=None): """ *New in version 0.2.0.* Inserts pandas DataFrame with specified query. :param query: query that will be send to server. :param dataframe: pandas DataFrame. :param external_tables: external tables to send. Defaults to ``None`` (no external tables). :param query_id: the query identifier. If no query id specified ClickHouse server will generate it. :param settings: dictionary of query settings. Defaults to ``None`` (no additional settings). :return: number of inserted rows. """ try: import pandas as pd # noqa: F401 except ImportError: raise RuntimeError('Extras for NumPy must be installed') start_time = time() with self.disconnect_on_error(query, settings): self.connection.send_query(query, query_id=query_id) self.connection.send_external_tables(external_tables) sample_block = self.receive_sample_block() rv = None if sample_block: columns = [x[0] for x in sample_block.columns_with_types] # raise if any columns are missing from the dataframe diff = set(columns) - set(dataframe.columns) if len(diff): msg = "DataFrame missing required columns: {}" raise ValueError(msg.format(list(diff))) data = [dataframe[column].values for column in columns] rv = self.send_data(sample_block, data, columnar=True) self.receive_end_of_query() self.last_query.store_elapsed(time() - start_time) return rv def query_arrow( self, query, params=None, external_tables=None, query_id=None, settings=None, field_metadata=True, arrow_types=None): """ *New in version 0.2.11.* Queries data as PyArrow Table with specified SELECT query. :param query: query that will be send to server. :param params: substitution parameters. Defaults to ``None`` (no parameters or data). :param external_tables: external tables to send. Defaults to ``None`` (no external tables). :param query_id: the query identifier. If no query id specified ClickHouse server will generate it. :param settings: dictionary of query settings. Defaults to ``None`` (no additional settings). :param field_metadata: attach original ClickHouse column types to Arrow fields as ``clickhouse_type`` metadata. Defaults to ``True``. :param arrow_types: dictionary mapping column names to Arrow types, overriding the default mapping. Required for columns without a default Arrow representation (``JSON``). Defaults to ``None``. :return: pyarrow.Table. """ return self.query_arrow_stream( query, params=params, external_tables=external_tables, query_id=query_id, settings=settings, field_metadata=field_metadata, arrow_types=arrow_types ).read_all() def query_arrow_stream( self, query, params=None, external_tables=None, query_id=None, settings=None, field_metadata=True, arrow_types=None): """ *New in version 0.2.11.* Queries data as PyArrow RecordBatchReader with specified SELECT query. One record batch is yielded per ClickHouse block, so arbitrarily large results can be processed with constant memory usage. Block size can be controlled with ``max_block_size`` setting. The reader doesn't have to be consumed to the end: the streamed query is cancelled when the next query on this client starts. :param query: query that will be send to server. :param params: substitution parameters. Defaults to ``None`` (no parameters or data). :param external_tables: external tables to send. Defaults to ``None`` (no external tables). :param query_id: the query identifier. If no query id specified ClickHouse server will generate it. :param settings: dictionary of query settings. Defaults to ``None`` (no additional settings). :param field_metadata: attach original ClickHouse column types to Arrow fields as ``clickhouse_type`` metadata. Defaults to ``True``. :param arrow_types: dictionary mapping column names to Arrow types, overriding the default mapping. Required for columns without a default Arrow representation (``JSON``). Defaults to ``None``. :return: pyarrow.RecordBatchReader. """ try: import pyarrow # noqa: F401 except ImportError: raise RuntimeError('Extras for PyArrow must be installed') from .arrow.convert import ArrowStreamState, \ create_record_batch_reader with self.disconnect_on_error(query, settings): # Let columns return Arrow-friendly forms (e.g. NumPy masked # arrays for Nullable). Reset by the next query's # make_query_settings. Context returns a copy of settings: # assignment is required for the flag to stick. client_settings = self.connection.context.client_settings client_settings['use_arrow'] = True self.connection.context.client_settings = client_settings if params is not None: query = self.substitute_params( query, params, self.connection.context ) self.connection.send_query(query, query_id=query_id, params=params) self.connection.send_external_tables(external_tables) state = ArrowStreamState(self.connection) self._pending_arrow_stream = state return create_record_batch_reader( self.packet_generator(), self.connection.context, state=state, field_metadata=field_metadata, arrow_types=arrow_types ) def process_ordinary_query_with_progress( self, query, params=None, with_column_types=False, external_tables=None, query_id=None, types_check=False, columnar=False): if params is not None: query = self.substitute_params( query, params, self.connection.context ) self.connection.send_query(query, query_id=query_id, params=params) self.connection.send_external_tables(external_tables, types_check=types_check) return self.receive_result(with_column_types=with_column_types, progress=True, columnar=columnar) def process_ordinary_query( self, query, params=None, with_column_types=False, external_tables=None, query_id=None, types_check=False, columnar=False): if params is not None: query = self.substitute_params( query, params, self.connection.context ) self.connection.send_query(query, query_id=query_id, params=params) self.connection.send_external_tables(external_tables, types_check=types_check) return self.receive_result(with_column_types=with_column_types, columnar=columnar) def iter_process_ordinary_query( self, query, params=None, with_column_types=False, external_tables=None, query_id=None, types_check=False): if params is not None: query = self.substitute_params( query, params, self.connection.context ) self.connection.send_query(query, query_id=query_id, params=params) self.connection.send_external_tables(external_tables, types_check=types_check) return self.iter_receive_result(with_column_types=with_column_types) def process_insert_query(self, query_without_data, data, external_tables=None, query_id=None, types_check=False, columnar=False): self.connection.send_query(query_without_data, query_id=query_id) self.connection.send_external_tables(external_tables, types_check=types_check) sample_block = self.receive_sample_block() if sample_block: rv = self.send_data(sample_block, data, types_check=types_check, columnar=columnar) self.receive_end_of_insert_query() return rv def receive_sample_block(self): while True: packet = self.connection.receive_packet() if packet.type == ServerPacketTypes.DATA: return packet.block elif packet.type == ServerPacketTypes.EXCEPTION: raise packet.exception elif packet.type == ServerPacketTypes.LOG: log_block(packet.block) elif packet.type == ServerPacketTypes.TABLE_COLUMNS: pass else: message = self.connection.unexpected_packet_message( 'Data, Exception, Log or TableColumns', packet.type ) raise errors.UnexpectedPacketFromServerError(message) def send_data(self, sample_block, data, types_check=False, columnar=False): inserted_rows = 0 client_settings = self.connection.context.client_settings block_cls = ColumnOrientedBlock if columnar else RowOrientedBlock if client_settings['use_numpy']: try: from .numpy.helpers import column_chunks as numpy_column_chunks if columnar: slicer = numpy_column_chunks else: raise ValueError( 'NumPy inserts is only allowed with columnar=True' ) except ImportError: raise RuntimeError('Extras for NumPy must be installed') else: slicer = column_chunks if columnar else chunks for chunk in slicer(data, client_settings['insert_block_size']): block = block_cls(sample_block.columns_with_types, chunk, types_check=types_check) self.connection.send_data(block) inserted_rows += block.num_rows # Starting from the specific revision there are profile events # sent by server in response to each inserted block self.receive_profile_events() # Empty block means end of data. self.connection.send_data(block_cls()) # If enabled by revision profile events are also sent after empty block self.receive_profile_events() return inserted_rows def receive_end_of_query(self): while True: packet = self.connection.receive_packet() if packet.type == ServerPacketTypes.END_OF_STREAM: break elif packet.type == ServerPacketTypes.PROGRESS: self.last_query.store_progress(packet.progress) elif packet.type == ServerPacketTypes.EXCEPTION: raise packet.exception elif packet.type == ServerPacketTypes.LOG: log_block(packet.block) elif packet.type == ServerPacketTypes.TABLE_COLUMNS: pass elif packet.type == ServerPacketTypes.PROFILE_EVENTS: self.last_query.store_profile(packet.profile_info) else: message = self.connection.unexpected_packet_message( 'Exception, EndOfStream, Progress, TableColumns, ' 'ProfileEvents or Log', packet.type ) raise errors.UnexpectedPacketFromServerError(message) def receive_end_of_insert_query(self): while True: packet = self.connection.receive_packet() if packet.type == ServerPacketTypes.END_OF_STREAM: break elif packet.type == ServerPacketTypes.LOG: log_block(packet.block) elif packet.type == ServerPacketTypes.PROGRESS: self.last_query.store_progress(packet.progress) elif packet.type == ServerPacketTypes.PROFILE_EVENTS: # noqa: E501 pragma: requires-clickhouse-25.0 # When ``receive_profile_events`` exited early (e.g. on # a ``TimezoneUpdate``), the actual ``ProfileEvents`` # packet can land in this loop instead. self.last_query.store_profile(packet.profile_info) elif packet.type == ServerPacketTypes.TIMEZONE_UPDATE: # noqa: E501 pragma: requires-clickhouse-25.0 pass elif packet.type == ServerPacketTypes.EXCEPTION: raise packet.exception else: message = self.connection.unexpected_packet_message( 'EndOfStream, Log, Progress, ProfileEvents, ' 'TimezoneUpdate or Exception', packet.type ) raise errors.UnexpectedPacketFromServerError(message) def receive_profile_events(self): revision = self.connection.server_info.used_revision if ( revision < defines.DBMS_MIN_PROTOCOL_VERSION_WITH_PROFILE_EVENTS_IN_INSERT ): return None while True: packet = self.connection.receive_packet() if packet.type == ServerPacketTypes.PROFILE_EVENTS: self.last_query.store_profile(packet.profile_info) break elif packet.type == ServerPacketTypes.PROGRESS: self.last_query.store_progress(packet.progress) elif packet.type == ServerPacketTypes.LOG: log_block(packet.block) elif packet.type == ServerPacketTypes.EXCEPTION: raise packet.exception elif packet.type == ServerPacketTypes.TIMEZONE_UPDATE: # noqa: E501 pragma: requires-clickhouse-25.0 # ClickHouse 25.x sends ``TimezoneUpdate`` in the slot # where 24.x sent ``ProfileEvents`` between blocks of # ``INSERT ... SELECT FROM input(...)``. The server then # waits for the next data block, so looping for a # ``ProfileEvents`` we are never going to get would # deadlock. Treat the timezone packet as "no profile # events for this block" and let the caller continue. # The ``receive_packet`` machinery has already applied # the new session timezone. break else: message = self.connection.unexpected_packet_message( 'ProfileEvents, Progress, Log, Exception or ' 'TimezoneUpdate', packet.type ) raise errors.UnexpectedPacketFromServerError(message) def cancel(self, with_column_types=False): # TODO: Add warning if already cancelled. self.connection.send_cancel() # Client must still read until END_OF_STREAM packet. return self.receive_result(with_column_types=with_column_types) def substitute_params(self, query, params, context): """ Substitutes parameters into a provided query. For example:: client = Client(...) substituted_query = client.substitute_params( query='SELECT 1234, %(foo)s', params={'foo': 'bar'}, context=client.connection.context ) # prints: SELECT 1234, 'bar' print(substituted_query) """ # In case of server side templating we don't substitute here. if self.connection.context.client_settings['server_side_params']: return query if not isinstance(params, dict): raise ValueError('Parameters are expected in dict form') escaped = escape_params(params, context) return query % escaped @classmethod def from_url(cls, url): """ Return a client configured from the given URL. For example:: clickhouse://[user:password]@localhost:9000/default clickhouses://[user:password]@localhost:9440/default Three URL schemes are supported: * clickhouse:// creates a normal TCP socket connection * clickhouses:// creates a SSL wrapped TCP socket connection Any additional querystring arguments will be passed along to the Connection class's initializer. """ host, kwargs = parse_url(url) return cls(host, **kwargs) clickhouse-driver-0.2.11/clickhouse_driver/clientinfo.py000066400000000000000000000102571522645447600234510ustar00rootroot00000000000000import socket import getpass from time import time from . import defines from . import errors from .opentelemetry import OpenTelemetryTraceContext from .varint import write_varint from .writer import write_binary_str, write_binary_uint8, \ write_binary_uint64, write_binary_uint128 class ClientInfo(object): class Interface(object): TCP = 1 HTTP = 2 class QueryKind(object): # Uninitialized object. NO_QUERY = 0 INITIAL_QUERY = 1 # Query that was initiated by another query for distributed query # execution. SECONDARY_QUERY = 2 client_version_major = defines.CLIENT_VERSION_MAJOR client_version_minor = defines.CLIENT_VERSION_MINOR client_version_patch = defines.CLIENT_VERSION_PATCH interface = Interface.TCP initial_user = '' initial_query_id = '' initial_address = '0.0.0.0:0' def __init__(self, client_name, context, client_revision): self.query_kind = ClientInfo.QueryKind.NO_QUERY try: self.os_user = getpass.getuser() except (KeyError, OSError): self.os_user = '' self.client_hostname = socket.gethostname() self.client_name = client_name self.client_revision = client_revision self.client_trace_context = OpenTelemetryTraceContext( context.client_settings['opentelemetry_traceparent'], context.client_settings['opentelemetry_tracestate'] ) self.quota_key = context.client_settings['quota_key'] self.distributed_depth = 0 self.initial_query_start_time_microseconds = int(time() * 1000000) super(ClientInfo, self).__init__() @property def empty(self): return self.query_kind == ClientInfo.QueryKind.NO_QUERY def write(self, server_revision, fout): revision = server_revision if server_revision < defines.DBMS_MIN_REVISION_WITH_CLIENT_INFO: raise errors.LogicalError('Method ClientInfo.write is called ' 'for unsupported server revision') write_binary_uint8(self.query_kind, fout) if self.empty: return write_binary_str(self.initial_user, fout) write_binary_str(self.initial_query_id, fout) write_binary_str(self.initial_address, fout) if ( revision >= defines.DBMS_MIN_PROTOCOL_VERSION_WITH_INITIAL_QUERY_START_TIME ): write_binary_uint64( self.initial_query_start_time_microseconds, fout ) write_binary_uint8(self.interface, fout) write_binary_str(self.os_user, fout) write_binary_str(self.client_hostname, fout) write_binary_str(self.client_name, fout) write_varint(self.client_version_major, fout) write_varint(self.client_version_minor, fout) write_varint(self.client_revision, fout) if revision >= defines.DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO: write_binary_str(self.quota_key, fout) if revision >= \ defines.DBMS_MIN_PROTOCOL_VERSION_WITH_DISTRIBUTED_DEPTH: write_varint(self.distributed_depth, fout) if revision >= defines.DBMS_MIN_REVISION_WITH_VERSION_PATCH: write_varint(self.client_version_patch, fout) if revision >= defines.DBMS_MIN_REVISION_WITH_OPENTELEMETRY: if self.client_trace_context.trace_id is not None: # Have OpenTelemetry header. write_binary_uint8(1, fout) write_binary_uint128(self.client_trace_context.trace_id, fout) write_binary_uint64(self.client_trace_context.span_id, fout) write_binary_str(self.client_trace_context.tracestate, fout) write_binary_uint8(self.client_trace_context.trace_flags, fout) else: # Don't have OpenTelemetry header. write_binary_uint8(0, fout) if revision >= defines.DBMS_MIN_REVISION_WITH_PARALLEL_REPLICAS: write_varint(0, fout) # collaborate_with_initiator write_varint(0, fout) # count_participating_replicas write_varint(0, fout) # number_of_current_replica clickhouse-driver-0.2.11/clickhouse_driver/columns/000077500000000000000000000000001522645447600224205ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/columns/__init__.py000066400000000000000000000000001522645447600245170ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/columns/arraycolumn.py000066400000000000000000000132331522645447600253300ustar00rootroot00000000000000from itertools import chain from struct import Struct from .base import Column from .intcolumn import UInt64Column from ..util.helpers import pairwise class ArrayColumn(Column): """ Nested arrays written in flatten form after information about their sizes (offsets really). One element of array of arrays can be represented as tree: (0 depth) [[3, 4], [5, 6]] | | (1 depth) [3, 4] [5, 6] | | | | (leaf) 3 4 5 6 Offsets (sizes) written in breadth-first search order. In example above following sequence of offset will be written: 4 -> 2 -> 4 1) size of whole array: 4 2) size of array 1 in depth=1: 2 3) size of array 2 plus size of all array before in depth=1: 2 + 2 = 4 After sizes info comes flatten data: 3 -> 4 -> 5 -> 6 """ py_types = (list, tuple) def __init__(self, nested_column, **kwargs): self.init_kwargs = kwargs self.size_column = UInt64Column(**kwargs) self.nested_column = nested_column self._write_depth_0_size = True super(ArrayColumn, self).__init__(**kwargs) self.null_value = [] self.prefix_needs_items = nested_column.prefix_needs_items def write_data(self, data, buf): # Column of Array(T) is stored in "compact" format and passed to server # wrapped into another Array without size of wrapper array. self.nested_column = ArrayColumn( self.nested_column, **self.init_kwargs ) self.nested_column.nullable = self.nullable self.nullable = False self._write_depth_0_size = False self._write(data, buf) def read_data(self, n_rows, buf): self.nested_column = ArrayColumn( self.nested_column, **self.init_kwargs ) self.nested_column.nullable = self.nullable self.nullable = False return self._read(n_rows, buf)[0] def _write_sizes(self, value, buf): nulls_map = [] column = self sizes = [len(value)] if self._write_depth_0_size else [] while True: nested_column = column.nested_column if not isinstance(nested_column, ArrayColumn): if column.nullable: nulls_map = [x is None for x in value] break offset = 0 new_value = [] for x in value: offset += len(x) sizes.append(offset) new_value.extend(x) value = new_value column = nested_column if nulls_map: self._write_nulls_map(nulls_map, buf) ns = Struct('<{}Q'.format(len(sizes))) buf.write(ns.pack(*sizes)) def _write_data(self, value, buf): if self.nullable: value = value or [] if isinstance(self.nested_column, ArrayColumn): value = list(chain.from_iterable(value)) if value: self.nested_column._write_data(value, buf) def _write_nulls_data(self, value, buf): if self.nullable: value = value or [] if isinstance(self.nested_column, ArrayColumn): value = list(chain.from_iterable(value)) self.nested_column._write_nulls_data(value, buf) else: if self.nested_column.nullable: self.nested_column._write_nulls_map(value, buf) def _write(self, value, buf): value = self.prepare_items(value) self._write_sizes(value, buf) self._write_nulls_data(value, buf) self._write_data(value, buf) def read_state_prefix(self, buf): super(ArrayColumn, self).read_state_prefix(buf) self.nested_column.read_state_prefix(buf) def write_state_prefix(self, buf, items=None): super(ArrayColumn, self).write_state_prefix(buf) nested_items = None if items is not None and self.nested_column.prefix_needs_items: # One level of flattening per Array level, so the leaf # column sees the same flat item list its data writer will # receive. nested_items = [x for item in items if item is not None for x in item] self.nested_column.write_state_prefix(buf, nested_items) def _read(self, size, buf): slices_series = [[0, size]] nested_column = self.nested_column cur_level_slice_size = size cur_level_slice = None while (isinstance(nested_column, ArrayColumn)): if cur_level_slice is None: cur_level_slice = [0] ns = Struct('<{}Q'.format(cur_level_slice_size)) nested_sizes = ns.unpack(buf.read(ns.size)) cur_level_slice.extend(nested_sizes) slices_series.append(cur_level_slice) cur_level_slice = None cur_level_slice_size = nested_sizes[-1] if len(nested_sizes) > 0 \ else 0 nested_column = nested_column.nested_column n_items = cur_level_slice_size if size > 0 else 0 nulls_map = None if nested_column.nullable: nulls_map = self._read_nulls_map(n_items, buf) data = [] if n_items: data = list(nested_column._read_data( n_items, buf, nulls_map=nulls_map )) # Build nested structure. for slices in reversed(slices_series): data = [data[begin:end] for begin, end in pairwise(slices)] return tuple(data) def create_array_column(spec, column_by_spec_getter, column_options): inner = spec[6:-1] return ArrayColumn(column_by_spec_getter(inner), **column_options) clickhouse-driver-0.2.11/clickhouse_driver/columns/arrow/000077500000000000000000000000001522645447600235525ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/columns/arrow/__init__.py000066400000000000000000000000001522645447600256510ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/columns/arrow/base.py000066400000000000000000000014751522645447600250450ustar00rootroot00000000000000import numpy as np class ArrowColumnMixin(object): """ Read-path override for Arrow result queries (``query_arrow``/``query_arrow_stream``). Values are kept in wire-friendly form and assembled into pyarrow arrays by ``clickhouse_driver.arrow.convert``. """ def _read_data(self, n_items, buf, nulls_map=None): items = self.read_items(n_items, buf) if self.after_read_items: return self.after_read_items(items, nulls_map) elif nulls_map is not None: # Arrow stores nullable columns the same way the wire # sends them: raw values plus a validity mask. No need to # convert to an object ndarray with None like the NumPy # family does. return np.ma.MaskedArray(items, mask=nulls_map) return items clickhouse-driver-0.2.11/clickhouse_driver/columns/arrow/boolcolumn.py000066400000000000000000000002271522645447600262760ustar00rootroot00000000000000from ..numpy.boolcolumn import NumpyBoolColumn from .base import ArrowColumnMixin class ArrowBoolColumn(ArrowColumnMixin, NumpyBoolColumn): pass clickhouse-driver-0.2.11/clickhouse_driver/columns/arrow/datecolumn.py000066400000000000000000000002271522645447600262600ustar00rootroot00000000000000from ..numpy.datecolumn import NumpyDateColumn from .base import ArrowColumnMixin class ArrowDateColumn(ArrowColumnMixin, NumpyDateColumn): pass clickhouse-driver-0.2.11/clickhouse_driver/columns/arrow/datetimecolumn.py000066400000000000000000000010001522645447600271250ustar00rootroot00000000000000from ..numpy.datetimecolumn import ( NumpyDateTime64Column, NumpyDateTimeColumn, create_numpy_datetime_column ) from .base import ArrowColumnMixin class ArrowDateTimeColumn(ArrowColumnMixin, NumpyDateTimeColumn): pass class ArrowDateTime64Column(ArrowColumnMixin, NumpyDateTime64Column): pass def create_arrow_datetime_column(spec, column_options): return create_numpy_datetime_column( spec, column_options, column_classes=(ArrowDateTimeColumn, ArrowDateTime64Column) ) clickhouse-driver-0.2.11/clickhouse_driver/columns/arrow/floatcolumn.py000066400000000000000000000004001522645447600264410ustar00rootroot00000000000000from ..numpy.floatcolumn import NumpyFloat32Column, NumpyFloat64Column from .base import ArrowColumnMixin class ArrowFloat32Column(ArrowColumnMixin, NumpyFloat32Column): pass class ArrowFloat64Column(ArrowColumnMixin, NumpyFloat64Column): pass clickhouse-driver-0.2.11/clickhouse_driver/columns/arrow/intcolumn.py000066400000000000000000000014321522645447600261340ustar00rootroot00000000000000from ..numpy.intcolumn import ( NumpyInt8Column, NumpyInt16Column, NumpyInt32Column, NumpyInt64Column, NumpyUInt8Column, NumpyUInt16Column, NumpyUInt32Column, NumpyUInt64Column ) from .base import ArrowColumnMixin class ArrowInt8Column(ArrowColumnMixin, NumpyInt8Column): pass class ArrowInt16Column(ArrowColumnMixin, NumpyInt16Column): pass class ArrowInt32Column(ArrowColumnMixin, NumpyInt32Column): pass class ArrowInt64Column(ArrowColumnMixin, NumpyInt64Column): pass class ArrowUInt8Column(ArrowColumnMixin, NumpyUInt8Column): pass class ArrowUInt16Column(ArrowColumnMixin, NumpyUInt16Column): pass class ArrowUInt32Column(ArrowColumnMixin, NumpyUInt32Column): pass class ArrowUInt64Column(ArrowColumnMixin, NumpyUInt64Column): pass clickhouse-driver-0.2.11/clickhouse_driver/columns/arrow/service.py000066400000000000000000000047471522645447600256000ustar00rootroot00000000000000from ... import errors from ..nullablecolumn import create_nullable_column from ..numpy.lowcardinalitycolumn import create_numpy_low_cardinality_column from ..numpy.tuplecolumn import create_tuple_column from ..service import aliases from .boolcolumn import ArrowBoolColumn from .datecolumn import ArrowDateColumn from .datetimecolumn import create_arrow_datetime_column from .floatcolumn import ArrowFloat32Column, ArrowFloat64Column from .intcolumn import ( ArrowInt8Column, ArrowInt16Column, ArrowInt32Column, ArrowInt64Column, ArrowUInt8Column, ArrowUInt16Column, ArrowUInt32Column, ArrowUInt64Column ) from .stringcolumn import create_arrow_string_column # Fixed-width types differ from their NumPy counterparts only in # nullable reads: ArrowColumnMixin keeps the values and the nulls map # intact instead of converting to an object ndarray. column_by_type = {c.ch_type: c for c in [ ArrowDateColumn, ArrowFloat32Column, ArrowFloat64Column, ArrowInt8Column, ArrowInt16Column, ArrowInt32Column, ArrowInt64Column, ArrowUInt8Column, ArrowUInt16Column, ArrowUInt32Column, ArrowUInt64Column, ArrowBoolColumn ]} def get_arrow_column_by_spec(spec, column_options): def create_column_with_options(x): return get_arrow_column_by_spec(x, column_options) if spec == 'String' or spec.startswith('FixedString'): return create_arrow_string_column(spec, column_options) elif spec.startswith('DateTime'): return create_arrow_datetime_column(spec, column_options) elif spec.startswith('Tuple'): return create_tuple_column( spec, create_column_with_options, column_options ) elif spec.startswith('Nullable'): return create_nullable_column(spec, create_column_with_options) elif spec.startswith('LowCardinality'): column = create_numpy_low_cardinality_column( spec, create_column_with_options, column_options ) # Dictionary values are consumed by pd.Categorical: real items # are needed, not Arrow buffers. column.nested_column.arrow_buffers_allowed = False return column else: for alias, primitive in aliases: if spec.startswith(alias): return create_column_with_options( primitive + spec[len(alias):] ) if spec in column_by_type: cls = column_by_type[spec] return cls(**column_options) raise errors.UnknownTypeError('Unknown type {}'.format(spec)) clickhouse-driver-0.2.11/clickhouse_driver/columns/arrow/stringcolumn.py000066400000000000000000000073221522645447600266540ustar00rootroot00000000000000import numpy as np from ..base import CommonSerialization from ..numpy.stringcolumn import ( NumpyByteFixedString, NumpyByteStringColumn, NumpyFixedString, NumpyStringColumn ) from .base import ArrowColumnMixin class ArrowStringBuffers(object): """ String column read into Arrow-style buffers: concatenated bytes plus int64 offsets, no per-string Python objects. Assembled into a pyarrow array by ``clickhouse_driver.arrow.convert``. """ __slots__ = ('offsets', 'data', 'nulls_map') def __init__(self, offsets, data, nulls_map=None): self.offsets = offsets self.data = data self.nulls_map = nulls_map def __len__(self): return len(self.offsets) // 8 - 1 class ArrowStringMixin(ArrowColumnMixin): # Reset for columns whose consumers need real items, e.g. # LowCardinality dictionaries. arrow_buffers_allowed = True def _buffers_encoding_ok(self): return self.encoding.lower() in ('utf-8', 'utf8') def _use_arrow_buffers(self, buf): return ( self.arrow_buffers_allowed and self._buffers_encoding_ok() and type(self.serialization) is CommonSerialization and hasattr(buf, 'read_strings_arrow') ) def _read_data(self, n_items, buf, nulls_map=None): if self._use_arrow_buffers(buf): offsets, data = buf.read_strings_arrow(n_items) return ArrowStringBuffers(offsets, data, nulls_map=nulls_map) return super(ArrowStringMixin, self)._read_data( n_items, buf, nulls_map=nulls_map ) def _wrap_items(self, items): # Wrapping strings into an ndarray re-encodes them (unicode # dtype). Arrow consumes the raw tuple directly; the ndarray # is only needed for the nullable masked path. if self.nullable: return np.array(items, dtype=self.dtype) return items class ArrowStringColumn(ArrowStringMixin, NumpyStringColumn): def read_items(self, n_items, buf): return self._wrap_items( buf.read_strings(n_items, encoding=self.encoding) ) class ArrowByteStringColumn(ArrowStringMixin, NumpyByteStringColumn): def _buffers_encoding_ok(self): # No decoding happens for byte strings: buffers can be used # regardless of encoding. return True def read_items(self, n_items, buf): return self._wrap_items(buf.read_strings(n_items)) class ArrowFixedString(ArrowStringMixin, NumpyFixedString): def _use_arrow_buffers(self, buf): # Fixed strings are trimmed of zero bytes on read: buffers # would keep the padding. return False def read_items(self, n_items, buf): return self._wrap_items(buf.read_fixed_strings( n_items, self.length, encoding=self.encoding )) class ArrowByteFixedString(ArrowStringMixin, NumpyByteFixedString): def _use_arrow_buffers(self, buf): return False def read_items(self, n_items, buf): return self._wrap_items( buf.read_fixed_strings(n_items, self.length) ) def create_arrow_string_column(spec, column_options): client_settings = column_options['context'].client_settings strings_as_bytes = client_settings['strings_as_bytes'] encoding = client_settings.get( 'strings_encoding', NumpyStringColumn.default_encoding ) if spec == 'String': cls = ArrowByteStringColumn if strings_as_bytes \ else ArrowStringColumn return cls(encoding=encoding, **column_options) else: length = int(spec[12:-1]) cls = ArrowByteFixedString if strings_as_bytes \ else ArrowFixedString return cls(length, encoding=encoding, **column_options) clickhouse-driver-0.2.11/clickhouse_driver/columns/base.py000066400000000000000000000152331522645447600237100ustar00rootroot00000000000000from struct import Struct, error as struct_error from . import exceptions from ..varint import read_varint class CommonSerialization(object): def __init__(self, column): self.column = column super(CommonSerialization, self).__init__() def read_sparse(self, n_items, buf): return n_items def apply_sparse(self, items): return items class SparseSerialization(CommonSerialization): def __init__(self, *args, **kwargs): self.sparse_indexes = [] self.items_total = None super(SparseSerialization, self).__init__(*args, **kwargs) def read_sparse(self, n_items, buf): sparse_indexes = [] items_total = 0 non_default_items = 0 END_OF_GRANULE_FLAG = 1 << 62 end_of_granule = False while not end_of_granule: group_size = read_varint(buf) end_of_granule = group_size & END_OF_GRANULE_FLAG group_size &= ~END_OF_GRANULE_FLAG items_total += group_size + 1 if not end_of_granule: non_default_items += 1 sparse_indexes.append(items_total) self.sparse_indexes = sparse_indexes self.items_total = items_total return non_default_items def apply_sparse(self, items): default = self.column.null_value if self.column.after_read_items: default = self.column.after_read_items([default])[0] rv = [default] * (self.items_total - 1) for item_number, i in enumerate(self.sparse_indexes): rv[i - 1] = items[item_number] return rv class Column(object): ch_type = None py_types = None check_item = None after_read_items = None before_write_items = None types_check_enabled = False null_value = 0 # True when ``write_state_prefix`` needs the block's items to emit # the prefix (JSON: the path list is data-dependent). Container # columns propagate the flag and thread flattened items through so # ordinary columns never pay for the flattening. prefix_needs_items = False def __init__(self, types_check=False, has_custom_serialization=False, **kwargs): self.nullable = False self.types_check_enabled = types_check self.has_custom_serialization = has_custom_serialization self.serialization = CommonSerialization(self) self.input_null_as_default = False self.context = kwargs['context'] self.input_null_as_default = self.context.client_settings \ .get('input_format_null_as_default', False) super(Column, self).__init__() def make_null_struct(self, n_items): return Struct('<{}B'.format(n_items)) def _read_nulls_map(self, n_items, buf): s = self.make_null_struct(n_items) return s.unpack(buf.read(s.size)) def _write_nulls_map(self, items, buf): s = self.make_null_struct(len(items)) items = [x is None for x in items] buf.write(s.pack(*items)) def check_item_type(self, value): if not isinstance(value, self.py_types): raise exceptions.ColumnTypeMismatchException(value) def prepare_items(self, items): nullable = self.nullable null_value = self.null_value null_as_default = self.input_null_as_default check_item = self.check_item if self.types_check_enabled: check_item_type = self.check_item_type else: check_item_type = False if (not (self.nullable or null_as_default) and not check_item_type and not check_item and not self.before_write_items): return items nulls_map = [False] * len(items) if self.nullable else None for i, x in enumerate(items): if x is None: if nullable: nulls_map[i] = True x = null_value elif null_as_default: x = null_value else: if check_item_type: check_item_type(x) if check_item: check_item(x) items[i] = x if self.before_write_items: self.before_write_items(items, nulls_map=nulls_map) return items def write_data(self, items, buf): if self.nullable: self._write_nulls_map(items, buf) self._write_data(items, buf) def _write_data(self, items, buf): prepared = self.prepare_items(items) self.write_items(prepared, buf) def write_items(self, items, buf): raise NotImplementedError def read_data(self, n_items, buf): n_items = self.serialization.read_sparse(n_items, buf) if self.nullable: nulls_map = self._read_nulls_map(n_items, buf) else: nulls_map = None items = self._read_data(n_items, buf, nulls_map=nulls_map) return self.serialization.apply_sparse(items) def _read_data(self, n_items, buf, nulls_map=None): items = self.read_items(n_items, buf) if self.after_read_items: return self.after_read_items(items, nulls_map) elif nulls_map is not None: return tuple( (None if is_null else items[i]) for i, is_null in enumerate(nulls_map) ) return items def read_items(self, n_items, buf): raise NotImplementedError def read_state_prefix(self, buf): if self.has_custom_serialization: use_custom_serialization = read_varint(buf) if use_custom_serialization: self.serialization = SparseSerialization(self) def write_state_prefix(self, buf, items=None): pass class FormatColumn(Column): """ Uses struct.pack for bulk items writing. """ format = None def make_struct(self, n_items): return Struct('<{}{}'.format(n_items, self.format)) def write_items(self, items, buf): s = self.make_struct(len(items)) try: buf.write(s.pack(*items)) except struct_error as e: raise exceptions.StructPackException(e) def read_items(self, n_items, buf): s = self.make_struct(n_items) return s.unpack(buf.read(s.size)) # How to write new column? # - Check ClickHouse documentation for column # - Wireshark and tcpdump are your friends. # - Use `clickhouse-client --compression 0` to see what's going on data # transmission. # - Check for similar existing columns and tests. # - Use `FormatColumn` for columns that use "simple" types under the hood. # - Some columns have before_write and after_read hooks. # Use them to convert items in column into "simple" types. clickhouse-driver-0.2.11/clickhouse_driver/columns/boolcolumn.py000066400000000000000000000001771522645447600251500ustar00rootroot00000000000000from .base import FormatColumn class BoolColumn(FormatColumn): ch_type = 'Bool' py_types = (bool, ) format = '?' clickhouse-driver-0.2.11/clickhouse_driver/columns/datecolumn.py000066400000000000000000000062111522645447600251250ustar00rootroot00000000000000from os import getenv from datetime import date, timedelta from .base import FormatColumn epoch_start = date(1970, 1, 1) epoch_end = date(2149, 6, 6) epoch_start_date32 = date(1900, 1, 1) epoch_end_date32 = date(2299, 12, 31) class LazyLUT(dict): def __init__(self, *args, _factory, **kwargs): super().__init__(*args, **kwargs) self._default_factory = _factory def __missing__(self, key): return self.setdefault(key, self._default_factory(key)) def make_date_lut_range(date_start, date_end): return range( (date_start - epoch_start).days, (date_end - epoch_start).days + 1, ) enable_lazy_date_lut = getenv('CLICKHOUSE_DRIVER_LASY_DATE_LUT', False) if enable_lazy_date_lut: try: start, end = enable_lazy_date_lut.split(':') start_date = date.fromisoformat(start) end_date = date.fromisoformat(end) date_range = make_date_lut_range(start_date, end_date) except ValueError: date_range = () # Since we initialize lazy lut with some initially warmed values, # we use iterator and not dict comprehension for memory & time optimization _date_lut = LazyLUT( ((x, epoch_start + timedelta(days=x)) for x in date_range), _factory=lambda x: epoch_start + timedelta(days=x), ) _date_lut_reverse = LazyLUT( ((value, key) for key, value in _date_lut.items()), _factory=lambda x: (x - epoch_start).days, ) else: # If lazy lut is not enabled, we fallback to static dict initialization # In both cases, we use same lut for both data types, # since one encompasses the other and we can avoid duplicating overlap date_range = make_date_lut_range(epoch_start_date32, epoch_end_date32) _date_lut = {x: epoch_start + timedelta(days=x) for x in date_range} _date_lut_reverse = {value: key for key, value in _date_lut.items()} class DateColumn(FormatColumn): ch_type = 'Date' py_types = (date, ) format = 'H' min_value = epoch_start max_value = epoch_end date_lut = _date_lut date_lut_reverse = _date_lut_reverse def before_write_items(self, items, nulls_map=None): null_value = self.null_value date_lut_reverse = self.date_lut_reverse min_value = self.min_value max_value = self.max_value for i, item in enumerate(items): if nulls_map and nulls_map[i]: items[i] = null_value continue if item is not date: item = date(item.year, item.month, item.day) if min_value <= item <= max_value: items[i] = date_lut_reverse[item] else: items[i] = 0 def after_read_items(self, items, nulls_map=None): date_lut = self.date_lut if nulls_map is None: return tuple(date_lut[item] for item in items) else: return tuple( (None if is_null else date_lut[items[i]]) for i, is_null in enumerate(nulls_map) ) class Date32Column(DateColumn): ch_type = 'Date32' format = 'i' min_value = epoch_start_date32 max_value = epoch_end_date32 clickhouse-driver-0.2.11/clickhouse_driver/columns/datetimecolumn.py000066400000000000000000000151121522645447600260040ustar00rootroot00000000000000from datetime import datetime from pytz import timezone as get_timezone, utc from ..util.compat import get_localzone_name_compat from .base import FormatColumn EPOCH = datetime(1970, 1, 1, tzinfo=utc) class DateTimeColumn(FormatColumn): ch_type = 'DateTime' py_types = (datetime, int) format = 'I' def __init__(self, timezone=None, offset_naive=True, **kwargs): self.timezone = timezone self.offset_naive = offset_naive super(DateTimeColumn, self).__init__(**kwargs) def after_read_items(self, items, nulls_map=None): tz = self.timezone fromts = datetime.fromtimestamp # A bit ugly copy-paste. But it helps save time on items # processing by avoiding lambda calls or if in loop. if self.offset_naive: if tz: if nulls_map is None: return tuple( fromts(item, tz).replace(tzinfo=None) for item in items ) else: return tuple( (None if is_null else fromts(items[i], tz).replace(tzinfo=None)) for i, is_null in enumerate(nulls_map) ) else: if nulls_map is None: return tuple(fromts(item) for item in items) else: return tuple( (None if is_null else fromts(items[i])) for i, is_null in enumerate(nulls_map) ) else: if nulls_map is None: return tuple(fromts(item, tz) for item in items) else: return tuple( (None if is_null else fromts(items[i], tz)) for i, is_null in enumerate(nulls_map) ) def before_write_items(self, items, nulls_map=None): timezone = self.timezone null_value = self.null_value to_timestamp = datetime.timestamp for i, item in enumerate(items): if nulls_map and nulls_map[i]: items[i] = null_value continue if isinstance(item, int): # support supplying raw integers to avoid # costly timezone conversions when using datetime continue if timezone: # Set server's timezone for offset-naive datetime. if item.tzinfo is None: item = timezone.localize(item) item = item.astimezone(utc) else: # If datetime is offset-aware use it's timezone. if item.tzinfo is not None: item = item.astimezone(utc) items[i] = int(to_timestamp(item)) class DateTime64Column(DateTimeColumn): ch_type = 'DateTime64' format = 'q' max_scale = 6 def __init__(self, scale=0, **kwargs): self.scale = scale super(DateTime64Column, self).__init__(**kwargs) def after_read_items(self, items, nulls_map=None): scale = float(10 ** self.scale) tz = self.timezone fromts = datetime.fromtimestamp # A bit ugly copy-paste. But it helps save time on items # processing by avoiding lambda calls or if in loop. if self.offset_naive: if tz: if nulls_map is None: return tuple( fromts(item / scale, tz).replace(tzinfo=None) for item in items ) else: return tuple( (None if is_null else fromts(items[i] / scale, tz).replace(tzinfo=None)) for i, is_null in enumerate(nulls_map) ) else: if nulls_map is None: return tuple(fromts(item / scale) for item in items) else: return tuple( (None if is_null else fromts(items[i] / scale)) for i, is_null in enumerate(nulls_map) ) else: if nulls_map is None: return tuple(fromts(item / scale, tz) for item in items) else: return tuple( (None if is_null else fromts(items[i] / scale, tz)) for i, is_null in enumerate(nulls_map) ) def before_write_items(self, items, nulls_map=None): scale = 10 ** self.scale frac_scale = 10 ** (self.max_scale - self.scale) timezone = self.timezone null_value = self.null_value to_timestamp = datetime.timestamp for i, item in enumerate(items): if nulls_map and nulls_map[i]: items[i] = null_value continue if isinstance(item, int): # support supplying raw integers to avoid # costly timezone conversions when using datetime continue if timezone: # Set server's timezone for offset-naive datetime. if item.tzinfo is None: item = timezone.localize(item) item = item.astimezone(utc) else: # If datetime is offset-aware use it's timezone. if item.tzinfo is not None: item = item.astimezone(utc) items[i] = ( int(to_timestamp(item)) * scale + int(item.microsecond / frac_scale) ) def create_datetime_column(spec, column_options): if spec.startswith('DateTime64'): cls = DateTime64Column spec = spec[11:-1] params = spec.split(',', 1) column_options['scale'] = int(params[0]) if len(params) > 1: spec = params[1].strip() + ')' else: cls = DateTimeColumn spec = spec[9:] context = column_options['context'] tz_name = timezone = None offset_naive = True # Use column's timezone if it's specified. if spec and spec[-1] == ')': tz_name = spec[1:-2] offset_naive = False else: if not context.settings.get('use_client_time_zone', False): local_timezone = get_localzone_name_compat() remote_timezone = context.server_info.get_timezone() if local_timezone != remote_timezone: tz_name = remote_timezone if tz_name: timezone = get_timezone(tz_name) return cls(timezone=timezone, offset_naive=offset_naive, **column_options) clickhouse-driver-0.2.11/clickhouse_driver/columns/decimalcolumn.py000066400000000000000000000065721522645447600256200ustar00rootroot00000000000000from decimal import Decimal, localcontext from .base import FormatColumn from .exceptions import ColumnTypeMismatchException from .intcolumn import Int128Column, Int256Column class DecimalColumn(FormatColumn): py_types = (Decimal, float, int) max_precision = None def __init__(self, precision, scale, types_check=False, **kwargs): self.precision = precision self.scale = scale super(DecimalColumn, self).__init__(**kwargs) if types_check: def check_item(value): parts = str(value).split('.') int_part = parts[0] if len(int_part) > precision: raise ColumnTypeMismatchException(value) self.check_item = check_item def after_read_items(self, items, nulls_map=None): if self.scale >= 1: scale = 10 ** self.scale if nulls_map is None: return tuple(Decimal(item) / scale for item in items) else: return tuple( (None if is_null else Decimal(items[i]) / scale) for i, is_null in enumerate(nulls_map) ) else: if nulls_map is None: return tuple(Decimal(item) for item in items) else: return tuple( (None if is_null else Decimal(items[i])) for i, is_null in enumerate(nulls_map) ) def before_write_items(self, items, nulls_map=None): null_value = self.null_value if self.scale >= 1: scale = 10 ** self.scale for i, item in enumerate(items): if nulls_map and nulls_map[i]: items[i] = null_value else: items[i] = int(Decimal(str(item)) * scale) else: for i, item in enumerate(items): if nulls_map and nulls_map[i]: items[i] = null_value else: items[i] = int(Decimal(str(item))) # Override default precision to the maximum supported by underlying type. def _write_data(self, items, buf): with localcontext() as ctx: ctx.prec = self.max_precision super(DecimalColumn, self)._write_data(items, buf) def _read_data(self, n_items, buf, nulls_map=None): with localcontext() as ctx: ctx.prec = self.max_precision return super(DecimalColumn, self)._read_data( n_items, buf, nulls_map=nulls_map ) class Decimal32Column(DecimalColumn): format = 'i' max_precision = 9 class Decimal64Column(DecimalColumn): format = 'q' max_precision = 18 class Decimal128Column(DecimalColumn, Int128Column): max_precision = 38 class Decimal256Column(DecimalColumn, Int256Column): max_precision = 76 def create_decimal_column(spec, column_options): precision, scale = spec[8:-1].split(',') precision, scale = int(precision), int(scale) # Maximum precisions for underlying types are: # Int32 10**9 # Int64 10**18 # Int128 10**38 # Int256 10**76 if precision <= 9: cls = Decimal32Column elif precision <= 18: cls = Decimal64Column elif precision <= 38: cls = Decimal128Column else: cls = Decimal256Column return cls(precision, scale, **column_options) clickhouse-driver-0.2.11/clickhouse_driver/columns/dynamiccolumn.py000066400000000000000000000472011522645447600256400ustar00rootroot00000000000000""" Reader for ClickHouse's Dynamic / Variant column families. These are not exposed as user-facing types in clickhouse-driver yet — they exist here so the JSON column reader can compose them instead of hand-rolling Variant deserialization. The byte layout mirrors ``SerializationDynamic`` and ``SerializationVariant`` in ClickHouse 25.5. """ from .base import Column from .stringcolumn import ByteString from ..reader import ( read_binary_str, read_binary_uint64, ) from ..varint import read_varint __all__ = [ 'DynamicColumn', 'SharedValueDecoder', 'DYNAMIC_V1', 'DYNAMIC_V2', 'VARIANT_MODE_BASIC', 'VARIANT_MODE_COMPACT', 'NULL_DISCRIMINATOR', 'SHARED_VARIANT_NAME', ] # DynamicSerializationVersion enum (ClickHouse 25.5). Note these # numeric values differ from ObjectSerializationVersion in # newjsoncolumn — each enum is independent on the server side. DYNAMIC_V1 = 1 DYNAMIC_V2 = 2 # VariantDiscriminatorsSerializationMode. VARIANT_MODE_BASIC = 0 VARIANT_MODE_COMPACT = 1 # ColumnVariant::NULL_DISCRIMINATOR — the global discriminator value used # to mark a NULL row. NULL_DISCRIMINATOR = 0xFF # SHARED_VARIANT_TYPE_NAME from ClickHouse src/Columns/ColumnDynamic.h. # Participates in the alphabetical sort of variant names alongside # user-declared variants. SHARED_VARIANT_NAME = "SharedVariant" class DynamicColumn(Column): """ Reader for a ClickHouse ``Dynamic`` column. Construction does not know the inner variant types yet — those come from the wire in ``read_state_prefix``. The variant list always ends with an implicit ``SharedVariant`` (a ``ByteString`` carrying ``encodeDataType + serializeBinary`` blobs) that catches values whose type does not match any of the declared variants. """ py_types = (object,) def __init__(self, column_by_spec_getter, shared_value_decoder=None, **kwargs): self.column_by_spec_getter = column_by_spec_getter # Pre-built decoder for the implicit SharedVariant. Sharing one # across all DynamicColumns of a block (plus the JSON column # itself) lets the handler/column caches accumulate across # every overflow value in the block. if shared_value_decoder is None: shared_value_decoder = SharedValueDecoder( column_by_spec_getter) self.shared_value_decoder = shared_value_decoder self._column_kwargs = kwargs self.variant_specs = [] self.variant_columns = [] self.discriminators_mode = VARIANT_MODE_BASIC super(DynamicColumn, self).__init__(**kwargs) def read_state_prefix(self, buf): # ObjectStructure stream: # UInt64 LE structure_version (V1 = 1, V2 = 2) # if V1: VarUInt num_dynamic_types (legacy max_dynamic_types # slot, value reused for the # variant count — discarded # by the server too) # VarUInt num_dynamic_types (excludes the implicit # SharedVariant) # N × String variant type spec # SerializationVariant prefix: # UInt64 LE discriminators_mode (BASIC = 0, COMPACT = 1) structure_version = read_binary_uint64(buf) if structure_version not in (DYNAMIC_V1, DYNAMIC_V2): raise NotImplementedError( "Unsupported Dynamic serialization version {}".format( structure_version)) if structure_version == DYNAMIC_V1: read_varint(buf) # legacy slot num_dynamic_types = read_varint(buf) declared_specs = [ read_binary_str(buf) for _ in range(num_dynamic_types) ] # SerializationVariant / DataTypeVariant sort their global # discriminators by ``DataType::getName()`` alphabetically. The # SharedVariant type name ("SharedVariant") participates in the # sort, so we have to interleave it back in to know which # discriminator index it claims. all_names = list(declared_specs) + [SHARED_VARIANT_NAME] sorted_names = sorted(all_names) self.variant_specs = list(declared_specs) self.variant_columns = [] self._shared_variant_index = None for i, name in enumerate(sorted_names): if name == SHARED_VARIANT_NAME: self.variant_columns.append( ByteString(**self._column_kwargs)) self._shared_variant_index = i else: self.variant_columns.append( self.column_by_spec_getter(name)) self.discriminators_mode = read_binary_uint64(buf) if self.discriminators_mode not in ( VARIANT_MODE_BASIC, VARIANT_MODE_COMPACT): raise NotImplementedError( "Unsupported Variant discriminators mode {}".format( self.discriminators_mode)) # Variant element state prefixes — most primitives are no-ops but # any composed type (LowCardinality, etc.) needs to consume its # own bytes. The SharedVariant String has no prefix. for i, column in enumerate(self.variant_columns): if i == self._shared_variant_index: continue column.read_state_prefix(buf) def read_items(self, n_items, buf): """ Read ``n_items`` rows of the SerializationVariant body in BASIC mode. Wire layout per ClickHouse 25.5: * ``n_items × UInt8`` global discriminators (``255`` for NULL). * For each variant in global discriminator order, the per-variant column data sized by how many rows landed in that variant. Rows that hit the SharedVariant slot are passed through ``self.shared_value_decoder`` to recover their Python form. """ if self.discriminators_mode == VARIANT_MODE_COMPACT: raise NotImplementedError( "Compact Variant discriminators are not supported yet") variant_columns = self.variant_columns shared_variant_index = self._shared_variant_index shared_variant_decoder = self.shared_value_decoder.decode discriminators = buf.read(n_items) if len(discriminators) != n_items: raise EOFError( "Variant discriminators truncated: got {} bytes, " "want {}".format(len(discriminators), n_items)) # Count rows per variant (preserving wire-order row appearance). per_variant_indices = [[] for _ in range(len(variant_columns))] for row, disc in enumerate(discriminators): if disc == NULL_DISCRIMINATOR: continue if disc >= len(variant_columns): raise ValueError( "Variant discriminator {} out of range " "(have {} variants)".format( disc, len(variant_columns))) per_variant_indices[disc].append(row) values_by_row = [None] * n_items for variant_idx, rows in enumerate(per_variant_indices): if not rows: continue column = variant_columns[variant_idx] # ``read_data`` handles nulls maps / nested column wiring; # ``read_items`` is a thinner low-level API. Pick whichever # the underlying column exposes — most primitives implement # both. if hasattr(column, 'read_data'): chunk = column.read_data(len(rows), buf) else: chunk = column.read_items(len(rows), buf) chunk = list(chunk) if variant_idx == shared_variant_index: chunk = [shared_variant_decoder(b) for b in chunk] for row, value in zip(rows, chunk): values_by_row[row] = value return values_by_row # ---------------------------------------------------------------------- # encodeDataType / serializeBinary decoder for SharedVariant blobs # ---------------------------------------------------------------------- # BinaryTypeIndex tags from ClickHouse 25.5 # (src/DataTypes/DataTypesBinaryEncoding.cpp). Only the tags reachable # from values that fit in a JSON document are mapped; unmapped tags # raise on read so we surface gaps loudly instead of silently dropping # data. _TAG_NOTHING = 0x00 _TAG_UINT8 = 0x01 _TAG_UINT16 = 0x02 _TAG_UINT32 = 0x03 _TAG_UINT64 = 0x04 _TAG_UINT128 = 0x05 _TAG_UINT256 = 0x06 _TAG_INT8 = 0x07 _TAG_INT16 = 0x08 _TAG_INT32 = 0x09 _TAG_INT64 = 0x0A _TAG_INT128 = 0x0B _TAG_INT256 = 0x0C _TAG_FLOAT32 = 0x0D _TAG_FLOAT64 = 0x0E _TAG_DATE = 0x0F _TAG_DATE32 = 0x10 _TAG_DATETIME_UTC = 0x11 _TAG_DATETIME_TZ = 0x12 _TAG_DATETIME64_UTC = 0x13 _TAG_DATETIME64_TZ = 0x14 _TAG_STRING = 0x15 _TAG_FIXED_STRING = 0x16 _TAG_ARRAY = 0x1E _TAG_TUPLE_UNNAMED = 0x1F _TAG_TUPLE_NAMED = 0x20 _TAG_NULLABLE = 0x23 _TAG_BOOL = 0x2D _TAG_JSON = 0x30 def _read_varint(reader): """LEB128 decoder for any reader exposing ``read_one`` returning an ``int`` byte. The Cython ``read_varint`` in ``..varint`` only works against the driver's buffered reader; shared-value decoding works against an in-memory blob, so we re-implement the trivial loop here to keep the hot path free of adapter layers.""" shift = 0 result = 0 while True: b = reader.read_one() result |= (b & 0x7F) << shift shift += 7 if b < 0x80: return result def _read_binary_string(reader): length = _read_varint(reader) return reader.read(length) _PRIMITIVE_TYPE_NAMES = { _TAG_NOTHING: "Nothing", _TAG_UINT8: "UInt8", _TAG_UINT16: "UInt16", _TAG_UINT32: "UInt32", _TAG_UINT64: "UInt64", _TAG_UINT128: "UInt128", _TAG_UINT256: "UInt256", _TAG_INT8: "Int8", _TAG_INT16: "Int16", _TAG_INT32: "Int32", _TAG_INT64: "Int64", _TAG_INT128: "Int128", _TAG_INT256: "Int256", _TAG_FLOAT32: "Float32", _TAG_FLOAT64: "Float64", _TAG_DATE: "Date", _TAG_DATE32: "Date32", _TAG_DATETIME_UTC: "DateTime", _TAG_STRING: "String", _TAG_BOOL: "Bool", } def _decode_type_spec(buf): """ Parse the ``encodeDataType`` byte stream into a ClickHouse type string suitable for ``column_by_spec_getter``. The string form is intentional: it keeps the SharedVariant handler cache keyable by a single hash and lets us reuse the driver's existing column-by-spec machinery instead of reimplementing it on a parallel AST. """ tag = buf.read(1) if not tag: raise EOFError("Unexpected end of encoded type stream") tag = tag[0] name = _PRIMITIVE_TYPE_NAMES.get(tag) if name is not None: return name if tag == _TAG_FIXED_STRING: n = _read_varint(buf) return "FixedString({})".format(n) if tag == _TAG_DATETIME_TZ: tz = _read_binary_string(buf).decode('utf-8') return "DateTime('{}')".format(tz) if tag == _TAG_DATETIME64_UTC: scale = _read_varint(buf) return "DateTime64({})".format(scale) if tag == _TAG_DATETIME64_TZ: scale = _read_varint(buf) tz = _read_binary_string(buf).decode('utf-8') return "DateTime64({}, '{}')".format(scale, tz) if tag == _TAG_NULLABLE: inner = _decode_type_spec(buf) return "Nullable({})".format(inner) if tag == _TAG_ARRAY: inner = _decode_type_spec(buf) return "Array({})".format(inner) if tag == _TAG_TUPLE_UNNAMED: size = _read_varint(buf) elems = [_decode_type_spec(buf) for _ in range(size)] return "Tuple({})".format(", ".join(elems)) if tag == _TAG_TUPLE_NAMED: size = _read_varint(buf) parts = [] for _ in range(size): element_name = _read_binary_string(buf).decode('utf-8') element_type = _decode_type_spec(buf) parts.append("{} {}".format(element_name, element_type)) return "Tuple({})".format(", ".join(parts)) if tag == _TAG_JSON: # encodeDataType layout for JSON (ClickHouse 25.5): # UInt8 serialization version # VarUInt max_dynamic_paths # UInt8 max_dynamic_types # VarUInt typed_paths_count, then per path: String + type # VarUInt paths_to_skip_count, then per path: String # VarUInt path_regexps_count, then per regexp: String # None of these parameters change how a JSON value is laid out on # the wire (every path is dynamic), so the spec collapses to the # bare "JSON" handler once the bytes are consumed. buf.read_one() # serialization version _read_varint(buf) # max_dynamic_paths buf.read_one() # max_dynamic_types for _ in range(_read_varint(buf)): # typed paths _read_binary_string(buf) _decode_type_spec(buf) for _ in range(_read_varint(buf)): # paths to skip _read_binary_string(buf) for _ in range(_read_varint(buf)): # path regexps to skip _read_binary_string(buf) return "JSON" raise NotImplementedError( "Cannot decode binary type tag 0x{:02x} in shared JSON value" .format(tag)) def _nothing_handler(reader): return None def _insert_dotted_path(obj, dotted, value): """Place ``value`` into ``obj`` under a dotted JSON path, creating the intermediate dicts. ``{"a.b": 1}`` becomes ``{"a": {"b": 1}}`` so a nested JSON value read out of a SharedVariant matches the shape the top-level reader produces.""" parts = dotted.split('.') cursor = obj for part in parts[:-1]: child = cursor.get(part) if not isinstance(child, dict): child = {} cursor[part] = child cursor = child cursor[parts[-1]] = value def _split_tuple_elements(inner): """Split a ``Tuple(...)`` body on top-level commas.""" parts = [] depth = 0 start = 0 for i, ch in enumerate(inner): if ch == '(': depth += 1 elif ch == ')': depth -= 1 elif ch == ',' and depth == 0: parts.append(inner[start:i].strip()) start = i + 1 last = inner[start:].strip() if last: parts.append(last) return parts class SharedValueDecoder: """ Per-block decoder for the ``encodeDataType + serializeBinary`` payloads found in a SharedVariant's underlying String column. Two caches keep the hot path tight: * ``_handler_cache`` maps a decoded type spec (e.g. ``"Int64"``, ``"Array(Nullable(String))"``) to a precompiled callable that reads only the value bytes — no per-value ``startswith`` chain or recursive ``_decode_value_by_spec`` walk. * ``_column_cache`` keeps the scalar column readers alive across values so we don't reconstruct ``Int64Column`` / ``String`` for every overflow entry. A single ``_SharedValueReader`` is reused for every value rather than allocating an ``io.BytesIO`` + adapter pair per call. """ __slots__ = ( '_column_by_spec_getter', '_column_cache', '_handler_cache', '_reader', ) def __init__(self, column_by_spec_getter): self._column_by_spec_getter = column_by_spec_getter self._column_cache = {} self._handler_cache = {} self._reader = _SharedValueReader() def decode(self, blob): if not blob: return None reader = self._reader reader.reset(blob) return self._decode_dynamic_value(reader) def _decode_dynamic_value(self, reader): """Decode one ``encodeDataType + serializeBinary`` value from the current reader position. Used both for a top-level SharedVariant blob and, recursively, for each dynamic path of a nested JSON value.""" type_spec = _decode_type_spec(reader) handler = self._handler_cache.get(type_spec) if handler is None: handler = self._build_handler(type_spec) self._handler_cache[type_spec] = handler return handler(reader) def _build_handler(self, type_spec): if type_spec == "Nothing": return _nothing_handler if type_spec == "JSON": def json_handler(reader, _decode=self._decode_dynamic_value): # VarUInt path count, then per path: String name + a # dynamic value. Absent paths arrive as Nothing-typed # values; drop them so the object matches its input. obj = {} for _ in range(_read_varint(reader)): path = _read_binary_string(reader).decode('utf-8') value = _decode(reader) if value is not None: _insert_dotted_path(obj, path, value) return obj return json_handler if type_spec.startswith("Nullable("): inner_spec = type_spec[len("Nullable("):-1] inner_handler = self._lookup_handler(inner_spec) def nullable_handler(reader, _inner=inner_handler): if reader.read_one(): return None return _inner(reader) return nullable_handler if type_spec.startswith("Array("): inner_spec = type_spec[len("Array("):-1] inner_handler = self._lookup_handler(inner_spec) def array_handler(reader, _inner=inner_handler): size = _read_varint(reader) return [_inner(reader) for _ in range(size)] return array_handler if type_spec.startswith("Tuple("): elements = _split_tuple_elements( type_spec[len("Tuple("):-1]) element_handlers = tuple( self._lookup_handler(e) for e in elements) def tuple_handler(reader, _handlers=element_handlers): return tuple(h(reader) for h in _handlers) return tuple_handler # Scalar — bind the column reader once and let it handle bytes. column = self._column_cache.get(type_spec) if column is None: column = self._column_by_spec_getter(type_spec) self._column_cache[type_spec] = column def scalar_handler(reader, _column=column): return _column.read_items(1, reader)[0] return scalar_handler def _lookup_handler(self, type_spec): handler = self._handler_cache.get(type_spec) if handler is None: handler = self._build_handler(type_spec) self._handler_cache[type_spec] = handler return handler class _SharedValueReader: """ Reusable reader over an in-memory bytes blob. Exposes the surface the driver's column readers need (``read``, ``read_one``, ``read_strings``) without allocating an ``io.BytesIO`` plus an adapter every call — both are hot-loop overhead on the shared path. The owning :class:`SharedValueDecoder` resets the underlying bytes between values. """ __slots__ = ('_blob', '_pos') def __init__(self): self._blob = b'' self._pos = 0 def reset(self, blob): self._blob = blob self._pos = 0 def read(self, n): start = self._pos end = start + n self._pos = end return self._blob[start:end] def read_one(self): pos = self._pos b = self._blob[pos] self._pos = pos + 1 return b def read_strings(self, n_items, encoding=None): out = [] for _ in range(n_items): length = _read_varint(self) chunk = self.read(length) if encoding is not None: chunk = chunk.decode(encoding) out.append(chunk) return out clickhouse-driver-0.2.11/clickhouse_driver/columns/enumcolumn.py000066400000000000000000000071321522645447600251570ustar00rootroot00000000000000from enum import Enum from collections import OrderedDict from .. import errors from .intcolumn import IntColumn invalid_names_for_python_enum = frozenset(['mro', '']) class EnumColumn(IntColumn): py_types = (Enum, int, str) def __init__(self, name_by_value, value_by_name, **kwargs): self.name_by_value = name_by_value self.value_by_name = value_by_name super(EnumColumn, self).__init__(**kwargs) def before_write_items(self, items, nulls_map=None): null_value = self.null_value name_by_value = self.name_by_value value_by_name = self.value_by_name for i, item in enumerate(items): if nulls_map and nulls_map[i]: items[i] = null_value continue source_value = item.name if isinstance(item, Enum) else item # Check real enum value try: if isinstance(source_value, str): items[i] = value_by_name[source_value] else: items[i] = value_by_name[name_by_value[source_value]] except (ValueError, KeyError): choices = ', '.join( "'{}' = {}".format(name.replace("'", r"\'"), value) for name, value in value_by_name.items() ) enum_str = '{}({})'.format(self.ch_type, choices) raise errors.LogicalError( "Unknown element '{}' for type {}" .format(source_value, enum_str) ) def after_read_items(self, items, nulls_map=None): name_by_value = self.name_by_value if nulls_map is None: return tuple(name_by_value[item] for item in items) else: return tuple( (None if is_null else name_by_value[items[i]]) for i, is_null in enumerate(nulls_map) ) class Enum8Column(EnumColumn): ch_type = 'Enum8' format = 'b' int_size = 1 class Enum16Column(EnumColumn): ch_type = 'Enum16' format = 'h' int_size = 2 def create_enum_column(spec, column_options): if spec.startswith('Enum8'): params = spec[6:-1] cls = Enum8Column else: params = spec[7:-1] cls = Enum16Column name_by_value, value_by_name = _parse_options(params) return cls(name_by_value, value_by_name, **column_options) def _parse_options(option_string): name_by_value, value_by_name = {}, OrderedDict() after_name = False escaped = False quote_character = None name = '' value = '' for ch in option_string: if escaped: name += ch escaped = False # accepting escaped character elif after_name: if ch in (' ', '='): pass elif ch == ',': value = int(value) name_by_value[value] = name value_by_name[name] = value after_name = False name = '' value = '' # reset before collecting new option else: value += ch elif quote_character: if ch == '\\': escaped = True elif ch == quote_character: quote_character = None after_name = True # start collecting option value else: name += ch else: if ch == "'": quote_character = ch if after_name: value = int(value) name_by_value[value] = name value_by_name[name] = value return name_by_value, value_by_name clickhouse-driver-0.2.11/clickhouse_driver/columns/exceptions.py000066400000000000000000000002431522645447600251520ustar00rootroot00000000000000 class ColumnException(Exception): pass class ColumnTypeMismatchException(ColumnException): pass class StructPackException(ColumnException): pass clickhouse-driver-0.2.11/clickhouse_driver/columns/floatcolumn.py000066400000000000000000000016351522645447600253220ustar00rootroot00000000000000from ctypes import c_float from .base import FormatColumn class FloatColumn(FormatColumn): py_types = (float, int) class Float32Column(FloatColumn): ch_type = 'Float32' format = 'f' def __init__(self, types_check=False, **kwargs): super(Float32Column, self).__init__(types_check=types_check, **kwargs) if types_check: # Chop only bytes that fit current type. # Cast to -nan or nan if overflows. def before_write_items(items, nulls_map=None): null_value = self.null_value for i, item in enumerate(items): if nulls_map and nulls_map[i]: items[i] = null_value else: items[i] = c_float(item).value self.before_write_items = before_write_items class Float64Column(FloatColumn): ch_type = 'Float64' format = 'd' clickhouse-driver-0.2.11/clickhouse_driver/columns/intcolumn.py000066400000000000000000000066771522645447600250220ustar00rootroot00000000000000 from .exceptions import ColumnTypeMismatchException from .base import FormatColumn from .largeint import ( int128_from_quads, int128_to_quads, uint128_from_quads, uint128_to_quads, int256_from_quads, int256_to_quads, uint256_from_quads, uint256_to_quads ) class IntColumn(FormatColumn): py_types = (int, ) int_size = None def __init__(self, types_check=False, **kwargs): super(IntColumn, self).__init__(types_check=types_check, **kwargs) if types_check: self.mask = (1 << 8 * self.int_size) - 1 # Chop only bytes that fit current type. # ctypes.c_intXX is slower. def before_write_items(items, nulls_map=None): # TODO: cythonize null_value = self.null_value for i, item in enumerate(items): if nulls_map and nulls_map[i]: items[i] = null_value continue if item >= 0: sign = 1 else: sign = -1 item = -item items[i] = sign * (item & self.mask) self.before_write_items = before_write_items class UIntColumn(IntColumn): def __init__(self, types_check=False, **kwargs): super(UIntColumn, self).__init__(types_check=types_check, **kwargs) if types_check: def check_item(value): if value < 0: raise ColumnTypeMismatchException(value) self.check_item = check_item class Int8Column(IntColumn): ch_type = 'Int8' format = 'b' int_size = 1 class Int16Column(IntColumn): ch_type = 'Int16' format = 'h' int_size = 2 class Int32Column(IntColumn): ch_type = 'Int32' format = 'i' int_size = 4 class Int64Column(IntColumn): ch_type = 'Int64' format = 'q' int_size = 8 class UInt8Column(UIntColumn): ch_type = 'UInt8' format = 'B' int_size = 1 class UInt16Column(UIntColumn): ch_type = 'UInt16' format = 'H' int_size = 2 class UInt32Column(UIntColumn): ch_type = 'UInt32' format = 'I' int_size = 4 class UInt64Column(UIntColumn): ch_type = 'UInt64' format = 'Q' int_size = 8 class LargeIntColumn(IntColumn): format = 'Q' # We manually deal with sign in read/write. factor = None to_quads = None from_quads = None def write_items(self, items, buf): n_items = len(items) s = self.make_struct(self.factor * n_items) uint_64_pairs = self.to_quads(items, n_items) buf.write(s.pack(*uint_64_pairs)) def read_items(self, n_items, buf): s = self.make_struct(self.factor * n_items) items = s.unpack(buf.read(s.size)) return self.from_quads(items, n_items) class Int128Column(LargeIntColumn): ch_type = 'Int128' int_size = 16 factor = 2 to_quads = int128_to_quads from_quads = int128_from_quads class UInt128Column(LargeIntColumn): ch_type = 'UInt128' int_size = 16 factor = 2 to_quads = uint128_to_quads from_quads = uint128_from_quads class Int256Column(LargeIntColumn): ch_type = 'Int256' int_size = 32 factor = 4 to_quads = int256_to_quads from_quads = int256_from_quads class UInt256Column(LargeIntColumn): ch_type = 'UInt256' int_size = 32 factor = 4 to_quads = uint256_to_quads from_quads = uint256_from_quads clickhouse-driver-0.2.11/clickhouse_driver/columns/intervalcolumn.py000066400000000000000000000011301522645447600260270ustar00rootroot00000000000000from .intcolumn import Int64Column class IntervalColumn(Int64Column): pass class IntervalDayColumn(IntervalColumn): ch_type = 'IntervalDay' class IntervalWeekColumn(IntervalColumn): ch_type = 'IntervalWeek' class IntervalMonthColumn(IntervalColumn): ch_type = 'IntervalMonth' class IntervalYearColumn(IntervalColumn): ch_type = 'IntervalYear' class IntervalHourColumn(IntervalColumn): ch_type = 'IntervalHour' class IntervalMinuteColumn(IntervalColumn): ch_type = 'IntervalMinute' class IntervalSecondColumn(IntervalColumn): ch_type = 'IntervalSecond' clickhouse-driver-0.2.11/clickhouse_driver/columns/ipcolumn.py000066400000000000000000000103331522645447600246200ustar00rootroot00000000000000from ipaddress import IPv4Address, IPv6Address, AddressValueError from .. import errors from .exceptions import ColumnTypeMismatchException from .stringcolumn import ByteFixedString from .intcolumn import UInt32Column class IPv4Column(UInt32Column): ch_type = "IPv4" py_types = (str, IPv4Address, int) def __init__(self, types_check=False, **kwargs): # UIntColumn overrides before_write_item and check_item # in its __init__ when types_check is True so we force # __init__ without it then add the appropriate check method for IPv4 super(UInt32Column, self).__init__(types_check=False, **kwargs) self.types_check_enabled = types_check if types_check: def check_item(value): if isinstance(value, int) and value < 0: raise ColumnTypeMismatchException(value) if not isinstance(value, IPv4Address): try: value = IPv4Address(value) except AddressValueError: # Cannot parse input in a valid IPv4 raise ColumnTypeMismatchException(value) self.check_item = check_item def after_read_items(self, items, nulls_map=None): if nulls_map is None: return tuple(IPv4Address(item) for item in items) else: return tuple( (None if is_null else IPv4Address(items[i])) for i, is_null in enumerate(nulls_map) ) def before_write_items(self, items, nulls_map=None): null_value = self.null_value for i, item in enumerate(items): if nulls_map and nulls_map[i]: items[i] = null_value continue # allow Ipv4 in integer, string or IPv4Address object try: if isinstance(item, int): continue if not isinstance(item, IPv4Address): item = IPv4Address(item) items[i] = int(item) except AddressValueError: raise errors.CannotParseDomainError( "Cannot parse IPv4 '{}'".format(item) ) class IPv6Column(ByteFixedString): ch_type = "IPv6" py_types = (str, IPv6Address, bytes) # Wire-format default: must be readable by after_read_items and # writable by write_items as-is (sparse deserialization and # LowCardinality pass it to both without conversion). null_value = b'\x00' * 16 def __init__(self, types_check=False, **kwargs): super(IPv6Column, self).__init__(16, types_check=types_check, **kwargs) if types_check: def check_item(value): if isinstance(value, bytes) and len(value) != 16: raise ColumnTypeMismatchException(value) if not isinstance(value, IPv6Address): try: value = IPv6Address(value) except AddressValueError: # Cannot parse input in a valid IPv6 raise ColumnTypeMismatchException(value) self.check_item = check_item def after_read_items(self, items, nulls_map=None): if nulls_map is None: return tuple(IPv6Address(item) for item in items) else: return tuple( (None if is_null else IPv6Address(items[i])) for i, is_null in enumerate(nulls_map) ) def before_write_items(self, items, nulls_map=None): null_value = self.null_value for i, item in enumerate(items): if nulls_map and nulls_map[i]: items[i] = null_value continue # allow Ipv6 in bytes or python IPv6Address # this is raw bytes (not encoded) in order to fit FixedString(16) try: if isinstance(item, bytes): continue if not isinstance(item, IPv6Address): item = IPv6Address(item) items[i] = item.packed except AddressValueError: raise errors.CannotParseDomainError( "Cannot parse IPv6 '{}'".format(item) ) clickhouse-driver-0.2.11/clickhouse_driver/columns/jsoncolumn.py000066400000000000000000000022431522645447600251620ustar00rootroot00000000000000from .base import Column from .stringcolumn import String from ..reader import read_binary_uint8, read_binary_str from ..util.compat import json from ..writer import write_binary_uint8 class JsonColumn(Column): py_types = (dict, ) # No NULL value actually null_value = {} def __init__(self, column_by_spec_getter, **kwargs): self.column_by_spec_getter = column_by_spec_getter self.string_column = String(**kwargs) super(JsonColumn, self).__init__(**kwargs) def write_state_prefix(self, buf, items=None): # Read in binary format. # Write in text format. write_binary_uint8(1, buf) def read_items(self, n_items, buf): read_binary_uint8(buf) spec = read_binary_str(buf) col = self.column_by_spec_getter(spec) col.read_state_prefix(buf) return col.read_data(n_items, buf) def write_items(self, items, buf): items = [x if isinstance(x, str) else json.dumps(x) for x in items] self.string_column.write_items(items, buf) def create_json_column(spec, column_by_spec_getter, column_options): return JsonColumn(column_by_spec_getter, **column_options) clickhouse-driver-0.2.11/clickhouse_driver/columns/largeint.c000066400000000000000000017214471522645447600244110ustar00rootroot00000000000000/* Generated by Cython 3.2.0 */ #ifndef PY_SSIZE_T_CLEAN #define PY_SSIZE_T_CLEAN #endif /* PY_SSIZE_T_CLEAN */ /* InitLimitedAPI */ #if defined(Py_LIMITED_API) #if !defined(CYTHON_LIMITED_API) #define CYTHON_LIMITED_API 1 #endif #elif defined(CYTHON_LIMITED_API) #ifdef _MSC_VER #pragma message ("Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead.") #else #warning Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead. #endif #endif #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x03080000 #error Cython requires Python 3.8+. #else #define __PYX_ABI_VERSION "3_2_0" #define CYTHON_HEX_VERSION 0x030200F0 #define CYTHON_FUTURE_DIVISION 1 /* CModulePreamble */ #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(_WIN32) && !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #define __PYX_COMMA , #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #define __PYX_LIMITED_VERSION_HEX PY_VERSION_HEX #if defined(GRAALVM_PYTHON) /* For very preliminary testing purposes. Most variables are set the same as PyPy. The existence of this section does not imply that anything works or is even tested */ #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 1 #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_ASSUME_SAFE_SIZE #define CYTHON_ASSUME_SAFE_SIZE 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #undef CYTHON_USE_SYS_MONITORING #define CYTHON_USE_SYS_MONITORING 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #undef CYTHON_USE_AM_SEND #define CYTHON_USE_AM_SEND 0 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 1 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #undef CYTHON_USE_FREELISTS #define CYTHON_USE_FREELISTS 0 #undef CYTHON_IMMORTAL_CONSTANTS #define CYTHON_IMMORTAL_CONSTANTS 0 #elif defined(PYPY_VERSION) #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #ifndef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #endif #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #ifndef CYTHON_ASSUME_SAFE_SIZE #define CYTHON_ASSUME_SAFE_SIZE 1 #endif #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #if PY_VERSION_HEX < 0x03090000 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT) #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #undef CYTHON_USE_SYS_MONITORING #define CYTHON_USE_SYS_MONITORING 0 #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE (PYPY_VERSION_NUM >= 0x07030C00) #endif #undef CYTHON_USE_AM_SEND #define CYTHON_USE_AM_SEND 0 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_NUM >= 0x07031100) #endif #undef CYTHON_USE_FREELISTS #define CYTHON_USE_FREELISTS 0 #undef CYTHON_IMMORTAL_CONSTANTS #define CYTHON_IMMORTAL_CONSTANTS 0 #elif defined(CYTHON_LIMITED_API) #ifdef Py_LIMITED_API #undef __PYX_LIMITED_VERSION_HEX #define __PYX_LIMITED_VERSION_HEX Py_LIMITED_API #endif #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 1 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 1 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #ifndef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #endif #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0 #endif #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_ASSUME_SAFE_SIZE #define CYTHON_ASSUME_SAFE_SIZE 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL (__PYX_LIMITED_VERSION_HEX >= 0x030C0000) #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #ifndef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #endif #undef CYTHON_USE_SYS_MONITORING #define CYTHON_USE_SYS_MONITORING 0 #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #endif #ifndef CYTHON_USE_AM_SEND #define CYTHON_USE_AM_SEND (__PYX_LIMITED_VERSION_HEX >= 0x030A0000) #endif #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #ifndef CYTHON_USE_FREELISTS #define CYTHON_USE_FREELISTS 1 #endif #undef CYTHON_IMMORTAL_CONSTANTS #define CYTHON_IMMORTAL_CONSTANTS 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 0 #ifdef Py_GIL_DISABLED #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 1 #else #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0 #endif #if PY_VERSION_HEX < 0x030A0000 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #elif !defined(CYTHON_USE_TYPE_SLOTS) #define CYTHON_USE_TYPE_SLOTS 1 #endif #ifndef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #endif #ifndef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 1 #endif #ifndef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #elif !defined(CYTHON_USE_PYLIST_INTERNALS) #define CYTHON_USE_PYLIST_INTERNALS 1 #endif #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING || PY_VERSION_HEX >= 0x030B00A2 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #elif !defined(CYTHON_USE_UNICODE_WRITER) #define CYTHON_USE_UNICODE_WRITER 1 #endif #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1 #elif !defined(CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS) #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_ASSUME_SAFE_SIZE #define CYTHON_ASSUME_SAFE_SIZE 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #ifndef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 1 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #elif !defined(CYTHON_FAST_GIL) #define CYTHON_FAST_GIL (PY_VERSION_HEX < 0x030C00A6) #endif #ifndef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 1 #endif #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #ifndef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #endif #ifndef CYTHON_USE_SYS_MONITORING #define CYTHON_USE_SYS_MONITORING (PY_VERSION_HEX >= 0x030d00B1) #endif #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 1 #endif #ifndef CYTHON_USE_AM_SEND #define CYTHON_USE_AM_SEND 1 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #elif !defined(CYTHON_USE_DICT_VERSIONS) #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX < 0x030C00A5 && !CYTHON_USE_MODULE_STATE) #endif #ifndef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 1 #endif #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 1 #endif #ifndef CYTHON_USE_FREELISTS #define CYTHON_USE_FREELISTS (!CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) #endif #if defined(CYTHON_IMMORTAL_CONSTANTS) && PY_VERSION_HEX < 0x030C0000 #undef CYTHON_IMMORTAL_CONSTANTS #define CYTHON_IMMORTAL_CONSTANTS 0 // definitely won't work #elif !defined(CYTHON_IMMORTAL_CONSTANTS) #define CYTHON_IMMORTAL_CONSTANTS (PY_VERSION_HEX >= 0x030C0000 && !CYTHON_USE_MODULE_STATE && CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) #endif #endif #ifndef CYTHON_COMPRESS_STRINGS #define CYTHON_COMPRESS_STRINGS 1 #endif #ifndef CYTHON_FAST_PYCCALL #define CYTHON_FAST_PYCCALL CYTHON_FAST_PYCALL #endif #ifndef CYTHON_VECTORCALL #if CYTHON_COMPILING_IN_LIMITED_API #define CYTHON_VECTORCALL (__PYX_LIMITED_VERSION_HEX >= 0x030C0000) #else #define CYTHON_VECTORCALL (CYTHON_FAST_PYCCALL) #endif #endif #if CYTHON_USE_PYLONG_INTERNALS #undef SHIFT #undef BASE #undef MASK #ifdef SIZEOF_VOID_P enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; #endif #endif #ifndef __has_attribute #define __has_attribute(x) 0 #endif #ifndef __has_cpp_attribute #define __has_cpp_attribute(x) 0 #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #ifndef CYTHON_UNUSED #if defined(__cplusplus) /* for clang __has_cpp_attribute(maybe_unused) is true even before C++17 * but leads to warnings with -pedantic, since it is a C++17 feature */ #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) #if __has_cpp_attribute(maybe_unused) #define CYTHON_UNUSED [[maybe_unused]] #endif #endif #endif #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_UNUSED_VAR # if defined(__cplusplus) template void CYTHON_UNUSED_VAR( const T& ) { } # else # define CYTHON_UNUSED_VAR(x) (void)(x) # endif #endif #ifndef CYTHON_MAYBE_UNUSED_VAR #define CYTHON_MAYBE_UNUSED_VAR(x) CYTHON_UNUSED_VAR(x) #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif #ifndef CYTHON_USE_CPP_STD_MOVE #if defined(__cplusplus) && (\ __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)) #define CYTHON_USE_CPP_STD_MOVE 1 #else #define CYTHON_USE_CPP_STD_MOVE 0 #endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #include typedef uintptr_t __pyx_uintptr_t; #ifndef CYTHON_FALLTHROUGH #if defined(__cplusplus) /* for clang __has_cpp_attribute(fallthrough) is true even before C++17 * but leads to warnings with -pedantic, since it is a C++17 feature */ #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) #if __has_cpp_attribute(fallthrough) #define CYTHON_FALLTHROUGH [[fallthrough]] #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_cpp_attribute(clang::fallthrough) #define CYTHON_FALLTHROUGH [[clang::fallthrough]] #elif __has_cpp_attribute(gnu::fallthrough) #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] #endif #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_attribute(fallthrough) #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) #else #define CYTHON_FALLTHROUGH #endif #endif #if defined(__clang__) && defined(__apple_build_version__) #if __apple_build_version__ < 7000000 #undef CYTHON_FALLTHROUGH #define CYTHON_FALLTHROUGH #endif #endif #endif #ifndef Py_UNREACHABLE #define Py_UNREACHABLE() assert(0); abort() #endif #ifdef __cplusplus template struct __PYX_IS_UNSIGNED_IMPL {static const bool value = T(0) < T(-1);}; #define __PYX_IS_UNSIGNED(type) (__PYX_IS_UNSIGNED_IMPL::value) #else #define __PYX_IS_UNSIGNED(type) (((type)-1) > 0) #endif #if CYTHON_COMPILING_IN_PYPY == 1 #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX < 0x030A0000) #else #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX < 0x03090000) #endif #define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer)) /* CInitCode */ #ifndef CYTHON_INLINE #if defined(__clang__) #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) #elif defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #endif /* PythonCompatibility */ #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_DefaultClassType PyType_Type #if CYTHON_COMPILING_IN_LIMITED_API #ifndef CO_OPTIMIZED static int CO_OPTIMIZED; #endif #ifndef CO_NEWLOCALS static int CO_NEWLOCALS; #endif #ifndef CO_VARARGS static int CO_VARARGS; #endif #ifndef CO_VARKEYWORDS static int CO_VARKEYWORDS; #endif #ifndef CO_ASYNC_GENERATOR static int CO_ASYNC_GENERATOR; #endif #ifndef CO_GENERATOR static int CO_GENERATOR; #endif #ifndef CO_COROUTINE static int CO_COROUTINE; #endif #else #ifndef CO_COROUTINE #define CO_COROUTINE 0x80 #endif #ifndef CO_ASYNC_GENERATOR #define CO_ASYNC_GENERATOR 0x200 #endif #endif static int __Pyx_init_co_variables(void); #if PY_VERSION_HEX >= 0x030900A4 || defined(Py_IS_TYPE) #define __Pyx_IS_TYPE(ob, type) Py_IS_TYPE(ob, type) #else #define __Pyx_IS_TYPE(ob, type) (((const PyObject*)ob)->ob_type == (type)) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_Is) #define __Pyx_Py_Is(x, y) Py_Is(x, y) #else #define __Pyx_Py_Is(x, y) ((x) == (y)) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsNone) #define __Pyx_Py_IsNone(ob) Py_IsNone(ob) #else #define __Pyx_Py_IsNone(ob) __Pyx_Py_Is((ob), Py_None) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsTrue) #define __Pyx_Py_IsTrue(ob) Py_IsTrue(ob) #else #define __Pyx_Py_IsTrue(ob) __Pyx_Py_Is((ob), Py_True) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsFalse) #define __Pyx_Py_IsFalse(ob) Py_IsFalse(ob) #else #define __Pyx_Py_IsFalse(ob) __Pyx_Py_Is((ob), Py_False) #endif #define __Pyx_NoneAsNull(obj) (__Pyx_Py_IsNone(obj) ? NULL : (obj)) #if PY_VERSION_HEX >= 0x030900F0 && !CYTHON_COMPILING_IN_PYPY #define __Pyx_PyObject_GC_IsFinalized(o) PyObject_GC_IsFinalized(o) #else #define __Pyx_PyObject_GC_IsFinalized(o) _PyGC_FINALIZED(o) #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #ifndef Py_TPFLAGS_SEQUENCE #define Py_TPFLAGS_SEQUENCE 0 #endif #ifndef Py_TPFLAGS_MAPPING #define Py_TPFLAGS_MAPPING 0 #endif #ifndef Py_TPFLAGS_IMMUTABLETYPE #define Py_TPFLAGS_IMMUTABLETYPE (1UL << 8) #endif #ifndef Py_TPFLAGS_DISALLOW_INSTANTIATION #define Py_TPFLAGS_DISALLOW_INSTANTIATION (1UL << 7) #endif #ifndef METH_STACKLESS #define METH_STACKLESS 0 #endif #ifndef METH_FASTCALL #ifndef METH_FASTCALL #define METH_FASTCALL 0x80 #endif typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames); #else #if PY_VERSION_HEX >= 0x030d00A4 # define __Pyx_PyCFunctionFast PyCFunctionFast # define __Pyx_PyCFunctionFastWithKeywords PyCFunctionFastWithKeywords #else # define __Pyx_PyCFunctionFast _PyCFunctionFast # define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords #endif #endif #if CYTHON_METH_FASTCALL #define __Pyx_METH_FASTCALL METH_FASTCALL #define __Pyx_PyCFunction_FastCall __Pyx_PyCFunctionFast #define __Pyx_PyCFunction_FastCallWithKeywords __Pyx_PyCFunctionFastWithKeywords #else #define __Pyx_METH_FASTCALL METH_VARARGS #define __Pyx_PyCFunction_FastCall PyCFunction #define __Pyx_PyCFunction_FastCallWithKeywords PyCFunctionWithKeywords #endif #if CYTHON_VECTORCALL #define __pyx_vectorcallfunc vectorcallfunc #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET PY_VECTORCALL_ARGUMENTS_OFFSET #define __Pyx_PyVectorcall_NARGS(n) PyVectorcall_NARGS((size_t)(n)) #else #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET 0 #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(n)) #endif #if PY_VERSION_HEX >= 0x030900B1 #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_CheckExact(func) #else #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_Check(func) #endif #define __Pyx_CyOrPyCFunction_Check(func) PyCFunction_Check(func) #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) (((PyCFunctionObject*)(func))->m_ml->ml_meth) #elif !CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(func) #endif #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CyOrPyCFunction_GET_FLAGS(func) (((PyCFunctionObject*)(func))->m_ml->ml_flags) static CYTHON_INLINE PyObject* __Pyx_CyOrPyCFunction_GET_SELF(PyObject *func) { return (__Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_STATIC) ? NULL : ((PyCFunctionObject*)func)->m_self; } #endif static CYTHON_INLINE int __Pyx__IsSameCFunction(PyObject *func, void (*cfunc)(void)) { #if CYTHON_COMPILING_IN_LIMITED_API return PyCFunction_Check(func) && PyCFunction_GetFunction(func) == (PyCFunction) cfunc; #else return PyCFunction_Check(func) && PyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; #endif } #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCFunction(func, cfunc) #if PY_VERSION_HEX < 0x03090000 || (CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000) #define __Pyx_PyType_FromModuleAndSpec(m, s, b) ((void)m, PyType_FromSpecWithBases(s, b)) typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *); #else #define __Pyx_PyType_FromModuleAndSpec(m, s, b) PyType_FromModuleAndSpec(m, s, b) #define __Pyx_PyCMethod PyCMethod #endif #ifndef METH_METHOD #define METH_METHOD 0x200 #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) #define PyObject_Malloc(s) PyMem_Malloc(s) #define PyObject_Free(p) PyMem_Free(p) #define PyObject_Realloc(p) PyMem_Realloc(p) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyFrame_SetLineNumber(frame, lineno) #elif CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) GraalPyFrame_SetLineNumber((frame), (lineno)) #elif CYTHON_COMPILING_IN_GRAAL #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) _PyFrame_SetLineNumber((frame), (lineno)) #else #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyThreadState_Current PyThreadState_Get() #elif !CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_Current PyThreadState_GET() #elif PY_VERSION_HEX >= 0x030d00A1 #define __Pyx_PyThreadState_Current PyThreadState_GetUnchecked() #else #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() #endif #if CYTHON_USE_MODULE_STATE static CYTHON_INLINE void *__Pyx__PyModule_GetState(PyObject *op) { void *result; result = PyModule_GetState(op); if (!result) Py_FatalError("Couldn't find the module state"); return result; } #define __Pyx_PyModule_GetState(o) (__pyx_mstatetype *)__Pyx__PyModule_GetState(o) #else #define __Pyx_PyModule_GetState(op) ((void)op,__pyx_mstate_global) #endif #define __Pyx_PyObject_GetSlot(obj, name, func_ctype) __Pyx_PyType_GetSlot(Py_TYPE((PyObject *) obj), name, func_ctype) #define __Pyx_PyObject_TryGetSlot(obj, name, func_ctype) __Pyx_PyType_TryGetSlot(Py_TYPE(obj), name, func_ctype) #define __Pyx_PyObject_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(Py_TYPE(obj), sub, name, func_ctype) #define __Pyx_PyObject_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSubSlot(Py_TYPE(obj), sub, name, func_ctype) #if CYTHON_USE_TYPE_SLOTS #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((type)->name) #define __Pyx_PyType_TryGetSlot(type, name, func_ctype) __Pyx_PyType_GetSlot(type, name, func_ctype) #define __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype) (((type)->sub) ? ((type)->sub->name) : NULL) #define __Pyx_PyType_TryGetSubSlot(type, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype) #else #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((func_ctype) PyType_GetSlot((type), Py_##name)) #define __Pyx_PyType_TryGetSlot(type, name, func_ctype)\ ((__PYX_LIMITED_VERSION_HEX >= 0x030A0000 ||\ (PyType_GetFlags(type) & Py_TPFLAGS_HEAPTYPE) || __Pyx_get_runtime_version() >= 0x030A0000) ?\ __Pyx_PyType_GetSlot(type, name, func_ctype) : NULL) #define __Pyx_PyType_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSlot(obj, name, func_ctype) #define __Pyx_PyType_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSlot(obj, name, func_ctype) #endif #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) #else #define __Pyx_PyDict_NewPresized(n) PyDict_New() #endif #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_UNICODE_INTERNALS #define __Pyx_PyDict_GetItemStrWithError(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) { PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name); if (res == NULL) PyErr_Clear(); return res; } #elif !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000 #define __Pyx_PyDict_GetItemStrWithError PyDict_GetItemWithError #define __Pyx_PyDict_GetItemStr PyDict_GetItem #else static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, PyObject *name) { #if CYTHON_COMPILING_IN_PYPY return PyDict_GetItem(dict, name); #else PyDictEntry *ep; PyDictObject *mp = (PyDictObject*) dict; long hash = ((PyStringObject *) name)->ob_shash; assert(hash != -1); ep = (mp->ma_lookup)(mp, name, hash); if (ep == NULL) { return NULL; } return ep->me_value; #endif } #define __Pyx_PyDict_GetItemStr PyDict_GetItem #endif #if CYTHON_USE_TYPE_SLOTS #define __Pyx_PyType_GetFlags(tp) (((PyTypeObject *)tp)->tp_flags) #define __Pyx_PyType_HasFeature(type, feature) ((__Pyx_PyType_GetFlags(type) & (feature)) != 0) #else #define __Pyx_PyType_GetFlags(tp) (PyType_GetFlags((PyTypeObject *)tp)) #define __Pyx_PyType_HasFeature(type, feature) PyType_HasFeature(type, feature) #endif #define __Pyx_PyObject_GetIterNextFunc(iterator) __Pyx_PyObject_GetSlot(iterator, tp_iternext, iternextfunc) #if CYTHON_USE_TYPE_SPECS #define __Pyx_PyHeapTypeObject_GC_Del(obj) {\ PyTypeObject *type = Py_TYPE((PyObject*)obj);\ assert(__Pyx_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE));\ PyObject_GC_Del(obj);\ Py_DECREF(type);\ } #else #define __Pyx_PyHeapTypeObject_GC_Del(obj) PyObject_GC_Del(obj) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_ReadChar(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((void)u, 1114111U) #define __Pyx_PyUnicode_KIND(u) ((void)u, (0)) #define __Pyx_PyUnicode_DATA(u) ((void*)u) #define __Pyx_PyUnicode_READ(k, d, i) ((void)k, PyUnicode_ReadChar((PyObject*)(d), i)) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GetLength(u)) #else #if PY_VERSION_HEX >= 0x030C0000 #define __Pyx_PyUnicode_READY(op) (0) #else #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #endif #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) #define __Pyx_PyUnicode_KIND(u) ((int)PyUnicode_KIND(u)) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, (Py_UCS4) ch) #if PY_VERSION_HEX >= 0x030C0000 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) #else #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) #else #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) #endif #endif #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY #if !defined(PyUnicode_DecodeUnicodeEscape) #define PyUnicode_DecodeUnicodeEscape(s, size, errors) PyUnicode_Decode(s, size, "unicode_escape", errors) #endif #if !defined(PyUnicode_Contains) #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #if !defined(PyByteArray_Check) #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) #endif #if !defined(PyObject_Format) #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) #endif #endif #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 #define __Pyx_PySequence_ListKeepNew(obj)\ (likely(PyList_CheckExact(obj) && PyUnstable_Object_IsUniquelyReferenced(obj)) ? __Pyx_NewRef(obj) : PySequence_List(obj)) #elif CYTHON_COMPILING_IN_CPYTHON #define __Pyx_PySequence_ListKeepNew(obj)\ (likely(PyList_CheckExact(obj) && Py_REFCNT(obj) == 1) ? __Pyx_NewRef(obj) : PySequence_List(obj)) #else #define __Pyx_PySequence_ListKeepNew(obj) PySequence_List(obj) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) __Pyx_IS_TYPE(obj, &PySet_Type) #endif #if PY_VERSION_HEX >= 0x030900A4 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) #else #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) #endif enum __Pyx_ReferenceSharing { __Pyx_ReferenceSharing_DefinitelyUnique, // We created it so we know it's unshared - no need to check __Pyx_ReferenceSharing_OwnStrongReference, __Pyx_ReferenceSharing_FunctionArgument, __Pyx_ReferenceSharing_SharedReference, // Never trust it to be unshared because it's a global or similar }; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && PY_VERSION_HEX >= 0x030E0000 #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing)\ (sharing == __Pyx_ReferenceSharing_DefinitelyUnique ? 1 :\ (sharing == __Pyx_ReferenceSharing_FunctionArgument ? PyUnstable_Object_IsUniqueReferencedTemporary(o) :\ (sharing == __Pyx_ReferenceSharing_OwnStrongReference ? PyUnstable_Object_IsUniquelyReferenced(o) : 0))) #elif (CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)sharing), Py_REFCNT(o) == 1) #else #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)o), ((void)sharing), 0) #endif #if CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyList_GetItemRef(o, i) PyList_GetItemRef(o, i) #elif CYTHON_COMPILING_IN_LIMITED_API || !CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PyList_GetItemRef(o, i) (likely((i) >= 0) ? PySequence_GetItem(o, i) : (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) #else #define __Pyx_PyList_GetItemRef(o, i) PySequence_ITEM(o, i) #endif #elif CYTHON_COMPILING_IN_LIMITED_API || !CYTHON_ASSUME_SAFE_MACROS #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyList_GetItemRef(o, i) PyList_GetItemRef(o, i) #else #define __Pyx_PyList_GetItemRef(o, i) __Pyx_XNewRef(PyList_GetItem(o, i)) #endif #else #define __Pyx_PyList_GetItemRef(o, i) __Pyx_NewRef(PyList_GET_ITEM(o, i)) #endif #if CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS && !CYTHON_COMPILING_IN_LIMITED_API && CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PyList_GetItemRefFast(o, i, unsafe_shared) (__Pyx_IS_UNIQUELY_REFERENCED(o, unsafe_shared) ?\ __Pyx_NewRef(PyList_GET_ITEM(o, i)) : __Pyx_PyList_GetItemRef(o, i)) #else #define __Pyx_PyList_GetItemRefFast(o, i, unsafe_shared) __Pyx_PyList_GetItemRef(o, i) #endif #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyDict_GetItemRef(dict, key, result) PyDict_GetItemRef(dict, key, result) #elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) { *result = PyObject_GetItem(dict, key); if (*result == NULL) { if (PyErr_ExceptionMatches(PyExc_KeyError)) { PyErr_Clear(); return 0; } return -1; } return 1; } #else static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) { *result = PyDict_GetItemWithError(dict, key); if (*result == NULL) { return PyErr_Occurred() ? -1 : 0; } Py_INCREF(*result); return 1; } #endif #if defined(CYTHON_DEBUG_VISIT_CONST) && CYTHON_DEBUG_VISIT_CONST #define __Pyx_VISIT_CONST(obj) Py_VISIT(obj) #else #define __Pyx_VISIT_CONST(obj) #endif #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PySequence_ITEM(o, i) PySequence_ITEM(o, i) #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) #define __Pyx_PyTuple_SET_ITEM(o, i, v) (PyTuple_SET_ITEM(o, i, v), (0)) #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GET_ITEM(o, i) #define __Pyx_PyList_SET_ITEM(o, i, v) (PyList_SET_ITEM(o, i, v), (0)) #define __Pyx_PyList_GET_ITEM(o, i) PyList_GET_ITEM(o, i) #else #define __Pyx_PySequence_ITEM(o, i) PySequence_GetItem(o, i) #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) #define __Pyx_PyTuple_SET_ITEM(o, i, v) PyTuple_SetItem(o, i, v) #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GetItem(o, i) #define __Pyx_PyList_SET_ITEM(o, i, v) PyList_SetItem(o, i, v) #define __Pyx_PyList_GET_ITEM(o, i) PyList_GetItem(o, i) #endif #if CYTHON_ASSUME_SAFE_SIZE #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_GET_SIZE(o) #define __Pyx_PyList_GET_SIZE(o) PyList_GET_SIZE(o) #define __Pyx_PySet_GET_SIZE(o) PySet_GET_SIZE(o) #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o) #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_GET_SIZE(o) #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GET_LENGTH(o) #else #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_Size(o) #define __Pyx_PyList_GET_SIZE(o) PyList_Size(o) #define __Pyx_PySet_GET_SIZE(o) PySet_Size(o) #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_Size(o) #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_Size(o) #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GetLength(o) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_InternFromString) #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #define __Pyx_PyLong_FromHash_t PyLong_FromSsize_t #define __Pyx_PyLong_AsHash_t __Pyx_PyIndex_AsSsize_t #if __PYX_LIMITED_VERSION_HEX >= 0x030A0000 #define __Pyx_PySendResult PySendResult #else typedef enum { PYGEN_RETURN = 0, PYGEN_ERROR = -1, PYGEN_NEXT = 1, } __Pyx_PySendResult; #endif #if CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX < 0x030A00A3 typedef __Pyx_PySendResult (*__Pyx_pyiter_sendfunc)(PyObject *iter, PyObject *value, PyObject **result); #else #define __Pyx_pyiter_sendfunc sendfunc #endif #if !CYTHON_USE_AM_SEND #define __PYX_HAS_PY_AM_SEND 0 #elif __PYX_LIMITED_VERSION_HEX >= 0x030A0000 #define __PYX_HAS_PY_AM_SEND 1 #else #define __PYX_HAS_PY_AM_SEND 2 // our own backported implementation #endif #if __PYX_HAS_PY_AM_SEND < 2 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #else typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; __Pyx_pyiter_sendfunc am_send; } __Pyx_PyAsyncMethodsStruct; #define __Pyx_SlotTpAsAsync(s) ((PyAsyncMethods*)(s)) #endif #if CYTHON_USE_AM_SEND && PY_VERSION_HEX < 0x030A00F0 #define __Pyx_TPFLAGS_HAVE_AM_SEND (1UL << 21) #else #define __Pyx_TPFLAGS_HAVE_AM_SEND (0) #endif #if PY_VERSION_HEX >= 0x03090000 #define __Pyx_PyInterpreterState_Get() PyInterpreterState_Get() #else #define __Pyx_PyInterpreterState_Get() PyThreadState_Get()->interp #endif #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030A0000 #ifdef __cplusplus extern "C" #endif PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize); #endif #if CYTHON_COMPILING_IN_LIMITED_API static int __Pyx_init_co_variable(PyObject *inspect, const char* name, int *write_to) { int value; PyObject *py_value = PyObject_GetAttrString(inspect, name); if (!py_value) return 0; value = (int) PyLong_AsLong(py_value); Py_DECREF(py_value); *write_to = value; return value != -1 || !PyErr_Occurred(); } static int __Pyx_init_co_variables(void) { PyObject *inspect; int result; inspect = PyImport_ImportModule("inspect"); result = #if !defined(CO_OPTIMIZED) __Pyx_init_co_variable(inspect, "CO_OPTIMIZED", &CO_OPTIMIZED) && #endif #if !defined(CO_NEWLOCALS) __Pyx_init_co_variable(inspect, "CO_NEWLOCALS", &CO_NEWLOCALS) && #endif #if !defined(CO_VARARGS) __Pyx_init_co_variable(inspect, "CO_VARARGS", &CO_VARARGS) && #endif #if !defined(CO_VARKEYWORDS) __Pyx_init_co_variable(inspect, "CO_VARKEYWORDS", &CO_VARKEYWORDS) && #endif #if !defined(CO_ASYNC_GENERATOR) __Pyx_init_co_variable(inspect, "CO_ASYNC_GENERATOR", &CO_ASYNC_GENERATOR) && #endif #if !defined(CO_GENERATOR) __Pyx_init_co_variable(inspect, "CO_GENERATOR", &CO_GENERATOR) && #endif #if !defined(CO_COROUTINE) __Pyx_init_co_variable(inspect, "CO_COROUTINE", &CO_COROUTINE) && #endif 1; Py_DECREF(inspect); return result ? 0 : -1; } #else static int __Pyx_init_co_variables(void) { return 0; // It's a limited API-only feature } #endif /* MathInitCode */ #if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS) #ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES #endif #endif #include #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) #define __Pyx_truncl trunc #else #define __Pyx_truncl truncl #endif #ifndef CYTHON_CLINE_IN_TRACEBACK_RUNTIME #define CYTHON_CLINE_IN_TRACEBACK_RUNTIME 0 #endif #ifndef CYTHON_CLINE_IN_TRACEBACK #define CYTHON_CLINE_IN_TRACEBACK CYTHON_CLINE_IN_TRACEBACK_RUNTIME #endif #if CYTHON_CLINE_IN_TRACEBACK #define __PYX_MARK_ERR_POS(f_index, lineno) { __pyx_filename = __pyx_f[f_index]; (void) __pyx_filename; __pyx_lineno = lineno; (void) __pyx_lineno; __pyx_clineno = __LINE__; (void) __pyx_clineno; } #else #define __PYX_MARK_ERR_POS(f_index, lineno) { __pyx_filename = __pyx_f[f_index]; (void) __pyx_filename; __pyx_lineno = lineno; (void) __pyx_lineno; (void) __pyx_clineno; } #endif #define __PYX_ERR(f_index, lineno, Ln_error) \ { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } #ifdef CYTHON_EXTERN_C #undef __PYX_EXTERN_C #define __PYX_EXTERN_C CYTHON_EXTERN_C #elif defined(__PYX_EXTERN_C) #ifdef _MSC_VER #pragma message ("Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.") #else #warning Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead. #endif #else #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__clickhouse_driver__columns__largeint #define __PYX_HAVE_API__clickhouse_driver__columns__largeint /* Early includes */ #include #include #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyFloat_FromString(obj) PyFloat_FromString(obj) #else #define __Pyx_PyFloat_FromString(obj) PyFloat_FromString(obj, NULL) #endif #include #if PY_MAJOR_VERSION <= 2 #define PyDict_GetItemWithError _PyDict_GetItemWithError #endif #if PY_VERSION_HEX < 0x030d0000 static CYTHON_INLINE int __Pyx_PyWeakref_GetRef(PyObject *ref, PyObject **pobj) { PyObject *obj = PyWeakref_GetObject(ref); if (obj == NULL) { // SystemError if ref is NULL *pobj = NULL; return -1; } if (obj == Py_None) { *pobj = NULL; return 0; } Py_INCREF(obj); *pobj = obj; return 1; } #else #define __Pyx_PyWeakref_GetRef PyWeakref_GetRef #endif #include "pythread.h" #if (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030600) && !defined(PyContextVar_Get) #define PyContextVar_Get(var, d, v) ((d) ? ((void)(var), Py_INCREF(d), (v)[0] = (d), 0) : ((v)[0] = NULL, 0) ) #endif #ifdef _OPENMP #include #endif /* _OPENMP */ #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0 #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { return (size_t) i < (size_t) limit; } #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s); static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char*); #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyByteArray_AsString(s) PyByteArray_AS_STRING(s) #else #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AsString(s)) #define __Pyx_PyByteArray_AsString(s) PyByteArray_AsString(s) #endif #define __Pyx_PyObject_AsWritableString(s) ((char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) #define __Pyx_PyUnicode_FromOrdinal(o) PyUnicode_FromOrdinal((int)o) #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode static CYTHON_INLINE PyObject *__Pyx_NewRef(PyObject *obj) { #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_NewRef) return Py_NewRef(obj); #else Py_INCREF(obj); return obj; #endif } static CYTHON_INLINE PyObject *__Pyx_XNewRef(PyObject *obj) { #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_XNewRef) return Py_XNewRef(obj); #else Py_XINCREF(obj); return obj; #endif } static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b); static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x); #define __Pyx_PySequence_Tuple(obj)\ (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t); static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AS_DOUBLE(x) #else #define __Pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AsDouble(x) #endif #define __Pyx_PyFloat_AsFloat(x) ((float) __Pyx_PyFloat_AsDouble(x)) #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) #if CYTHON_USE_PYLONG_INTERNALS #if PY_VERSION_HEX >= 0x030C00A7 #ifndef _PyLong_SIGN_MASK #define _PyLong_SIGN_MASK 3 #endif #ifndef _PyLong_NON_SIZE_BITS #define _PyLong_NON_SIZE_BITS 3 #endif #define __Pyx_PyLong_Sign(x) (((PyLongObject*)x)->long_value.lv_tag & _PyLong_SIGN_MASK) #define __Pyx_PyLong_IsNeg(x) ((__Pyx_PyLong_Sign(x) & 2) != 0) #define __Pyx_PyLong_IsNonNeg(x) (!__Pyx_PyLong_IsNeg(x)) #define __Pyx_PyLong_IsZero(x) (__Pyx_PyLong_Sign(x) & 1) #define __Pyx_PyLong_IsPos(x) (__Pyx_PyLong_Sign(x) == 0) #define __Pyx_PyLong_CompactValueUnsigned(x) (__Pyx_PyLong_Digits(x)[0]) #define __Pyx_PyLong_DigitCount(x) ((Py_ssize_t) (((PyLongObject*)x)->long_value.lv_tag >> _PyLong_NON_SIZE_BITS)) #define __Pyx_PyLong_SignedDigitCount(x)\ ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * __Pyx_PyLong_DigitCount(x)) #if defined(PyUnstable_Long_IsCompact) && defined(PyUnstable_Long_CompactValue) #define __Pyx_PyLong_IsCompact(x) PyUnstable_Long_IsCompact((PyLongObject*) x) #define __Pyx_PyLong_CompactValue(x) PyUnstable_Long_CompactValue((PyLongObject*) x) #else #define __Pyx_PyLong_IsCompact(x) (((PyLongObject*)x)->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS)) #define __Pyx_PyLong_CompactValue(x) ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_Digits(x)[0]) #endif typedef Py_ssize_t __Pyx_compact_pylong; typedef size_t __Pyx_compact_upylong; #else #define __Pyx_PyLong_IsNeg(x) (Py_SIZE(x) < 0) #define __Pyx_PyLong_IsNonNeg(x) (Py_SIZE(x) >= 0) #define __Pyx_PyLong_IsZero(x) (Py_SIZE(x) == 0) #define __Pyx_PyLong_IsPos(x) (Py_SIZE(x) > 0) #define __Pyx_PyLong_CompactValueUnsigned(x) ((Py_SIZE(x) == 0) ? 0 : __Pyx_PyLong_Digits(x)[0]) #define __Pyx_PyLong_DigitCount(x) __Pyx_sst_abs(Py_SIZE(x)) #define __Pyx_PyLong_SignedDigitCount(x) Py_SIZE(x) #define __Pyx_PyLong_IsCompact(x) (Py_SIZE(x) == 0 || Py_SIZE(x) == 1 || Py_SIZE(x) == -1) #define __Pyx_PyLong_CompactValue(x)\ ((Py_SIZE(x) == 0) ? (sdigit) 0 : ((Py_SIZE(x) < 0) ? -(sdigit)__Pyx_PyLong_Digits(x)[0] : (sdigit)__Pyx_PyLong_Digits(x)[0])) typedef sdigit __Pyx_compact_pylong; typedef digit __Pyx_compact_upylong; #endif #if PY_VERSION_HEX >= 0x030C00A5 #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->long_value.ob_digit) #else #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->ob_digit) #endif #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #elif __PYX_DEFAULT_STRING_ENCODING_IS_ASCII #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeASCII(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ /* PretendToInitialize */ #ifdef __cplusplus #if __cplusplus > 201103L #include #endif template static void __Pyx_pretend_to_initialize(T* ptr) { #if __cplusplus > 201103L if ((std::is_trivially_default_constructible::value)) #endif *ptr = T(); (void)ptr; } #else static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } #endif #if !CYTHON_USE_MODULE_STATE static PyObject *__pyx_m = NULL; #endif static int __pyx_lineno; static int __pyx_clineno = 0; static const char * const __pyx_cfilenm = __FILE__; static const char *__pyx_filename; /* #### Code section: filename_table ### */ static const char* const __pyx_f[] = { "clickhouse_driver/columns/largeint.pyx", "cpython/contextvars.pxd", "cpython/type.pxd", "cpython/bool.pxd", "cpython/complex.pxd", }; /* #### Code section: utility_code_proto_before_types ### */ /* Atomics.proto */ #include #ifndef CYTHON_ATOMICS #define CYTHON_ATOMICS 1 #endif #define __PYX_CYTHON_ATOMICS_ENABLED() CYTHON_ATOMICS #define __PYX_GET_CYTHON_COMPILING_IN_CPYTHON_FREETHREADING() CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #define __pyx_atomic_int_type int #define __pyx_nonatomic_int_type int #if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\ (__STDC_VERSION__ >= 201112L) &&\ !defined(__STDC_NO_ATOMICS__)) #include #elif CYTHON_ATOMICS && (defined(__cplusplus) && (\ (__cplusplus >= 201103L) ||\ (defined(_MSC_VER) && _MSC_VER >= 1700))) #include #endif #if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\ (__STDC_VERSION__ >= 201112L) &&\ !defined(__STDC_NO_ATOMICS__) &&\ ATOMIC_INT_LOCK_FREE == 2) #undef __pyx_atomic_int_type #define __pyx_atomic_int_type atomic_int #define __pyx_atomic_ptr_type atomic_uintptr_t #define __pyx_nonatomic_ptr_type uintptr_t #define __pyx_atomic_incr_relaxed(value) atomic_fetch_add_explicit(value, 1, memory_order_relaxed) #define __pyx_atomic_incr_acq_rel(value) atomic_fetch_add_explicit(value, 1, memory_order_acq_rel) #define __pyx_atomic_decr_acq_rel(value) atomic_fetch_sub_explicit(value, 1, memory_order_acq_rel) #define __pyx_atomic_sub(value, arg) atomic_fetch_sub(value, arg) #define __pyx_atomic_int_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired) #define __pyx_atomic_load(value) atomic_load(value) #define __pyx_atomic_store(value, new_value) atomic_store(value, new_value) #define __pyx_atomic_pointer_load_relaxed(value) atomic_load_explicit(value, memory_order_relaxed) #define __pyx_atomic_pointer_load_acquire(value) atomic_load_explicit(value, memory_order_acquire) #define __pyx_atomic_pointer_exchange(value, new_value) atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value) #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired) #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER) #pragma message ("Using standard C atomics") #elif defined(__PYX_DEBUG_ATOMICS) #warning "Using standard C atomics" #endif #elif CYTHON_ATOMICS && (defined(__cplusplus) && (\ (__cplusplus >= 201103L) ||\ \ (defined(_MSC_VER) && _MSC_VER >= 1700)) &&\ ATOMIC_INT_LOCK_FREE == 2) #undef __pyx_atomic_int_type #define __pyx_atomic_int_type std::atomic_int #define __pyx_atomic_ptr_type std::atomic_uintptr_t #define __pyx_nonatomic_ptr_type uintptr_t #define __pyx_atomic_incr_relaxed(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_relaxed) #define __pyx_atomic_incr_acq_rel(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_acq_rel) #define __pyx_atomic_decr_acq_rel(value) std::atomic_fetch_sub_explicit(value, 1, std::memory_order_acq_rel) #define __pyx_atomic_sub(value, arg) std::atomic_fetch_sub(value, arg) #define __pyx_atomic_int_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired) #define __pyx_atomic_load(value) std::atomic_load(value) #define __pyx_atomic_store(value, new_value) std::atomic_store(value, new_value) #define __pyx_atomic_pointer_load_relaxed(value) std::atomic_load_explicit(value, std::memory_order_relaxed) #define __pyx_atomic_pointer_load_acquire(value) std::atomic_load_explicit(value, std::memory_order_acquire) #define __pyx_atomic_pointer_exchange(value, new_value) std::atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value) #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired) #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER) #pragma message ("Using standard C++ atomics") #elif defined(__PYX_DEBUG_ATOMICS) #warning "Using standard C++ atomics" #endif #elif CYTHON_ATOMICS && (__GNUC__ >= 5 || (__GNUC__ == 4 &&\ (__GNUC_MINOR__ > 1 ||\ (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ >= 2)))) #define __pyx_atomic_ptr_type void* #define __pyx_nonatomic_ptr_type void* #define __pyx_atomic_incr_relaxed(value) __sync_fetch_and_add(value, 1) #define __pyx_atomic_incr_acq_rel(value) __sync_fetch_and_add(value, 1) #define __pyx_atomic_decr_acq_rel(value) __sync_fetch_and_sub(value, 1) #define __pyx_atomic_sub(value, arg) __sync_fetch_and_sub(value, arg) static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) { __pyx_nonatomic_int_type old = __sync_val_compare_and_swap(value, *expected, desired); int result = old == *expected; *expected = old; return result; } #define __pyx_atomic_load(value) __sync_fetch_and_add(value, 0) #define __pyx_atomic_store(value, new_value) __sync_lock_test_and_set(value, new_value) #define __pyx_atomic_pointer_load_relaxed(value) __sync_fetch_and_add(value, 0) #define __pyx_atomic_pointer_load_acquire(value) __sync_fetch_and_add(value, 0) #define __pyx_atomic_pointer_exchange(value, new_value) __sync_lock_test_and_set(value, (__pyx_atomic_ptr_type)new_value) static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) { __pyx_nonatomic_ptr_type old = __sync_val_compare_and_swap(value, *expected, desired); int result = old == *expected; *expected = old; return result; } #ifdef __PYX_DEBUG_ATOMICS #warning "Using GNU atomics" #endif #elif CYTHON_ATOMICS && defined(_MSC_VER) #include #undef __pyx_atomic_int_type #define __pyx_atomic_int_type long #define __pyx_atomic_ptr_type void* #undef __pyx_nonatomic_int_type #define __pyx_nonatomic_int_type long #define __pyx_nonatomic_ptr_type void* #pragma intrinsic (_InterlockedExchangeAdd, _InterlockedExchange, _InterlockedCompareExchange, _InterlockedCompareExchangePointer, _InterlockedExchangePointer) #define __pyx_atomic_incr_relaxed(value) _InterlockedExchangeAdd(value, 1) #define __pyx_atomic_incr_acq_rel(value) _InterlockedExchangeAdd(value, 1) #define __pyx_atomic_decr_acq_rel(value) _InterlockedExchangeAdd(value, -1) #define __pyx_atomic_sub(value, arg) _InterlockedExchangeAdd(value, -arg) static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) { __pyx_nonatomic_int_type old = _InterlockedCompareExchange(value, desired, *expected); int result = old == *expected; *expected = old; return result; } #define __pyx_atomic_load(value) _InterlockedExchangeAdd(value, 0) #define __pyx_atomic_store(value, new_value) _InterlockedExchange(value, new_value) #define __pyx_atomic_pointer_load_relaxed(value) *(void * volatile *)value #define __pyx_atomic_pointer_load_acquire(value) _InterlockedCompareExchangePointer(value, 0, 0) #define __pyx_atomic_pointer_exchange(value, new_value) _InterlockedExchangePointer(value, (__pyx_atomic_ptr_type)new_value) static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) { __pyx_atomic_ptr_type old = _InterlockedCompareExchangePointer(value, desired, *expected); int result = old == *expected; *expected = old; return result; } #ifdef __PYX_DEBUG_ATOMICS #pragma message ("Using MSVC atomics") #endif #else #undef CYTHON_ATOMICS #define CYTHON_ATOMICS 0 #ifdef __PYX_DEBUG_ATOMICS #warning "Not using atomics" #endif #endif /* CriticalSectionsDefinition.proto */ #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #define __Pyx_PyCriticalSection void* #define __Pyx_PyCriticalSection2 void* #define __Pyx_PyCriticalSection_End(cs) #define __Pyx_PyCriticalSection2_End(cs) #else #define __Pyx_PyCriticalSection PyCriticalSection #define __Pyx_PyCriticalSection2 PyCriticalSection2 #define __Pyx_PyCriticalSection_End PyCriticalSection_End #define __Pyx_PyCriticalSection2_End PyCriticalSection2_End #endif /* CriticalSections.proto */ #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #define __Pyx_PyCriticalSection_Begin(cs, arg) (void)(cs) #define __Pyx_PyCriticalSection2_Begin(cs, arg1, arg2) (void)(cs) #else #define __Pyx_PyCriticalSection_Begin PyCriticalSection_Begin #define __Pyx_PyCriticalSection2_Begin PyCriticalSection2_Begin #endif #if PY_VERSION_HEX < 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_BEGIN_CRITICAL_SECTION(o) { #define __Pyx_END_CRITICAL_SECTION() } #else #define __Pyx_BEGIN_CRITICAL_SECTION Py_BEGIN_CRITICAL_SECTION #define __Pyx_END_CRITICAL_SECTION Py_END_CRITICAL_SECTION #endif /* IncludeStructmemberH.proto */ #include /* #### Code section: numeric_typedefs ### */ /* #### Code section: complex_type_declarations ### */ /* #### Code section: type_declarations ### */ /*--- Type declarations ---*/ struct __pyx_opt_args_7cpython_11contextvars_get_value; struct __pyx_opt_args_7cpython_11contextvars_get_value_no_default; /* "cpython/contextvars.pxd":116 * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline object get_value(var, default_value=None): # <<<<<<<<<<<<<< * """Return a new reference to the value of the context variable, * or the default value of the context variable, */ struct __pyx_opt_args_7cpython_11contextvars_get_value { int __pyx_n; PyObject *default_value; }; /* "cpython/contextvars.pxd":134 * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline object get_value_no_default(var, default_value=None): # <<<<<<<<<<<<<< * """Return a new reference to the value of the context variable, * or the provided default value if no such value was found. */ struct __pyx_opt_args_7cpython_11contextvars_get_value_no_default { int __pyx_n; PyObject *default_value; }; /* #### Code section: utility_code_proto ### */ /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, Py_ssize_t); void (*DECREF)(void*, PyObject*, Py_ssize_t); void (*GOTREF)(void*, PyObject*, Py_ssize_t); void (*GIVEREF)(void*, PyObject*, Py_ssize_t); void* (*SetupContext)(const char*, Py_ssize_t, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\ } #define __Pyx_RefNannyFinishContextNogil() {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __Pyx_RefNannyFinishContext();\ PyGILState_Release(__pyx_gilstate_save);\ } #define __Pyx_RefNannyFinishContextNogil() {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __Pyx_RefNannyFinishContext();\ PyGILState_Release(__pyx_gilstate_save);\ } #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_XINCREF(r) do { if((r) == NULL); else {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) == NULL); else {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) == NULL); else {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) == NULL); else {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContextNogil() #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_Py_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; Py_XDECREF(tmp);\ } while (0) #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) /* TupleAndListFromArray.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n); #endif #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_METH_FASTCALL static CYTHON_INLINE PyObject* __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n); #endif /* IncludeStringH.proto */ #include /* BytesEquals.proto */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /* UnicodeEquals.proto */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /* fastcall.proto */ #if CYTHON_AVOID_BORROWED_REFS #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_PySequence_ITEM(args, i) #elif CYTHON_ASSUME_SAFE_MACROS #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_NewRef(__Pyx_PyTuple_GET_ITEM(args, i)) #else #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_XNewRef(PyTuple_GetItem(args, i)) #endif #define __Pyx_NumKwargs_VARARGS(kwds) PyDict_Size(kwds) #define __Pyx_KwValues_VARARGS(args, nargs) NULL #define __Pyx_GetKwValue_VARARGS(kw, kwvalues, s) __Pyx_PyDict_GetItemStrWithError(kw, s) #define __Pyx_KwargsAsDict_VARARGS(kw, kwvalues) PyDict_Copy(kw) #if CYTHON_METH_FASTCALL #define __Pyx_ArgRef_FASTCALL(args, i) __Pyx_NewRef(args[i]) #define __Pyx_NumKwargs_FASTCALL(kwds) __Pyx_PyTuple_GET_SIZE(kwds) #define __Pyx_KwValues_FASTCALL(args, nargs) ((args) + (nargs)) static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues); #else #define __Pyx_KwargsAsDict_FASTCALL(kw, kwvalues) _PyStack_AsDict(kwvalues, kw) #endif #else #define __Pyx_ArgRef_FASTCALL __Pyx_ArgRef_VARARGS #define __Pyx_NumKwargs_FASTCALL __Pyx_NumKwargs_VARARGS #define __Pyx_KwValues_FASTCALL __Pyx_KwValues_VARARGS #define __Pyx_GetKwValue_FASTCALL __Pyx_GetKwValue_VARARGS #define __Pyx_KwargsAsDict_FASTCALL __Pyx_KwargsAsDict_VARARGS #endif #define __Pyx_ArgsSlice_VARARGS(args, start, stop) PyTuple_GetSlice(args, start, stop) #if CYTHON_METH_FASTCALL || (CYTHON_COMPILING_IN_CPYTHON && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) __Pyx_PyTuple_FromArray(args + start, stop - start) #else #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) PyTuple_GetSlice(args, start, stop) #endif /* py_dict_items.proto */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d); /* CallCFunction.proto */ #define __Pyx_CallCFunction(cfunc, self, args)\ ((PyCFunction)(void(*)(void))(cfunc)->func)(self, args) #define __Pyx_CallCFunctionWithKeywords(cfunc, self, args, kwargs)\ ((PyCFunctionWithKeywords)(void(*)(void))(cfunc)->func)(self, args, kwargs) #define __Pyx_CallCFunctionFast(cfunc, self, args, nargs)\ ((__Pyx_PyCFunctionFast)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs) #define __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, nargs, kwnames)\ ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs, kwnames) /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif /* PyObjectCallMethO.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); #endif /* PyObjectFastCall.proto */ #define __Pyx_PyObject_FastCall(func, args, nargs) __Pyx_PyObject_FastCallDict(func, args, (size_t)(nargs), NULL) static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs); /* PyObjectCallOneArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); /* PyObjectGetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif /* UnpackUnboundCMethod.proto */ typedef struct { PyObject *type; PyObject **method_name; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && CYTHON_ATOMICS __pyx_atomic_int_type initialized; #endif PyCFunction func; PyObject *method; int flag; } __Pyx_CachedCFunction; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING static CYTHON_INLINE int __Pyx_CachedCFunction_GetAndSetInitializing(__Pyx_CachedCFunction *cfunc) { #if !CYTHON_ATOMICS return 1; #else __pyx_nonatomic_int_type expected = 0; if (__pyx_atomic_int_cmp_exchange(&cfunc->initialized, &expected, 1)) { return 0; } return expected; #endif } static CYTHON_INLINE void __Pyx_CachedCFunction_SetFinishedInitializing(__Pyx_CachedCFunction *cfunc) { #if CYTHON_ATOMICS __pyx_atomic_store(&cfunc->initialized, 2); #endif } #else #define __Pyx_CachedCFunction_GetAndSetInitializing(cfunc) 2 #define __Pyx_CachedCFunction_SetFinishedInitializing(cfunc) #endif /* CallUnboundCMethod0.proto */ CYTHON_UNUSED static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self); #else #define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self) #endif /* py_dict_values.proto */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d); /* OwnedDictNext.proto */ #if CYTHON_AVOID_BORROWED_REFS static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue); #else CYTHON_INLINE static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue); #endif /* RaiseDoubleKeywords.proto */ static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /* ParseKeywordsImpl.export */ static int __Pyx_ParseKeywordsTuple( PyObject *kwds, PyObject * const *kwvalues, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs ); static int __Pyx_ParseKeywordDictToDict( PyObject *kwds, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name ); static int __Pyx_ParseKeywordDict( PyObject *kwds, PyObject ** const argnames[], PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs ); /* CallUnboundCMethod2.proto */ CYTHON_UNUSED static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2); #else #define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2) __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2) #endif /* ParseKeywords.proto */ static CYTHON_INLINE int __Pyx_ParseKeywords( PyObject *kwds, PyObject *const *kwvalues, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs ); /* RaiseArgTupleInvalid.proto */ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /* GetItemInt.proto */ #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck, unsafe_shared) :\ (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ __Pyx_GetItemInt_Generic(o, to_py_func(i)))) #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) :\ (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck, int unsafe_shared); #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) :\ (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck, int unsafe_shared); static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck, int unsafe_shared); /* PyLongBinop.proto */ #if !CYTHON_COMPILING_IN_PYPY static CYTHON_INLINE PyObject* __Pyx_PyLong_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); #else #define __Pyx_PyLong_SubtractObjC(op1, op2, intval, inplace, zerodivision_check)\ (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2)) #endif /* TypeImport.proto */ #ifndef __PYX_HAVE_RT_ImportType_proto_3_2_0 #define __PYX_HAVE_RT_ImportType_proto_3_2_0 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #include #endif #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || __cplusplus >= 201103L #define __PYX_GET_STRUCT_ALIGNMENT_3_2_0(s) alignof(s) #else #define __PYX_GET_STRUCT_ALIGNMENT_3_2_0(s) sizeof(void*) #endif enum __Pyx_ImportType_CheckSize_3_2_0 { __Pyx_ImportType_CheckSize_Error_3_2_0 = 0, __Pyx_ImportType_CheckSize_Warn_3_2_0 = 1, __Pyx_ImportType_CheckSize_Ignore_3_2_0 = 2 }; static PyTypeObject *__Pyx_ImportType_3_2_0(PyObject* module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_2_0 check_size); #endif /* PyErrExceptionMatches.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); #else #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) #endif /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; #if PY_VERSION_HEX >= 0x030C00A6 #define __Pyx_PyErr_Occurred() (__pyx_tstate->current_exception != NULL) #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->current_exception ? (PyObject*) Py_TYPE(__pyx_tstate->current_exception) : (PyObject*) NULL) #else #define __Pyx_PyErr_Occurred() (__pyx_tstate->curexc_type != NULL) #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->curexc_type) #endif #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign #define __Pyx_PyErr_Occurred() (PyErr_Occurred() != NULL) #define __Pyx_PyErr_CurrentExceptionType() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A6 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) #else #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #endif #else #define __Pyx_PyErr_Clear() PyErr_Clear() #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) #endif /* PyObjectGetAttrStrNoError.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name); /* HasAttr.proto */ #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_HasAttr(o, n) PyObject_HasAttrWithError(o, n) #else static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *); #endif /* Import.export */ static PyObject *__Pyx_Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, int level); /* ImportFrom.proto */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /* GetBuiltinName.proto */ static PyObject *__Pyx_GetBuiltinName(PyObject *name); /* PyDictVersioning.proto */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ (version_var) = __PYX_GET_DICT_VERSION(dict);\ (cache_var) = (value); #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ (VAR) = __Pyx_XNewRef(__pyx_dict_cached_value);\ } else {\ (VAR) = __pyx_dict_cached_value = (LOOKUP);\ __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ }\ } static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); #else #define __PYX_GET_DICT_VERSION(dict) (0) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); #endif /* GetModuleGlobalName.proto */ #if CYTHON_USE_DICT_VERSIONS #define __Pyx_GetModuleGlobalName(var, name) do {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_mstate_global->__pyx_d))) ?\ (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } while(0) #define __Pyx_GetModuleGlobalNameUncached(var, name) do {\ PY_UINT64_T __pyx_dict_version;\ PyObject *__pyx_dict_cached_value;\ (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } while(0) static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); #else #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); #endif /* dict_setdefault.proto */ static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value); /* LimitedApiGetTypeDict.proto */ #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp); #endif /* SetItemOnTypeDict.proto */ static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v); #define __Pyx_SetItemOnTypeDict(tp, k, v) __Pyx__SetItemOnTypeDict((PyTypeObject*)tp, k, v) /* FixUpExtensionType.proto */ static CYTHON_INLINE int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type); /* AddModuleRef.proto */ #if ((CYTHON_COMPILING_IN_CPYTHON_FREETHREADING ) ||\ __PYX_LIMITED_VERSION_HEX < 0x030d0000) static PyObject *__Pyx_PyImport_AddModuleRef(const char *name); #else #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name) #endif /* FetchSharedCythonModule.proto */ static PyObject *__Pyx_FetchSharedCythonABIModule(void); /* FetchCommonType.proto */ static PyTypeObject* __Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases); /* CommonTypesMetaclass.proto */ static int __pyx_CommonTypesMetaclass_init(PyObject *module); #define __Pyx_CommonTypesMetaclass_USED /* CallTypeTraverse.proto */ #if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000) #define __Pyx_call_type_traverse(o, always_call, visit, arg) 0 #else static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg); #endif /* PyMethodNew.proto */ static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ); /* PyVectorcallFastCallDict.proto */ #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw); #endif /* CythonFunctionShared.proto */ #define __Pyx_CyFunction_USED #define __Pyx_CYFUNCTION_STATICMETHOD 0x01 #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 #define __Pyx_CYFUNCTION_CCLASS 0x04 #define __Pyx_CYFUNCTION_COROUTINE 0x08 #define __Pyx_CyFunction_GetClosure(f)\ (((__pyx_CyFunctionObject *) (f))->func_closure) #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_GetClassObj(f)\ (((__pyx_CyFunctionObject *) (f))->func_classobj) #else #define __Pyx_CyFunction_GetClassObj(f)\ ((PyObject*) ((PyCMethodObject *) (f))->mm_class) #endif #define __Pyx_CyFunction_SetClassObj(f, classobj)\ __Pyx__CyFunction_SetClassObj((__pyx_CyFunctionObject *) (f), (classobj)) #define __Pyx_CyFunction_Defaults(type, f)\ ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) typedef struct { #if CYTHON_COMPILING_IN_LIMITED_API PyObject_HEAD PyObject *func; #elif PY_VERSION_HEX < 0x030900B1 PyCFunctionObject func; #else PyCMethodObject func; #endif #if CYTHON_COMPILING_IN_LIMITED_API && CYTHON_METH_FASTCALL __pyx_vectorcallfunc func_vectorcall; #endif #if CYTHON_COMPILING_IN_LIMITED_API PyObject *func_weakreflist; #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API PyObject *func_dict; #endif PyObject *func_name; PyObject *func_qualname; PyObject *func_doc; PyObject *func_globals; PyObject *func_code; PyObject *func_closure; #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API PyObject *func_classobj; #endif PyObject *defaults; int flags; PyObject *defaults_tuple; PyObject *defaults_kwdict; PyObject *(*defaults_getter)(PyObject *); PyObject *func_annotations; PyObject *func_is_coroutine; } __pyx_CyFunctionObject; #undef __Pyx_CyOrPyCFunction_Check #define __Pyx_CyFunction_Check(obj) __Pyx_TypeCheck(obj, __pyx_mstate_global->__pyx_CyFunctionType) #define __Pyx_CyOrPyCFunction_Check(obj) __Pyx_TypeCheck2(obj, __pyx_mstate_global->__pyx_CyFunctionType, &PyCFunction_Type) #define __Pyx_CyFunction_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_mstate_global->__pyx_CyFunctionType) static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)); #undef __Pyx_IsSameCFunction #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCyOrCFunction(func, cfunc) static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject *globals, PyObject* code); static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj); static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, PyObject *tuple); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, PyObject *dict); static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, PyObject *dict); static int __pyx_CyFunction_init(PyObject *module); #if CYTHON_METH_FASTCALL static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_func_vectorcall(f) (((__pyx_CyFunctionObject*)f)->func_vectorcall) #else #define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall) #endif #endif /* CythonFunction.proto */ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject *globals, PyObject* code); /* CLineInTraceback.proto */ #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); #else #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) #endif /* CodeObjectCache.proto */ #if CYTHON_COMPILING_IN_LIMITED_API typedef PyObject __Pyx_CachedCodeObjectType; #else typedef PyCodeObject __Pyx_CachedCodeObjectType; #endif typedef struct { __Pyx_CachedCodeObjectType* code_object; int code_line; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_atomic_int_type accessor_count; #endif }; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object); /* AddTraceback.proto */ static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); /* GCCDiagnostics.proto */ #if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #define __Pyx_HAS_GCC_DIAGNOSTIC #endif /* CIntFromPy.proto */ static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyLong_As_unsigned_PY_LONG_LONG(PyObject *); /* PyObjectVectorCallKwBuilder.proto */ CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n); #if CYTHON_VECTORCALL #if PY_VERSION_HEX >= 0x03090000 #define __Pyx_Object_Vectorcall_CallFromBuilder PyObject_Vectorcall #else #define __Pyx_Object_Vectorcall_CallFromBuilder _PyObject_Vectorcall #endif #define __Pyx_MakeVectorcallBuilderKwds(n) PyTuple_New(n) static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n); static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n); #else #define __Pyx_Object_Vectorcall_CallFromBuilder __Pyx_PyObject_FastCallDict #define __Pyx_MakeVectorcallBuilderKwds(n) __Pyx_PyDict_NewPresized(n) #define __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n) PyDict_SetItem(builder, key, value) #define __Pyx_VectorcallBuilder_AddArgStr(key, value, builder, args, n) PyDict_SetItemString(builder, key, value) #endif /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value); /* FormatTypeName.proto */ #if CYTHON_COMPILING_IN_LIMITED_API typedef PyObject *__Pyx_TypeName; #define __Pyx_FMT_TYPENAME "%U" #define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj) #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyType_GetFullyQualifiedName PyType_GetFullyQualifiedName #else static __Pyx_TypeName __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp); #endif #else // !LIMITED_API typedef const char *__Pyx_TypeName; #define __Pyx_FMT_TYPENAME "%.200s" #define __Pyx_PyType_GetFullyQualifiedName(tp) ((tp)->tp_name) #define __Pyx_DECREF_TypeName(obj) #endif /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *); /* FastTypeChecks.proto */ #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) #define __Pyx_TypeCheck2(obj, type1, type2) __Pyx_IsAnySubtype2(Py_TYPE(obj), (PyTypeObject *)type1, (PyTypeObject *)type2) static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); #else #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_TypeCheck2(obj, type1, type2) (PyObject_TypeCheck(obj, (PyTypeObject *)type1) || PyObject_TypeCheck(obj, (PyTypeObject *)type2)) #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2) { return PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2); } #endif #define __Pyx_PyErr_ExceptionMatches2(err1, err2) __Pyx_PyErr_GivenExceptionMatches2(__Pyx_PyErr_CurrentExceptionType(), err1, err2) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #ifdef PyExceptionInstance_Check #define __Pyx_PyBaseException_Check(obj) PyExceptionInstance_Check(obj) #else #define __Pyx_PyBaseException_Check(obj) __Pyx_TypeCheck(obj, PyExc_BaseException) #endif /* GetRuntimeVersion.proto */ #if __PYX_LIMITED_VERSION_HEX < 0x030b0000 static unsigned long __Pyx_cached_runtime_version = 0; static void __Pyx_init_runtime_version(void); #else #define __Pyx_init_runtime_version() #endif static unsigned long __Pyx_get_runtime_version(void); /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer); /* DecompressString.proto */ static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo); /* MultiPhaseInitModuleState.proto */ #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE static PyObject *__Pyx_State_FindModule(void*); static int __Pyx_State_AddModule(PyObject* module, void*); static int __Pyx_State_RemoveModule(void*); #elif CYTHON_USE_MODULE_STATE #define __Pyx_State_FindModule PyState_FindModule #define __Pyx_State_AddModule PyState_AddModule #define __Pyx_State_RemoveModule PyState_RemoveModule #endif /* #### Code section: module_declarations ### */ /* CythonABIVersion.proto */ #if CYTHON_COMPILING_IN_LIMITED_API #if CYTHON_METH_FASTCALL #define __PYX_FASTCALL_ABI_SUFFIX "_fastcall" #else #define __PYX_FASTCALL_ABI_SUFFIX #endif #define __PYX_LIMITED_ABI_SUFFIX "limited" __PYX_FASTCALL_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX #else #define __PYX_LIMITED_ABI_SUFFIX #endif #if __PYX_HAS_PY_AM_SEND == 1 #define __PYX_AM_SEND_ABI_SUFFIX #elif __PYX_HAS_PY_AM_SEND == 2 #define __PYX_AM_SEND_ABI_SUFFIX "amsendbackport" #else #define __PYX_AM_SEND_ABI_SUFFIX "noamsend" #endif #ifndef __PYX_MONITORING_ABI_SUFFIX #define __PYX_MONITORING_ABI_SUFFIX #endif #if CYTHON_USE_TP_FINALIZE #define __PYX_TP_FINALIZE_ABI_SUFFIX #else #define __PYX_TP_FINALIZE_ABI_SUFFIX "nofinalize" #endif #if CYTHON_USE_FREELISTS || !defined(__Pyx_AsyncGen_USED) #define __PYX_FREELISTS_ABI_SUFFIX #else #define __PYX_FREELISTS_ABI_SUFFIX "nofreelists" #endif #define CYTHON_ABI __PYX_ABI_VERSION __PYX_LIMITED_ABI_SUFFIX __PYX_MONITORING_ABI_SUFFIX __PYX_TP_FINALIZE_ABI_SUFFIX __PYX_FREELISTS_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX #define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI #define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "." #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4real_real(PyComplexObject *__pyx_v_self); /* proto*/ #endif #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4imag_imag(PyComplexObject *__pyx_v_self); /* proto*/ #endif /* Module declarations from "cpython.version" */ /* Module declarations from "__builtin__" */ /* Module declarations from "cpython.type" */ /* Module declarations from "libc.string" */ /* Module declarations from "libc.stdio" */ /* Module declarations from "cpython.object" */ /* Module declarations from "cpython.ref" */ /* Module declarations from "cpython.exc" */ /* Module declarations from "cpython.module" */ /* Module declarations from "cpython.mem" */ /* Module declarations from "cpython.tuple" */ /* Module declarations from "cpython.list" */ /* Module declarations from "cpython.sequence" */ /* Module declarations from "cpython.mapping" */ /* Module declarations from "cpython.iterator" */ /* Module declarations from "cpython.number" */ /* Module declarations from "__builtin__" */ /* Module declarations from "cpython.bool" */ /* Module declarations from "cpython.long" */ /* Module declarations from "cpython.float" */ /* Module declarations from "cython" */ /* Module declarations from "__builtin__" */ /* Module declarations from "cpython.complex" */ /* Module declarations from "libc.stddef" */ /* Module declarations from "cpython.unicode" */ /* Module declarations from "cpython.pyport" */ /* Module declarations from "cpython.dict" */ /* Module declarations from "cpython.instance" */ /* Module declarations from "cpython.function" */ /* Module declarations from "cpython.method" */ /* Module declarations from "cpython.weakref" */ /* Module declarations from "cpython.getargs" */ /* Module declarations from "cpython.pythread" */ /* Module declarations from "cpython.pystate" */ /* Module declarations from "cpython.set" */ /* Module declarations from "cpython.buffer" */ /* Module declarations from "cpython.bytes" */ /* Module declarations from "cpython.pycapsule" */ /* Module declarations from "cpython.contextvars" */ /* Module declarations from "cpython" */ /* Module declarations from "clickhouse_driver.columns.largeint" */ static PyObject *__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64 = 0; static PyObject *__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_INT64 = 0; /* #### Code section: typeinfo ### */ /* #### Code section: before_global_var ### */ #define __Pyx_MODULE_NAME "clickhouse_driver.columns.largeint" extern int __pyx_module_is_main_clickhouse_driver__columns__largeint; int __pyx_module_is_main_clickhouse_driver__columns__largeint = 0; /* Implementation of "clickhouse_driver.columns.largeint" */ /* #### Code section: global_var ### */ /* #### Code section: string_decls ### */ /* #### Code section: decls ### */ static PyObject *__pyx_pf_17clickhouse_driver_7columns_8largeint_int128_from_quads(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_quad_items, unsigned PY_LONG_LONG __pyx_v_n_items); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_7columns_8largeint_2int128_to_quads(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_items, unsigned PY_LONG_LONG __pyx_v_n_items); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_7columns_8largeint_4uint128_from_quads(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_quad_items, unsigned PY_LONG_LONG __pyx_v_n_items); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_7columns_8largeint_6uint128_to_quads(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_items, unsigned PY_LONG_LONG __pyx_v_n_items); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_7columns_8largeint_8int256_from_quads(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_quad_items, unsigned PY_LONG_LONG __pyx_v_n_items); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_7columns_8largeint_10int256_to_quads(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_items, unsigned PY_LONG_LONG __pyx_v_n_items); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_7columns_8largeint_12uint256_from_quads(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_quad_items, unsigned PY_LONG_LONG __pyx_v_n_items); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_7columns_8largeint_14uint256_to_quads(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_items, unsigned PY_LONG_LONG __pyx_v_n_items); /* proto */ /* #### Code section: late_includes ### */ /* #### Code section: module_state ### */ /* SmallCodeConfig */ #ifndef CYTHON_SMALL_CODE #if defined(__clang__) #define CYTHON_SMALL_CODE #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) #define CYTHON_SMALL_CODE __attribute__((cold)) #else #define CYTHON_SMALL_CODE #endif #endif typedef struct { PyObject *__pyx_d; PyObject *__pyx_b; PyObject *__pyx_cython_runtime; PyObject *__pyx_empty_tuple; PyObject *__pyx_empty_bytes; PyObject *__pyx_empty_unicode; PyTypeObject *__pyx_ptype_7cpython_4type_type; PyTypeObject *__pyx_ptype_7cpython_4bool_bool; PyTypeObject *__pyx_ptype_7cpython_7complex_complex; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_values; PyObject *__pyx_codeobj_tab[8]; PyObject *__pyx_string_tab[48]; PyObject *__pyx_number_tab[5]; /* #### Code section: module_state_contents ### */ /* CommonTypesMetaclass.module_state_decls */ PyTypeObject *__pyx_CommonTypesMetaclassType; /* CachedMethodType.module_state_decls */ #if CYTHON_COMPILING_IN_LIMITED_API PyObject *__Pyx_CachedMethodType; #endif /* CythonFunctionShared.module_state_decls */ PyTypeObject *__pyx_CyFunctionType; /* CodeObjectCache.module_state_decls */ struct __Pyx_CodeObjectCache __pyx_code_cache; /* #### Code section: module_state_end ### */ } __pyx_mstatetype; #if CYTHON_USE_MODULE_STATE #ifdef __cplusplus namespace { extern struct PyModuleDef __pyx_moduledef; } /* anonymous namespace */ #else static struct PyModuleDef __pyx_moduledef; #endif #define __pyx_mstate_global (__Pyx_PyModule_GetState(__Pyx_State_FindModule(&__pyx_moduledef))) #define __pyx_m (__Pyx_State_FindModule(&__pyx_moduledef)) #else static __pyx_mstatetype __pyx_mstate_global_static = #ifdef __cplusplus {}; #else {0}; #endif static __pyx_mstatetype * const __pyx_mstate_global = &__pyx_mstate_global_static; #endif /* #### Code section: constant_name_defines ### */ #define __pyx_kp_u__2 __pyx_string_tab[0] #define __pyx_kp_u__3 __pyx_string_tab[1] #define __pyx_kp_u_clickhouse_driver __pyx_string_tab[2] #define __pyx_kp_u_clickhouse_driver_columns_largei_2 __pyx_string_tab[3] #define __pyx_n_u_ __pyx_string_tab[4] #define __pyx_n_u_MAX_INT64 __pyx_string_tab[5] #define __pyx_n_u_MAX_UINT64 __pyx_string_tab[6] #define __pyx_n_u_Pyx_PyDict_NextRef __pyx_string_tab[7] #define __pyx_n_u_asyncio_coroutines __pyx_string_tab[8] #define __pyx_n_u_clickhouse_driver_columns_largei __pyx_string_tab[9] #define __pyx_n_u_cline_in_traceback __pyx_string_tab[10] #define __pyx_n_u_factor __pyx_string_tab[11] #define __pyx_n_u_func __pyx_string_tab[12] #define __pyx_n_u_i __pyx_string_tab[13] #define __pyx_n_u_int128_from_quads __pyx_string_tab[14] #define __pyx_n_u_int128_to_quads __pyx_string_tab[15] #define __pyx_n_u_int256_from_quads __pyx_string_tab[16] #define __pyx_n_u_int256_to_quads __pyx_string_tab[17] #define __pyx_n_u_is_coroutine __pyx_string_tab[18] #define __pyx_n_u_item __pyx_string_tab[19] #define __pyx_n_u_items __pyx_string_tab[20] #define __pyx_n_u_ix __pyx_string_tab[21] #define __pyx_n_u_main __pyx_string_tab[22] #define __pyx_n_u_module __pyx_string_tab[23] #define __pyx_n_u_n_items __pyx_string_tab[24] #define __pyx_n_u_name __pyx_string_tab[25] #define __pyx_n_u_pop __pyx_string_tab[26] #define __pyx_n_u_quad_items __pyx_string_tab[27] #define __pyx_n_u_qualname __pyx_string_tab[28] #define __pyx_n_u_self __pyx_string_tab[29] #define __pyx_n_u_set_name __pyx_string_tab[30] #define __pyx_n_u_setdefault __pyx_string_tab[31] #define __pyx_n_u_test __pyx_string_tab[32] #define __pyx_n_u_uint128_from_quads __pyx_string_tab[33] #define __pyx_n_u_uint128_to_quads __pyx_string_tab[34] #define __pyx_n_u_uint256_from_quads __pyx_string_tab[35] #define __pyx_n_u_uint256_to_quads __pyx_string_tab[36] #define __pyx_n_u_values __pyx_string_tab[37] #define __pyx_n_u_writer __pyx_string_tab[38] #define __pyx_n_u_x __pyx_string_tab[39] #define __pyx_kp_b_iso88591_q_AXRq_U_1_WBa_E_2Rq_2Q_b_A_Qa __pyx_string_tab[40] #define __pyx_kp_b_iso88591_q_AXRq_U_1_WBa_E_2Rq_2Q_b_A_Qa_2 __pyx_string_tab[41] #define __pyx_kp_b_iso88591_q_AXRq_U_1_WBa_E_r_1_T_T_1_S_Q __pyx_string_tab[42] #define __pyx_kp_b_iso88591_q_AXRq_U_1_WBa_E_r_1_T_T_1_S_Q_2 __pyx_string_tab[43] #define __pyx_kp_b_iso88591_q_Kq_U_1_WBa_3b_3d_Jaq_1_1 __pyx_string_tab[44] #define __pyx_kp_b_iso88591_q_Kq_U_1_WBa_Qc_3b_b_3b_Cq_b_1 __pyx_string_tab[45] #define __pyx_kp_b_iso88591_q_Kq_U_1_WBa_Qc_3b_b_3b_Cq_b_3b __pyx_string_tab[46] #define __pyx_kp_b_iso88591_q_Kq_U_1_WBa_q_2S_5_q_2S_5_q_2S __pyx_string_tab[47] #define __pyx_int_0 __pyx_number_tab[0] #define __pyx_int_1 __pyx_number_tab[1] #define __pyx_int_64 __pyx_number_tab[2] #define __pyx_int_128 __pyx_number_tab[3] #define __pyx_int_192 __pyx_number_tab[4] /* #### Code section: module_state_clear ### */ #if CYTHON_USE_MODULE_STATE static CYTHON_SMALL_CODE int __pyx_m_clear(PyObject *m) { __pyx_mstatetype *clear_module_state = __Pyx_PyModule_GetState(m); if (!clear_module_state) return 0; Py_CLEAR(clear_module_state->__pyx_d); Py_CLEAR(clear_module_state->__pyx_b); Py_CLEAR(clear_module_state->__pyx_cython_runtime); Py_CLEAR(clear_module_state->__pyx_empty_tuple); Py_CLEAR(clear_module_state->__pyx_empty_bytes); Py_CLEAR(clear_module_state->__pyx_empty_unicode); #if CYTHON_PEP489_MULTI_PHASE_INIT __Pyx_State_RemoveModule(NULL); #endif Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_4type_type); Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_4bool_bool); Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_7complex_complex); for (int i=0; i<8; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); } for (int i=0; i<48; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); } for (int i=0; i<5; ++i) { Py_CLEAR(clear_module_state->__pyx_number_tab[i]); } /* #### Code section: module_state_clear_contents ### */ /* CommonTypesMetaclass.module_state_clear */ Py_CLEAR(clear_module_state->__pyx_CommonTypesMetaclassType); /* CythonFunctionShared.module_state_clear */ Py_CLEAR(clear_module_state->__pyx_CyFunctionType); /* #### Code section: module_state_clear_end ### */ return 0; } #endif /* #### Code section: module_state_traverse ### */ #if CYTHON_USE_MODULE_STATE static CYTHON_SMALL_CODE int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) { __pyx_mstatetype *traverse_module_state = __Pyx_PyModule_GetState(m); if (!traverse_module_state) return 0; Py_VISIT(traverse_module_state->__pyx_d); Py_VISIT(traverse_module_state->__pyx_b); Py_VISIT(traverse_module_state->__pyx_cython_runtime); __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_tuple); __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_bytes); __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_unicode); Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_4type_type); Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_4bool_bool); Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_7complex_complex); for (int i=0; i<8; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); } for (int i=0; i<48; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); } for (int i=0; i<5; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_number_tab[i]); } /* #### Code section: module_state_traverse_contents ### */ /* CommonTypesMetaclass.module_state_traverse */ Py_VISIT(traverse_module_state->__pyx_CommonTypesMetaclassType); /* CythonFunctionShared.module_state_traverse */ Py_VISIT(traverse_module_state->__pyx_CyFunctionType); /* #### Code section: module_state_traverse_end ### */ return 0; } #endif /* #### Code section: module_code ### */ /* "cpython/complex.pxd":20 * * # unavailable in limited API * @property # <<<<<<<<<<<<<< * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double real(self) noexcept: */ #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4real_real(PyComplexObject *__pyx_v_self) { double __pyx_r; /* "cpython/complex.pxd":23 * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double real(self) noexcept: * return self.cval.real # <<<<<<<<<<<<<< * * # unavailable in limited API */ __pyx_r = __pyx_v_self->cval.real; goto __pyx_L0; /* "cpython/complex.pxd":20 * * # unavailable in limited API * @property # <<<<<<<<<<<<<< * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double real(self) noexcept: */ /* function exit code */ __pyx_L0:; return __pyx_r; } #endif /*!(#if !CYTHON_COMPILING_IN_LIMITED_API)*/ /* "cpython/complex.pxd":26 * * # unavailable in limited API * @property # <<<<<<<<<<<<<< * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double imag(self) noexcept: */ #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4imag_imag(PyComplexObject *__pyx_v_self) { double __pyx_r; /* "cpython/complex.pxd":29 * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double imag(self) noexcept: * return self.cval.imag # <<<<<<<<<<<<<< * * # PyTypeObject PyComplex_Type */ __pyx_r = __pyx_v_self->cval.imag; goto __pyx_L0; /* "cpython/complex.pxd":26 * * # unavailable in limited API * @property # <<<<<<<<<<<<<< * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double imag(self) noexcept: */ /* function exit code */ __pyx_L0:; return __pyx_r; } #endif /*!(#if !CYTHON_COMPILING_IN_LIMITED_API)*/ /* "cpython/contextvars.pxd":115 * * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") # <<<<<<<<<<<<<< * cdef inline object get_value(var, default_value=None): * """Return a new reference to the value of the context variable, */ #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE PyObject *__pyx_f_7cpython_11contextvars_get_value(PyObject *__pyx_v_var, struct __pyx_opt_args_7cpython_11contextvars_get_value *__pyx_optional_args) { /* "cpython/contextvars.pxd":116 * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline object get_value(var, default_value=None): # <<<<<<<<<<<<<< * """Return a new reference to the value of the context variable, * or the default value of the context variable, */ PyObject *__pyx_v_default_value = ((PyObject *)Py_None); PyObject *__pyx_v_value; PyObject *__pyx_v_pyvalue = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_value", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_default_value = __pyx_optional_args->default_value; } } /* "cpython/contextvars.pxd":121 * or None if no such value or default was found. * """ * cdef PyObject *value = NULL # <<<<<<<<<<<<<< * PyContextVar_Get(var, NULL, &value) * if value is NULL: */ __pyx_v_value = NULL; /* "cpython/contextvars.pxd":122 * """ * cdef PyObject *value = NULL * PyContextVar_Get(var, NULL, &value) # <<<<<<<<<<<<<< * if value is NULL: * # context variable does not have a default */ __pyx_t_1 = PyContextVar_Get(__pyx_v_var, NULL, (&__pyx_v_value)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(1, 122, __pyx_L1_error) /* "cpython/contextvars.pxd":123 * cdef PyObject *value = NULL * PyContextVar_Get(var, NULL, &value) * if value is NULL: # <<<<<<<<<<<<<< * # context variable does not have a default * pyvalue = default_value */ __pyx_t_2 = (__pyx_v_value == NULL); if (__pyx_t_2) { /* "cpython/contextvars.pxd":125 * if value is NULL: * # context variable does not have a default * pyvalue = default_value # <<<<<<<<<<<<<< * else: * # value or default value of context variable */ __Pyx_INCREF(__pyx_v_default_value); __pyx_v_pyvalue = __pyx_v_default_value; /* "cpython/contextvars.pxd":123 * cdef PyObject *value = NULL * PyContextVar_Get(var, NULL, &value) * if value is NULL: # <<<<<<<<<<<<<< * # context variable does not have a default * pyvalue = default_value */ goto __pyx_L3; } /* "cpython/contextvars.pxd":128 * else: * # value or default value of context variable * pyvalue = value # <<<<<<<<<<<<<< * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' * return pyvalue */ /*else*/ { __pyx_t_3 = ((PyObject *)__pyx_v_value); __Pyx_INCREF(__pyx_t_3); __pyx_v_pyvalue = __pyx_t_3; __pyx_t_3 = 0; /* "cpython/contextvars.pxd":129 * # value or default value of context variable * pyvalue = value * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' # <<<<<<<<<<<<<< * return pyvalue * */ Py_XDECREF(__pyx_v_value); } __pyx_L3:; /* "cpython/contextvars.pxd":130 * pyvalue = value * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' * return pyvalue # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_pyvalue); __pyx_r = __pyx_v_pyvalue; goto __pyx_L0; /* "cpython/contextvars.pxd":115 * * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") # <<<<<<<<<<<<<< * cdef inline object get_value(var, default_value=None): * """Return a new reference to the value of the context variable, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("cpython.contextvars.get_value", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_pyvalue); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /*!(#if !CYTHON_COMPILING_IN_LIMITED_API)*/ /* "cpython/contextvars.pxd":133 * * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") # <<<<<<<<<<<<<< * cdef inline object get_value_no_default(var, default_value=None): * """Return a new reference to the value of the context variable, */ #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE PyObject *__pyx_f_7cpython_11contextvars_get_value_no_default(PyObject *__pyx_v_var, struct __pyx_opt_args_7cpython_11contextvars_get_value_no_default *__pyx_optional_args) { /* "cpython/contextvars.pxd":134 * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline object get_value_no_default(var, default_value=None): # <<<<<<<<<<<<<< * """Return a new reference to the value of the context variable, * or the provided default value if no such value was found. */ PyObject *__pyx_v_default_value = ((PyObject *)Py_None); PyObject *__pyx_v_value; PyObject *__pyx_v_pyvalue = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_value_no_default", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_default_value = __pyx_optional_args->default_value; } } /* "cpython/contextvars.pxd":140 * Ignores the default value of the context variable, if any. * """ * cdef PyObject *value = NULL # <<<<<<<<<<<<<< * PyContextVar_Get(var, default_value, &value) * # value of context variable or 'default_value' */ __pyx_v_value = NULL; /* "cpython/contextvars.pxd":141 * """ * cdef PyObject *value = NULL * PyContextVar_Get(var, default_value, &value) # <<<<<<<<<<<<<< * # value of context variable or 'default_value' * pyvalue = value */ __pyx_t_1 = PyContextVar_Get(__pyx_v_var, ((PyObject *)__pyx_v_default_value), (&__pyx_v_value)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(1, 141, __pyx_L1_error) /* "cpython/contextvars.pxd":143 * PyContextVar_Get(var, default_value, &value) * # value of context variable or 'default_value' * pyvalue = value # <<<<<<<<<<<<<< * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' * return pyvalue */ __pyx_t_2 = ((PyObject *)__pyx_v_value); __Pyx_INCREF(__pyx_t_2); __pyx_v_pyvalue = __pyx_t_2; __pyx_t_2 = 0; /* "cpython/contextvars.pxd":144 * # value of context variable or 'default_value' * pyvalue = value * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' # <<<<<<<<<<<<<< * return pyvalue */ Py_XDECREF(__pyx_v_value); /* "cpython/contextvars.pxd":145 * pyvalue = value * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' * return pyvalue # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_pyvalue); __pyx_r = __pyx_v_pyvalue; goto __pyx_L0; /* "cpython/contextvars.pxd":133 * * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") # <<<<<<<<<<<<<< * cdef inline object get_value_no_default(var, default_value=None): * """Return a new reference to the value of the context variable, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("cpython.contextvars.get_value_no_default", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_pyvalue); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /*!(#if !CYTHON_COMPILING_IN_LIMITED_API)*/ /* "clickhouse_driver/columns/largeint.pyx":10 * * * def int128_from_quads(self, quad_items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 2 * items = PyTuple_New(n_items) */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_7columns_8largeint_1int128_from_quads(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_8largeint_1int128_from_quads = {"int128_from_quads", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_7columns_8largeint_1int128_from_quads, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_7columns_8largeint_1int128_from_quads(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; PyObject *__pyx_v_quad_items = 0; unsigned PY_LONG_LONG __pyx_v_n_items; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("int128_from_quads (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_quad_items,&__pyx_mstate_global->__pyx_n_u_n_items,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 10, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 10, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 10, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 10, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "int128_from_quads", 0) < (0)) __PYX_ERR(0, 10, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 3; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("int128_from_quads", 1, 3, 3, i); __PYX_ERR(0, 10, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 10, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 10, __pyx_L3_error) values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 10, __pyx_L3_error) } __pyx_v_self = values[0]; __pyx_v_quad_items = values[1]; __pyx_v_n_items = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(values[2]); if (unlikely((__pyx_v_n_items == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 10, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("int128_from_quads", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 10, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.columns.largeint.int128_from_quads", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_7columns_8largeint_int128_from_quads(__pyx_self, __pyx_v_self, __pyx_v_quad_items, __pyx_v_n_items); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_7columns_8largeint_int128_from_quads(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_quad_items, unsigned PY_LONG_LONG __pyx_v_n_items) { unsigned int __pyx_v_factor; PyObject *__pyx_v_items = NULL; unsigned PY_LONG_LONG __pyx_v_i; unsigned PY_LONG_LONG __pyx_v_ix; PyObject *__pyx_v_item = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; unsigned PY_LONG_LONG __pyx_t_2; unsigned PY_LONG_LONG __pyx_t_3; unsigned PY_LONG_LONG __pyx_t_4; unsigned PY_LONG_LONG __pyx_t_5; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; PyObject *__pyx_t_8 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("int128_from_quads", 0); /* "clickhouse_driver/columns/largeint.pyx":11 * * def int128_from_quads(self, quad_items, unsigned long long n_items): * cdef unsigned int factor = 2 # <<<<<<<<<<<<<< * items = PyTuple_New(n_items) * */ __pyx_v_factor = 2; /* "clickhouse_driver/columns/largeint.pyx":12 * def int128_from_quads(self, quad_items, unsigned long long n_items): * cdef unsigned int factor = 2 * items = PyTuple_New(n_items) # <<<<<<<<<<<<<< * * cdef unsigned long long i, ix */ __pyx_t_1 = PyTuple_New(__pyx_v_n_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_items = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":17 * cdef object item * * for i in range(n_items): # <<<<<<<<<<<<<< * ix = factor * i * */ __pyx_t_2 = __pyx_v_n_items; __pyx_t_3 = __pyx_t_2; for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_i = __pyx_t_4; /* "clickhouse_driver/columns/largeint.pyx":18 * * for i in range(n_items): * ix = factor * i # <<<<<<<<<<<<<< * * if quad_items[ix + 1] > MAX_INT64: */ __pyx_v_ix = (__pyx_v_factor * __pyx_v_i); /* "clickhouse_driver/columns/largeint.pyx":20 * ix = factor * i * * if quad_items[ix + 1] > MAX_INT64: # <<<<<<<<<<<<<< * item = ( * -((MAX_UINT64 - quad_items[ix + 1]) << 64) */ __pyx_t_5 = (__pyx_v_ix + 1); __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_t_5, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_INT64, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_7) { /* "clickhouse_driver/columns/largeint.pyx":22 * if quad_items[ix + 1] > MAX_INT64: * item = ( * -((MAX_UINT64 - quad_items[ix + 1]) << 64) # <<<<<<<<<<<<<< * - (MAX_UINT64 - quad_items[ix]) * - 1 */ __pyx_t_5 = (__pyx_v_ix + 1); __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_t_5, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = PyNumber_Subtract(__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyNumber_Lshift(__pyx_t_1, __pyx_mstate_global->__pyx_int_64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Negative(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* "clickhouse_driver/columns/largeint.pyx":23 * item = ( * -((MAX_UINT64 - quad_items[ix + 1]) << 64) * - (MAX_UINT64 - quad_items[ix]) # <<<<<<<<<<<<<< * - 1 * ) */ __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_v_ix, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = PyNumber_Subtract(__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyNumber_Subtract(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "clickhouse_driver/columns/largeint.pyx":24 * -((MAX_UINT64 - quad_items[ix + 1]) << 64) * - (MAX_UINT64 - quad_items[ix]) * - 1 # <<<<<<<<<<<<<< * ) * */ __pyx_t_8 = __Pyx_PyLong_SubtractObjC(__pyx_t_6, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_8); __pyx_t_8 = 0; /* "clickhouse_driver/columns/largeint.pyx":20 * ix = factor * i * * if quad_items[ix + 1] > MAX_INT64: # <<<<<<<<<<<<<< * item = ( * -((MAX_UINT64 - quad_items[ix + 1]) << 64) */ goto __pyx_L5; } /* "clickhouse_driver/columns/largeint.pyx":28 * * else: * item = (quad_items[ix + 1] << 64) + quad_items[ix] # <<<<<<<<<<<<<< * * Py_INCREF(item) */ /*else*/ { __pyx_t_5 = (__pyx_v_ix + 1); __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_t_5, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = PyNumber_Lshift(__pyx_t_8, __pyx_mstate_global->__pyx_int_64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_v_ix, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_1 = PyNumber_Add(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_1); __pyx_t_1 = 0; } __pyx_L5:; /* "clickhouse_driver/columns/largeint.pyx":30 * item = (quad_items[ix + 1] << 64) + quad_items[ix] * * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(items, i, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":31 * * Py_INCREF(item) * PyTuple_SET_ITEM(items, i, item) # <<<<<<<<<<<<<< * * return items */ PyTuple_SET_ITEM(__pyx_v_items, __pyx_v_i, __pyx_v_item); } /* "clickhouse_driver/columns/largeint.pyx":33 * PyTuple_SET_ITEM(items, i, item) * * return items # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_items); __pyx_r = __pyx_v_items; goto __pyx_L0; /* "clickhouse_driver/columns/largeint.pyx":10 * * * def int128_from_quads(self, quad_items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 2 * items = PyTuple_New(n_items) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("clickhouse_driver.columns.largeint.int128_from_quads", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_items); __Pyx_XDECREF(__pyx_v_item); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/columns/largeint.pyx":36 * * * def int128_to_quads(self, items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 2 * quad_items = PyTuple_New(n_items * factor) */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_7columns_8largeint_3int128_to_quads(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_8largeint_3int128_to_quads = {"int128_to_quads", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_7columns_8largeint_3int128_to_quads, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_7columns_8largeint_3int128_to_quads(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; PyObject *__pyx_v_items = 0; unsigned PY_LONG_LONG __pyx_v_n_items; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("int128_to_quads (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_items,&__pyx_mstate_global->__pyx_n_u_n_items,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 36, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 36, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 36, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 36, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "int128_to_quads", 0) < (0)) __PYX_ERR(0, 36, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 3; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("int128_to_quads", 1, 3, 3, i); __PYX_ERR(0, 36, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 36, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 36, __pyx_L3_error) values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 36, __pyx_L3_error) } __pyx_v_self = values[0]; __pyx_v_items = values[1]; __pyx_v_n_items = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(values[2]); if (unlikely((__pyx_v_n_items == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 36, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("int128_to_quads", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 36, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.columns.largeint.int128_to_quads", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_7columns_8largeint_2int128_to_quads(__pyx_self, __pyx_v_self, __pyx_v_items, __pyx_v_n_items); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_7columns_8largeint_2int128_to_quads(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_items, unsigned PY_LONG_LONG __pyx_v_n_items) { unsigned int __pyx_v_factor; PyObject *__pyx_v_quad_items = NULL; unsigned PY_LONG_LONG __pyx_v_i; unsigned PY_LONG_LONG __pyx_v_ix; PyObject *__pyx_v_x = 0; PyObject *__pyx_v_item = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; unsigned PY_LONG_LONG __pyx_t_2; unsigned PY_LONG_LONG __pyx_t_3; unsigned PY_LONG_LONG __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("int128_to_quads", 0); /* "clickhouse_driver/columns/largeint.pyx":37 * * def int128_to_quads(self, items, unsigned long long n_items): * cdef unsigned int factor = 2 # <<<<<<<<<<<<<< * quad_items = PyTuple_New(n_items * factor) * */ __pyx_v_factor = 2; /* "clickhouse_driver/columns/largeint.pyx":38 * def int128_to_quads(self, items, unsigned long long n_items): * cdef unsigned int factor = 2 * quad_items = PyTuple_New(n_items * factor) # <<<<<<<<<<<<<< * * cdef unsigned long long i, ix */ __pyx_t_1 = PyTuple_New((__pyx_v_n_items * __pyx_v_factor)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_quad_items = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":43 * cdef object x, item * * for i in range(n_items): # <<<<<<<<<<<<<< * ix = factor * i * */ __pyx_t_2 = __pyx_v_n_items; __pyx_t_3 = __pyx_t_2; for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_i = __pyx_t_4; /* "clickhouse_driver/columns/largeint.pyx":44 * * for i in range(n_items): * ix = factor * i # <<<<<<<<<<<<<< * * x = items[i] */ __pyx_v_ix = (__pyx_v_factor * __pyx_v_i); /* "clickhouse_driver/columns/largeint.pyx":46 * ix = factor * i * * x = items[i] # <<<<<<<<<<<<<< * if x < 0: * x = -x - 1 */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_items, __pyx_v_i, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":47 * * x = items[i] * if x < 0: # <<<<<<<<<<<<<< * x = -x - 1 * */ __pyx_t_1 = PyObject_RichCompare(__pyx_v_x, __pyx_mstate_global->__pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* "clickhouse_driver/columns/largeint.pyx":48 * x = items[i] * if x < 0: * x = -x - 1 # <<<<<<<<<<<<<< * * item = MAX_UINT64 - x & MAX_UINT64 */ __pyx_t_1 = PyNumber_Negative(__pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyLong_SubtractObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_x, __pyx_t_6); __pyx_t_6 = 0; /* "clickhouse_driver/columns/largeint.pyx":50 * x = -x - 1 * * item = MAX_UINT64 - x & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix, item) */ __pyx_t_6 = PyNumber_Subtract(__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64, __pyx_v_x); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = PyNumber_And(__pyx_t_6, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":51 * * item = MAX_UINT64 - x & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":52 * item = MAX_UINT64 - x & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix, item) # <<<<<<<<<<<<<< * * item = MAX_UINT64 - (x >> 64) & MAX_UINT64 */ PyTuple_SET_ITEM(__pyx_v_quad_items, __pyx_v_ix, __pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":54 * PyTuple_SET_ITEM(quad_items, ix, item) * * item = MAX_UINT64 - (x >> 64) & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 1, item) */ __pyx_t_1 = PyNumber_Rshift(__pyx_v_x, __pyx_mstate_global->__pyx_int_64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyNumber_Subtract(__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_And(__pyx_t_6, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":55 * * item = MAX_UINT64 - (x >> 64) & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix + 1, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":56 * item = MAX_UINT64 - (x >> 64) & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 1, item) # <<<<<<<<<<<<<< * * else: */ PyTuple_SET_ITEM(__pyx_v_quad_items, (__pyx_v_ix + 1), __pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":47 * * x = items[i] * if x < 0: # <<<<<<<<<<<<<< * x = -x - 1 * */ goto __pyx_L5; } /* "clickhouse_driver/columns/largeint.pyx":59 * * else: * item = x & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix, item) */ /*else*/ { __pyx_t_1 = PyNumber_And(__pyx_v_x, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":60 * else: * item = x & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":61 * item = x & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix, item) # <<<<<<<<<<<<<< * * item = (x >> 64) & MAX_UINT64 */ PyTuple_SET_ITEM(__pyx_v_quad_items, __pyx_v_ix, __pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":63 * PyTuple_SET_ITEM(quad_items, ix, item) * * item = (x >> 64) & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 1, item) */ __pyx_t_1 = PyNumber_Rshift(__pyx_v_x, __pyx_mstate_global->__pyx_int_64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyNumber_And(__pyx_t_1, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_6); __pyx_t_6 = 0; /* "clickhouse_driver/columns/largeint.pyx":64 * * item = (x >> 64) & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix + 1, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":65 * item = (x >> 64) & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 1, item) # <<<<<<<<<<<<<< * * return quad_items */ PyTuple_SET_ITEM(__pyx_v_quad_items, (__pyx_v_ix + 1), __pyx_v_item); } __pyx_L5:; } /* "clickhouse_driver/columns/largeint.pyx":67 * PyTuple_SET_ITEM(quad_items, ix + 1, item) * * return quad_items # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_quad_items); __pyx_r = __pyx_v_quad_items; goto __pyx_L0; /* "clickhouse_driver/columns/largeint.pyx":36 * * * def int128_to_quads(self, items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 2 * quad_items = PyTuple_New(n_items * factor) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("clickhouse_driver.columns.largeint.int128_to_quads", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_quad_items); __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_item); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/columns/largeint.pyx":70 * * * def uint128_from_quads(self, quad_items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 2 * items = PyTuple_New(n_items) */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_7columns_8largeint_5uint128_from_quads(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_8largeint_5uint128_from_quads = {"uint128_from_quads", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_7columns_8largeint_5uint128_from_quads, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_7columns_8largeint_5uint128_from_quads(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; PyObject *__pyx_v_quad_items = 0; unsigned PY_LONG_LONG __pyx_v_n_items; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("uint128_from_quads (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_quad_items,&__pyx_mstate_global->__pyx_n_u_n_items,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 70, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 70, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 70, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 70, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "uint128_from_quads", 0) < (0)) __PYX_ERR(0, 70, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 3; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("uint128_from_quads", 1, 3, 3, i); __PYX_ERR(0, 70, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 70, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 70, __pyx_L3_error) values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 70, __pyx_L3_error) } __pyx_v_self = values[0]; __pyx_v_quad_items = values[1]; __pyx_v_n_items = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(values[2]); if (unlikely((__pyx_v_n_items == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 70, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("uint128_from_quads", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 70, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.columns.largeint.uint128_from_quads", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_7columns_8largeint_4uint128_from_quads(__pyx_self, __pyx_v_self, __pyx_v_quad_items, __pyx_v_n_items); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_7columns_8largeint_4uint128_from_quads(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_quad_items, unsigned PY_LONG_LONG __pyx_v_n_items) { unsigned int __pyx_v_factor; PyObject *__pyx_v_items = NULL; unsigned PY_LONG_LONG __pyx_v_i; unsigned PY_LONG_LONG __pyx_v_ix; PyObject *__pyx_v_item = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; unsigned PY_LONG_LONG __pyx_t_2; unsigned PY_LONG_LONG __pyx_t_3; unsigned PY_LONG_LONG __pyx_t_4; unsigned PY_LONG_LONG __pyx_t_5; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("uint128_from_quads", 0); /* "clickhouse_driver/columns/largeint.pyx":71 * * def uint128_from_quads(self, quad_items, unsigned long long n_items): * cdef unsigned int factor = 2 # <<<<<<<<<<<<<< * items = PyTuple_New(n_items) * */ __pyx_v_factor = 2; /* "clickhouse_driver/columns/largeint.pyx":72 * def uint128_from_quads(self, quad_items, unsigned long long n_items): * cdef unsigned int factor = 2 * items = PyTuple_New(n_items) # <<<<<<<<<<<<<< * * cdef unsigned long long i, ix */ __pyx_t_1 = PyTuple_New(__pyx_v_n_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_items = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":77 * cdef object item * * for i in range(n_items): # <<<<<<<<<<<<<< * ix = factor * i * item = (quad_items[ix + 1] << 64) + quad_items[ix] */ __pyx_t_2 = __pyx_v_n_items; __pyx_t_3 = __pyx_t_2; for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_i = __pyx_t_4; /* "clickhouse_driver/columns/largeint.pyx":78 * * for i in range(n_items): * ix = factor * i # <<<<<<<<<<<<<< * item = (quad_items[ix + 1] << 64) + quad_items[ix] * */ __pyx_v_ix = (__pyx_v_factor * __pyx_v_i); /* "clickhouse_driver/columns/largeint.pyx":79 * for i in range(n_items): * ix = factor * i * item = (quad_items[ix + 1] << 64) + quad_items[ix] # <<<<<<<<<<<<<< * * Py_INCREF(item) */ __pyx_t_5 = (__pyx_v_ix + 1); __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_t_5, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyNumber_Lshift(__pyx_t_1, __pyx_mstate_global->__pyx_int_64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 79, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_v_ix, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = PyNumber_Add(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 79, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7); __pyx_t_7 = 0; /* "clickhouse_driver/columns/largeint.pyx":81 * item = (quad_items[ix + 1] << 64) + quad_items[ix] * * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(items, i, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":82 * * Py_INCREF(item) * PyTuple_SET_ITEM(items, i, item) # <<<<<<<<<<<<<< * * return items */ PyTuple_SET_ITEM(__pyx_v_items, __pyx_v_i, __pyx_v_item); } /* "clickhouse_driver/columns/largeint.pyx":84 * PyTuple_SET_ITEM(items, i, item) * * return items # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_items); __pyx_r = __pyx_v_items; goto __pyx_L0; /* "clickhouse_driver/columns/largeint.pyx":70 * * * def uint128_from_quads(self, quad_items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 2 * items = PyTuple_New(n_items) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("clickhouse_driver.columns.largeint.uint128_from_quads", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_items); __Pyx_XDECREF(__pyx_v_item); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/columns/largeint.pyx":87 * * * def uint128_to_quads(self, items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 2 * quad_items = PyTuple_New(n_items * factor) */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_7columns_8largeint_7uint128_to_quads(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_8largeint_7uint128_to_quads = {"uint128_to_quads", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_7columns_8largeint_7uint128_to_quads, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_7columns_8largeint_7uint128_to_quads(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; PyObject *__pyx_v_items = 0; unsigned PY_LONG_LONG __pyx_v_n_items; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("uint128_to_quads (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_items,&__pyx_mstate_global->__pyx_n_u_n_items,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 87, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 87, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 87, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 87, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "uint128_to_quads", 0) < (0)) __PYX_ERR(0, 87, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 3; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("uint128_to_quads", 1, 3, 3, i); __PYX_ERR(0, 87, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 87, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 87, __pyx_L3_error) values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 87, __pyx_L3_error) } __pyx_v_self = values[0]; __pyx_v_items = values[1]; __pyx_v_n_items = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(values[2]); if (unlikely((__pyx_v_n_items == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 87, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("uint128_to_quads", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 87, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.columns.largeint.uint128_to_quads", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_7columns_8largeint_6uint128_to_quads(__pyx_self, __pyx_v_self, __pyx_v_items, __pyx_v_n_items); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_7columns_8largeint_6uint128_to_quads(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_items, unsigned PY_LONG_LONG __pyx_v_n_items) { unsigned int __pyx_v_factor; PyObject *__pyx_v_quad_items = NULL; unsigned PY_LONG_LONG __pyx_v_i; unsigned PY_LONG_LONG __pyx_v_ix; PyObject *__pyx_v_x = 0; PyObject *__pyx_v_item = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; unsigned PY_LONG_LONG __pyx_t_2; unsigned PY_LONG_LONG __pyx_t_3; unsigned PY_LONG_LONG __pyx_t_4; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("uint128_to_quads", 0); /* "clickhouse_driver/columns/largeint.pyx":88 * * def uint128_to_quads(self, items, unsigned long long n_items): * cdef unsigned int factor = 2 # <<<<<<<<<<<<<< * quad_items = PyTuple_New(n_items * factor) * */ __pyx_v_factor = 2; /* "clickhouse_driver/columns/largeint.pyx":89 * def uint128_to_quads(self, items, unsigned long long n_items): * cdef unsigned int factor = 2 * quad_items = PyTuple_New(n_items * factor) # <<<<<<<<<<<<<< * * cdef unsigned long long i, ix */ __pyx_t_1 = PyTuple_New((__pyx_v_n_items * __pyx_v_factor)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_quad_items = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":94 * cdef object x, item * * for i in range(n_items): # <<<<<<<<<<<<<< * ix = factor * i * */ __pyx_t_2 = __pyx_v_n_items; __pyx_t_3 = __pyx_t_2; for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_i = __pyx_t_4; /* "clickhouse_driver/columns/largeint.pyx":95 * * for i in range(n_items): * ix = factor * i # <<<<<<<<<<<<<< * * x = items[i] */ __pyx_v_ix = (__pyx_v_factor * __pyx_v_i); /* "clickhouse_driver/columns/largeint.pyx":97 * ix = factor * i * * x = items[i] # <<<<<<<<<<<<<< * item = x & MAX_UINT64 * Py_INCREF(item) */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_items, __pyx_v_i, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":98 * * x = items[i] * item = x & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix, item) */ __pyx_t_1 = PyNumber_And(__pyx_v_x, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":99 * x = items[i] * item = x & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":100 * item = x & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix, item) # <<<<<<<<<<<<<< * * item = (x >> 64) & MAX_UINT64 */ PyTuple_SET_ITEM(__pyx_v_quad_items, __pyx_v_ix, __pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":102 * PyTuple_SET_ITEM(quad_items, ix, item) * * item = (x >> 64) & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 1, item) */ __pyx_t_1 = PyNumber_Rshift(__pyx_v_x, __pyx_mstate_global->__pyx_int_64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = PyNumber_And(__pyx_t_1, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_5); __pyx_t_5 = 0; /* "clickhouse_driver/columns/largeint.pyx":103 * * item = (x >> 64) & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix + 1, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":104 * item = (x >> 64) & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 1, item) # <<<<<<<<<<<<<< * * return quad_items */ PyTuple_SET_ITEM(__pyx_v_quad_items, (__pyx_v_ix + 1), __pyx_v_item); } /* "clickhouse_driver/columns/largeint.pyx":106 * PyTuple_SET_ITEM(quad_items, ix + 1, item) * * return quad_items # <<<<<<<<<<<<<< * * # 256 bits */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_quad_items); __pyx_r = __pyx_v_quad_items; goto __pyx_L0; /* "clickhouse_driver/columns/largeint.pyx":87 * * * def uint128_to_quads(self, items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 2 * quad_items = PyTuple_New(n_items * factor) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("clickhouse_driver.columns.largeint.uint128_to_quads", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_quad_items); __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_item); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/columns/largeint.pyx":111 * * * def int256_from_quads(self, quad_items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 4 * items = PyTuple_New(n_items) */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_7columns_8largeint_9int256_from_quads(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_8largeint_9int256_from_quads = {"int256_from_quads", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_7columns_8largeint_9int256_from_quads, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_7columns_8largeint_9int256_from_quads(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; PyObject *__pyx_v_quad_items = 0; unsigned PY_LONG_LONG __pyx_v_n_items; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("int256_from_quads (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_quad_items,&__pyx_mstate_global->__pyx_n_u_n_items,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 111, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 111, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 111, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 111, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "int256_from_quads", 0) < (0)) __PYX_ERR(0, 111, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 3; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("int256_from_quads", 1, 3, 3, i); __PYX_ERR(0, 111, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 111, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 111, __pyx_L3_error) values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 111, __pyx_L3_error) } __pyx_v_self = values[0]; __pyx_v_quad_items = values[1]; __pyx_v_n_items = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(values[2]); if (unlikely((__pyx_v_n_items == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 111, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("int256_from_quads", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 111, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.columns.largeint.int256_from_quads", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_7columns_8largeint_8int256_from_quads(__pyx_self, __pyx_v_self, __pyx_v_quad_items, __pyx_v_n_items); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_7columns_8largeint_8int256_from_quads(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_quad_items, unsigned PY_LONG_LONG __pyx_v_n_items) { unsigned int __pyx_v_factor; PyObject *__pyx_v_items = NULL; unsigned PY_LONG_LONG __pyx_v_i; unsigned PY_LONG_LONG __pyx_v_ix; PyObject *__pyx_v_item = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; unsigned PY_LONG_LONG __pyx_t_2; unsigned PY_LONG_LONG __pyx_t_3; unsigned PY_LONG_LONG __pyx_t_4; unsigned PY_LONG_LONG __pyx_t_5; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; PyObject *__pyx_t_8 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("int256_from_quads", 0); /* "clickhouse_driver/columns/largeint.pyx":112 * * def int256_from_quads(self, quad_items, unsigned long long n_items): * cdef unsigned int factor = 4 # <<<<<<<<<<<<<< * items = PyTuple_New(n_items) * */ __pyx_v_factor = 4; /* "clickhouse_driver/columns/largeint.pyx":113 * def int256_from_quads(self, quad_items, unsigned long long n_items): * cdef unsigned int factor = 4 * items = PyTuple_New(n_items) # <<<<<<<<<<<<<< * * cdef unsigned long long i, ix */ __pyx_t_1 = PyTuple_New(__pyx_v_n_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_items = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":118 * cdef object item * * for i in range(n_items): # <<<<<<<<<<<<<< * ix = factor * i * */ __pyx_t_2 = __pyx_v_n_items; __pyx_t_3 = __pyx_t_2; for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_i = __pyx_t_4; /* "clickhouse_driver/columns/largeint.pyx":119 * * for i in range(n_items): * ix = factor * i # <<<<<<<<<<<<<< * * if quad_items[ix + 3] > MAX_INT64: */ __pyx_v_ix = (__pyx_v_factor * __pyx_v_i); /* "clickhouse_driver/columns/largeint.pyx":121 * ix = factor * i * * if quad_items[ix + 3] > MAX_INT64: # <<<<<<<<<<<<<< * item = ( * -((MAX_UINT64 - quad_items[ix + 3]) << 192) */ __pyx_t_5 = (__pyx_v_ix + 3); __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_t_5, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_INT64, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_7) { /* "clickhouse_driver/columns/largeint.pyx":123 * if quad_items[ix + 3] > MAX_INT64: * item = ( * -((MAX_UINT64 - quad_items[ix + 3]) << 192) # <<<<<<<<<<<<<< * -((MAX_UINT64 - quad_items[ix + 2]) << 128) * -((MAX_UINT64 - quad_items[ix + 1]) << 64) */ __pyx_t_5 = (__pyx_v_ix + 3); __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_t_5, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = PyNumber_Subtract(__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyNumber_Lshift(__pyx_t_1, __pyx_mstate_global->__pyx_int_192); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Negative(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* "clickhouse_driver/columns/largeint.pyx":124 * item = ( * -((MAX_UINT64 - quad_items[ix + 3]) << 192) * -((MAX_UINT64 - quad_items[ix + 2]) << 128) # <<<<<<<<<<<<<< * -((MAX_UINT64 - quad_items[ix + 1]) << 64) * - (MAX_UINT64 - quad_items[ix]) */ __pyx_t_5 = (__pyx_v_ix + 2); __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_t_5, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = PyNumber_Subtract(__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyNumber_Lshift(__pyx_t_8, __pyx_mstate_global->__pyx_int_128); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = PyNumber_Subtract(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* "clickhouse_driver/columns/largeint.pyx":125 * -((MAX_UINT64 - quad_items[ix + 3]) << 192) * -((MAX_UINT64 - quad_items[ix + 2]) << 128) * -((MAX_UINT64 - quad_items[ix + 1]) << 64) # <<<<<<<<<<<<<< * - (MAX_UINT64 - quad_items[ix]) * - 1 */ __pyx_t_5 = (__pyx_v_ix + 1); __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_t_5, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = PyNumber_Subtract(__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyNumber_Lshift(__pyx_t_1, __pyx_mstate_global->__pyx_int_64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Subtract(__pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* "clickhouse_driver/columns/largeint.pyx":126 * -((MAX_UINT64 - quad_items[ix + 2]) << 128) * -((MAX_UINT64 - quad_items[ix + 1]) << 64) * - (MAX_UINT64 - quad_items[ix]) # <<<<<<<<<<<<<< * - 1 * ) */ __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_v_ix, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = PyNumber_Subtract(__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyNumber_Subtract(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "clickhouse_driver/columns/largeint.pyx":127 * -((MAX_UINT64 - quad_items[ix + 1]) << 64) * - (MAX_UINT64 - quad_items[ix]) * - 1 # <<<<<<<<<<<<<< * ) * */ __pyx_t_8 = __Pyx_PyLong_SubtractObjC(__pyx_t_6, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_8); __pyx_t_8 = 0; /* "clickhouse_driver/columns/largeint.pyx":121 * ix = factor * i * * if quad_items[ix + 3] > MAX_INT64: # <<<<<<<<<<<<<< * item = ( * -((MAX_UINT64 - quad_items[ix + 3]) << 192) */ goto __pyx_L5; } /* "clickhouse_driver/columns/largeint.pyx":134 * (quad_items[ix + 3] << 192) + * (quad_items[ix + 2] << 128) + * (quad_items[ix + 1] << 64) + # <<<<<<<<<<<<<< * quad_items[ix] * ) */ /*else*/ { /* "clickhouse_driver/columns/largeint.pyx":132 * else: * item = ( * (quad_items[ix + 3] << 192) + # <<<<<<<<<<<<<< * (quad_items[ix + 2] << 128) + * (quad_items[ix + 1] << 64) + */ __pyx_t_5 = (__pyx_v_ix + 3); __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_t_5, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 132, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = PyNumber_Lshift(__pyx_t_8, __pyx_mstate_global->__pyx_int_192); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 132, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "clickhouse_driver/columns/largeint.pyx":133 * item = ( * (quad_items[ix + 3] << 192) + * (quad_items[ix + 2] << 128) + # <<<<<<<<<<<<<< * (quad_items[ix + 1] << 64) + * quad_items[ix] */ __pyx_t_5 = (__pyx_v_ix + 2); __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_t_5, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_1 = PyNumber_Lshift(__pyx_t_8, __pyx_mstate_global->__pyx_int_128); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "clickhouse_driver/columns/largeint.pyx":132 * else: * item = ( * (quad_items[ix + 3] << 192) + # <<<<<<<<<<<<<< * (quad_items[ix + 2] << 128) + * (quad_items[ix + 1] << 64) + */ __pyx_t_8 = PyNumber_Add(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 132, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":134 * (quad_items[ix + 3] << 192) + * (quad_items[ix + 2] << 128) + * (quad_items[ix + 1] << 64) + # <<<<<<<<<<<<<< * quad_items[ix] * ) */ __pyx_t_5 = (__pyx_v_ix + 1); __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_t_5, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyNumber_Lshift(__pyx_t_1, __pyx_mstate_global->__pyx_int_64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":133 * item = ( * (quad_items[ix + 3] << 192) + * (quad_items[ix + 2] << 128) + # <<<<<<<<<<<<<< * (quad_items[ix + 1] << 64) + * quad_items[ix] */ __pyx_t_1 = PyNumber_Add(__pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* "clickhouse_driver/columns/largeint.pyx":135 * (quad_items[ix + 2] << 128) + * (quad_items[ix + 1] << 64) + * quad_items[ix] # <<<<<<<<<<<<<< * ) * */ __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_v_ix, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); /* "clickhouse_driver/columns/largeint.pyx":134 * (quad_items[ix + 3] << 192) + * (quad_items[ix + 2] << 128) + * (quad_items[ix + 1] << 64) + # <<<<<<<<<<<<<< * quad_items[ix] * ) */ __pyx_t_8 = PyNumber_Add(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_8); __pyx_t_8 = 0; } __pyx_L5:; /* "clickhouse_driver/columns/largeint.pyx":138 * ) * * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(items, i, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":139 * * Py_INCREF(item) * PyTuple_SET_ITEM(items, i, item) # <<<<<<<<<<<<<< * * return items */ PyTuple_SET_ITEM(__pyx_v_items, __pyx_v_i, __pyx_v_item); } /* "clickhouse_driver/columns/largeint.pyx":141 * PyTuple_SET_ITEM(items, i, item) * * return items # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_items); __pyx_r = __pyx_v_items; goto __pyx_L0; /* "clickhouse_driver/columns/largeint.pyx":111 * * * def int256_from_quads(self, quad_items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 4 * items = PyTuple_New(n_items) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("clickhouse_driver.columns.largeint.int256_from_quads", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_items); __Pyx_XDECREF(__pyx_v_item); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/columns/largeint.pyx":144 * * * def int256_to_quads(self, items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 4 * quad_items = PyTuple_New(n_items * factor) */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_7columns_8largeint_11int256_to_quads(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_8largeint_11int256_to_quads = {"int256_to_quads", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_7columns_8largeint_11int256_to_quads, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_7columns_8largeint_11int256_to_quads(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; PyObject *__pyx_v_items = 0; unsigned PY_LONG_LONG __pyx_v_n_items; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("int256_to_quads (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_items,&__pyx_mstate_global->__pyx_n_u_n_items,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 144, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 144, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 144, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 144, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "int256_to_quads", 0) < (0)) __PYX_ERR(0, 144, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 3; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("int256_to_quads", 1, 3, 3, i); __PYX_ERR(0, 144, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 144, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 144, __pyx_L3_error) values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 144, __pyx_L3_error) } __pyx_v_self = values[0]; __pyx_v_items = values[1]; __pyx_v_n_items = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(values[2]); if (unlikely((__pyx_v_n_items == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 144, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("int256_to_quads", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 144, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.columns.largeint.int256_to_quads", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_7columns_8largeint_10int256_to_quads(__pyx_self, __pyx_v_self, __pyx_v_items, __pyx_v_n_items); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_7columns_8largeint_10int256_to_quads(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_items, unsigned PY_LONG_LONG __pyx_v_n_items) { unsigned int __pyx_v_factor; PyObject *__pyx_v_quad_items = NULL; unsigned PY_LONG_LONG __pyx_v_i; unsigned PY_LONG_LONG __pyx_v_ix; PyObject *__pyx_v_x = 0; PyObject *__pyx_v_item = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; unsigned PY_LONG_LONG __pyx_t_2; unsigned PY_LONG_LONG __pyx_t_3; unsigned PY_LONG_LONG __pyx_t_4; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("int256_to_quads", 0); /* "clickhouse_driver/columns/largeint.pyx":145 * * def int256_to_quads(self, items, unsigned long long n_items): * cdef unsigned int factor = 4 # <<<<<<<<<<<<<< * quad_items = PyTuple_New(n_items * factor) * */ __pyx_v_factor = 4; /* "clickhouse_driver/columns/largeint.pyx":146 * def int256_to_quads(self, items, unsigned long long n_items): * cdef unsigned int factor = 4 * quad_items = PyTuple_New(n_items * factor) # <<<<<<<<<<<<<< * * cdef unsigned long long i, ix */ __pyx_t_1 = PyTuple_New((__pyx_v_n_items * __pyx_v_factor)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_quad_items = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":151 * cdef object x, item * * for i in range(n_items): # <<<<<<<<<<<<<< * ix = factor * i * */ __pyx_t_2 = __pyx_v_n_items; __pyx_t_3 = __pyx_t_2; for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_i = __pyx_t_4; /* "clickhouse_driver/columns/largeint.pyx":152 * * for i in range(n_items): * ix = factor * i # <<<<<<<<<<<<<< * * x = items[i] */ __pyx_v_ix = (__pyx_v_factor * __pyx_v_i); /* "clickhouse_driver/columns/largeint.pyx":154 * ix = factor * i * * x = items[i] # <<<<<<<<<<<<<< * if x < 0: * x = -x - 1 */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_items, __pyx_v_i, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":155 * * x = items[i] * if x < 0: # <<<<<<<<<<<<<< * x = -x - 1 * */ __pyx_t_1 = PyObject_RichCompare(__pyx_v_x, __pyx_mstate_global->__pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* "clickhouse_driver/columns/largeint.pyx":156 * x = items[i] * if x < 0: * x = -x - 1 # <<<<<<<<<<<<<< * * item = MAX_UINT64 - x & MAX_UINT64 */ __pyx_t_1 = PyNumber_Negative(__pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyLong_SubtractObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_x, __pyx_t_6); __pyx_t_6 = 0; /* "clickhouse_driver/columns/largeint.pyx":158 * x = -x - 1 * * item = MAX_UINT64 - x & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix, item) */ __pyx_t_6 = PyNumber_Subtract(__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64, __pyx_v_x); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = PyNumber_And(__pyx_t_6, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":159 * * item = MAX_UINT64 - x & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":160 * item = MAX_UINT64 - x & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix, item) # <<<<<<<<<<<<<< * * item = MAX_UINT64 - (x >> 64) & MAX_UINT64 */ PyTuple_SET_ITEM(__pyx_v_quad_items, __pyx_v_ix, __pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":162 * PyTuple_SET_ITEM(quad_items, ix, item) * * item = MAX_UINT64 - (x >> 64) & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 1, item) */ __pyx_t_1 = PyNumber_Rshift(__pyx_v_x, __pyx_mstate_global->__pyx_int_64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyNumber_Subtract(__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_And(__pyx_t_6, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":163 * * item = MAX_UINT64 - (x >> 64) & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix + 1, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":164 * item = MAX_UINT64 - (x >> 64) & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 1, item) # <<<<<<<<<<<<<< * * item = MAX_UINT64 - (x >> 128) & MAX_UINT64 */ PyTuple_SET_ITEM(__pyx_v_quad_items, (__pyx_v_ix + 1), __pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":166 * PyTuple_SET_ITEM(quad_items, ix + 1, item) * * item = MAX_UINT64 - (x >> 128) & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 2, item) */ __pyx_t_1 = PyNumber_Rshift(__pyx_v_x, __pyx_mstate_global->__pyx_int_128); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyNumber_Subtract(__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 166, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_And(__pyx_t_6, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":167 * * item = MAX_UINT64 - (x >> 128) & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix + 2, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":168 * item = MAX_UINT64 - (x >> 128) & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 2, item) # <<<<<<<<<<<<<< * * item = MAX_UINT64 - (x >> 192) & MAX_UINT64 */ PyTuple_SET_ITEM(__pyx_v_quad_items, (__pyx_v_ix + 2), __pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":170 * PyTuple_SET_ITEM(quad_items, ix + 2, item) * * item = MAX_UINT64 - (x >> 192) & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 3, item) */ __pyx_t_1 = PyNumber_Rshift(__pyx_v_x, __pyx_mstate_global->__pyx_int_192); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyNumber_Subtract(__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_And(__pyx_t_6, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":171 * * item = MAX_UINT64 - (x >> 192) & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix + 3, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":172 * item = MAX_UINT64 - (x >> 192) & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 3, item) # <<<<<<<<<<<<<< * * else: */ PyTuple_SET_ITEM(__pyx_v_quad_items, (__pyx_v_ix + 3), __pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":155 * * x = items[i] * if x < 0: # <<<<<<<<<<<<<< * x = -x - 1 * */ goto __pyx_L5; } /* "clickhouse_driver/columns/largeint.pyx":175 * * else: * item = x & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix, item) */ /*else*/ { __pyx_t_1 = PyNumber_And(__pyx_v_x, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 175, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":176 * else: * item = x & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":177 * item = x & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix, item) # <<<<<<<<<<<<<< * * item = (x >> 64) & MAX_UINT64 */ PyTuple_SET_ITEM(__pyx_v_quad_items, __pyx_v_ix, __pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":179 * PyTuple_SET_ITEM(quad_items, ix, item) * * item = (x >> 64) & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 1, item) */ __pyx_t_1 = PyNumber_Rshift(__pyx_v_x, __pyx_mstate_global->__pyx_int_64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyNumber_And(__pyx_t_1, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_6); __pyx_t_6 = 0; /* "clickhouse_driver/columns/largeint.pyx":180 * * item = (x >> 64) & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix + 1, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":181 * item = (x >> 64) & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 1, item) # <<<<<<<<<<<<<< * * item = (x >> 128) & MAX_UINT64 */ PyTuple_SET_ITEM(__pyx_v_quad_items, (__pyx_v_ix + 1), __pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":183 * PyTuple_SET_ITEM(quad_items, ix + 1, item) * * item = (x >> 128) & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 2, item) */ __pyx_t_6 = PyNumber_Rshift(__pyx_v_x, __pyx_mstate_global->__pyx_int_128); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = PyNumber_And(__pyx_t_6, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":184 * * item = (x >> 128) & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix + 2, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":185 * item = (x >> 128) & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 2, item) # <<<<<<<<<<<<<< * * item = (x >> 192) & MAX_UINT64 */ PyTuple_SET_ITEM(__pyx_v_quad_items, (__pyx_v_ix + 2), __pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":187 * PyTuple_SET_ITEM(quad_items, ix + 2, item) * * item = (x >> 192) & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 3, item) */ __pyx_t_1 = PyNumber_Rshift(__pyx_v_x, __pyx_mstate_global->__pyx_int_192); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyNumber_And(__pyx_t_1, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_6); __pyx_t_6 = 0; /* "clickhouse_driver/columns/largeint.pyx":188 * * item = (x >> 192) & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix + 3, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":189 * item = (x >> 192) & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 3, item) # <<<<<<<<<<<<<< * * return quad_items */ PyTuple_SET_ITEM(__pyx_v_quad_items, (__pyx_v_ix + 3), __pyx_v_item); } __pyx_L5:; } /* "clickhouse_driver/columns/largeint.pyx":191 * PyTuple_SET_ITEM(quad_items, ix + 3, item) * * return quad_items # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_quad_items); __pyx_r = __pyx_v_quad_items; goto __pyx_L0; /* "clickhouse_driver/columns/largeint.pyx":144 * * * def int256_to_quads(self, items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 4 * quad_items = PyTuple_New(n_items * factor) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("clickhouse_driver.columns.largeint.int256_to_quads", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_quad_items); __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_item); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/columns/largeint.pyx":194 * * * def uint256_from_quads(self, quad_items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 4 * items = PyTuple_New(n_items) */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_7columns_8largeint_13uint256_from_quads(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_8largeint_13uint256_from_quads = {"uint256_from_quads", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_7columns_8largeint_13uint256_from_quads, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_7columns_8largeint_13uint256_from_quads(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; PyObject *__pyx_v_quad_items = 0; unsigned PY_LONG_LONG __pyx_v_n_items; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("uint256_from_quads (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_quad_items,&__pyx_mstate_global->__pyx_n_u_n_items,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 194, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 194, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 194, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 194, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "uint256_from_quads", 0) < (0)) __PYX_ERR(0, 194, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 3; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("uint256_from_quads", 1, 3, 3, i); __PYX_ERR(0, 194, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 194, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 194, __pyx_L3_error) values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 194, __pyx_L3_error) } __pyx_v_self = values[0]; __pyx_v_quad_items = values[1]; __pyx_v_n_items = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(values[2]); if (unlikely((__pyx_v_n_items == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 194, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("uint256_from_quads", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 194, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.columns.largeint.uint256_from_quads", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_7columns_8largeint_12uint256_from_quads(__pyx_self, __pyx_v_self, __pyx_v_quad_items, __pyx_v_n_items); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_7columns_8largeint_12uint256_from_quads(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_quad_items, unsigned PY_LONG_LONG __pyx_v_n_items) { unsigned int __pyx_v_factor; PyObject *__pyx_v_items = NULL; unsigned PY_LONG_LONG __pyx_v_i; unsigned PY_LONG_LONG __pyx_v_ix; PyObject *__pyx_v_item = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; unsigned PY_LONG_LONG __pyx_t_2; unsigned PY_LONG_LONG __pyx_t_3; unsigned PY_LONG_LONG __pyx_t_4; unsigned PY_LONG_LONG __pyx_t_5; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("uint256_from_quads", 0); /* "clickhouse_driver/columns/largeint.pyx":195 * * def uint256_from_quads(self, quad_items, unsigned long long n_items): * cdef unsigned int factor = 4 # <<<<<<<<<<<<<< * items = PyTuple_New(n_items) * */ __pyx_v_factor = 4; /* "clickhouse_driver/columns/largeint.pyx":196 * def uint256_from_quads(self, quad_items, unsigned long long n_items): * cdef unsigned int factor = 4 * items = PyTuple_New(n_items) # <<<<<<<<<<<<<< * * cdef unsigned long long i, ix */ __pyx_t_1 = PyTuple_New(__pyx_v_n_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_items = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":201 * cdef object item * * for i in range(n_items): # <<<<<<<<<<<<<< * ix = factor * i * item = ( */ __pyx_t_2 = __pyx_v_n_items; __pyx_t_3 = __pyx_t_2; for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_i = __pyx_t_4; /* "clickhouse_driver/columns/largeint.pyx":202 * * for i in range(n_items): * ix = factor * i # <<<<<<<<<<<<<< * item = ( * (quad_items[ix + 3] << 192) + */ __pyx_v_ix = (__pyx_v_factor * __pyx_v_i); /* "clickhouse_driver/columns/largeint.pyx":204 * ix = factor * i * item = ( * (quad_items[ix + 3] << 192) + # <<<<<<<<<<<<<< * (quad_items[ix + 2] << 128) + * (quad_items[ix + 1] << 64) + */ __pyx_t_5 = (__pyx_v_ix + 3); __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_t_5, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyNumber_Lshift(__pyx_t_1, __pyx_mstate_global->__pyx_int_192); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":205 * item = ( * (quad_items[ix + 3] << 192) + * (quad_items[ix + 2] << 128) + # <<<<<<<<<<<<<< * (quad_items[ix + 1] << 64) + * quad_items[ix] */ __pyx_t_5 = (__pyx_v_ix + 2); __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_t_5, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = PyNumber_Lshift(__pyx_t_1, __pyx_mstate_global->__pyx_int_128); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":204 * ix = factor * i * item = ( * (quad_items[ix + 3] << 192) + # <<<<<<<<<<<<<< * (quad_items[ix + 2] << 128) + * (quad_items[ix + 1] << 64) + */ __pyx_t_1 = PyNumber_Add(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "clickhouse_driver/columns/largeint.pyx":206 * (quad_items[ix + 3] << 192) + * (quad_items[ix + 2] << 128) + * (quad_items[ix + 1] << 64) + # <<<<<<<<<<<<<< * quad_items[ix] * ) */ __pyx_t_5 = (__pyx_v_ix + 1); __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_t_5, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = PyNumber_Lshift(__pyx_t_7, __pyx_mstate_global->__pyx_int_64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "clickhouse_driver/columns/largeint.pyx":205 * item = ( * (quad_items[ix + 3] << 192) + * (quad_items[ix + 2] << 128) + # <<<<<<<<<<<<<< * (quad_items[ix + 1] << 64) + * quad_items[ix] */ __pyx_t_7 = PyNumber_Add(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* "clickhouse_driver/columns/largeint.pyx":207 * (quad_items[ix + 2] << 128) + * (quad_items[ix + 1] << 64) + * quad_items[ix] # <<<<<<<<<<<<<< * ) * */ __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_quad_items, __pyx_v_ix, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); /* "clickhouse_driver/columns/largeint.pyx":206 * (quad_items[ix + 3] << 192) + * (quad_items[ix + 2] << 128) + * (quad_items[ix + 1] << 64) + # <<<<<<<<<<<<<< * quad_items[ix] * ) */ __pyx_t_1 = PyNumber_Add(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":210 * ) * * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(items, i, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":211 * * Py_INCREF(item) * PyTuple_SET_ITEM(items, i, item) # <<<<<<<<<<<<<< * * return items */ PyTuple_SET_ITEM(__pyx_v_items, __pyx_v_i, __pyx_v_item); } /* "clickhouse_driver/columns/largeint.pyx":213 * PyTuple_SET_ITEM(items, i, item) * * return items # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_items); __pyx_r = __pyx_v_items; goto __pyx_L0; /* "clickhouse_driver/columns/largeint.pyx":194 * * * def uint256_from_quads(self, quad_items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 4 * items = PyTuple_New(n_items) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("clickhouse_driver.columns.largeint.uint256_from_quads", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_items); __Pyx_XDECREF(__pyx_v_item); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/columns/largeint.pyx":216 * * * def uint256_to_quads(self, items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 4 * quad_items = PyTuple_New(n_items * factor) */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_7columns_8largeint_15uint256_to_quads(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_8largeint_15uint256_to_quads = {"uint256_to_quads", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_7columns_8largeint_15uint256_to_quads, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_17clickhouse_driver_7columns_8largeint_15uint256_to_quads(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; PyObject *__pyx_v_items = 0; unsigned PY_LONG_LONG __pyx_v_n_items; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("uint256_to_quads (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_items,&__pyx_mstate_global->__pyx_n_u_n_items,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 216, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 3: values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 216, __pyx_L3_error) CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 216, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 216, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "uint256_to_quads", 0) < (0)) __PYX_ERR(0, 216, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 3; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("uint256_to_quads", 1, 3, 3, i); __PYX_ERR(0, 216, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 216, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 216, __pyx_L3_error) values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 216, __pyx_L3_error) } __pyx_v_self = values[0]; __pyx_v_items = values[1]; __pyx_v_n_items = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(values[2]); if (unlikely((__pyx_v_n_items == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 216, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("uint256_to_quads", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 216, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.columns.largeint.uint256_to_quads", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_7columns_8largeint_14uint256_to_quads(__pyx_self, __pyx_v_self, __pyx_v_items, __pyx_v_n_items); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_7columns_8largeint_14uint256_to_quads(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_items, unsigned PY_LONG_LONG __pyx_v_n_items) { unsigned int __pyx_v_factor; PyObject *__pyx_v_quad_items = NULL; unsigned PY_LONG_LONG __pyx_v_i; unsigned PY_LONG_LONG __pyx_v_ix; PyObject *__pyx_v_x = 0; PyObject *__pyx_v_item = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; unsigned PY_LONG_LONG __pyx_t_2; unsigned PY_LONG_LONG __pyx_t_3; unsigned PY_LONG_LONG __pyx_t_4; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("uint256_to_quads", 0); /* "clickhouse_driver/columns/largeint.pyx":217 * * def uint256_to_quads(self, items, unsigned long long n_items): * cdef unsigned int factor = 4 # <<<<<<<<<<<<<< * quad_items = PyTuple_New(n_items * factor) * */ __pyx_v_factor = 4; /* "clickhouse_driver/columns/largeint.pyx":218 * def uint256_to_quads(self, items, unsigned long long n_items): * cdef unsigned int factor = 4 * quad_items = PyTuple_New(n_items * factor) # <<<<<<<<<<<<<< * * cdef unsigned long long i, ix */ __pyx_t_1 = PyTuple_New((__pyx_v_n_items * __pyx_v_factor)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_quad_items = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":223 * cdef object x, item * * for i in range(n_items): # <<<<<<<<<<<<<< * ix = factor * i * */ __pyx_t_2 = __pyx_v_n_items; __pyx_t_3 = __pyx_t_2; for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_i = __pyx_t_4; /* "clickhouse_driver/columns/largeint.pyx":224 * * for i in range(n_items): * ix = factor * i # <<<<<<<<<<<<<< * * x = items[i] */ __pyx_v_ix = (__pyx_v_factor * __pyx_v_i); /* "clickhouse_driver/columns/largeint.pyx":226 * ix = factor * i * * x = items[i] # <<<<<<<<<<<<<< * item = x & MAX_UINT64 * Py_INCREF(item) */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_items, __pyx_v_i, unsigned PY_LONG_LONG, 0, __Pyx_PyLong_From_unsigned_PY_LONG_LONG, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":227 * * x = items[i] * item = x & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix, item) */ __pyx_t_1 = PyNumber_And(__pyx_v_x, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 227, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":228 * x = items[i] * item = x & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":229 * item = x & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix, item) # <<<<<<<<<<<<<< * * item = (x >> 64) & MAX_UINT64 */ PyTuple_SET_ITEM(__pyx_v_quad_items, __pyx_v_ix, __pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":231 * PyTuple_SET_ITEM(quad_items, ix, item) * * item = (x >> 64) & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 1, item) */ __pyx_t_1 = PyNumber_Rshift(__pyx_v_x, __pyx_mstate_global->__pyx_int_64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 231, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = PyNumber_And(__pyx_t_1, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 231, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_5); __pyx_t_5 = 0; /* "clickhouse_driver/columns/largeint.pyx":232 * * item = (x >> 64) & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix + 1, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":233 * item = (x >> 64) & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 1, item) # <<<<<<<<<<<<<< * * item = (x >> 128) & MAX_UINT64 */ PyTuple_SET_ITEM(__pyx_v_quad_items, (__pyx_v_ix + 1), __pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":235 * PyTuple_SET_ITEM(quad_items, ix + 1, item) * * item = (x >> 128) & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 2, item) */ __pyx_t_5 = PyNumber_Rshift(__pyx_v_x, __pyx_mstate_global->__pyx_int_128); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 235, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = PyNumber_And(__pyx_t_5, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 235, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_1); __pyx_t_1 = 0; /* "clickhouse_driver/columns/largeint.pyx":236 * * item = (x >> 128) & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix + 2, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":237 * item = (x >> 128) & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 2, item) # <<<<<<<<<<<<<< * * item = (x >> 192) & MAX_UINT64 */ PyTuple_SET_ITEM(__pyx_v_quad_items, (__pyx_v_ix + 2), __pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":239 * PyTuple_SET_ITEM(quad_items, ix + 2, item) * * item = (x >> 192) & MAX_UINT64 # <<<<<<<<<<<<<< * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 3, item) */ __pyx_t_1 = PyNumber_Rshift(__pyx_v_x, __pyx_mstate_global->__pyx_int_192); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = PyNumber_And(__pyx_t_1, __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_5); __pyx_t_5 = 0; /* "clickhouse_driver/columns/largeint.pyx":240 * * item = (x >> 192) & MAX_UINT64 * Py_INCREF(item) # <<<<<<<<<<<<<< * PyTuple_SET_ITEM(quad_items, ix + 3, item) * */ Py_INCREF(__pyx_v_item); /* "clickhouse_driver/columns/largeint.pyx":241 * item = (x >> 192) & MAX_UINT64 * Py_INCREF(item) * PyTuple_SET_ITEM(quad_items, ix + 3, item) # <<<<<<<<<<<<<< * * return quad_items */ PyTuple_SET_ITEM(__pyx_v_quad_items, (__pyx_v_ix + 3), __pyx_v_item); } /* "clickhouse_driver/columns/largeint.pyx":243 * PyTuple_SET_ITEM(quad_items, ix + 3, item) * * return quad_items # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_quad_items); __pyx_r = __pyx_v_quad_items; goto __pyx_L0; /* "clickhouse_driver/columns/largeint.pyx":216 * * * def uint256_to_quads(self, items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 4 * quad_items = PyTuple_New(n_items * factor) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("clickhouse_driver.columns.largeint.uint256_to_quads", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_quad_items); __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_item); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* #### Code section: module_exttypes ### */ static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; /* #### Code section: initfunc_declarations ### */ static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate); /*proto*/ /* #### Code section: init_module ### */ static int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); /*--- Global init code ---*/ __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64 = Py_None; Py_INCREF(Py_None); __pyx_v_17clickhouse_driver_7columns_8largeint_MAX_INT64 = Py_None; Py_INCREF(Py_None); __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); /*--- Variable export code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); /*--- Function export code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); /*--- Type init code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); /*--- Type import code ---*/ __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_mstate->__pyx_ptype_7cpython_4type_type = __Pyx_ImportType_3_2_0(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 sizeof(PyTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyTypeObject), #elif CYTHON_COMPILING_IN_LIMITED_API 0, 0, #else sizeof(PyHeapTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyHeapTypeObject), #endif __Pyx_ImportType_CheckSize_Warn_3_2_0); if (!__pyx_mstate->__pyx_ptype_7cpython_4type_type) __PYX_ERR(2, 9, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_mstate->__pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType_3_2_0(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "bool", #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 sizeof(PyLongObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyLongObject), #elif CYTHON_COMPILING_IN_LIMITED_API 0, 0, #else sizeof(PyLongObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyLongObject), #endif __Pyx_ImportType_CheckSize_Warn_3_2_0); if (!__pyx_mstate->__pyx_ptype_7cpython_4bool_bool) __PYX_ERR(3, 8, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_mstate->__pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType_3_2_0(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "complex", #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 sizeof(PyComplexObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyComplexObject), #elif CYTHON_COMPILING_IN_LIMITED_API 0, 0, #else sizeof(PyComplexObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyComplexObject), #endif __Pyx_ImportType_CheckSize_Warn_3_2_0); if (!__pyx_mstate->__pyx_ptype_7cpython_7complex_complex) __PYX_ERR(4, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); /*--- Variable import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); /*--- Function import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } #if CYTHON_PEP489_MULTI_PHASE_INIT static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ static int __pyx_pymod_exec_largeint(PyObject* module); /*proto*/ static PyModuleDef_Slot __pyx_moduledef_slots[] = { {Py_mod_create, (void*)__pyx_pymod_create}, {Py_mod_exec, (void*)__pyx_pymod_exec_largeint}, #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING {Py_mod_gil, Py_MOD_GIL_USED}, #endif #if PY_VERSION_HEX >= 0x030C0000 && CYTHON_USE_MODULE_STATE {Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED}, #endif {0, NULL} }; #endif #ifdef __cplusplus namespace { struct PyModuleDef __pyx_moduledef = #else static struct PyModuleDef __pyx_moduledef = #endif { PyModuleDef_HEAD_INIT, "largeint", 0, /* m_doc */ #if CYTHON_USE_MODULE_STATE sizeof(__pyx_mstatetype), /* m_size */ #else (CYTHON_PEP489_MULTI_PHASE_INIT) ? 0 : -1, /* m_size */ #endif __pyx_methods /* m_methods */, #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_moduledef_slots, /* m_slots */ #else NULL, /* m_reload */ #endif #if CYTHON_USE_MODULE_STATE __pyx_m_traverse, /* m_traverse */ __pyx_m_clear, /* m_clear */ NULL /* m_free */ #else NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ #endif }; #ifdef __cplusplus } /* anonymous namespace */ #endif /* PyModInitFuncType */ #ifndef CYTHON_NO_PYINIT_EXPORT #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC #else #ifdef __cplusplus #define __Pyx_PyMODINIT_FUNC extern "C" PyObject * #else #define __Pyx_PyMODINIT_FUNC PyObject * #endif #endif __Pyx_PyMODINIT_FUNC PyInit_largeint(void) CYTHON_SMALL_CODE; /*proto*/ __Pyx_PyMODINIT_FUNC PyInit_largeint(void) #if CYTHON_PEP489_MULTI_PHASE_INIT { return PyModuleDef_Init(&__pyx_moduledef); } /* ModuleCreationPEP489 */ #if CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\ || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000)) static PY_INT64_T __Pyx_GetCurrentInterpreterId(void) { { PyObject *module = PyImport_ImportModule("_interpreters"); // 3.13+ I think if (!module) { PyErr_Clear(); // just try the 3.8-3.12 version module = PyImport_ImportModule("_xxsubinterpreters"); if (!module) goto bad; } PyObject *current = PyObject_CallMethod(module, "get_current", NULL); Py_DECREF(module); if (!current) goto bad; if (PyTuple_Check(current)) { PyObject *new_current = PySequence_GetItem(current, 0); Py_DECREF(current); current = new_current; if (!new_current) goto bad; } long long as_c_int = PyLong_AsLongLong(current); Py_DECREF(current); return as_c_int; } bad: PySys_WriteStderr("__Pyx_GetCurrentInterpreterId failed. Try setting the C define CYTHON_PEP489_MULTI_PHASE_INIT=0\n"); return -1; } #endif #if !CYTHON_USE_MODULE_STATE static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { static PY_INT64_T main_interpreter_id = -1; #if CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000 PY_INT64_T current_id = GraalPyInterpreterState_GetIDFromThreadState(PyThreadState_Get()); #elif CYTHON_COMPILING_IN_GRAAL PY_INT64_T current_id = PyInterpreterState_GetIDFromThreadState(PyThreadState_Get()); #elif CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\ || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000)) PY_INT64_T current_id = __Pyx_GetCurrentInterpreterId(); #elif CYTHON_COMPILING_IN_LIMITED_API PY_INT64_T current_id = PyInterpreterState_GetID(PyInterpreterState_Get()); #else PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); #endif if (unlikely(current_id == -1)) { return -1; } if (main_interpreter_id == -1) { main_interpreter_id = current_id; return 0; } else if (unlikely(main_interpreter_id != current_id)) { PyErr_SetString( PyExc_ImportError, "Interpreter change detected - this module can only be loaded into one interpreter per process."); return -1; } return 0; } #endif static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { PyObject *value = PyObject_GetAttrString(spec, from_name); int result = 0; if (likely(value)) { if (allow_none || value != Py_None) { result = PyDict_SetItemString(moddict, to_name, value); } Py_DECREF(value); } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Clear(); } else { result = -1; } return result; } static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def) { PyObject *module = NULL, *moddict, *modname; CYTHON_UNUSED_VAR(def); #if !CYTHON_USE_MODULE_STATE if (__Pyx_check_single_interpreter()) return NULL; #endif if (__pyx_m) return __Pyx_NewRef(__pyx_m); modname = PyObject_GetAttrString(spec, "name"); if (unlikely(!modname)) goto bad; module = PyModule_NewObject(modname); Py_DECREF(modname); if (unlikely(!module)) goto bad; moddict = PyModule_GetDict(module); if (unlikely(!moddict)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; return module; bad: Py_XDECREF(module); return NULL; } static CYTHON_SMALL_CODE int __pyx_pymod_exec_largeint(PyObject *__pyx_pyinit_module) #endif { int stringtab_initialized = 0; #if CYTHON_USE_MODULE_STATE int pystate_addmodule_run = 0; #endif __pyx_mstatetype *__pyx_mstate = NULL; PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; Py_ssize_t __pyx_t_3; PyObject *__pyx_t_4 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #if CYTHON_PEP489_MULTI_PHASE_INIT if (__pyx_m) { if (__pyx_m == __pyx_pyinit_module) return 0; PyErr_SetString(PyExc_RuntimeError, "Module 'largeint' has already been imported. Re-initialisation is not supported."); return -1; } #else if (__pyx_m) return __Pyx_NewRef(__pyx_m); #endif /*--- Module creation code ---*/ #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_t_1 = __pyx_pyinit_module; Py_INCREF(__pyx_t_1); #else __pyx_t_1 = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) #endif #if CYTHON_USE_MODULE_STATE { int add_module_result = __Pyx_State_AddModule(__pyx_t_1, &__pyx_moduledef); __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to "largeint" pseudovariable */ if (unlikely((add_module_result < 0))) __PYX_ERR(0, 1, __pyx_L1_error) pystate_addmodule_run = 1; } #else __pyx_m = __pyx_t_1; #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING PyUnstable_Module_SetGIL(__pyx_m, Py_MOD_GIL_USED); #endif __pyx_mstate = __pyx_mstate_global; CYTHON_UNUSED_VAR(__pyx_t_1); __pyx_mstate->__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_mstate->__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_mstate->__pyx_d); __pyx_mstate->__pyx_b = __Pyx_PyImport_AddModuleRef(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_mstate->__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_mstate->__pyx_cython_runtime = __Pyx_PyImport_AddModuleRef("cython_runtime"); if (unlikely(!__pyx_mstate->__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_mstate->__pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error) /* ImportRefnannyAPI */ #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("PyInit_largeint", 0); __Pyx_init_runtime_version(); if (__Pyx_check_binary_version(__PYX_LIMITED_VERSION_HEX, __Pyx_get_runtime_version(), CYTHON_COMPILING_IN_LIMITED_API) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_mstate->__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_mstate->__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_mstate->__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_mstate->__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Library function declarations ---*/ /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) stringtab_initialized = 1; if (__Pyx_InitGlobals() < (0)) __PYX_ERR(0, 1, __pyx_L1_error) if (__pyx_module_is_main_clickhouse_driver__columns__largeint) { if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_name, __pyx_mstate_global->__pyx_n_u_main) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) } { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) if (!PyDict_GetItemString(modules, "clickhouse_driver.columns.largeint")) { if (unlikely((PyDict_SetItemString(modules, "clickhouse_driver.columns.largeint", __pyx_m) < 0))) __PYX_ERR(0, 1, __pyx_L1_error) } } /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_CreateCodeObjects(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Global type/function init code ---*/ (void)__Pyx_modinit_global_init_code(__pyx_mstate); (void)__Pyx_modinit_variable_export_code(__pyx_mstate); (void)__Pyx_modinit_function_export_code(__pyx_mstate); (void)__Pyx_modinit_type_init_code(__pyx_mstate); if (unlikely((__Pyx_modinit_type_import_code(__pyx_mstate) < 0))) __PYX_ERR(0, 1, __pyx_L1_error) (void)__Pyx_modinit_variable_import_code(__pyx_mstate); (void)__Pyx_modinit_function_import_code(__pyx_mstate); /*--- Execution code ---*/ /* "clickhouse_driver/columns/largeint.pyx":4 * from cpython.tuple cimport PyTuple_New, PyTuple_SET_ITEM * * from .. import writer # <<<<<<<<<<<<<< * * cdef object MAX_UINT64 = writer.MAX_UINT64 */ { PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_writer}; __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_, __pyx_imported_names, 1, __pyx_mstate_global->__pyx_kp_u_clickhouse_driver, 2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error) } __pyx_t_2 = __pyx_t_1; __Pyx_GOTREF(__pyx_t_2); { PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_writer}; __pyx_t_3 = 0; { __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/columns/largeint.pyx":6 * from .. import writer * * cdef object MAX_UINT64 = writer.MAX_UINT64 # <<<<<<<<<<<<<< * cdef object MAX_INT64 = writer.MAX_INT64 * */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_writer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_MAX_UINT64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XGOTREF(__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64); __Pyx_DECREF_SET(__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_UINT64, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; /* "clickhouse_driver/columns/largeint.pyx":7 * * cdef object MAX_UINT64 = writer.MAX_UINT64 * cdef object MAX_INT64 = writer.MAX_INT64 # <<<<<<<<<<<<<< * * */ __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_writer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_MAX_INT64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XGOTREF(__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_INT64); __Pyx_DECREF_SET(__pyx_v_17clickhouse_driver_7columns_8largeint_MAX_INT64, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/columns/largeint.pyx":10 * * * def int128_from_quads(self, quad_items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 2 * items = PyTuple_New(n_items) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_7columns_8largeint_1int128_from_quads, 0, __pyx_mstate_global->__pyx_n_u_int128_from_quads, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_columns_largei, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_int128_from_quads, __pyx_t_2) < (0)) __PYX_ERR(0, 10, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/columns/largeint.pyx":36 * * * def int128_to_quads(self, items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 2 * quad_items = PyTuple_New(n_items * factor) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_7columns_8largeint_3int128_to_quads, 0, __pyx_mstate_global->__pyx_n_u_int128_to_quads, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_columns_largei, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_int128_to_quads, __pyx_t_2) < (0)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/columns/largeint.pyx":70 * * * def uint128_from_quads(self, quad_items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 2 * items = PyTuple_New(n_items) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_7columns_8largeint_5uint128_from_quads, 0, __pyx_mstate_global->__pyx_n_u_uint128_from_quads, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_columns_largei, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[2])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_uint128_from_quads, __pyx_t_2) < (0)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/columns/largeint.pyx":87 * * * def uint128_to_quads(self, items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 2 * quad_items = PyTuple_New(n_items * factor) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_7columns_8largeint_7uint128_to_quads, 0, __pyx_mstate_global->__pyx_n_u_uint128_to_quads, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_columns_largei, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[3])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_uint128_to_quads, __pyx_t_2) < (0)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/columns/largeint.pyx":111 * * * def int256_from_quads(self, quad_items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 4 * items = PyTuple_New(n_items) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_7columns_8largeint_9int256_from_quads, 0, __pyx_mstate_global->__pyx_n_u_int256_from_quads, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_columns_largei, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[4])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_int256_from_quads, __pyx_t_2) < (0)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/columns/largeint.pyx":144 * * * def int256_to_quads(self, items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 4 * quad_items = PyTuple_New(n_items * factor) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_7columns_8largeint_11int256_to_quads, 0, __pyx_mstate_global->__pyx_n_u_int256_to_quads, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_columns_largei, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[5])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_int256_to_quads, __pyx_t_2) < (0)) __PYX_ERR(0, 144, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/columns/largeint.pyx":194 * * * def uint256_from_quads(self, quad_items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 4 * items = PyTuple_New(n_items) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_7columns_8largeint_13uint256_from_quads, 0, __pyx_mstate_global->__pyx_n_u_uint256_from_quads, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_columns_largei, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[6])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_uint256_from_quads, __pyx_t_2) < (0)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/columns/largeint.pyx":216 * * * def uint256_to_quads(self, items, unsigned long long n_items): # <<<<<<<<<<<<<< * cdef unsigned int factor = 4 * quad_items = PyTuple_New(n_items * factor) */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_7columns_8largeint_15uint256_to_quads, 0, __pyx_mstate_global->__pyx_n_u_uint256_to_quads, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_columns_largei, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[7])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_uint256_to_quads, __pyx_t_2) < (0)) __PYX_ERR(0, 216, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/columns/largeint.pyx":1 * from cpython cimport Py_INCREF # <<<<<<<<<<<<<< * from cpython.tuple cimport PyTuple_New, PyTuple_SET_ITEM * */ __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_test, __pyx_t_2) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); if (__pyx_m) { if (__pyx_mstate->__pyx_d && stringtab_initialized) { __Pyx_AddTraceback("init clickhouse_driver.columns.largeint", __pyx_clineno, __pyx_lineno, __pyx_filename); } #if !CYTHON_USE_MODULE_STATE Py_CLEAR(__pyx_m); #else Py_DECREF(__pyx_m); if (pystate_addmodule_run) { PyObject *tp, *value, *tb; PyErr_Fetch(&tp, &value, &tb); PyState_RemoveModule(&__pyx_moduledef); PyErr_Restore(tp, value, tb); } #endif } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init clickhouse_driver.columns.largeint"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if CYTHON_PEP489_MULTI_PHASE_INIT return (__pyx_m != NULL) ? 0 : -1; #else return __pyx_m; #endif } /* #### Code section: pystring_table ### */ /* #### Code section: cached_builtins ### */ static int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate) { CYTHON_UNUSED_VAR(__pyx_mstate); /* Cached unbound methods */ __pyx_mstate->__pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type; __pyx_mstate->__pyx_umethod_PyDict_Type_items.method_name = &__pyx_mstate->__pyx_n_u_items; __pyx_mstate->__pyx_umethod_PyDict_Type_pop.type = (PyObject*)&PyDict_Type; __pyx_mstate->__pyx_umethod_PyDict_Type_pop.method_name = &__pyx_mstate->__pyx_n_u_pop; __pyx_mstate->__pyx_umethod_PyDict_Type_values.type = (PyObject*)&PyDict_Type; __pyx_mstate->__pyx_umethod_PyDict_Type_values.method_name = &__pyx_mstate->__pyx_n_u_values; return 0; } /* #### Code section: cached_constants ### */ static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); __Pyx_RefNannyFinishContext(); return 0; } /* #### Code section: init_constants ### */ static int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate) { CYTHON_UNUSED_VAR(__pyx_mstate); { const struct { const unsigned int length: 9; } index[] = {{1},{1},{18},{38},{0},{9},{10},{20},{18},{34},{18},{6},{8},{1},{17},{15},{17},{15},{13},{4},{5},{2},{8},{10},{7},{8},{3},{10},{12},{4},{12},{10},{8},{18},{16},{18},{16},{6},{6},{1},{210},{358},{118},{188},{86},{147},{227},{124}}; #if (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (814 bytes) */ const char* const cstring = "BZh91AY&SY\n\254Q\002\000\000\363\377\373\377\177\377\334\274\001\277X\276;~\304\277\357\377\340@@@@@@@@\000@@\000@\000P\003>\000\345v\240\003\206\206\214\2324h\323C#!\204\001\220\003 \323@\000\014\201\220\006\2222\246z\214)\350\000\2322\014\000\001\032\0320\010\310\3011\000\315 i\250Si5?Rd\364\217I\243\324\320\320\014\232h\003& \000\000\r\250\031\000\341\241\243&\215\0324\320\310\310a\000d\000\3104\320\000\003 d\000\251BCA(\336\204\331&\247\250\364A\345\0314\032i\243\324\365\032\006&\2152\017I\214#5Lc\022\372)\337\344r\243\220s\034\353\027\026X\264\250\351\035!\320f\035\003R]0%\021B\224P.l\rl\003.4\307\2600\027\230\321HJ\2261\226\226\033M\025Z\026V+(0\030\322^\366\224M\247Yq\3245\214\213\222\205f!\225c\002\305\254K)YS\"0\356K\314$\300\231E\205W\246\253\005\231%\322\305#\267\312\365ss\332\272,RLr\361E\027\314fK\260\231\014LE\323\022\223\024T\357+\365\024~\357\260\261z\362w|\014\210dcQ\200\224\026\2264\232\2577\274\227\337q\253\213\302\3050\244\302\224P\330\304\26331IC\306\262\254X\005\224\037\243\010]\346\2775\255G\033\330\336\217]\214\223!\200-I\313\0310\005\262\t\030\2159W\211\004\225 ~X-\\\317g~ \022\317\353S\354J\0241)(\004\020\255\002c\240o\3117\323\302,\310\217n\032\236k\202e2\213_\212Th\367\246}\231\255=\275\317V\347:\354\031\215\022\226\246\233\235\214\314\336\315,\350#\013F%\326O+\300\r\240\347\022I\\-Q\023\334\003\322\200\243E\367\330\003\226b\004\351BA\305\225\td\030\314\031\022\316L\003\021\006@Q\330d\006\316\250l\216\022\303.\025 \335\223tp(\253F\364V\246\274\307\255\262\325\356\316\301\201\207+,\335l6o\303\2658\311RA\324\000\3139a$\004\230\020\242\271A\227 \262\340\30082\177\201\004\252\222]s\206\232\213\330r\312u\225\326\333\365\340\333\257\323\033\024p\217\001;\303\270\357\216!\362__pyx_string_tab; Py_ssize_t pos = 0; for (int i = 0; i < 40; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyUnicode_DecodeUTF8(bytes + pos, bytes_length, NULL); if (likely(string) && i >= 4) PyUnicode_InternInPlace(&string); if (unlikely(!string)) { Py_XDECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } stringtab[i] = string; pos += bytes_length; } for (int i = 40; i < 48; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyBytes_FromStringAndSize(bytes + pos, bytes_length); stringtab[i] = string; pos += bytes_length; if (unlikely(!string)) { Py_XDECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } } Py_XDECREF(data); for (Py_ssize_t i = 0; i < 48; i++) { if (unlikely(PyObject_Hash(stringtab[i]) == -1)) { __PYX_ERR(0, 1, __pyx_L1_error) } } #if CYTHON_IMMORTAL_CONSTANTS { PyObject **table = stringtab + 40; for (Py_ssize_t i=0; i<8; ++i) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL); #else Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT); #endif } } #endif } { PyObject **numbertab = __pyx_mstate->__pyx_number_tab + 0; int8_t const cint_constants_1[] = {0,1,64}; int16_t const cint_constants_2[] = {128,192}; for (int i = 0; i < 5; i++) { numbertab[i] = PyLong_FromLong((i < 3 ? cint_constants_1[i - 0] : cint_constants_2[i - 3])); if (unlikely(!numbertab[i])) __PYX_ERR(0, 1, __pyx_L1_error) } } #if CYTHON_IMMORTAL_CONSTANTS { PyObject **table = __pyx_mstate->__pyx_number_tab; for (Py_ssize_t i=0; i<5; ++i) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL); #else Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT); #endif } } #endif return 0; __pyx_L1_error:; return -1; } /* #### Code section: init_codeobjects ### */ typedef struct { unsigned int argcount : 2; unsigned int num_posonly_args : 1; unsigned int num_kwonly_args : 1; unsigned int nlocals : 4; unsigned int flags : 10; unsigned int first_line : 8; } __Pyx_PyCode_New_function_description; /* NewCodeObj.proto */ static PyObject* __Pyx_PyCode_New( const __Pyx_PyCode_New_function_description descr, PyObject * const *varnames, PyObject *filename, PyObject *funcname, PyObject *line_table, PyObject *tuple_dedup_map ); static int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate) { PyObject* tuple_dedup_map = PyDict_New(); if (unlikely(!tuple_dedup_map)) return -1; { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 8, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 10}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_quad_items, __pyx_mstate->__pyx_n_u_n_items, __pyx_mstate->__pyx_n_u_factor, __pyx_mstate->__pyx_n_u_items, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_ix, __pyx_mstate->__pyx_n_u_item}; __pyx_mstate_global->__pyx_codeobj_tab[0] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_columns_largei_2, __pyx_mstate->__pyx_n_u_int128_from_quads, __pyx_mstate->__pyx_kp_b_iso88591_q_Kq_U_1_WBa_Qc_3b_b_3b_Cq_b_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[0])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 9, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 36}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_items, __pyx_mstate->__pyx_n_u_n_items, __pyx_mstate->__pyx_n_u_factor, __pyx_mstate->__pyx_n_u_quad_items, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_ix, __pyx_mstate->__pyx_n_u_x, __pyx_mstate->__pyx_n_u_item}; __pyx_mstate_global->__pyx_codeobj_tab[1] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_columns_largei_2, __pyx_mstate->__pyx_n_u_int128_to_quads, __pyx_mstate->__pyx_kp_b_iso88591_q_AXRq_U_1_WBa_E_2Rq_2Q_b_A_Qa, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[1])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 8, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 70}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_quad_items, __pyx_mstate->__pyx_n_u_n_items, __pyx_mstate->__pyx_n_u_factor, __pyx_mstate->__pyx_n_u_items, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_ix, __pyx_mstate->__pyx_n_u_item}; __pyx_mstate_global->__pyx_codeobj_tab[2] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_columns_largei_2, __pyx_mstate->__pyx_n_u_uint128_from_quads, __pyx_mstate->__pyx_kp_b_iso88591_q_Kq_U_1_WBa_3b_3d_Jaq_1_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[2])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 9, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 87}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_items, __pyx_mstate->__pyx_n_u_n_items, __pyx_mstate->__pyx_n_u_factor, __pyx_mstate->__pyx_n_u_quad_items, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_ix, __pyx_mstate->__pyx_n_u_x, __pyx_mstate->__pyx_n_u_item}; __pyx_mstate_global->__pyx_codeobj_tab[3] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_columns_largei_2, __pyx_mstate->__pyx_n_u_uint128_to_quads, __pyx_mstate->__pyx_kp_b_iso88591_q_AXRq_U_1_WBa_E_r_1_T_T_1_S_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[3])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 8, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 111}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_quad_items, __pyx_mstate->__pyx_n_u_n_items, __pyx_mstate->__pyx_n_u_factor, __pyx_mstate->__pyx_n_u_items, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_ix, __pyx_mstate->__pyx_n_u_item}; __pyx_mstate_global->__pyx_codeobj_tab[4] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_columns_largei_2, __pyx_mstate->__pyx_n_u_int256_from_quads, __pyx_mstate->__pyx_kp_b_iso88591_q_Kq_U_1_WBa_Qc_3b_b_3b_Cq_b_3b, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[4])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 9, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 144}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_items, __pyx_mstate->__pyx_n_u_n_items, __pyx_mstate->__pyx_n_u_factor, __pyx_mstate->__pyx_n_u_quad_items, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_ix, __pyx_mstate->__pyx_n_u_x, __pyx_mstate->__pyx_n_u_item}; __pyx_mstate_global->__pyx_codeobj_tab[5] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_columns_largei_2, __pyx_mstate->__pyx_n_u_int256_to_quads, __pyx_mstate->__pyx_kp_b_iso88591_q_AXRq_U_1_WBa_E_2Rq_2Q_b_A_Qa_2, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[5])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 8, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 194}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_quad_items, __pyx_mstate->__pyx_n_u_n_items, __pyx_mstate->__pyx_n_u_factor, __pyx_mstate->__pyx_n_u_items, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_ix, __pyx_mstate->__pyx_n_u_item}; __pyx_mstate_global->__pyx_codeobj_tab[6] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_columns_largei_2, __pyx_mstate->__pyx_n_u_uint256_from_quads, __pyx_mstate->__pyx_kp_b_iso88591_q_Kq_U_1_WBa_q_2S_5_q_2S_5_q_2S, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[6])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 9, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 216}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_items, __pyx_mstate->__pyx_n_u_n_items, __pyx_mstate->__pyx_n_u_factor, __pyx_mstate->__pyx_n_u_quad_items, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_ix, __pyx_mstate->__pyx_n_u_x, __pyx_mstate->__pyx_n_u_item}; __pyx_mstate_global->__pyx_codeobj_tab[7] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_columns_largei_2, __pyx_mstate->__pyx_n_u_uint256_to_quads, __pyx_mstate->__pyx_kp_b_iso88591_q_AXRq_U_1_WBa_E_r_1_T_T_1_S_Q_2, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[7])) goto bad; } Py_DECREF(tuple_dedup_map); return 0; bad: Py_DECREF(tuple_dedup_map); return -1; } /* #### Code section: init_globals ### */ static int __Pyx_InitGlobals(void) { /* PythonCompatibility.init */ if (likely(__Pyx_init_co_variables() == 0)); else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) /* CommonTypesMetaclass.init */ if (likely(__pyx_CommonTypesMetaclass_init(__pyx_m) == 0)); else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) /* CachedMethodType.init */ #if CYTHON_COMPILING_IN_LIMITED_API { PyObject *typesModule=NULL; typesModule = PyImport_ImportModule("types"); if (typesModule) { __pyx_mstate_global->__Pyx_CachedMethodType = PyObject_GetAttrString(typesModule, "MethodType"); Py_DECREF(typesModule); } } // error handling follows #endif if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) /* CythonFunctionShared.init */ if (likely(__pyx_CyFunction_init(__pyx_m) == 0)); else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } /* #### Code section: cleanup_globals ### */ /* #### Code section: cleanup_module ### */ /* #### Code section: main_method ### */ /* #### Code section: utility_code_pragmas ### */ #ifdef _MSC_VER #pragma warning( push ) /* Warning 4127: conditional expression is constant * Cython uses constant conditional expressions to allow in inline functions to be optimized at * compile-time, so this warning is not useful */ #pragma warning( disable : 4127 ) #endif /* #### Code section: utility_code_def ### */ /* --- Runtime support code --- */ /* Refnanny */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule(modname); if (!m) goto end; p = PyObject_GetAttrString(m, "RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif /* TupleAndListFromArray */ #if !CYTHON_COMPILING_IN_CPYTHON && CYTHON_METH_FASTCALL static CYTHON_INLINE PyObject * __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n) { PyObject *res; Py_ssize_t i; if (n <= 0) { return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple); } res = PyTuple_New(n); if (unlikely(res == NULL)) return NULL; for (i = 0; i < n; i++) { if (unlikely(__Pyx_PyTuple_SET_ITEM(res, i, src[i]) < (0))) { Py_DECREF(res); return NULL; } Py_INCREF(src[i]); } return res; } #elif CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE void __Pyx_copy_object_array(PyObject *const *CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) { PyObject *v; Py_ssize_t i; for (i = 0; i < length; i++) { v = dest[i] = src[i]; Py_INCREF(v); } } static CYTHON_INLINE PyObject * __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n) { PyObject *res; if (n <= 0) { return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple); } res = PyTuple_New(n); if (unlikely(res == NULL)) return NULL; __Pyx_copy_object_array(src, ((PyTupleObject*)res)->ob_item, n); return res; } static CYTHON_INLINE PyObject * __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n) { PyObject *res; if (n <= 0) { return PyList_New(0); } res = PyList_New(n); if (unlikely(res == NULL)) return NULL; __Pyx_copy_object_array(src, ((PyListObject*)res)->ob_item, n); return res; } #endif /* BytesEquals */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL ||\ !(CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS) return PyObject_RichCompareBool(s1, s2, equals); #else if (s1 == s2) { return (equals == Py_EQ); } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { const char *ps1, *ps2; Py_ssize_t length = PyBytes_GET_SIZE(s1); if (length != PyBytes_GET_SIZE(s2)) return (equals == Py_NE); ps1 = PyBytes_AS_STRING(s1); ps2 = PyBytes_AS_STRING(s2); if (ps1[0] != ps2[0]) { return (equals == Py_NE); } else if (length == 1) { return (equals == Py_EQ); } else { int result; #if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000) Py_hash_t hash1, hash2; hash1 = ((PyBytesObject*)s1)->ob_shash; hash2 = ((PyBytesObject*)s2)->ob_shash; if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { return (equals == Py_NE); } #endif result = memcmp(ps1, ps2, (size_t)length); return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { return (equals == Py_NE); } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { return (equals == Py_NE); } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } #endif } /* UnicodeEquals */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL return PyObject_RichCompareBool(s1, s2, equals); #else int s1_is_unicode, s2_is_unicode; if (s1 == s2) { goto return_eq; } s1_is_unicode = PyUnicode_CheckExact(s1); s2_is_unicode = PyUnicode_CheckExact(s2); if (s1_is_unicode & s2_is_unicode) { Py_ssize_t length, length2; int kind; void *data1, *data2; #if !CYTHON_COMPILING_IN_LIMITED_API if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0)) return -1; #endif length = __Pyx_PyUnicode_GET_LENGTH(s1); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(length < 0)) return -1; #endif length2 = __Pyx_PyUnicode_GET_LENGTH(s2); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(length2 < 0)) return -1; #endif if (length != length2) { goto return_ne; } #if CYTHON_USE_UNICODE_INTERNALS { Py_hash_t hash1, hash2; hash1 = ((PyASCIIObject*)s1)->hash; hash2 = ((PyASCIIObject*)s2)->hash; if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { goto return_ne; } } #endif kind = __Pyx_PyUnicode_KIND(s1); if (kind != __Pyx_PyUnicode_KIND(s2)) { goto return_ne; } data1 = __Pyx_PyUnicode_DATA(s1); data2 = __Pyx_PyUnicode_DATA(s2); if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) { goto return_ne; } else if (length == 1) { goto return_eq; } else { int result = memcmp(data1, data2, (size_t)(length * kind)); return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & s2_is_unicode) { goto return_ne; } else if ((s2 == Py_None) & s1_is_unicode) { goto return_ne; } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } return_eq: return (equals == Py_EQ); return_ne: return (equals == Py_NE); #endif } /* fastcall */ #if CYTHON_METH_FASTCALL static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s) { Py_ssize_t i, n = __Pyx_PyTuple_GET_SIZE(kwnames); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(n == -1)) return NULL; #endif for (i = 0; i < n; i++) { PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely(!namei)) return NULL; #endif if (s == namei) return kwvalues[i]; } for (i = 0; i < n; i++) { PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely(!namei)) return NULL; #endif int eq = __Pyx_PyUnicode_Equals(s, namei, Py_EQ); if (unlikely(eq != 0)) { if (unlikely(eq < 0)) return NULL; return kwvalues[i]; } } return NULL; } #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues) { Py_ssize_t i, nkwargs; PyObject *dict; #if !CYTHON_ASSUME_SAFE_SIZE nkwargs = PyTuple_Size(kwnames); if (unlikely(nkwargs < 0)) return NULL; #else nkwargs = PyTuple_GET_SIZE(kwnames); #endif dict = PyDict_New(); if (unlikely(!dict)) return NULL; for (i=0; itp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) return NULL; result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectCallMethO */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { PyObject *self, *result; PyCFunction cfunc; cfunc = __Pyx_CyOrPyCFunction_GET_FUNCTION(func); self = __Pyx_CyOrPyCFunction_GET_SELF(func); if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) return NULL; result = cfunc(self, arg); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectFastCall */ #if PY_VERSION_HEX < 0x03090000 || CYTHON_COMPILING_IN_LIMITED_API static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs) { PyObject *argstuple; PyObject *result = 0; size_t i; argstuple = PyTuple_New((Py_ssize_t)nargs); if (unlikely(!argstuple)) return NULL; for (i = 0; i < nargs; i++) { Py_INCREF(args[i]); if (__Pyx_PyTuple_SET_ITEM(argstuple, (Py_ssize_t)i, args[i]) != (0)) goto bad; } result = __Pyx_PyObject_Call(func, argstuple, kwargs); bad: Py_DECREF(argstuple); return result; } #endif #if CYTHON_VECTORCALL && !CYTHON_COMPILING_IN_LIMITED_API #if PY_VERSION_HEX < 0x03090000 #define __Pyx_PyVectorcall_Function(callable) _PyVectorcall_Function(callable) #elif CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE vectorcallfunc __Pyx_PyVectorcall_Function(PyObject *callable) { PyTypeObject *tp = Py_TYPE(callable); #if defined(__Pyx_CyFunction_USED) if (__Pyx_CyFunction_CheckExact(callable)) { return __Pyx_CyFunction_func_vectorcall(callable); } #endif if (!PyType_HasFeature(tp, Py_TPFLAGS_HAVE_VECTORCALL)) { return NULL; } assert(PyCallable_Check(callable)); Py_ssize_t offset = tp->tp_vectorcall_offset; assert(offset > 0); vectorcallfunc ptr; memcpy(&ptr, (char *) callable + offset, sizeof(ptr)); return ptr; } #else #define __Pyx_PyVectorcall_Function(callable) PyVectorcall_Function(callable) #endif #endif static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject *const *args, size_t _nargs, PyObject *kwargs) { Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs); #if CYTHON_COMPILING_IN_CPYTHON if (nargs == 0 && kwargs == NULL) { if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_NOARGS)) return __Pyx_PyObject_CallMethO(func, NULL); } else if (nargs == 1 && kwargs == NULL) { if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_O)) return __Pyx_PyObject_CallMethO(func, args[0]); } #endif if (kwargs == NULL) { #if CYTHON_VECTORCALL #if CYTHON_COMPILING_IN_LIMITED_API return PyObject_Vectorcall(func, args, _nargs, NULL); #else vectorcallfunc f = __Pyx_PyVectorcall_Function(func); if (f) { return f(func, args, _nargs, NULL); } #endif #endif } if (nargs == 0) { return __Pyx_PyObject_Call(func, __pyx_mstate_global->__pyx_empty_tuple, kwargs); } #if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API return PyObject_VectorcallDict(func, args, (size_t)nargs, kwargs); #else return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs); #endif } /* PyObjectCallOneArg */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *args[2] = {NULL, arg}; return __Pyx_PyObject_FastCall(func, args+1, 1 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } /* PyObjectGetAttrStr */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); return PyObject_GetAttr(obj, attr_name); } #endif /* UnpackUnboundCMethod */ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000 static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *args, PyObject *kwargs) { PyObject *result; PyObject *selfless_args = PyTuple_GetSlice(args, 1, PyTuple_Size(args)); if (unlikely(!selfless_args)) return NULL; result = PyObject_Call(method, selfless_args, kwargs); Py_DECREF(selfless_args); return result; } #elif CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03090000 static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { return _PyObject_Vectorcall (method, args ? args+1 : NULL, nargs ? nargs-1 : 0, kwnames); } #else static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { return #if PY_VERSION_HEX < 0x03090000 _PyObject_Vectorcall #else PyObject_Vectorcall #endif (method, args ? args+1 : NULL, nargs ? (size_t) nargs-1 : 0, kwnames); } #endif static PyMethodDef __Pyx_UnboundCMethod_Def = { "CythonUnboundCMethod", __PYX_REINTERPRET_FUNCION(PyCFunction, __Pyx_SelflessCall), #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000 METH_VARARGS | METH_KEYWORDS, #else METH_FASTCALL | METH_KEYWORDS, #endif NULL }; static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) { PyObject *method, *result=NULL; method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name); if (unlikely(!method)) return -1; result = method; #if CYTHON_COMPILING_IN_CPYTHON if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type))) { PyMethodDescrObject *descr = (PyMethodDescrObject*) method; target->func = descr->d_method->ml_meth; target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS); } else #endif #if CYTHON_COMPILING_IN_PYPY #else if (PyCFunction_Check(method)) #endif { PyObject *self; int self_found; #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY self = PyObject_GetAttrString(method, "__self__"); if (!self) { PyErr_Clear(); } #else self = PyCFunction_GET_SELF(method); #endif self_found = (self && self != Py_None); #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY Py_XDECREF(self); #endif if (self_found) { PyObject *unbound_method = PyCFunction_New(&__Pyx_UnboundCMethod_Def, method); if (unlikely(!unbound_method)) return -1; Py_DECREF(method); result = unbound_method; } } #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING if (unlikely(target->method)) { Py_DECREF(result); } else #endif target->method = result; return 0; } /* CallUnboundCMethod0 */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) { int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc); if (likely(was_initialized == 2 && cfunc->func)) { if (likely(cfunc->flag == METH_NOARGS)) return __Pyx_CallCFunction(cfunc, self, NULL); if (likely(cfunc->flag == METH_FASTCALL)) return __Pyx_CallCFunctionFast(cfunc, self, NULL, 0); if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS)) return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, NULL, 0, NULL); if (likely(cfunc->flag == (METH_VARARGS | METH_KEYWORDS))) return __Pyx_CallCFunctionWithKeywords(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple, NULL); if (cfunc->flag == METH_VARARGS) return __Pyx_CallCFunction(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple); return __Pyx__CallUnboundCMethod0(cfunc, self); } #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING else if (unlikely(was_initialized == 1)) { __Pyx_CachedCFunction tmp_cfunc = { #ifndef __cplusplus 0 #endif }; tmp_cfunc.type = cfunc->type; tmp_cfunc.method_name = cfunc->method_name; return __Pyx__CallUnboundCMethod0(&tmp_cfunc, self); } #endif PyObject *result = __Pyx__CallUnboundCMethod0(cfunc, self); __Pyx_CachedCFunction_SetFinishedInitializing(cfunc); return result; } #endif static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) { PyObject *result; if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; result = __Pyx_PyObject_CallOneArg(cfunc->method, self); return result; } /* py_dict_items */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) { return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_items, d); } /* py_dict_values */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d) { return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_values, d); } /* OwnedDictNext */ #if CYTHON_AVOID_BORROWED_REFS static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue) { PyObject *next = NULL; if (!*ppos) { if (pvalue) { PyObject *dictview = pkey ? __Pyx_PyDict_Items(p) : __Pyx_PyDict_Values(p); if (unlikely(!dictview)) goto bad; *ppos = PyObject_GetIter(dictview); Py_DECREF(dictview); } else { *ppos = PyObject_GetIter(p); } if (unlikely(!*ppos)) goto bad; } next = PyIter_Next(*ppos); if (!next) { if (PyErr_Occurred()) goto bad; return 0; } if (pkey && pvalue) { *pkey = __Pyx_PySequence_ITEM(next, 0); if (unlikely(*pkey)) goto bad; *pvalue = __Pyx_PySequence_ITEM(next, 1); if (unlikely(*pvalue)) goto bad; Py_DECREF(next); } else if (pkey) { *pkey = next; } else { assert(pvalue); *pvalue = next; } return 1; bad: Py_XDECREF(next); #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000 PyErr_FormatUnraisable("Exception ignored in __Pyx_PyDict_NextRef"); #else PyErr_WriteUnraisable(__pyx_mstate_global->__pyx_n_u_Pyx_PyDict_NextRef); #endif if (pkey) *pkey = NULL; if (pvalue) *pvalue = NULL; return 0; } #else // !CYTHON_AVOID_BORROWED_REFS static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue) { int result = PyDict_Next(p, ppos, pkey, pvalue); if (likely(result == 1)) { if (pkey) Py_INCREF(*pkey); if (pvalue) Py_INCREF(*pvalue); } return result; } #endif /* RaiseDoubleKeywords */ static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { PyErr_Format(PyExc_TypeError, "%s() got multiple values for keyword argument '%U'", func_name, kw_name); } /* CallUnboundCMethod2 */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) { int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc); if (likely(was_initialized == 2 && cfunc->func)) { PyObject *args[2] = {arg1, arg2}; if (cfunc->flag == METH_FASTCALL) { return __Pyx_CallCFunctionFast(cfunc, self, args, 2); } if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS)) return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, 2, NULL); } #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING else if (unlikely(was_initialized == 1)) { __Pyx_CachedCFunction tmp_cfunc = { #ifndef __cplusplus 0 #endif }; tmp_cfunc.type = cfunc->type; tmp_cfunc.method_name = cfunc->method_name; return __Pyx__CallUnboundCMethod2(&tmp_cfunc, self, arg1, arg2); } #endif PyObject *result = __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2); __Pyx_CachedCFunction_SetFinishedInitializing(cfunc); return result; } #endif static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){ if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; #if CYTHON_COMPILING_IN_CPYTHON if (cfunc->func && (cfunc->flag & METH_VARARGS)) { PyObject *result = NULL; PyObject *args = PyTuple_New(2); if (unlikely(!args)) return NULL; Py_INCREF(arg1); PyTuple_SET_ITEM(args, 0, arg1); Py_INCREF(arg2); PyTuple_SET_ITEM(args, 1, arg2); if (cfunc->flag & METH_KEYWORDS) result = __Pyx_CallCFunctionWithKeywords(cfunc, self, args, NULL); else result = __Pyx_CallCFunction(cfunc, self, args); Py_DECREF(args); return result; } #endif { PyObject *args[4] = {NULL, self, arg1, arg2}; return __Pyx_PyObject_FastCall(cfunc->method, args+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } } /* ParseKeywordsImpl */ static int __Pyx_ValidateDuplicatePosArgs( PyObject *kwds, PyObject ** const argnames[], PyObject ** const *first_kw_arg, const char* function_name) { PyObject ** const *name = argnames; while (name != first_kw_arg) { PyObject *key = **name; int found = PyDict_Contains(kwds, key); if (unlikely(found)) { if (found == 1) __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; } name++; } return 0; bad: return -1; } #if CYTHON_USE_UNICODE_INTERNALS static CYTHON_INLINE int __Pyx_UnicodeKeywordsEqual(PyObject *s1, PyObject *s2) { int kind; Py_ssize_t len = PyUnicode_GET_LENGTH(s1); if (len != PyUnicode_GET_LENGTH(s2)) return 0; kind = PyUnicode_KIND(s1); if (kind != PyUnicode_KIND(s2)) return 0; const void *data1 = PyUnicode_DATA(s1); const void *data2 = PyUnicode_DATA(s2); return (memcmp(data1, data2, (size_t) len * (size_t) kind) == 0); } #endif static int __Pyx_MatchKeywordArg_str( PyObject *key, PyObject ** const argnames[], PyObject ** const *first_kw_arg, size_t *index_found, const char *function_name) { PyObject ** const *name; #if CYTHON_USE_UNICODE_INTERNALS Py_hash_t key_hash = ((PyASCIIObject*)key)->hash; if (unlikely(key_hash == -1)) { key_hash = PyObject_Hash(key); if (unlikely(key_hash == -1)) goto bad; } #endif name = first_kw_arg; while (*name) { PyObject *name_str = **name; #if CYTHON_USE_UNICODE_INTERNALS if (key_hash == ((PyASCIIObject*)name_str)->hash && __Pyx_UnicodeKeywordsEqual(name_str, key)) { *index_found = (size_t) (name - argnames); return 1; } #else #if CYTHON_ASSUME_SAFE_SIZE if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key)) #endif { int cmp = PyUnicode_Compare(name_str, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { *index_found = (size_t) (name - argnames); return 1; } } #endif name++; } name = argnames; while (name != first_kw_arg) { PyObject *name_str = **name; #if CYTHON_USE_UNICODE_INTERNALS if (unlikely(key_hash == ((PyASCIIObject*)name_str)->hash)) { if (__Pyx_UnicodeKeywordsEqual(name_str, key)) goto arg_passed_twice; } #else #if CYTHON_ASSUME_SAFE_SIZE if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key)) #endif { if (unlikely(name_str == key)) goto arg_passed_twice; int cmp = PyUnicode_Compare(name_str, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) goto arg_passed_twice; } #endif name++; } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; bad: return -1; } static int __Pyx_MatchKeywordArg_nostr( PyObject *key, PyObject ** const argnames[], PyObject ** const *first_kw_arg, size_t *index_found, const char *function_name) { PyObject ** const *name; if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type; name = first_kw_arg; while (*name) { int cmp = PyObject_RichCompareBool(**name, key, Py_EQ); if (cmp == 1) { *index_found = (size_t) (name - argnames); return 1; } if (unlikely(cmp == -1)) goto bad; name++; } name = argnames; while (name != first_kw_arg) { int cmp = PyObject_RichCompareBool(**name, key, Py_EQ); if (unlikely(cmp != 0)) { if (cmp == 1) goto arg_passed_twice; else goto bad; } name++; } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); goto bad; bad: return -1; } static CYTHON_INLINE int __Pyx_MatchKeywordArg( PyObject *key, PyObject ** const argnames[], PyObject ** const *first_kw_arg, size_t *index_found, const char *function_name) { return likely(PyUnicode_CheckExact(key)) ? __Pyx_MatchKeywordArg_str(key, argnames, first_kw_arg, index_found, function_name) : __Pyx_MatchKeywordArg_nostr(key, argnames, first_kw_arg, index_found, function_name); } static void __Pyx_RejectUnknownKeyword( PyObject *kwds, PyObject ** const argnames[], PyObject ** const *first_kw_arg, const char *function_name) { #if CYTHON_AVOID_BORROWED_REFS PyObject *pos = NULL; #else Py_ssize_t pos = 0; #endif PyObject *key = NULL; __Pyx_BEGIN_CRITICAL_SECTION(kwds); while ( #if CYTHON_AVOID_BORROWED_REFS __Pyx_PyDict_NextRef(kwds, &pos, &key, NULL) #else PyDict_Next(kwds, &pos, &key, NULL) #endif ) { PyObject** const *name = first_kw_arg; while (*name && (**name != key)) name++; if (!*name) { size_t index_found = 0; int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name); if (cmp != 1) { if (cmp == 0) { PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%U'", function_name, key); } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(key); #endif break; } } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(key); #endif } __Pyx_END_CRITICAL_SECTION(); #if CYTHON_AVOID_BORROWED_REFS Py_XDECREF(pos); #endif assert(PyErr_Occurred()); } static int __Pyx_ParseKeywordDict( PyObject *kwds, PyObject ** const argnames[], PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs) { PyObject** const *name; PyObject** const *first_kw_arg = argnames + num_pos_args; Py_ssize_t extracted = 0; #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments) if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1; #endif name = first_kw_arg; while (*name && num_kwargs > extracted) { PyObject * key = **name; PyObject *value; int found = 0; #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 found = PyDict_GetItemRef(kwds, key, &value); #else value = PyDict_GetItemWithError(kwds, key); if (value) { Py_INCREF(value); found = 1; } else { if (unlikely(PyErr_Occurred())) goto bad; } #endif if (found) { if (unlikely(found < 0)) goto bad; values[name-argnames] = value; extracted++; } name++; } if (num_kwargs > extracted) { if (ignore_unknown_kwargs) { if (unlikely(__Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name) == -1)) goto bad; } else { __Pyx_RejectUnknownKeyword(kwds, argnames, first_kw_arg, function_name); goto bad; } } return 0; bad: return -1; } static int __Pyx_ParseKeywordDictToDict( PyObject *kwds, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject** const *name; PyObject** const *first_kw_arg = argnames + num_pos_args; Py_ssize_t len; #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments) if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1; #endif if (PyDict_Update(kwds2, kwds) < 0) goto bad; name = first_kw_arg; while (*name) { PyObject *key = **name; PyObject *value; #if !CYTHON_COMPILING_IN_LIMITED_API && (PY_VERSION_HEX >= 0x030d00A2 || defined(PyDict_Pop)) int found = PyDict_Pop(kwds2, key, &value); if (found) { if (unlikely(found < 0)) goto bad; values[name-argnames] = value; } #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000 int found = PyDict_GetItemRef(kwds2, key, &value); if (found) { if (unlikely(found < 0)) goto bad; values[name-argnames] = value; if (unlikely(PyDict_DelItem(kwds2, key) < 0)) goto bad; } #else #if CYTHON_COMPILING_IN_CPYTHON value = _PyDict_Pop(kwds2, key, kwds2); #else value = __Pyx_CallUnboundCMethod2(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_pop, kwds2, key, kwds2); #endif if (value == kwds2) { Py_DECREF(value); } else { if (unlikely(!value)) goto bad; values[name-argnames] = value; } #endif name++; } len = PyDict_Size(kwds2); if (len > 0) { return __Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name); } else if (unlikely(len == -1)) { goto bad; } return 0; bad: return -1; } static int __Pyx_ParseKeywordsTuple( PyObject *kwds, PyObject * const *kwvalues, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs) { PyObject *key = NULL; PyObject** const * name; PyObject** const *first_kw_arg = argnames + num_pos_args; for (Py_ssize_t pos = 0; pos < num_kwargs; pos++) { #if CYTHON_AVOID_BORROWED_REFS key = __Pyx_PySequence_ITEM(kwds, pos); #else key = __Pyx_PyTuple_GET_ITEM(kwds, pos); #endif #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely(!key)) goto bad; #endif name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { PyObject *value = kwvalues[pos]; values[name-argnames] = __Pyx_NewRef(value); } else { size_t index_found = 0; int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name); if (cmp == 1) { PyObject *value = kwvalues[pos]; values[index_found] = __Pyx_NewRef(value); } else { if (unlikely(cmp == -1)) goto bad; if (kwds2) { PyObject *value = kwvalues[pos]; if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else if (!ignore_unknown_kwargs) { goto invalid_keyword; } } } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(key); key = NULL; #endif } return 0; invalid_keyword: PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%U'", function_name, key); goto bad; bad: #if CYTHON_AVOID_BORROWED_REFS Py_XDECREF(key); #endif return -1; } /* ParseKeywords */ static int __Pyx_ParseKeywords( PyObject *kwds, PyObject * const *kwvalues, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs) { if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds))) return __Pyx_ParseKeywordsTuple(kwds, kwvalues, argnames, kwds2, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs); else if (kwds2) return __Pyx_ParseKeywordDictToDict(kwds, argnames, kwds2, values, num_pos_args, function_name); else return __Pyx_ParseKeywordDict(kwds, argnames, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs); } /* RaiseArgTupleInvalid */ static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found) { Py_ssize_t num_expected; const char *more_or_less; if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; } else { num_expected = num_max; more_or_less = "at most"; } if (exact) { more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } /* GetItemInt */ static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; if (unlikely(!j)) return NULL; r = PyObject_GetItem(o, j); Py_DECREF(j); return r; } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck, int unsafe_shared) { CYTHON_MAYBE_UNUSED_VAR(unsafe_shared); #if CYTHON_ASSUME_SAFE_SIZE Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyList_GET_SIZE(o); } if ((CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS || !CYTHON_ASSUME_SAFE_MACROS)) { return __Pyx_PyList_GetItemRefFast(o, wrapped_i, unsafe_shared); } else if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { return __Pyx_NewRef(PyList_GET_ITEM(o, wrapped_i)); } return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i)); #else (void)wraparound; (void)boundscheck; return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck, int unsafe_shared) { CYTHON_MAYBE_UNUSED_VAR(unsafe_shared); #if CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyTuple_GET_SIZE(o); } if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { return __Pyx_NewRef(PyTuple_GET_ITEM(o, wrapped_i)); } return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i)); #else (void)wraparound; (void)boundscheck; return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck, int unsafe_shared) { CYTHON_MAYBE_UNUSED_VAR(unsafe_shared); #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); if ((CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)) { return __Pyx_PyList_GetItemRefFast(o, n, unsafe_shared); } else if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { return __Pyx_NewRef(PyList_GET_ITEM(o, n)); } } else #if !CYTHON_AVOID_BORROWED_REFS if (PyTuple_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { return __Pyx_NewRef(PyTuple_GET_ITEM(o, n)); } } else #endif #endif #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY { PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping; PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence; if (!is_list && mm && mm->mp_subscript) { PyObject *r, *key = PyLong_FromSsize_t(i); if (unlikely(!key)) return NULL; r = mm->mp_subscript(o, key); Py_DECREF(key); return r; } if (is_list || likely(sm && sm->sq_item)) { if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) { Py_ssize_t l = sm->sq_length(o); if (likely(l >= 0)) { i += l; } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) return NULL; PyErr_Clear(); } } return sm->sq_item(o, i); } } #else if (is_list || !PyMapping_Check(o)) { return PySequence_GetItem(o, i); } #endif (void)wraparound; (void)boundscheck; return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i)); } /* PyLongBinop */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_Fallback___Pyx_PyLong_SubtractObjC(PyObject *op1, PyObject *op2, int inplace) { return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2); } #if CYTHON_USE_PYLONG_INTERNALS static PyObject* __Pyx_Unpacked___Pyx_PyLong_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) { CYTHON_MAYBE_UNUSED_VAR(inplace); CYTHON_UNUSED_VAR(zerodivision_check); const long b = intval; long a; const PY_LONG_LONG llb = intval; PY_LONG_LONG lla; if (unlikely(__Pyx_PyLong_IsZero(op1))) { return PyLong_FromLong(-intval); } const int is_positive = __Pyx_PyLong_IsPos(op1); const digit* digits = __Pyx_PyLong_Digits(op1); const Py_ssize_t size = __Pyx_PyLong_DigitCount(op1); if (likely(size == 1)) { a = (long) digits[0]; if (!is_positive) a *= -1; } else { switch (size) { case 2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); if (!is_positive) a *= -1; goto calculate_long; } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); if (!is_positive) lla *= -1; goto calculate_long_long; } break; case 3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); if (!is_positive) a *= -1; goto calculate_long; } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); if (!is_positive) lla *= -1; goto calculate_long_long; } break; case 4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); if (!is_positive) a *= -1; goto calculate_long; } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); if (!is_positive) lla *= -1; goto calculate_long_long; } break; } return PyLong_Type.tp_as_number->nb_subtract(op1, op2); } calculate_long: { long x; x = a - b; return PyLong_FromLong(x); } calculate_long_long: { PY_LONG_LONG llx; llx = lla - llb; return PyLong_FromLongLong(llx); } } #endif static PyObject* __Pyx_Float___Pyx_PyLong_SubtractObjC(PyObject *float_val, long intval, int zerodivision_check) { CYTHON_UNUSED_VAR(zerodivision_check); const long b = intval; double a = __Pyx_PyFloat_AS_DOUBLE(float_val); double result; result = ((double)a) - (double)b; return PyFloat_FromDouble(result); } static CYTHON_INLINE PyObject* __Pyx_PyLong_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) { CYTHON_MAYBE_UNUSED_VAR(intval); CYTHON_UNUSED_VAR(zerodivision_check); #if CYTHON_USE_PYLONG_INTERNALS if (likely(PyLong_CheckExact(op1))) { return __Pyx_Unpacked___Pyx_PyLong_SubtractObjC(op1, op2, intval, inplace, zerodivision_check); } #endif if (PyFloat_CheckExact(op1)) { return __Pyx_Float___Pyx_PyLong_SubtractObjC(op1, intval, zerodivision_check); } return __Pyx_Fallback___Pyx_PyLong_SubtractObjC(op1, op2, inplace); } #endif /* TypeImport */ #ifndef __PYX_HAVE_RT_ImportType_3_2_0 #define __PYX_HAVE_RT_ImportType_3_2_0 static PyTypeObject *__Pyx_ImportType_3_2_0(PyObject *module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_2_0 check_size) { PyObject *result = 0; Py_ssize_t basicsize; Py_ssize_t itemsize; #if defined(Py_LIMITED_API) || (defined(CYTHON_COMPILING_IN_LIMITED_API) && CYTHON_COMPILING_IN_LIMITED_API) PyObject *py_basicsize; PyObject *py_itemsize; #endif result = PyObject_GetAttrString(module, class_name); if (!result) goto bad; if (!PyType_Check(result)) { PyErr_Format(PyExc_TypeError, "%.200s.%.200s is not a type object", module_name, class_name); goto bad; } #if !( defined(Py_LIMITED_API) || (defined(CYTHON_COMPILING_IN_LIMITED_API) && CYTHON_COMPILING_IN_LIMITED_API) ) basicsize = ((PyTypeObject *)result)->tp_basicsize; itemsize = ((PyTypeObject *)result)->tp_itemsize; #else if (size == 0) { return (PyTypeObject *)result; } py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); if (!py_basicsize) goto bad; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = 0; if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; py_itemsize = PyObject_GetAttrString(result, "__itemsize__"); if (!py_itemsize) goto bad; itemsize = PyLong_AsSsize_t(py_itemsize); Py_DECREF(py_itemsize); py_itemsize = 0; if (itemsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; #endif if (itemsize) { if (size % alignment) { alignment = size % alignment; } if (itemsize < (Py_ssize_t)alignment) itemsize = (Py_ssize_t)alignment; } if ((size_t)(basicsize + itemsize) < size) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", module_name, class_name, size, basicsize+itemsize); goto bad; } if (check_size == __Pyx_ImportType_CheckSize_Error_3_2_0 && ((size_t)basicsize > size || (size_t)(basicsize + itemsize) < size)) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd-%zd from PyObject", module_name, class_name, size, basicsize, basicsize+itemsize); goto bad; } else if (check_size == __Pyx_ImportType_CheckSize_Warn_3_2_0 && (size_t)basicsize > size) { if (PyErr_WarnFormat(NULL, 0, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", module_name, class_name, size, basicsize) < 0) { goto bad; } } return (PyTypeObject *)result; bad: Py_XDECREF(result); return NULL; } #endif /* PyErrExceptionMatches */ #if CYTHON_FAST_THREAD_STATE static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(tuple); for (i=0; i= 0x030C00A6 PyObject *current_exception = tstate->current_exception; if (unlikely(!current_exception)) return 0; exc_type = (PyObject*) Py_TYPE(current_exception); if (exc_type == err) return 1; #else exc_type = tstate->curexc_type; if (exc_type == err) return 1; if (unlikely(!exc_type)) return 0; #endif #if CYTHON_AVOID_BORROWED_REFS Py_INCREF(exc_type); #endif if (unlikely(PyTuple_Check(err))) { result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); } else { result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err); } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(exc_type); #endif return result; } #endif /* PyErrFetchRestore */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyObject *tmp_value; assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value))); if (value) { #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb)) #endif PyException_SetTraceback(value, tb); } tmp_value = tstate->current_exception; tstate->current_exception = value; Py_XDECREF(tmp_value); Py_XDECREF(type); Py_XDECREF(tb); #else PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #endif } static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyObject* exc_value; exc_value = tstate->current_exception; tstate->current_exception = 0; *value = exc_value; *type = NULL; *tb = NULL; if (exc_value) { *type = (PyObject*) Py_TYPE(exc_value); Py_INCREF(*type); #if CYTHON_COMPILING_IN_CPYTHON *tb = ((PyBaseExceptionObject*) exc_value)->traceback; Py_XINCREF(*tb); #else *tb = PyException_GetTraceback(exc_value); #endif } #else *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #endif } #endif /* PyObjectGetAttrStrNoError */ #if __PYX_LIMITED_VERSION_HEX < 0x030d0000 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) __Pyx_PyErr_Clear(); } #endif static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { PyObject *result; #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 (void) PyObject_GetOptionalAttr(obj, attr_name, &result); return result; #else #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); } #endif result = __Pyx_PyObject_GetAttrStr(obj, attr_name); if (unlikely(!result)) { __Pyx_PyObject_GetAttrStr_ClearAttributeError(); } return result; #endif } /* HasAttr */ #if __PYX_LIMITED_VERSION_HEX < 0x030d0000 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) { PyObject *r; if (unlikely(!PyUnicode_Check(n))) { PyErr_SetString(PyExc_TypeError, "hasattr(): attribute name must be string"); return -1; } r = __Pyx_PyObject_GetAttrStrNoError(o, n); if (!r) { return (unlikely(PyErr_Occurred())) ? -1 : 0; } else { Py_DECREF(r); return 1; } } #endif /* Import */ static int __Pyx__Import_GetModule(PyObject *qualname, PyObject **module) { PyObject *imported_module = PyImport_GetModule(qualname); if (unlikely(!imported_module)) { *module = NULL; if (PyErr_Occurred()) { return -1; } return 0; } *module = imported_module; return 1; } static int __Pyx__Import_Lookup(PyObject *qualname, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject **module) { PyObject *imported_module; PyObject *top_level_package_name; Py_ssize_t i; int status, module_found; Py_ssize_t dot_index; module_found = __Pyx__Import_GetModule(qualname, &imported_module); if (unlikely(!module_found || module_found == -1)) { *module = NULL; return module_found; } if (imported_names) { for (i = 0; i < len_imported_names; i++) { PyObject *imported_name = imported_names[i]; #if __PYX_LIMITED_VERSION_HEX < 0x030d0000 int has_imported_attribute = PyObject_HasAttr(imported_module, imported_name); #else int has_imported_attribute = PyObject_HasAttrWithError(imported_module, imported_name); if (unlikely(has_imported_attribute == -1)) goto error; #endif if (!has_imported_attribute) { goto not_found; } } *module = imported_module; return 1; } dot_index = PyUnicode_FindChar(qualname, '.', 0, PY_SSIZE_T_MAX, 1); if (dot_index == -1) { *module = imported_module; return 1; } if (unlikely(dot_index == -2)) goto error; top_level_package_name = PyUnicode_Substring(qualname, 0, dot_index); if (unlikely(!top_level_package_name)) goto error; Py_DECREF(imported_module); status = __Pyx__Import_GetModule(top_level_package_name, module); Py_DECREF(top_level_package_name); return status; error: Py_DECREF(imported_module); *module = NULL; return -1; not_found: Py_DECREF(imported_module); *module = NULL; return 0; } static PyObject *__Pyx_Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, int level) { PyObject *module = 0; PyObject *empty_dict = 0; PyObject *from_list = 0; int module_found; if (!qualname) { qualname = name; } module_found = __Pyx__Import_Lookup(qualname, imported_names, len_imported_names, &module); if (likely(module_found == 1)) { return module; } else if (unlikely(module_found == -1)) { return NULL; } empty_dict = PyDict_New(); if (unlikely(!empty_dict)) goto bad; if (imported_names) { #if CYTHON_COMPILING_IN_CPYTHON from_list = __Pyx_PyList_FromArray(imported_names, len_imported_names); if (unlikely(!from_list)) goto bad; #else from_list = PyList_New(len_imported_names); if (unlikely(!from_list)) goto bad; for (Py_ssize_t i=0; i__pyx_d, empty_dict, from_list, 1); if (unlikely(!module)) { if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError))) goto bad; PyErr_Clear(); } } level = 0; } if (!module) { module = PyImport_ImportModuleLevelObject( name, __pyx_mstate_global->__pyx_d, empty_dict, from_list, level); } bad: Py_XDECREF(from_list); Py_XDECREF(empty_dict); return module; } /* ImportFrom */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { const char* module_name_str = 0; PyObject* module_name = 0; PyObject* module_dot = 0; PyObject* full_name = 0; PyErr_Clear(); module_name_str = PyModule_GetName(module); if (unlikely(!module_name_str)) { goto modbad; } module_name = PyUnicode_FromString(module_name_str); if (unlikely(!module_name)) { goto modbad; } module_dot = PyUnicode_Concat(module_name, __pyx_mstate_global->__pyx_kp_u__2); if (unlikely(!module_dot)) { goto modbad; } full_name = PyUnicode_Concat(module_dot, name); if (unlikely(!full_name)) { goto modbad; } #if (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) ||\ CYTHON_COMPILING_IN_GRAAL { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) goto modbad; value = PyObject_GetItem(modules, full_name); } #else value = PyImport_GetModule(full_name); #endif modbad: Py_XDECREF(full_name); Py_XDECREF(module_dot); Py_XDECREF(module_name); } if (unlikely(!value)) { PyErr_Format(PyExc_ImportError, "cannot import name %S", name); } return value; } /* GetBuiltinName */ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStrNoError(__pyx_mstate_global->__pyx_b, name); if (unlikely(!result) && !PyErr_Occurred()) { PyErr_Format(PyExc_NameError, "name '%U' is not defined", name); } return result; } /* PyDictVersioning */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { PyObject *dict = Py_TYPE(obj)->tp_dict; return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; } static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { PyObject **dictptr = NULL; Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; if (offset) { #if CYTHON_COMPILING_IN_CPYTHON dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); #else dictptr = _PyObject_GetDictPtr(obj); #endif } return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; } static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { PyObject *dict = Py_TYPE(obj)->tp_dict; if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) return 0; return obj_dict_version == __Pyx_get_object_dict_version(obj); } #endif /* GetModuleGlobalName */ #if CYTHON_USE_DICT_VERSIONS static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) #else static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) #endif { PyObject *result; #if CYTHON_COMPILING_IN_LIMITED_API if (unlikely(!__pyx_m)) { if (!PyErr_Occurred()) PyErr_SetNone(PyExc_NameError); return NULL; } result = PyObject_GetAttr(__pyx_m, name); if (likely(result)) { return result; } PyErr_Clear(); #elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS if (unlikely(__Pyx_PyDict_GetItemRef(__pyx_mstate_global->__pyx_d, name, &result) == -1)) PyErr_Clear(); __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return result; } #else result = _PyDict_GetItem_KnownHash(__pyx_mstate_global->__pyx_d, name, ((PyASCIIObject *) name)->hash); __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } PyErr_Clear(); #endif return __Pyx_GetBuiltinName(name); } /* dict_setdefault */ static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value) { PyObject* value; #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX >= 0x030C0000 PyObject *args[] = {d, key, default_value}; value = PyObject_VectorcallMethod(__pyx_mstate_global->__pyx_n_u_setdefault, args, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); #elif CYTHON_COMPILING_IN_LIMITED_API value = PyObject_CallMethodObjArgs(d, __pyx_mstate_global->__pyx_n_u_setdefault, key, default_value, NULL); #elif PY_VERSION_HEX >= 0x030d0000 PyDict_SetDefaultRef(d, key, default_value, &value); #else value = PyDict_SetDefault(d, key, default_value); if (unlikely(!value)) return NULL; Py_INCREF(value); #endif return value; } /* LimitedApiGetTypeDict */ #if CYTHON_COMPILING_IN_LIMITED_API static Py_ssize_t __Pyx_GetTypeDictOffset(void) { PyObject *tp_dictoffset_o; Py_ssize_t tp_dictoffset; tp_dictoffset_o = PyObject_GetAttrString((PyObject*)(&PyType_Type), "__dictoffset__"); if (unlikely(!tp_dictoffset_o)) return -1; tp_dictoffset = PyLong_AsSsize_t(tp_dictoffset_o); Py_DECREF(tp_dictoffset_o); if (unlikely(tp_dictoffset == 0)) { PyErr_SetString( PyExc_TypeError, "'type' doesn't have a dictoffset"); return -1; } else if (unlikely(tp_dictoffset < 0)) { PyErr_SetString( PyExc_TypeError, "'type' has an unexpected negative dictoffset. " "Please report this as Cython bug"); return -1; } return tp_dictoffset; } static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp) { static Py_ssize_t tp_dictoffset = 0; if (unlikely(tp_dictoffset == 0)) { tp_dictoffset = __Pyx_GetTypeDictOffset(); if (unlikely(tp_dictoffset == -1 && PyErr_Occurred())) { tp_dictoffset = 0; // try again next time? return NULL; } } return *(PyObject**)((char*)tp + tp_dictoffset); } #endif /* SetItemOnTypeDict */ static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v) { int result; PyObject *tp_dict; #if CYTHON_COMPILING_IN_LIMITED_API tp_dict = __Pyx_GetTypeDict(tp); if (unlikely(!tp_dict)) return -1; #else tp_dict = tp->tp_dict; #endif result = PyDict_SetItem(tp_dict, k, v); if (likely(!result)) { PyType_Modified(tp); if (unlikely(PyObject_HasAttr(v, __pyx_mstate_global->__pyx_n_u_set_name))) { PyObject *setNameResult = PyObject_CallMethodObjArgs(v, __pyx_mstate_global->__pyx_n_u_set_name, (PyObject *) tp, k, NULL); if (!setNameResult) return -1; Py_DECREF(setNameResult); } } return result; } /* FixUpExtensionType */ static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type) { #if __PYX_LIMITED_VERSION_HEX > 0x030900B1 CYTHON_UNUSED_VAR(spec); CYTHON_UNUSED_VAR(type); CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict); #else const PyType_Slot *slot = spec->slots; int changed = 0; #if !CYTHON_COMPILING_IN_LIMITED_API while (slot && slot->slot && slot->slot != Py_tp_members) slot++; if (slot && slot->slot == Py_tp_members) { #if !CYTHON_COMPILING_IN_CPYTHON const #endif // !CYTHON_COMPILING_IN_CPYTHON) PyMemberDef *memb = (PyMemberDef*) slot->pfunc; while (memb && memb->name) { if (memb->name[0] == '_' && memb->name[1] == '_') { if (strcmp(memb->name, "__weaklistoffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); type->tp_weaklistoffset = memb->offset; changed = 1; } else if (strcmp(memb->name, "__dictoffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); type->tp_dictoffset = memb->offset; changed = 1; } #if CYTHON_METH_FASTCALL else if (strcmp(memb->name, "__vectorcalloffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); type->tp_vectorcall_offset = memb->offset; changed = 1; } #endif // CYTHON_METH_FASTCALL #if !CYTHON_COMPILING_IN_PYPY else if (strcmp(memb->name, "__module__") == 0) { PyObject *descr; assert(memb->type == T_OBJECT); assert(memb->flags == 0 || memb->flags == READONLY); descr = PyDescr_NewMember(type, memb); if (unlikely(!descr)) return -1; int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr); Py_DECREF(descr); if (unlikely(set_item_result < 0)) { return -1; } changed = 1; } #endif // !CYTHON_COMPILING_IN_PYPY } memb++; } } #endif // !CYTHON_COMPILING_IN_LIMITED_API #if !CYTHON_COMPILING_IN_PYPY slot = spec->slots; while (slot && slot->slot && slot->slot != Py_tp_getset) slot++; if (slot && slot->slot == Py_tp_getset) { PyGetSetDef *getset = (PyGetSetDef*) slot->pfunc; while (getset && getset->name) { if (getset->name[0] == '_' && getset->name[1] == '_' && strcmp(getset->name, "__module__") == 0) { PyObject *descr = PyDescr_NewGetSet(type, getset); if (unlikely(!descr)) return -1; #if CYTHON_COMPILING_IN_LIMITED_API PyObject *pyname = PyUnicode_FromString(getset->name); if (unlikely(!pyname)) { Py_DECREF(descr); return -1; } int set_item_result = __Pyx_SetItemOnTypeDict(type, pyname, descr); Py_DECREF(pyname); #else CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict); int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr); #endif Py_DECREF(descr); if (unlikely(set_item_result < 0)) { return -1; } changed = 1; } ++getset; } } #else CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict); #endif // !CYTHON_COMPILING_IN_PYPY if (changed) PyType_Modified(type); #endif // PY_VERSION_HEX > 0x030900B1 return 0; } /* AddModuleRef */ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING static PyObject *__Pyx_PyImport_AddModuleObjectRef(PyObject *name) { PyObject *module_dict = PyImport_GetModuleDict(); PyObject *m; if (PyMapping_GetOptionalItem(module_dict, name, &m) < 0) { return NULL; } if (m != NULL && PyModule_Check(m)) { return m; } Py_XDECREF(m); m = PyModule_NewObject(name); if (m == NULL) return NULL; if (PyDict_CheckExact(module_dict)) { PyObject *new_m; (void)PyDict_SetDefaultRef(module_dict, name, m, &new_m); Py_DECREF(m); return new_m; } else { if (PyObject_SetItem(module_dict, name, m) != 0) { Py_DECREF(m); return NULL; } return m; } } static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) { PyObject *py_name = PyUnicode_FromString(name); if (!py_name) return NULL; PyObject *module = __Pyx_PyImport_AddModuleObjectRef(py_name); Py_DECREF(py_name); return module; } #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name) #else static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) { PyObject *module = PyImport_AddModule(name); Py_XINCREF(module); return module; } #endif /* FetchSharedCythonModule */ static PyObject *__Pyx_FetchSharedCythonABIModule(void) { return __Pyx_PyImport_AddModuleRef(__PYX_ABI_MODULE_NAME); } /* FetchCommonType */ #if __PYX_LIMITED_VERSION_HEX < 0x030C0000 static PyObject* __Pyx_PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) { PyObject *result = __Pyx_PyType_FromModuleAndSpec(module, spec, bases); if (result && metaclass) { PyObject *old_tp = (PyObject*)Py_TYPE(result); Py_INCREF((PyObject*)metaclass); #if __PYX_LIMITED_VERSION_HEX >= 0x03090000 Py_SET_TYPE(result, metaclass); #else result->ob_type = metaclass; #endif Py_DECREF(old_tp); } return result; } #else #define __Pyx_PyType_FromMetaclass(me, mo, s, b) PyType_FromMetaclass(me, mo, s, b) #endif static int __Pyx_VerifyCachedType(PyObject *cached_type, const char *name, Py_ssize_t expected_basicsize) { Py_ssize_t basicsize; if (!PyType_Check(cached_type)) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s is not a type object", name); return -1; } if (expected_basicsize == 0) { return 0; // size is inherited, nothing useful to check } #if CYTHON_COMPILING_IN_LIMITED_API PyObject *py_basicsize; py_basicsize = PyObject_GetAttrString(cached_type, "__basicsize__"); if (unlikely(!py_basicsize)) return -1; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = NULL; if (unlikely(basicsize == (Py_ssize_t)-1) && PyErr_Occurred()) return -1; #else basicsize = ((PyTypeObject*) cached_type)->tp_basicsize; #endif if (basicsize != expected_basicsize) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s has the wrong size, try recompiling", name); return -1; } return 0; } static PyTypeObject *__Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) { PyObject *abi_module = NULL, *cached_type = NULL, *abi_module_dict, *new_cached_type, *py_object_name; int get_item_ref_result; const char* object_name = strrchr(spec->name, '.'); object_name = object_name ? object_name+1 : spec->name; py_object_name = PyUnicode_FromString(object_name); if (!py_object_name) return NULL; abi_module = __Pyx_FetchSharedCythonABIModule(); if (!abi_module) goto done; abi_module_dict = PyModule_GetDict(abi_module); if (!abi_module_dict) goto done; get_item_ref_result = __Pyx_PyDict_GetItemRef(abi_module_dict, py_object_name, &cached_type); if (get_item_ref_result == 1) { if (__Pyx_VerifyCachedType( cached_type, object_name, spec->basicsize) < 0) { goto bad; } goto done; } else if (unlikely(get_item_ref_result == -1)) { goto bad; } cached_type = __Pyx_PyType_FromMetaclass( metaclass, CYTHON_USE_MODULE_STATE ? module : abi_module, spec, bases); if (unlikely(!cached_type)) goto bad; if (unlikely(__Pyx_fix_up_extension_type_from_spec(spec, (PyTypeObject *) cached_type) < 0)) goto bad; new_cached_type = __Pyx_PyDict_SetDefault(abi_module_dict, py_object_name, cached_type); if (unlikely(new_cached_type != cached_type)) { if (unlikely(!new_cached_type)) goto bad; Py_DECREF(cached_type); cached_type = new_cached_type; if (__Pyx_VerifyCachedType( cached_type, object_name, spec->basicsize) < 0) { goto bad; } goto done; } else { Py_DECREF(new_cached_type); } done: Py_XDECREF(abi_module); Py_DECREF(py_object_name); assert(cached_type == NULL || PyType_Check(cached_type)); return (PyTypeObject *) cached_type; bad: Py_XDECREF(cached_type); cached_type = NULL; goto done; } /* CommonTypesMetaclass */ static PyObject* __pyx_CommonTypesMetaclass_get_module(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED void* context) { return PyUnicode_FromString(__PYX_ABI_MODULE_NAME); } #if __PYX_LIMITED_VERSION_HEX < 0x030A0000 static PyObject* __pyx_CommonTypesMetaclass_call(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *args, CYTHON_UNUSED PyObject *kwds) { PyErr_SetString(PyExc_TypeError, "Cannot instantiate Cython internal types"); return NULL; } static int __pyx_CommonTypesMetaclass_setattr(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *attr, CYTHON_UNUSED PyObject *value) { PyErr_SetString(PyExc_TypeError, "Cython internal types are immutable"); return -1; } #endif static PyGetSetDef __pyx_CommonTypesMetaclass_getset[] = { {"__module__", __pyx_CommonTypesMetaclass_get_module, NULL, NULL, NULL}, {0, 0, 0, 0, 0} }; static PyType_Slot __pyx_CommonTypesMetaclass_slots[] = { {Py_tp_getset, (void *)__pyx_CommonTypesMetaclass_getset}, #if __PYX_LIMITED_VERSION_HEX < 0x030A0000 {Py_tp_call, (void*)__pyx_CommonTypesMetaclass_call}, {Py_tp_new, (void*)__pyx_CommonTypesMetaclass_call}, {Py_tp_setattro, (void*)__pyx_CommonTypesMetaclass_setattr}, #endif {0, 0} }; static PyType_Spec __pyx_CommonTypesMetaclass_spec = { __PYX_TYPE_MODULE_PREFIX "_common_types_metatype", 0, 0, Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_DEFAULT, __pyx_CommonTypesMetaclass_slots }; static int __pyx_CommonTypesMetaclass_init(PyObject *module) { __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module); PyObject *bases = PyTuple_Pack(1, &PyType_Type); if (unlikely(!bases)) { return -1; } mstate->__pyx_CommonTypesMetaclassType = __Pyx_FetchCommonTypeFromSpec(NULL, module, &__pyx_CommonTypesMetaclass_spec, bases); Py_DECREF(bases); if (unlikely(mstate->__pyx_CommonTypesMetaclassType == NULL)) { return -1; } return 0; } /* CallTypeTraverse */ #if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000) #else static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg) { #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x03090000 if (__Pyx_get_runtime_version() < 0x03090000) return 0; #endif if (!always_call) { PyTypeObject *base = __Pyx_PyObject_GetSlot(o, tp_base, PyTypeObject*); unsigned long flags = PyType_GetFlags(base); if (flags & Py_TPFLAGS_HEAPTYPE) { return 0; } } Py_VISIT((PyObject*)Py_TYPE(o)); return 0; } #endif /* PyMethodNew */ #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) { PyObject *result; CYTHON_UNUSED_VAR(typ); if (!self) return __Pyx_NewRef(func); #if __PYX_LIMITED_VERSION_HEX >= 0x030C0000 { PyObject *args[] = {func, self}; result = PyObject_Vectorcall(__pyx_mstate_global->__Pyx_CachedMethodType, args, 2, NULL); } #else result = PyObject_CallFunctionObjArgs(__pyx_mstate_global->__Pyx_CachedMethodType, func, self, NULL); #endif return result; } #else static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) { CYTHON_UNUSED_VAR(typ); if (!self) return __Pyx_NewRef(func); return PyMethod_New(func, self); } #endif /* PyVectorcallFastCallDict */ #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL static PyObject *__Pyx_PyVectorcall_FastCallDict_kw(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw) { PyObject *res = NULL; PyObject *kwnames; PyObject **newargs; PyObject **kwvalues; Py_ssize_t i; #if CYTHON_AVOID_BORROWED_REFS PyObject *pos; #else Py_ssize_t pos; #endif size_t j; PyObject *key, *value; unsigned long keys_are_strings; #if !CYTHON_ASSUME_SAFE_SIZE Py_ssize_t nkw = PyDict_Size(kw); if (unlikely(nkw == -1)) return NULL; #else Py_ssize_t nkw = PyDict_GET_SIZE(kw); #endif newargs = (PyObject **)PyMem_Malloc((nargs + (size_t)nkw) * sizeof(args[0])); if (unlikely(newargs == NULL)) { PyErr_NoMemory(); return NULL; } for (j = 0; j < nargs; j++) newargs[j] = args[j]; kwnames = PyTuple_New(nkw); if (unlikely(kwnames == NULL)) { PyMem_Free(newargs); return NULL; } kwvalues = newargs + nargs; pos = 0; i = 0; keys_are_strings = Py_TPFLAGS_UNICODE_SUBCLASS; while (__Pyx_PyDict_NextRef(kw, &pos, &key, &value)) { keys_are_strings &= #if CYTHON_COMPILING_IN_LIMITED_API PyType_GetFlags(Py_TYPE(key)); #else Py_TYPE(key)->tp_flags; #endif #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely(PyTuple_SetItem(kwnames, i, key) < 0)) goto cleanup; #else PyTuple_SET_ITEM(kwnames, i, key); #endif kwvalues[i] = value; i++; } if (unlikely(!keys_are_strings)) { PyErr_SetString(PyExc_TypeError, "keywords must be strings"); goto cleanup; } res = vc(func, newargs, nargs, kwnames); cleanup: #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(pos); #endif Py_DECREF(kwnames); for (i = 0; i < nkw; i++) Py_DECREF(kwvalues[i]); PyMem_Free(newargs); return res; } static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw) { Py_ssize_t kw_size = likely(kw == NULL) ? 0 : #if !CYTHON_ASSUME_SAFE_SIZE PyDict_Size(kw); #else PyDict_GET_SIZE(kw); #endif if (kw_size == 0) { return vc(func, args, nargs, NULL); } #if !CYTHON_ASSUME_SAFE_SIZE else if (unlikely(kw_size == -1)) { return NULL; } #endif return __Pyx_PyVectorcall_FastCallDict_kw(func, vc, args, nargs, kw); } #endif /* CythonFunctionShared */ #if CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE int __Pyx__IsSameCyOrCFunctionNoMethod(PyObject *func, void (*cfunc)(void)) { if (__Pyx_CyFunction_Check(func)) { return PyCFunction_GetFunction(((__pyx_CyFunctionObject*)func)->func) == (PyCFunction) cfunc; } else if (PyCFunction_Check(func)) { return PyCFunction_GetFunction(func) == (PyCFunction) cfunc; } return 0; } static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) { if ((PyObject*)Py_TYPE(func) == __pyx_mstate_global->__Pyx_CachedMethodType) { int result; PyObject *newFunc = PyObject_GetAttr(func, __pyx_mstate_global->__pyx_n_u_func); if (unlikely(!newFunc)) { PyErr_Clear(); // It's only an optimization, so don't throw an error return 0; } result = __Pyx__IsSameCyOrCFunctionNoMethod(newFunc, cfunc); Py_DECREF(newFunc); return result; } return __Pyx__IsSameCyOrCFunctionNoMethod(func, cfunc); } #else static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) { if (PyMethod_Check(func)) { func = PyMethod_GET_FUNCTION(func); } return __Pyx_CyOrPyCFunction_Check(func) && __Pyx_CyOrPyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; } #endif static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) { #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API __Pyx_Py_XDECREF_SET( __Pyx_CyFunction_GetClassObj(f), ((classobj) ? __Pyx_NewRef(classobj) : NULL)); #else __Pyx_Py_XDECREF_SET( ((PyCMethodObject *) (f))->mm_class, (PyTypeObject*)((classobj) ? __Pyx_NewRef(classobj) : NULL)); #endif } static PyObject * __Pyx_CyFunction_get_doc_locked(__pyx_CyFunctionObject *op) { if (unlikely(op->func_doc == NULL)) { #if CYTHON_COMPILING_IN_LIMITED_API op->func_doc = PyObject_GetAttrString(op->func, "__doc__"); if (unlikely(!op->func_doc)) return NULL; #else if (((PyCFunctionObject*)op)->m_ml->ml_doc) { op->func_doc = PyUnicode_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc); if (unlikely(op->func_doc == NULL)) return NULL; } else { Py_INCREF(Py_None); return Py_None; } #endif } Py_INCREF(op->func_doc); return op->func_doc; } static PyObject * __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, void *closure) { PyObject *result; CYTHON_UNUSED_VAR(closure); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_doc_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); if (value == NULL) { value = Py_None; } Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->func_doc, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_name_locked(__pyx_CyFunctionObject *op) { if (unlikely(op->func_name == NULL)) { #if CYTHON_COMPILING_IN_LIMITED_API op->func_name = PyObject_GetAttrString(op->func, "__name__"); #else op->func_name = PyUnicode_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name); #endif if (unlikely(op->func_name == NULL)) return NULL; } Py_INCREF(op->func_name); return op->func_name; } static PyObject * __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, void *context) { PyObject *result = NULL; CYTHON_UNUSED_VAR(context); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_name_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(value == NULL || !PyUnicode_Check(value))) { PyErr_SetString(PyExc_TypeError, "__name__ must be set to a string object"); return -1; } Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->func_name, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); PyObject *result; __Pyx_BEGIN_CRITICAL_SECTION(op); Py_INCREF(op->func_qualname); result = op->func_qualname; __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(value == NULL || !PyUnicode_Check(value))) { PyErr_SetString(PyExc_TypeError, "__qualname__ must be set to a string object"); return -1; } Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->func_qualname, value); __Pyx_END_CRITICAL_SECTION(); return 0; } #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 static PyObject * __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(op->func_dict == NULL)) { op->func_dict = PyDict_New(); if (unlikely(op->func_dict == NULL)) return NULL; } Py_INCREF(op->func_dict); return op->func_dict; } #endif static PyObject * __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); Py_INCREF(op->func_globals); return op->func_globals; } static PyObject * __Pyx_CyFunction_get_closure(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(op); CYTHON_UNUSED_VAR(context); Py_INCREF(Py_None); return Py_None; } static PyObject * __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, void *context) { PyObject* result = (op->func_code) ? op->func_code : Py_None; CYTHON_UNUSED_VAR(context); Py_INCREF(result); return result; } static int __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { int result = 0; PyObject *res = op->defaults_getter((PyObject *) op); if (unlikely(!res)) return -1; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS op->defaults_tuple = PyTuple_GET_ITEM(res, 0); Py_INCREF(op->defaults_tuple); op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); Py_INCREF(op->defaults_kwdict); #else op->defaults_tuple = __Pyx_PySequence_ITEM(res, 0); if (unlikely(!op->defaults_tuple)) result = -1; else { op->defaults_kwdict = __Pyx_PySequence_ITEM(res, 1); if (unlikely(!op->defaults_kwdict)) result = -1; } #endif Py_DECREF(res); return result; } static int __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value) { value = Py_None; } else if (unlikely(value != Py_None && !PyTuple_Check(value))) { PyErr_SetString(PyExc_TypeError, "__defaults__ must be set to a tuple object"); return -1; } PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__defaults__ will not " "currently affect the values used in function calls", 1); Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->defaults_tuple, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_defaults_locked(__pyx_CyFunctionObject *op) { PyObject* result = op->defaults_tuple; if (unlikely(!result)) { if (op->defaults_getter) { if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL; result = op->defaults_tuple; } else { result = Py_None; } } Py_INCREF(result); return result; } static PyObject * __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, void *context) { PyObject* result = NULL; CYTHON_UNUSED_VAR(context); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_defaults_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value) { value = Py_None; } else if (unlikely(value != Py_None && !PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "__kwdefaults__ must be set to a dict object"); return -1; } PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__kwdefaults__ will not " "currently affect the values used in function calls", 1); Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->defaults_kwdict, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_kwdefaults_locked(__pyx_CyFunctionObject *op) { PyObject* result = op->defaults_kwdict; if (unlikely(!result)) { if (op->defaults_getter) { if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL; result = op->defaults_kwdict; } else { result = Py_None; } } Py_INCREF(result); return result; } static PyObject * __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, void *context) { PyObject* result; CYTHON_UNUSED_VAR(context); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_kwdefaults_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value || value == Py_None) { value = NULL; } else if (unlikely(!PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "__annotations__ must be set to a dict object"); return -1; } Py_XINCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->func_annotations, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_annotations_locked(__pyx_CyFunctionObject *op) { PyObject* result = op->func_annotations; if (unlikely(!result)) { result = PyDict_New(); if (unlikely(!result)) return NULL; op->func_annotations = result; } Py_INCREF(result); return result; } static PyObject * __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, void *context) { PyObject *result; CYTHON_UNUSED_VAR(context); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_annotations_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static PyObject * __Pyx_CyFunction_get_is_coroutine_value(__pyx_CyFunctionObject *op) { int is_coroutine = op->flags & __Pyx_CYFUNCTION_COROUTINE; if (is_coroutine) { PyObject *is_coroutine_value, *module, *fromlist, *marker = __pyx_mstate_global->__pyx_n_u_is_coroutine; fromlist = PyList_New(1); if (unlikely(!fromlist)) return NULL; Py_INCREF(marker); #if CYTHON_ASSUME_SAFE_MACROS PyList_SET_ITEM(fromlist, 0, marker); #else if (unlikely(PyList_SetItem(fromlist, 0, marker) < 0)) { Py_DECREF(marker); Py_DECREF(fromlist); return NULL; } #endif module = PyImport_ImportModuleLevelObject(__pyx_mstate_global->__pyx_n_u_asyncio_coroutines, NULL, NULL, fromlist, 0); Py_DECREF(fromlist); if (unlikely(!module)) goto ignore; is_coroutine_value = __Pyx_PyObject_GetAttrStr(module, marker); Py_DECREF(module); if (likely(is_coroutine_value)) { return is_coroutine_value; } ignore: PyErr_Clear(); } return __Pyx_PyBool_FromLong(is_coroutine); } static PyObject * __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) { PyObject *result; CYTHON_UNUSED_VAR(context); if (op->func_is_coroutine) { return __Pyx_NewRef(op->func_is_coroutine); } result = __Pyx_CyFunction_get_is_coroutine_value(op); if (unlikely(!result)) return NULL; __Pyx_BEGIN_CRITICAL_SECTION(op); if (op->func_is_coroutine) { Py_DECREF(result); result = __Pyx_NewRef(op->func_is_coroutine); } else { op->func_is_coroutine = __Pyx_NewRef(result); } __Pyx_END_CRITICAL_SECTION(); return result; } static void __Pyx_CyFunction_raise_argument_count_error(__pyx_CyFunctionObject *func, const char* message, Py_ssize_t size) { #if CYTHON_COMPILING_IN_LIMITED_API PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL); if (!py_name) return; PyErr_Format(PyExc_TypeError, "%.200S() %s (%" CYTHON_FORMAT_SSIZE_T "d given)", py_name, message, size); Py_DECREF(py_name); #else const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name; PyErr_Format(PyExc_TypeError, "%.200s() %s (%" CYTHON_FORMAT_SSIZE_T "d given)", name, message, size); #endif } static void __Pyx_CyFunction_raise_type_error(__pyx_CyFunctionObject *func, const char* message) { #if CYTHON_COMPILING_IN_LIMITED_API PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL); if (!py_name) return; PyErr_Format(PyExc_TypeError, "%.200S() %s", py_name, message); Py_DECREF(py_name); #else const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name; PyErr_Format(PyExc_TypeError, "%.200s() %s", name, message); #endif } #if CYTHON_COMPILING_IN_LIMITED_API static PyObject * __Pyx_CyFunction_get_module(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); return PyObject_GetAttrString(op->func, "__module__"); } static int __Pyx_CyFunction_set_module(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); return PyObject_SetAttrString(op->func, "__module__", value); } #endif static PyGetSetDef __pyx_CyFunction_getsets[] = { {"func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {"__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {"func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {"__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {"__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 {"func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0}, {"__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0}, #else {"func_dict", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0}, {"__dict__", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0}, #endif {"func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {"__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {"func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {"__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {"func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {"__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {"func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {"__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {"__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, {"__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, {"_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0}, #if CYTHON_COMPILING_IN_LIMITED_API {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0}, #endif {0, 0, 0, 0, 0} }; static PyMemberDef __pyx_CyFunction_members[] = { #if !CYTHON_COMPILING_IN_LIMITED_API {"__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0}, #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API {"__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict), READONLY, 0}, #endif #if CYTHON_METH_FASTCALL #if CYTHON_COMPILING_IN_LIMITED_API {"__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall), READONLY, 0}, #else {"__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0}, #endif #if CYTHON_COMPILING_IN_LIMITED_API {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist), READONLY, 0}, #else {"__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0}, #endif #endif {0, 0, 0, 0, 0} }; static PyObject * __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, PyObject *args) { PyObject *result = NULL; CYTHON_UNUSED_VAR(args); __Pyx_BEGIN_CRITICAL_SECTION(m); Py_INCREF(m->func_qualname); result = m->func_qualname; __Pyx_END_CRITICAL_SECTION(); return result; } static PyMethodDef __pyx_CyFunction_methods[] = { {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, {0, 0, 0, 0} }; #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) #else #define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist) #endif static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { #if !CYTHON_COMPILING_IN_LIMITED_API PyCFunctionObject *cf = (PyCFunctionObject*) op; #endif if (unlikely(op == NULL)) return NULL; #if CYTHON_COMPILING_IN_LIMITED_API op->func = PyCFunction_NewEx(ml, (PyObject*)op, module); if (unlikely(!op->func)) return NULL; #endif op->flags = flags; __Pyx_CyFunction_weakreflist(op) = NULL; #if !CYTHON_COMPILING_IN_LIMITED_API cf->m_ml = ml; cf->m_self = (PyObject *) op; #endif Py_XINCREF(closure); op->func_closure = closure; #if !CYTHON_COMPILING_IN_LIMITED_API Py_XINCREF(module); cf->m_module = module; #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API op->func_dict = NULL; #endif op->func_name = NULL; Py_INCREF(qualname); op->func_qualname = qualname; op->func_doc = NULL; #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API op->func_classobj = NULL; #else ((PyCMethodObject*)op)->mm_class = NULL; #endif op->func_globals = globals; Py_INCREF(op->func_globals); Py_XINCREF(code); op->func_code = code; op->defaults = NULL; op->defaults_tuple = NULL; op->defaults_kwdict = NULL; op->defaults_getter = NULL; op->func_annotations = NULL; op->func_is_coroutine = NULL; #if CYTHON_METH_FASTCALL switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) { case METH_NOARGS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_NOARGS; break; case METH_O: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_O; break; case METH_METHOD | METH_FASTCALL | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD; break; case METH_FASTCALL | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS; break; case METH_VARARGS | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = NULL; break; default: PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction"); Py_DECREF(op); return NULL; } #endif return (PyObject *) op; } static int __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) { Py_CLEAR(m->func_closure); #if CYTHON_COMPILING_IN_LIMITED_API Py_CLEAR(m->func); #else Py_CLEAR(((PyCFunctionObject*)m)->m_module); #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API Py_CLEAR(m->func_dict); #elif PY_VERSION_HEX < 0x030d0000 _PyObject_ClearManagedDict((PyObject*)m); #else PyObject_ClearManagedDict((PyObject*)m); #endif Py_CLEAR(m->func_name); Py_CLEAR(m->func_qualname); Py_CLEAR(m->func_doc); Py_CLEAR(m->func_globals); Py_CLEAR(m->func_code); #if !CYTHON_COMPILING_IN_LIMITED_API #if PY_VERSION_HEX < 0x030900B1 Py_CLEAR(__Pyx_CyFunction_GetClassObj(m)); #else { PyObject *cls = (PyObject*) ((PyCMethodObject *) (m))->mm_class; ((PyCMethodObject *) (m))->mm_class = NULL; Py_XDECREF(cls); } #endif #endif Py_CLEAR(m->defaults_tuple); Py_CLEAR(m->defaults_kwdict); Py_CLEAR(m->func_annotations); Py_CLEAR(m->func_is_coroutine); Py_CLEAR(m->defaults); return 0; } static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m) { if (__Pyx_CyFunction_weakreflist(m) != NULL) PyObject_ClearWeakRefs((PyObject *) m); __Pyx_CyFunction_clear(m); __Pyx_PyHeapTypeObject_GC_Del(m); } static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) { PyObject_GC_UnTrack(m); __Pyx__CyFunction_dealloc(m); } static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) { { int e = __Pyx_call_type_traverse((PyObject*)m, 1, visit, arg); if (e) return e; } Py_VISIT(m->func_closure); #if CYTHON_COMPILING_IN_LIMITED_API Py_VISIT(m->func); #else Py_VISIT(((PyCFunctionObject*)m)->m_module); #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API Py_VISIT(m->func_dict); #else { int e = #if PY_VERSION_HEX < 0x030d0000 _PyObject_VisitManagedDict #else PyObject_VisitManagedDict #endif ((PyObject*)m, visit, arg); if (e != 0) return e; } #endif __Pyx_VISIT_CONST(m->func_name); __Pyx_VISIT_CONST(m->func_qualname); Py_VISIT(m->func_doc); Py_VISIT(m->func_globals); __Pyx_VISIT_CONST(m->func_code); #if !CYTHON_COMPILING_IN_LIMITED_API Py_VISIT(__Pyx_CyFunction_GetClassObj(m)); #endif Py_VISIT(m->defaults_tuple); Py_VISIT(m->defaults_kwdict); Py_VISIT(m->func_is_coroutine); Py_VISIT(m->defaults); return 0; } static PyObject* __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) { PyObject *repr; __Pyx_BEGIN_CRITICAL_SECTION(op); repr = PyUnicode_FromFormat("", op->func_qualname, (void *)op); __Pyx_END_CRITICAL_SECTION(); return repr; } static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { #if CYTHON_COMPILING_IN_LIMITED_API PyObject *f = ((__pyx_CyFunctionObject*)func)->func; PyCFunction meth; int flags; meth = PyCFunction_GetFunction(f); if (unlikely(!meth)) return NULL; flags = PyCFunction_GetFlags(f); if (unlikely(flags < 0)) return NULL; #else PyCFunctionObject* f = (PyCFunctionObject*)func; PyCFunction meth = f->m_ml->ml_meth; int flags = f->m_ml->ml_flags; #endif Py_ssize_t size; switch (flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { case METH_VARARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) return (*meth)(self, arg); break; case METH_VARARGS | METH_KEYWORDS: return (*(PyCFunctionWithKeywords)(void(*)(void))meth)(self, arg, kw); case METH_NOARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { #if CYTHON_ASSUME_SAFE_SIZE size = PyTuple_GET_SIZE(arg); #else size = PyTuple_Size(arg); if (unlikely(size < 0)) return NULL; #endif if (likely(size == 0)) return (*meth)(self, NULL); __Pyx_CyFunction_raise_argument_count_error( (__pyx_CyFunctionObject*)func, "takes no arguments", size); return NULL; } break; case METH_O: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { #if CYTHON_ASSUME_SAFE_SIZE size = PyTuple_GET_SIZE(arg); #else size = PyTuple_Size(arg); if (unlikely(size < 0)) return NULL; #endif if (likely(size == 1)) { PyObject *result, *arg0; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS arg0 = PyTuple_GET_ITEM(arg, 0); #else arg0 = __Pyx_PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; #endif result = (*meth)(self, arg0); #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) Py_DECREF(arg0); #endif return result; } __Pyx_CyFunction_raise_argument_count_error( (__pyx_CyFunctionObject*)func, "takes exactly one argument", size); return NULL; } break; default: PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction"); return NULL; } __Pyx_CyFunction_raise_type_error( (__pyx_CyFunctionObject*)func, "takes no keyword arguments"); return NULL; } static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *self, *result; #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)func)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)func)->m_self; #endif result = __Pyx_CyFunction_CallMethod(func, self, arg, kw); return result; } static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { PyObject *result; __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc); if (vc) { #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw); #else (void) &__Pyx_PyVectorcall_FastCallDict; return PyVectorcall_Call(func, args, kw); #endif } #endif if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { Py_ssize_t argc; PyObject *new_args; PyObject *self; #if CYTHON_ASSUME_SAFE_SIZE argc = PyTuple_GET_SIZE(args); #else argc = PyTuple_Size(args); if (unlikely(argc < 0)) return NULL; #endif new_args = PyTuple_GetSlice(args, 1, argc); if (unlikely(!new_args)) return NULL; self = PyTuple_GetItem(args, 0); if (unlikely(!self)) { Py_DECREF(new_args); PyErr_Format(PyExc_TypeError, "unbound method %.200S() needs an argument", cyfunc->func_qualname); return NULL; } result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); Py_DECREF(new_args); } else { result = __Pyx_CyFunction_Call(func, args, kw); } return result; } #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(__pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames) { int ret = 0; if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { if (unlikely(nargs < 1)) { __Pyx_CyFunction_raise_type_error( cyfunc, "needs an argument"); return -1; } ret = 1; } if (unlikely(kwnames) && unlikely(__Pyx_PyTuple_GET_SIZE(kwnames))) { __Pyx_CyFunction_raise_type_error( cyfunc, "takes no keyword arguments"); return -1; } return ret; } static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); PyObject *self; #if CYTHON_COMPILING_IN_LIMITED_API PyCFunction meth = PyCFunction_GetFunction(cyfunc->func); if (unlikely(!meth)) return NULL; #else PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth; #endif switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)cyfunc)->m_self; #endif break; default: return NULL; } if (unlikely(nargs != 0)) { __Pyx_CyFunction_raise_argument_count_error( cyfunc, "takes no arguments", nargs); return NULL; } return meth(self, NULL); } static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); PyObject *self; #if CYTHON_COMPILING_IN_LIMITED_API PyCFunction meth = PyCFunction_GetFunction(cyfunc->func); if (unlikely(!meth)) return NULL; #else PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth; #endif switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)cyfunc)->m_self; #endif break; default: return NULL; } if (unlikely(nargs != 1)) { __Pyx_CyFunction_raise_argument_count_error( cyfunc, "takes exactly one argument", nargs); return NULL; } return meth(self, args[0]); } static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); PyObject *self; #if CYTHON_COMPILING_IN_LIMITED_API PyCFunction meth = PyCFunction_GetFunction(cyfunc->func); if (unlikely(!meth)) return NULL; #else PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth; #endif switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)cyfunc)->m_self; #endif break; default: return NULL; } return ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))meth)(self, args, nargs, kwnames); } static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; PyTypeObject *cls = (PyTypeObject *) __Pyx_CyFunction_GetClassObj(cyfunc); Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); PyObject *self; #if CYTHON_COMPILING_IN_LIMITED_API PyCFunction meth = PyCFunction_GetFunction(cyfunc->func); if (unlikely(!meth)) return NULL; #else PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth; #endif switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)cyfunc)->m_self; #endif break; default: return NULL; } #if PY_VERSION_HEX < 0x030e00A6 size_t nargs_value = (size_t) nargs; #else Py_ssize_t nargs_value = nargs; #endif return ((__Pyx_PyCMethod)(void(*)(void))meth)(self, cls, args, nargs_value, kwnames); } #endif static PyType_Slot __pyx_CyFunctionType_slots[] = { {Py_tp_dealloc, (void *)__Pyx_CyFunction_dealloc}, {Py_tp_repr, (void *)__Pyx_CyFunction_repr}, {Py_tp_call, (void *)__Pyx_CyFunction_CallAsMethod}, {Py_tp_traverse, (void *)__Pyx_CyFunction_traverse}, {Py_tp_clear, (void *)__Pyx_CyFunction_clear}, {Py_tp_methods, (void *)__pyx_CyFunction_methods}, {Py_tp_members, (void *)__pyx_CyFunction_members}, {Py_tp_getset, (void *)__pyx_CyFunction_getsets}, {Py_tp_descr_get, (void *)__Pyx_PyMethod_New}, {0, 0}, }; static PyType_Spec __pyx_CyFunctionType_spec = { __PYX_TYPE_MODULE_PREFIX "cython_function_or_method", sizeof(__pyx_CyFunctionObject), 0, #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR Py_TPFLAGS_METHOD_DESCRIPTOR | #endif #if CYTHON_METH_FASTCALL #if defined(Py_TPFLAGS_HAVE_VECTORCALL) Py_TPFLAGS_HAVE_VECTORCALL | #elif defined(_Py_TPFLAGS_HAVE_VECTORCALL) _Py_TPFLAGS_HAVE_VECTORCALL | #endif #endif // CYTHON_METH_FASTCALL #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API Py_TPFLAGS_MANAGED_DICT | #endif Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, __pyx_CyFunctionType_slots }; static int __pyx_CyFunction_init(PyObject *module) { __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module); mstate->__pyx_CyFunctionType = __Pyx_FetchCommonTypeFromSpec( mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_CyFunctionType_spec, NULL); if (unlikely(mstate->__pyx_CyFunctionType == NULL)) { return -1; } return 0; } static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults = PyObject_CallObject((PyObject*)defaults_type, NULL); // _PyObject_New(defaults_type); if (unlikely(!m->defaults)) return NULL; return m->defaults; } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_tuple = tuple; Py_INCREF(tuple); } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_kwdict = dict; Py_INCREF(dict); } static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->func_annotations = dict; Py_INCREF(dict); } /* CythonFunction */ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { PyObject *op = __Pyx_CyFunction_Init( PyObject_GC_New(__pyx_CyFunctionObject, __pyx_mstate_global->__pyx_CyFunctionType), ml, flags, qualname, closure, module, globals, code ); if (likely(op)) { PyObject_GC_Track(op); } return op; } /* CLineInTraceback */ #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 #define __Pyx_PyProbablyModule_GetDict(o) __Pyx_XNewRef(PyModule_GetDict(o)) #elif !CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #define __Pyx_PyProbablyModule_GetDict(o) PyObject_GenericGetDict(o, NULL); #else PyObject* __Pyx_PyProbablyModule_GetDict(PyObject *o) { PyObject **dict_ptr = _PyObject_GetDictPtr(o); return dict_ptr ? __Pyx_XNewRef(*dict_ptr) : NULL; } #endif static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) { PyObject *use_cline = NULL; PyObject *ptype, *pvalue, *ptraceback; PyObject *cython_runtime_dict; CYTHON_MAYBE_UNUSED_VAR(tstate); if (unlikely(!__pyx_mstate_global->__pyx_cython_runtime)) { return c_line; } __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); cython_runtime_dict = __Pyx_PyProbablyModule_GetDict(__pyx_mstate_global->__pyx_cython_runtime); if (likely(cython_runtime_dict)) { __PYX_PY_DICT_LOOKUP_IF_MODIFIED( use_cline, cython_runtime_dict, __Pyx_PyDict_SetDefault(cython_runtime_dict, __pyx_mstate_global->__pyx_n_u_cline_in_traceback, Py_False)) } if (use_cline == NULL || use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { c_line = 0; } Py_XDECREF(use_cline); Py_XDECREF(cython_runtime_dict); __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); return c_line; } #endif /* CodeObjectCache */ static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static __Pyx_CachedCodeObjectType *__pyx__find_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line) { __Pyx_CachedCodeObjectType* code_object; int pos; if (unlikely(!code_line) || unlikely(!code_cache->entries)) { return NULL; } pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line); if (unlikely(pos >= code_cache->count) || unlikely(code_cache->entries[pos].code_line != code_line)) { return NULL; } code_object = code_cache->entries[pos].code_object; Py_INCREF(code_object); return code_object; } static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS (void)__pyx__find_code_object; return NULL; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just miss. #else struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_nonatomic_int_type old_count = __pyx_atomic_incr_acq_rel(&code_cache->accessor_count); if (old_count < 0) { __pyx_atomic_decr_acq_rel(&code_cache->accessor_count); return NULL; } #endif __Pyx_CachedCodeObjectType *result = __pyx__find_code_object(code_cache, code_line); #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_atomic_decr_acq_rel(&code_cache->accessor_count); #endif return result; #endif } static void __pyx__insert_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line, __Pyx_CachedCodeObjectType* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = code_cache->entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { code_cache->entries = entries; code_cache->max_count = 64; code_cache->count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line); if ((pos < code_cache->count) && unlikely(code_cache->entries[pos].code_line == code_line)) { __Pyx_CachedCodeObjectType* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_INCREF(code_object); Py_DECREF(tmp); return; } if (code_cache->count == code_cache->max_count) { int new_max = code_cache->max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( code_cache->entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } code_cache->entries = entries; code_cache->max_count = new_max; } for (i=code_cache->count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; code_cache->count++; Py_INCREF(code_object); } static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS (void)__pyx__insert_code_object; return; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just fail. #else struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_nonatomic_int_type expected = 0; if (!__pyx_atomic_int_cmp_exchange(&code_cache->accessor_count, &expected, INT_MIN)) { return; } #endif __pyx__insert_code_object(code_cache, code_line, code_object); #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_atomic_sub(&code_cache->accessor_count, INT_MIN); #endif #endif } /* AddTraceback */ #include "compile.h" #include "frameobject.h" #include "traceback.h" #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION) #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif #include "internal/pycore_frame.h" #endif #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict, PyObject *firstlineno, PyObject *name) { PyObject *replace = NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL; replace = PyObject_GetAttrString(code, "replace"); if (likely(replace)) { PyObject *result = PyObject_Call(replace, __pyx_mstate_global->__pyx_empty_tuple, scratch_dict); Py_DECREF(replace); return result; } PyErr_Clear(); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL; PyObject *replace = NULL, *getframe = NULL, *frame = NULL; PyObject *exc_type, *exc_value, *exc_traceback; int success = 0; if (c_line) { c_line = __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line); } PyErr_Fetch(&exc_type, &exc_value, &exc_traceback); code_object = __pyx_find_code_object(c_line ? -c_line : py_line); if (!code_object) { code_object = Py_CompileString("_getframe()", filename, Py_eval_input); if (unlikely(!code_object)) goto bad; py_py_line = PyLong_FromLong(py_line); if (unlikely(!py_py_line)) goto bad; if (c_line) { py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); } else { py_funcname = PyUnicode_FromString(funcname); } if (unlikely(!py_funcname)) goto bad; dict = PyDict_New(); if (unlikely(!dict)) goto bad; { PyObject *old_code_object = code_object; code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname); Py_DECREF(old_code_object); } if (unlikely(!code_object)) goto bad; __pyx_insert_code_object(c_line ? -c_line : py_line, code_object); } else { dict = PyDict_New(); } getframe = PySys_GetObject("_getframe"); if (unlikely(!getframe)) goto bad; if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad; frame = PyEval_EvalCode(code_object, dict, dict); if (unlikely(!frame) || frame == Py_None) goto bad; success = 1; bad: PyErr_Restore(exc_type, exc_value, exc_traceback); Py_XDECREF(code_object); Py_XDECREF(py_py_line); Py_XDECREF(py_funcname); Py_XDECREF(dict); Py_XDECREF(replace); if (success) { PyTraceBack_Here( (struct _frame*)frame); } Py_XDECREF(frame); } #else static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = NULL; PyObject *py_funcname = NULL; if (c_line) { py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); if (!py_funcname) goto bad; funcname = PyUnicode_AsUTF8(py_funcname); if (!funcname) goto bad; } py_code = PyCode_NewEmpty(filename, funcname, py_line); Py_XDECREF(py_funcname); return py_code; bad: Py_XDECREF(py_funcname); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject *ptype, *pvalue, *ptraceback; if (c_line) { c_line = __Pyx_CLineForTraceback(tstate, c_line); } py_code = __pyx_find_code_object(c_line ? -c_line : py_line); if (!py_code) { __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) { /* If the code object creation fails, then we should clear the fetched exception references and propagate the new exception */ Py_XDECREF(ptype); Py_XDECREF(pvalue); Py_XDECREF(ptraceback); goto bad; } __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); } py_frame = PyFrame_New( tstate, /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_mstate_global->__pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } #endif /* CIntFromPyVerify */ #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } /* CIntFromPy */ static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyLong_As_unsigned_PY_LONG_LONG(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) -1, const_zero = (unsigned PY_LONG_LONG) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (unlikely(!PyLong_Check(x))) { unsigned PY_LONG_LONG val; PyObject *tmp = __Pyx_PyNumber_Long(x); if (!tmp) return (unsigned PY_LONG_LONG) -1; val = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(tmp); Py_DECREF(tmp); return val; } if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) >= 2 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); } } break; case 3: if ((8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) >= 3 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); } } break; case 4: if ((8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) >= 4 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (unsigned PY_LONG_LONG) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned long, PyLong_AsUnsignedLong(x)) } else if ((sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case 2: if ((8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) ((((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case -3: if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case 3: if ((8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) ((((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case -4: if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case 4: if ((8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) ((((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; } } #endif if ((sizeof(unsigned PY_LONG_LONG) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, long, PyLong_AsLong(x)) } else if ((sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { unsigned PY_LONG_LONG val; int ret = -1; #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API Py_ssize_t bytes_copied = PyLong_AsNativeBytes( x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0)); if (unlikely(bytes_copied == -1)) { } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) { goto raise_overflow; } else { ret = 0; } #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)x, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *v; PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (likely(PyLong_CheckExact(x))) { v = __Pyx_NewRef(x); } else { v = PyNumber_Long(x); if (unlikely(!v)) return (unsigned PY_LONG_LONG) -1; assert(PyLong_CheckExact(v)); } { int result = PyObject_RichCompareBool(v, Py_False, Py_LT); if (unlikely(result < 0)) { Py_DECREF(v); return (unsigned PY_LONG_LONG) -1; } is_negative = result == 1; } if (is_unsigned && unlikely(is_negative)) { Py_DECREF(v); goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); Py_DECREF(v); if (unlikely(!stepval)) return (unsigned PY_LONG_LONG) -1; } else { stepval = v; } v = NULL; val = (unsigned PY_LONG_LONG) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(unsigned PY_LONG_LONG) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; long idigit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; val |= ((unsigned PY_LONG_LONG) idigit) << bits; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; } Py_DECREF(shift); shift = NULL; Py_DECREF(mask); mask = NULL; { long idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(unsigned PY_LONG_LONG) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((unsigned PY_LONG_LONG) idigit) << bits; } if (!is_unsigned) { if (unlikely(val & (((unsigned PY_LONG_LONG) 1) << (sizeof(unsigned PY_LONG_LONG) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif if (unlikely(ret)) return (unsigned PY_LONG_LONG) -1; return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned PY_LONG_LONG"); return (unsigned PY_LONG_LONG) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to unsigned PY_LONG_LONG"); return (unsigned PY_LONG_LONG) -1; } /* PyObjectVectorCallKwBuilder */ #if CYTHON_VECTORCALL static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) { (void)__Pyx_PyObject_FastCallDict; if (__Pyx_PyTuple_SET_ITEM(builder, n, key) != (0)) return -1; Py_INCREF(key); args[n] = value; return 0; } CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) { (void)__Pyx_VectorcallBuilder_AddArgStr; if (unlikely(!PyUnicode_Check(key))) { PyErr_SetString(PyExc_TypeError, "keywords must be strings"); return -1; } return __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n); } static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n) { PyObject *pyKey = PyUnicode_FromString(key); if (!pyKey) return -1; return __Pyx_VectorcallBuilder_AddArg(pyKey, value, builder, args, n); } #else // CYTHON_VECTORCALL CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, CYTHON_UNUSED PyObject **args, CYTHON_UNUSED int n) { if (unlikely(!PyUnicode_Check(key))) { PyErr_SetString(PyExc_TypeError, "keywords must be strings"); return -1; } return PyDict_SetItem(builder, key, value); } #endif /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) -1, const_zero = (unsigned PY_LONG_LONG) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(unsigned PY_LONG_LONG) < sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #if !CYTHON_COMPILING_IN_PYPY } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(unsigned PY_LONG_LONG) <= sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4 if (is_unsigned) { return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1); } else { return PyLong_FromNativeBytes(bytes, sizeof(value), -1); } #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 int one = 1; int little = (int)*(unsigned char *)&one; return _PyLong_FromByteArray(bytes, sizeof(unsigned PY_LONG_LONG), little, !is_unsigned); #else int one = 1; int little = (int)*(unsigned char *)&one; PyObject *from_bytes, *result = NULL, *kwds = NULL; PyObject *py_bytes = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(unsigned PY_LONG_LONG)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; { PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str }; if (!is_unsigned) { kwds = __Pyx_MakeVectorcallBuilderKwds(1); if (!kwds) goto limited_bad; if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad; } result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds); } limited_bad: Py_XDECREF(kwds); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* FormatTypeName */ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000 static __Pyx_TypeName __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp) { PyObject *module = NULL, *name = NULL, *result = NULL; #if __PYX_LIMITED_VERSION_HEX < 0x030b0000 name = __Pyx_PyObject_GetAttrStr((PyObject *)tp, __pyx_mstate_global->__pyx_n_u_qualname); #else name = PyType_GetQualName(tp); #endif if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) goto bad; module = __Pyx_PyObject_GetAttrStr((PyObject *)tp, __pyx_mstate_global->__pyx_n_u_module); if (unlikely(module == NULL) || unlikely(!PyUnicode_Check(module))) goto bad; if (PyUnicode_CompareWithASCIIString(module, "builtins") == 0) { result = name; name = NULL; goto done; } result = PyUnicode_FromFormat("%U.%U", module, name); if (unlikely(result == NULL)) goto bad; done: Py_XDECREF(name); Py_XDECREF(module); return result; bad: PyErr_Clear(); if (name) { result = name; name = NULL; } else { result = __Pyx_NewRef(__pyx_mstate_global->__pyx_kp_u__3); } goto done; } #endif /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #if !CYTHON_COMPILING_IN_PYPY } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(long) <= sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4 if (is_unsigned) { return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1); } else { return PyLong_FromNativeBytes(bytes, sizeof(value), -1); } #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 int one = 1; int little = (int)*(unsigned char *)&one; return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); #else int one = 1; int little = (int)*(unsigned char *)&one; PyObject *from_bytes, *result = NULL, *kwds = NULL; PyObject *py_bytes = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(long)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; { PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str }; if (!is_unsigned) { kwds = __Pyx_MakeVectorcallBuilderKwds(1); if (!kwds) goto limited_bad; if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad; } result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds); } limited_bad: Py_XDECREF(kwds); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* CIntFromPy */ static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (unlikely(!PyLong_Check(x))) { long val; PyObject *tmp = __Pyx_PyNumber_Long(x); if (!tmp) return (long) -1; val = __Pyx_PyLong_As_long(tmp); Py_DECREF(tmp); return val; } if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(long) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } } #endif if ((sizeof(long) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { long val; int ret = -1; #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API Py_ssize_t bytes_copied = PyLong_AsNativeBytes( x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0)); if (unlikely(bytes_copied == -1)) { } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) { goto raise_overflow; } else { ret = 0; } #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)x, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *v; PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (likely(PyLong_CheckExact(x))) { v = __Pyx_NewRef(x); } else { v = PyNumber_Long(x); if (unlikely(!v)) return (long) -1; assert(PyLong_CheckExact(v)); } { int result = PyObject_RichCompareBool(v, Py_False, Py_LT); if (unlikely(result < 0)) { Py_DECREF(v); return (long) -1; } is_negative = result == 1; } if (is_unsigned && unlikely(is_negative)) { Py_DECREF(v); goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); Py_DECREF(v); if (unlikely(!stepval)) return (long) -1; } else { stepval = v; } v = NULL; val = (long) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; long idigit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; val |= ((long) idigit) << bits; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; } Py_DECREF(shift); shift = NULL; Py_DECREF(mask); mask = NULL; { long idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((long) idigit) << bits; } if (!is_unsigned) { if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif if (unlikely(ret)) return (long) -1; return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } /* CIntFromPy */ static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const int neg_one = (int) -1, const_zero = (int) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (unlikely(!PyLong_Check(x))) { int val; PyObject *tmp = __Pyx_PyNumber_Long(x); if (!tmp) return (int) -1; val = __Pyx_PyLong_As_int(tmp); Py_DECREF(tmp); return val; } if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(int) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } } #endif if ((sizeof(int) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { int val; int ret = -1; #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API Py_ssize_t bytes_copied = PyLong_AsNativeBytes( x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0)); if (unlikely(bytes_copied == -1)) { } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) { goto raise_overflow; } else { ret = 0; } #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)x, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *v; PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (likely(PyLong_CheckExact(x))) { v = __Pyx_NewRef(x); } else { v = PyNumber_Long(x); if (unlikely(!v)) return (int) -1; assert(PyLong_CheckExact(v)); } { int result = PyObject_RichCompareBool(v, Py_False, Py_LT); if (unlikely(result < 0)) { Py_DECREF(v); return (int) -1; } is_negative = result == 1; } if (is_unsigned && unlikely(is_negative)) { Py_DECREF(v); goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); Py_DECREF(v); if (unlikely(!stepval)) return (int) -1; } else { stepval = v; } v = NULL; val = (int) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; long idigit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; val |= ((int) idigit) << bits; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; } Py_DECREF(shift); shift = NULL; Py_DECREF(mask); mask = NULL; { long idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((int) idigit) << bits; } if (!is_unsigned) { if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif if (unlikely(ret)) return (int) -1; return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } /* FastTypeChecks */ #if CYTHON_COMPILING_IN_CPYTHON static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { while (a) { a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*); if (a == b) return 1; } return b == &PyBaseObject_Type; } static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (a == b) return 1; mro = a->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(a, b); } static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (cls == a || cls == b) return 1; mro = cls->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { PyObject *base = PyTuple_GET_ITEM(mro, i); if (base == (PyObject *)a || base == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b); } static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { if (exc_type1) { return __Pyx_IsAnySubtype2((PyTypeObject*)err, (PyTypeObject*)exc_type1, (PyTypeObject*)exc_type2); } else { return __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); } } static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; assert(PyExceptionClass_Check(exc_type)); n = PyTuple_GET_SIZE(tuple); for (i=0; i>= 8; ++i; } __Pyx_cached_runtime_version = version; } } #endif static unsigned long __Pyx_get_runtime_version(void) { #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000 return Py_Version & ~0xFFUL; #else return __Pyx_cached_runtime_version; #endif } /* CheckBinaryVersion */ static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) { const unsigned long MAJOR_MINOR = 0xFFFF0000UL; if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR)) return 0; if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR))) return 1; { char message[200]; PyOS_snprintf(message, sizeof(message), "compile time Python version %d.%d " "of module '%.100s' " "%s " "runtime version %d.%d", (int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF), __Pyx_MODULE_NAME, (allow_newer) ? "was newer than" : "does not match", (int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF) ); return PyErr_WarnEx(NULL, message, 1); } } /* NewCodeObj */ #if CYTHON_COMPILING_IN_LIMITED_API static PyObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f, PyObject *code, PyObject *c, PyObject* n, PyObject *v, PyObject *fv, PyObject *cell, PyObject* fn, PyObject *name, int fline, PyObject *lnos) { PyObject *exception_table = NULL; PyObject *types_module=NULL, *code_type=NULL, *result=NULL; #if __PYX_LIMITED_VERSION_HEX < 0x030b0000 PyObject *version_info; PyObject *py_minor_version = NULL; #endif long minor_version = 0; PyObject *type, *value, *traceback; PyErr_Fetch(&type, &value, &traceback); #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000 minor_version = 11; #else if (!(version_info = PySys_GetObject("version_info"))) goto end; if (!(py_minor_version = PySequence_GetItem(version_info, 1))) goto end; minor_version = PyLong_AsLong(py_minor_version); Py_DECREF(py_minor_version); if (minor_version == -1 && PyErr_Occurred()) goto end; #endif if (!(types_module = PyImport_ImportModule("types"))) goto end; if (!(code_type = PyObject_GetAttrString(types_module, "CodeType"))) goto end; if (minor_version <= 7) { (void)p; result = PyObject_CallFunction(code_type, "iiiiiOOOOOOiOOO", a, k, l, s, f, code, c, n, v, fn, name, fline, lnos, fv, cell); } else if (minor_version <= 10) { result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOiOOO", a,p, k, l, s, f, code, c, n, v, fn, name, fline, lnos, fv, cell); } else { if (!(exception_table = PyBytes_FromStringAndSize(NULL, 0))) goto end; result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOOiOOOO", a,p, k, l, s, f, code, c, n, v, fn, name, name, fline, lnos, exception_table, fv, cell); } end: Py_XDECREF(code_type); Py_XDECREF(exception_table); Py_XDECREF(types_module); if (type) { PyErr_Restore(type, value, traceback); } return result; } #elif PY_VERSION_HEX >= 0x030B0000 static PyCodeObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f, PyObject *code, PyObject *c, PyObject* n, PyObject *v, PyObject *fv, PyObject *cell, PyObject* fn, PyObject *name, int fline, PyObject *lnos) { PyCodeObject *result; result = #if PY_VERSION_HEX >= 0x030C0000 PyUnstable_Code_NewWithPosOnlyArgs #else PyCode_NewWithPosOnlyArgs #endif (a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, name, fline, lnos, __pyx_mstate_global->__pyx_empty_bytes); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030c00A1 if (likely(result)) result->_co_firsttraceable = 0; #endif return result; } #elif !CYTHON_COMPILING_IN_PYPY #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #else #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #endif static PyObject* __Pyx_PyCode_New( const __Pyx_PyCode_New_function_description descr, PyObject * const *varnames, PyObject *filename, PyObject *funcname, PyObject *line_table, PyObject *tuple_dedup_map ) { PyObject *code_obj = NULL, *varnames_tuple_dedup = NULL, *code_bytes = NULL; Py_ssize_t var_count = (Py_ssize_t) descr.nlocals; PyObject *varnames_tuple = PyTuple_New(var_count); if (unlikely(!varnames_tuple)) return NULL; for (Py_ssize_t i=0; i < var_count; i++) { Py_INCREF(varnames[i]); if (__Pyx_PyTuple_SET_ITEM(varnames_tuple, i, varnames[i]) != (0)) goto done; } #if CYTHON_COMPILING_IN_LIMITED_API varnames_tuple_dedup = PyDict_GetItem(tuple_dedup_map, varnames_tuple); if (!varnames_tuple_dedup) { if (unlikely(PyDict_SetItem(tuple_dedup_map, varnames_tuple, varnames_tuple) < 0)) goto done; varnames_tuple_dedup = varnames_tuple; } #else varnames_tuple_dedup = PyDict_SetDefault(tuple_dedup_map, varnames_tuple, varnames_tuple); if (unlikely(!varnames_tuple_dedup)) goto done; #endif #if CYTHON_AVOID_BORROWED_REFS Py_INCREF(varnames_tuple_dedup); #endif if (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table != NULL && !CYTHON_COMPILING_IN_GRAAL) { Py_ssize_t line_table_length = __Pyx_PyBytes_GET_SIZE(line_table); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(line_table_length == -1)) goto done; #endif Py_ssize_t code_len = (line_table_length * 2 + 4) & ~3LL; code_bytes = PyBytes_FromStringAndSize(NULL, code_len); if (unlikely(!code_bytes)) goto done; char* c_code_bytes = PyBytes_AsString(code_bytes); if (unlikely(!c_code_bytes)) goto done; memset(c_code_bytes, 0, (size_t) code_len); } code_obj = (PyObject*) __Pyx__PyCode_New( (int) descr.argcount, (int) descr.num_posonly_args, (int) descr.num_kwonly_args, (int) descr.nlocals, 0, (int) descr.flags, code_bytes ? code_bytes : __pyx_mstate_global->__pyx_empty_bytes, __pyx_mstate_global->__pyx_empty_tuple, __pyx_mstate_global->__pyx_empty_tuple, varnames_tuple_dedup, __pyx_mstate_global->__pyx_empty_tuple, __pyx_mstate_global->__pyx_empty_tuple, filename, funcname, (int) descr.first_line, (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table) ? line_table : __pyx_mstate_global->__pyx_empty_bytes ); done: Py_XDECREF(code_bytes); #if CYTHON_AVOID_BORROWED_REFS Py_XDECREF(varnames_tuple_dedup); #endif Py_DECREF(varnames_tuple); return code_obj; } /* DecompressString */ static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo) { PyObject *module, *decompress, *compressed_bytes, *decompressed; const char* module_name = algo == 3 ? "compression.zstd" : algo == 2 ? "bz2" : "zlib"; PyObject *methodname = PyUnicode_FromString("decompress"); if (unlikely(!methodname)) return NULL; #if __PYX_LIMITED_VERSION_HEX >= 0x030e0000 if (algo == 3) { PyObject *fromlist = Py_BuildValue("[O]", methodname); if (unlikely(!fromlist)) return NULL; module = PyImport_ImportModuleLevel("compression.zstd", NULL, NULL, fromlist, 0); Py_DECREF(fromlist); } else #endif module = PyImport_ImportModule(module_name); if (unlikely(!module)) goto import_failed; decompress = PyObject_GetAttr(module, methodname); if (unlikely(!decompress)) goto import_failed; { #ifdef __cplusplus char *memview_bytes = const_cast(s); #else #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wcast-qual" #elif !defined(__INTEL_COMPILER) && defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-qual" #endif char *memview_bytes = (char*) s; #if defined(__clang__) #pragma clang diagnostic pop #elif !defined(__INTEL_COMPILER) && defined(__GNUC__) #pragma GCC diagnostic pop #endif #endif #if CYTHON_COMPILING_IN_LIMITED_API && !defined(PyBUF_READ) int memview_flags = 0x100; #else int memview_flags = PyBUF_READ; #endif compressed_bytes = PyMemoryView_FromMemory(memview_bytes, length, memview_flags); } if (unlikely(!compressed_bytes)) { Py_DECREF(decompress); goto bad; } decompressed = PyObject_CallFunctionObjArgs(decompress, compressed_bytes, NULL); Py_DECREF(compressed_bytes); Py_DECREF(decompress); Py_DECREF(module); Py_DECREF(methodname); return decompressed; import_failed: PyErr_Format(PyExc_ImportError, "Failed to import '%.20s.decompress' - cannot initialise module strings. " "String compression was configured with the C macro 'CYTHON_COMPRESS_STRINGS=%d'.", module_name, algo); bad: Py_XDECREF(module); Py_DECREF(methodname); return NULL; } #include static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s) { size_t len = strlen(s); if (unlikely(len > (size_t) PY_SSIZE_T_MAX)) { PyErr_SetString(PyExc_OverflowError, "byte string is too long"); return -1; } return (Py_ssize_t) len; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { Py_ssize_t len = __Pyx_ssize_strlen(c_str); if (unlikely(len < 0)) return NULL; return __Pyx_PyUnicode_FromStringAndSize(c_str, len); } static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char* c_str) { Py_ssize_t len = __Pyx_ssize_strlen(c_str); if (unlikely(len < 0)) return NULL; return PyByteArray_FromStringAndSize(c_str, len); } static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if CYTHON_COMPILING_IN_LIMITED_API { const char* result; Py_ssize_t unicode_length; CYTHON_MAYBE_UNUSED_VAR(unicode_length); // only for __PYX_DEFAULT_STRING_ENCODING_IS_ASCII #if __PYX_LIMITED_VERSION_HEX < 0x030A0000 if (unlikely(PyArg_Parse(o, "s#", &result, length) < 0)) return NULL; #else result = PyUnicode_AsUTF8AndSize(o, length); #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII unicode_length = PyUnicode_GetLength(o); if (unlikely(unicode_length < 0)) return NULL; if (unlikely(unicode_length != *length)) { PyUnicode_AsASCIIString(o); return NULL; } #endif return result; } #else #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (likely(PyUnicode_IS_ASCII(o))) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif #endif } #endif static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 if (PyUnicode_Check(o)) { return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif if (PyByteArray_Check(o)) { #if (CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS) || (CYTHON_COMPILING_IN_PYPY && (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))) *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); #else *length = PyByteArray_Size(o); if (*length == -1) return NULL; return PyByteArray_AsString(o); #endif } else { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { int retval; if (unlikely(!x)) return -1; retval = __Pyx_PyObject_IsTrue(x); Py_DECREF(x); return retval; } static PyObject* __Pyx_PyNumber_LongWrongResultType(PyObject* result) { __Pyx_TypeName result_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(result)); if (PyLong_Check(result)) { if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, "__int__ returned non-int (type " __Pyx_FMT_TYPENAME "). " "The ability to return an instance of a strict subclass of int is deprecated, " "and may be removed in a future version of Python.", result_type_name)) { __Pyx_DECREF_TypeName(result_type_name); Py_DECREF(result); return NULL; } __Pyx_DECREF_TypeName(result_type_name); return result; } PyErr_Format(PyExc_TypeError, "__int__ returned non-int (type " __Pyx_FMT_TYPENAME ")", result_type_name); __Pyx_DECREF_TypeName(result_type_name); Py_DECREF(result); return NULL; } static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; #endif PyObject *res = NULL; if (likely(PyLong_Check(x))) return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS m = Py_TYPE(x)->tp_as_number; if (likely(m && m->nb_int)) { res = m->nb_int(x); } #else if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { res = PyNumber_Long(x); } #endif if (likely(res)) { if (unlikely(!PyLong_CheckExact(res))) { return __Pyx_PyNumber_LongWrongResultType(res); } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS if (likely(__Pyx_PyLong_IsCompact(b))) { return __Pyx_PyLong_CompactValue(b); } else { const digit* digits = __Pyx_PyLong_Digits(b); const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(b); switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyLong_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) { if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) { return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o); } else { Py_ssize_t ival; PyObject *x; x = PyNumber_Index(o); if (!x) return -1; ival = PyLong_AsLong(x); Py_DECREF(x); return ival; } } static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b) { CYTHON_UNUSED_VAR(b); return __Pyx_NewRef(Py_None); } static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { return __Pyx_NewRef(b ? Py_True: Py_False); } static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t ival) { return PyLong_FromSize_t(ival); } /* MultiPhaseInitModuleState */ #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE #ifndef CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE #if (CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX >= 0x030C0000) #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 1 #else #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 0 #endif #endif #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE && !CYTHON_ATOMICS #error "Module state with PEP489 requires atomics. Currently that's one of\ C11, C++11, gcc atomic intrinsics or MSVC atomic intrinsics" #endif #if !CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE #define __Pyx_ModuleStateLookup_Lock() #define __Pyx_ModuleStateLookup_Unlock() #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000 static PyMutex __Pyx_ModuleStateLookup_mutex = {0}; #define __Pyx_ModuleStateLookup_Lock() PyMutex_Lock(&__Pyx_ModuleStateLookup_mutex) #define __Pyx_ModuleStateLookup_Unlock() PyMutex_Unlock(&__Pyx_ModuleStateLookup_mutex) #elif defined(__cplusplus) && __cplusplus >= 201103L #include static std::mutex __Pyx_ModuleStateLookup_mutex; #define __Pyx_ModuleStateLookup_Lock() __Pyx_ModuleStateLookup_mutex.lock() #define __Pyx_ModuleStateLookup_Unlock() __Pyx_ModuleStateLookup_mutex.unlock() #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201112L) && !defined(__STDC_NO_THREADS__) #include static mtx_t __Pyx_ModuleStateLookup_mutex; static once_flag __Pyx_ModuleStateLookup_mutex_once_flag = ONCE_FLAG_INIT; static void __Pyx_ModuleStateLookup_initialize_mutex(void) { mtx_init(&__Pyx_ModuleStateLookup_mutex, mtx_plain); } #define __Pyx_ModuleStateLookup_Lock()\ call_once(&__Pyx_ModuleStateLookup_mutex_once_flag, __Pyx_ModuleStateLookup_initialize_mutex);\ mtx_lock(&__Pyx_ModuleStateLookup_mutex) #define __Pyx_ModuleStateLookup_Unlock() mtx_unlock(&__Pyx_ModuleStateLookup_mutex) #elif defined(HAVE_PTHREAD_H) #include static pthread_mutex_t __Pyx_ModuleStateLookup_mutex = PTHREAD_MUTEX_INITIALIZER; #define __Pyx_ModuleStateLookup_Lock() pthread_mutex_lock(&__Pyx_ModuleStateLookup_mutex) #define __Pyx_ModuleStateLookup_Unlock() pthread_mutex_unlock(&__Pyx_ModuleStateLookup_mutex) #elif defined(_WIN32) #include // synchapi.h on its own doesn't work static SRWLOCK __Pyx_ModuleStateLookup_mutex = SRWLOCK_INIT; #define __Pyx_ModuleStateLookup_Lock() AcquireSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex) #define __Pyx_ModuleStateLookup_Unlock() ReleaseSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex) #else #error "No suitable lock available for CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE.\ Requires C standard >= C11, or C++ standard >= C++11,\ or pthreads, or the Windows 32 API, or Python >= 3.13." #endif typedef struct { int64_t id; PyObject *module; } __Pyx_InterpreterIdAndModule; typedef struct { char interpreter_id_as_index; Py_ssize_t count; Py_ssize_t allocated; __Pyx_InterpreterIdAndModule table[1]; } __Pyx_ModuleStateLookupData; #define __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE 32 #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE static __pyx_atomic_int_type __Pyx_ModuleStateLookup_read_counter = 0; #endif #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE static __pyx_atomic_ptr_type __Pyx_ModuleStateLookup_data = 0; #else static __Pyx_ModuleStateLookupData* __Pyx_ModuleStateLookup_data = NULL; #endif static __Pyx_InterpreterIdAndModule* __Pyx_State_FindModuleStateLookupTableLowerBound( __Pyx_InterpreterIdAndModule* table, Py_ssize_t count, int64_t interpreterId) { __Pyx_InterpreterIdAndModule* begin = table; __Pyx_InterpreterIdAndModule* end = begin + count; if (begin->id == interpreterId) { return begin; } while ((end - begin) > __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) { __Pyx_InterpreterIdAndModule* halfway = begin + (end - begin)/2; if (halfway->id == interpreterId) { return halfway; } if (halfway->id < interpreterId) { begin = halfway; } else { end = halfway; } } for (; begin < end; ++begin) { if (begin->id >= interpreterId) return begin; } return begin; } static PyObject *__Pyx_State_FindModule(CYTHON_UNUSED void* dummy) { int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get()); if (interpreter_id == -1) return NULL; #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __Pyx_ModuleStateLookupData* data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data); { __pyx_atomic_incr_acq_rel(&__Pyx_ModuleStateLookup_read_counter); if (likely(data)) { __Pyx_ModuleStateLookupData* new_data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_acquire(&__Pyx_ModuleStateLookup_data); if (likely(data == new_data)) { goto read_finished; } } __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter); __Pyx_ModuleStateLookup_Lock(); __pyx_atomic_incr_relaxed(&__Pyx_ModuleStateLookup_read_counter); data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data); __Pyx_ModuleStateLookup_Unlock(); } read_finished:; #else __Pyx_ModuleStateLookupData* data = __Pyx_ModuleStateLookup_data; #endif __Pyx_InterpreterIdAndModule* found = NULL; if (unlikely(!data)) goto end; if (data->interpreter_id_as_index) { if (interpreter_id < data->count) { found = data->table+interpreter_id; } } else { found = __Pyx_State_FindModuleStateLookupTableLowerBound( data->table, data->count, interpreter_id); } end: { PyObject *result=NULL; if (found && found->id == interpreter_id) { result = found->module; } #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter); #endif return result; } } #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE static void __Pyx_ModuleStateLookup_wait_until_no_readers(void) { while (__pyx_atomic_load(&__Pyx_ModuleStateLookup_read_counter) != 0); } #else #define __Pyx_ModuleStateLookup_wait_until_no_readers() #endif static int __Pyx_State_AddModuleInterpIdAsIndex(__Pyx_ModuleStateLookupData **old_data, PyObject* module, int64_t interpreter_id) { Py_ssize_t to_allocate = (*old_data)->allocated; while (to_allocate <= interpreter_id) { if (to_allocate == 0) to_allocate = 1; else to_allocate *= 2; } __Pyx_ModuleStateLookupData *new_data = *old_data; if (to_allocate != (*old_data)->allocated) { new_data = (__Pyx_ModuleStateLookupData *)realloc( *old_data, sizeof(__Pyx_ModuleStateLookupData)+(to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule)); if (!new_data) { PyErr_NoMemory(); return -1; } for (Py_ssize_t i = new_data->allocated; i < to_allocate; ++i) { new_data->table[i].id = i; new_data->table[i].module = NULL; } new_data->allocated = to_allocate; } new_data->table[interpreter_id].module = module; if (new_data->count < interpreter_id+1) { new_data->count = interpreter_id+1; } *old_data = new_data; return 0; } static void __Pyx_State_ConvertFromInterpIdAsIndex(__Pyx_ModuleStateLookupData *data) { __Pyx_InterpreterIdAndModule *read = data->table; __Pyx_InterpreterIdAndModule *write = data->table; __Pyx_InterpreterIdAndModule *end = read + data->count; for (; readmodule) { write->id = read->id; write->module = read->module; ++write; } } data->count = write - data->table; for (; writeid = 0; write->module = NULL; } data->interpreter_id_as_index = 0; } static int __Pyx_State_AddModule(PyObject* module, CYTHON_UNUSED void* dummy) { int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get()); if (interpreter_id == -1) return -1; int result = 0; __Pyx_ModuleStateLookup_Lock(); #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __Pyx_ModuleStateLookupData *old_data = (__Pyx_ModuleStateLookupData *) __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0); #else __Pyx_ModuleStateLookupData *old_data = __Pyx_ModuleStateLookup_data; #endif __Pyx_ModuleStateLookupData *new_data = old_data; if (!new_data) { new_data = (__Pyx_ModuleStateLookupData *)calloc(1, sizeof(__Pyx_ModuleStateLookupData)); if (!new_data) { result = -1; PyErr_NoMemory(); goto end; } new_data->allocated = 1; new_data->interpreter_id_as_index = 1; } __Pyx_ModuleStateLookup_wait_until_no_readers(); if (new_data->interpreter_id_as_index) { if (interpreter_id < __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) { result = __Pyx_State_AddModuleInterpIdAsIndex(&new_data, module, interpreter_id); goto end; } __Pyx_State_ConvertFromInterpIdAsIndex(new_data); } { Py_ssize_t insert_at = 0; { __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound( new_data->table, new_data->count, interpreter_id); assert(lower_bound); insert_at = lower_bound - new_data->table; if (unlikely(insert_at < new_data->count && lower_bound->id == interpreter_id)) { lower_bound->module = module; goto end; // already in table, nothing more to do } } if (new_data->count+1 >= new_data->allocated) { Py_ssize_t to_allocate = (new_data->count+1)*2; new_data = (__Pyx_ModuleStateLookupData*)realloc( new_data, sizeof(__Pyx_ModuleStateLookupData) + (to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule)); if (!new_data) { result = -1; new_data = old_data; PyErr_NoMemory(); goto end; } new_data->allocated = to_allocate; } ++new_data->count; int64_t last_id = interpreter_id; PyObject *last_module = module; for (Py_ssize_t i=insert_at; icount; ++i) { int64_t current_id = new_data->table[i].id; new_data->table[i].id = last_id; last_id = current_id; PyObject *current_module = new_data->table[i].module; new_data->table[i].module = last_module; last_module = current_module; } } end: #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, new_data); #else __Pyx_ModuleStateLookup_data = new_data; #endif __Pyx_ModuleStateLookup_Unlock(); return result; } static int __Pyx_State_RemoveModule(CYTHON_UNUSED void* dummy) { int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get()); if (interpreter_id == -1) return -1; __Pyx_ModuleStateLookup_Lock(); #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __Pyx_ModuleStateLookupData *data = (__Pyx_ModuleStateLookupData *) __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0); #else __Pyx_ModuleStateLookupData *data = __Pyx_ModuleStateLookup_data; #endif if (data->interpreter_id_as_index) { if (interpreter_id < data->count) { data->table[interpreter_id].module = NULL; } goto done; } { __Pyx_ModuleStateLookup_wait_until_no_readers(); __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound( data->table, data->count, interpreter_id); if (!lower_bound) goto done; if (lower_bound->id != interpreter_id) goto done; __Pyx_InterpreterIdAndModule *end = data->table+data->count; for (;lower_boundid = (lower_bound+1)->id; lower_bound->module = (lower_bound+1)->module; } } --data->count; if (data->count == 0) { free(data); data = NULL; } done: #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, data); #else __Pyx_ModuleStateLookup_data = data; #endif __Pyx_ModuleStateLookup_Unlock(); return 0; } #endif /* #### Code section: utility_code_pragmas_end ### */ #ifdef _MSC_VER #pragma warning( pop ) #endif /* #### Code section: end ### */ #endif /* Py_PYTHON_H */ clickhouse-driver-0.2.11/clickhouse_driver/columns/largeint.pyx000066400000000000000000000137561522645447600250030ustar00rootroot00000000000000from cpython cimport Py_INCREF from cpython.tuple cimport PyTuple_New, PyTuple_SET_ITEM from .. import writer cdef object MAX_UINT64 = writer.MAX_UINT64 cdef object MAX_INT64 = writer.MAX_INT64 def int128_from_quads(self, quad_items, unsigned long long n_items): cdef unsigned int factor = 2 items = PyTuple_New(n_items) cdef unsigned long long i, ix cdef object item for i in range(n_items): ix = factor * i if quad_items[ix + 1] > MAX_INT64: item = ( -((MAX_UINT64 - quad_items[ix + 1]) << 64) - (MAX_UINT64 - quad_items[ix]) - 1 ) else: item = (quad_items[ix + 1] << 64) + quad_items[ix] Py_INCREF(item) PyTuple_SET_ITEM(items, i, item) return items def int128_to_quads(self, items, unsigned long long n_items): cdef unsigned int factor = 2 quad_items = PyTuple_New(n_items * factor) cdef unsigned long long i, ix cdef object x, item for i in range(n_items): ix = factor * i x = items[i] if x < 0: x = -x - 1 item = MAX_UINT64 - x & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix, item) item = MAX_UINT64 - (x >> 64) & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix + 1, item) else: item = x & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix, item) item = (x >> 64) & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix + 1, item) return quad_items def uint128_from_quads(self, quad_items, unsigned long long n_items): cdef unsigned int factor = 2 items = PyTuple_New(n_items) cdef unsigned long long i, ix cdef object item for i in range(n_items): ix = factor * i item = (quad_items[ix + 1] << 64) + quad_items[ix] Py_INCREF(item) PyTuple_SET_ITEM(items, i, item) return items def uint128_to_quads(self, items, unsigned long long n_items): cdef unsigned int factor = 2 quad_items = PyTuple_New(n_items * factor) cdef unsigned long long i, ix cdef object x, item for i in range(n_items): ix = factor * i x = items[i] item = x & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix, item) item = (x >> 64) & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix + 1, item) return quad_items # 256 bits def int256_from_quads(self, quad_items, unsigned long long n_items): cdef unsigned int factor = 4 items = PyTuple_New(n_items) cdef unsigned long long i, ix cdef object item for i in range(n_items): ix = factor * i if quad_items[ix + 3] > MAX_INT64: item = ( -((MAX_UINT64 - quad_items[ix + 3]) << 192) -((MAX_UINT64 - quad_items[ix + 2]) << 128) -((MAX_UINT64 - quad_items[ix + 1]) << 64) - (MAX_UINT64 - quad_items[ix]) - 1 ) else: item = ( (quad_items[ix + 3] << 192) + (quad_items[ix + 2] << 128) + (quad_items[ix + 1] << 64) + quad_items[ix] ) Py_INCREF(item) PyTuple_SET_ITEM(items, i, item) return items def int256_to_quads(self, items, unsigned long long n_items): cdef unsigned int factor = 4 quad_items = PyTuple_New(n_items * factor) cdef unsigned long long i, ix cdef object x, item for i in range(n_items): ix = factor * i x = items[i] if x < 0: x = -x - 1 item = MAX_UINT64 - x & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix, item) item = MAX_UINT64 - (x >> 64) & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix + 1, item) item = MAX_UINT64 - (x >> 128) & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix + 2, item) item = MAX_UINT64 - (x >> 192) & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix + 3, item) else: item = x & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix, item) item = (x >> 64) & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix + 1, item) item = (x >> 128) & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix + 2, item) item = (x >> 192) & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix + 3, item) return quad_items def uint256_from_quads(self, quad_items, unsigned long long n_items): cdef unsigned int factor = 4 items = PyTuple_New(n_items) cdef unsigned long long i, ix cdef object item for i in range(n_items): ix = factor * i item = ( (quad_items[ix + 3] << 192) + (quad_items[ix + 2] << 128) + (quad_items[ix + 1] << 64) + quad_items[ix] ) Py_INCREF(item) PyTuple_SET_ITEM(items, i, item) return items def uint256_to_quads(self, items, unsigned long long n_items): cdef unsigned int factor = 4 quad_items = PyTuple_New(n_items * factor) cdef unsigned long long i, ix cdef object x, item for i in range(n_items): ix = factor * i x = items[i] item = x & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix, item) item = (x >> 64) & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix + 1, item) item = (x >> 128) & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix + 2, item) item = (x >> 192) & MAX_UINT64 Py_INCREF(item) PyTuple_SET_ITEM(quad_items, ix + 3, item) return quad_items clickhouse-driver-0.2.11/clickhouse_driver/columns/lowcardinalitycolumn.py000066400000000000000000000115041522645447600272360ustar00rootroot00000000000000from math import log from ..reader import read_binary_uint64 from ..writer import write_binary_int64 from .base import Column from .intcolumn import UInt8Column, UInt16Column, UInt32Column, UInt64Column def create_low_cardinality_column(spec, column_by_spec_getter, column_options): inner = spec[15:-1] nested = column_by_spec_getter(inner) return LowCardinalityColumn(nested, **column_options) class LowCardinalityColumn(Column): """ Stores column as index (unique elements) and keys. Good for de-duplication of large values with low cardinality. """ int_types = { 0: UInt8Column, 1: UInt16Column, 2: UInt32Column, 3: UInt64Column } # Need to read additional keys. # Additional keys are stored before indexes as value N and N keys # after them. has_additional_keys_bit = 1 << 9 # Need to update dictionary. # It means that previous granule has different dictionary. need_update_dictionary = 1 << 10 serialization_type = has_additional_keys_bit | need_update_dictionary def __init__(self, nested_column, **kwargs): self.init_kwargs = kwargs self.nested_column = nested_column super(LowCardinalityColumn, self).__init__(**kwargs) def read_state_prefix(self, buf): super(LowCardinalityColumn, self).read_state_prefix(buf) read_binary_uint64(buf) def write_state_prefix(self, buf, items=None): super(LowCardinalityColumn, self).write_state_prefix(buf) # KeysSerializationVersion. See ClickHouse docs. write_binary_int64(1, buf) def _write_data(self, items, buf): index, keys = [], [] key_by_index_element = {} nested_is_nullable = False if self.nested_column.nullable: # First element represents NULL if column is nullable. index.append(self.nested_column.null_value) # Prevent null map writing. Reset nested column nullable flag. self.nested_column.nullable = False nested_is_nullable = True for x in items: if x is None: # Zero element for null. keys.append(0) else: key = key_by_index_element.get(x) # Get key from index or add it to index. if key is None: key = len(key_by_index_element) key_by_index_element[x] = key index.append(x) keys.append(key + 1) else: for x in items: key = key_by_index_element.get(x) # Get key from index or add it to index. if key is None: key = len(key_by_index_element) key_by_index_element[x] = len(key_by_index_element) index.append(x) keys.append(key) # Do not write anything for empty column. # May happen while writing empty arrays. if not len(index): return int_type = int(log(len(index), 2) / 8) int_column = self.int_types[int_type](**self.init_kwargs) serialization_type = self.serialization_type | int_type write_binary_int64(serialization_type, buf) write_binary_int64(len(index), buf) if nested_is_nullable: # Given we reset nested column nullable flag above, # we need to write null map manually. If to invoke # write_data method, it will cause an exception, # because `prepare_data` may not be able to handle # null value correctly. self.nested_column.write_items( [self.nested_column.null_value], buf) # Remove null map from index, because it is already written. index_to_write = index[1:] self.nested_column.write_data(index_to_write, buf) else: self.nested_column.write_data(index, buf) write_binary_int64(len(items), buf) int_column.write_items(keys, buf) def _read_data(self, n_items, buf, nulls_map=None): if not n_items: return tuple() serialization_type = read_binary_uint64(buf) # Lowest byte contains info about key type. key_type = serialization_type & 0xf keys_column = self.int_types[key_type](**self.init_kwargs) nullable = self.nested_column.nullable # Prevent null map reading. Reset nested column nullable flag. self.nested_column.nullable = False index_size = read_binary_uint64(buf) index = self.nested_column.read_data(index_size, buf) if nullable: index = (None, ) + index[1:] read_binary_uint64(buf) # number of keys keys = keys_column.read_data(n_items, buf) return tuple(index[x] for x in keys) clickhouse-driver-0.2.11/clickhouse_driver/columns/mapcolumn.py000066400000000000000000000047141522645447600247730ustar00rootroot00000000000000import re from .base import Column from .intcolumn import UInt64Column from ..util.helpers import pairwise comma_re = re.compile(r',(?![^()]*\))') class MapColumn(Column): py_types = (dict, ) null_value = {} def __init__(self, key_column, value_column, **kwargs): self.offset_column = UInt64Column(**kwargs) self.key_column = key_column self.value_column = value_column super(MapColumn, self).__init__(**kwargs) # Map keys are restricted to scalar types, so only the value # column can carry a data-dependent prefix. self.prefix_needs_items = value_column.prefix_needs_items def read_state_prefix(self, buf): super(MapColumn, self).read_state_prefix(buf) self.key_column.read_state_prefix(buf) self.value_column.read_state_prefix(buf) def write_state_prefix(self, buf, items=None): super(MapColumn, self).write_state_prefix(buf) value_items = None if items is not None and self.value_column.prefix_needs_items: value_items = [v for x in items for v in x.values()] self.key_column.write_state_prefix(buf) self.value_column.write_state_prefix(buf, value_items) def read_items(self, n_items, buf): if not n_items: return [{}] offsets = list(self.offset_column.read_items(n_items, buf)) last_offset = offsets[-1] keys = self.key_column.read_data(last_offset, buf) values = self.value_column.read_data(last_offset, buf) offsets.insert(0, 0) return [ dict(zip(keys[begin:end], values[begin:end])) for begin, end in pairwise(offsets) ] def write_items(self, items, buf): offsets = [] keys = [] values = [] total = 0 for x in items: total += len(x) offsets.append(total) keys.extend(x.keys()) values.extend(x.values()) self.offset_column.write_items(offsets, buf) self.key_column.write_data(keys, buf) self.value_column.write_data(values, buf) def create_map_column(spec, column_by_spec_getter, column_options): # Match commas outside of parentheses, so we don't match the comma in # Decimal types. key, value = comma_re.split(spec[4:-1]) key_column = column_by_spec_getter(key.strip()) value_column = column_by_spec_getter(value.strip()) return MapColumn(key_column, value_column, **column_options) clickhouse-driver-0.2.11/clickhouse_driver/columns/nestedcolumn.py000066400000000000000000000004571522645447600255000ustar00rootroot00000000000000 from .arraycolumn import create_array_column from .util import get_inner_spec def create_nested_column(spec, column_by_spec_getter, column_options): return create_array_column( 'Array(Tuple({}))'.format(get_inner_spec('Nested', spec)), column_by_spec_getter, column_options ) clickhouse-driver-0.2.11/clickhouse_driver/columns/newjsoncolumn.py000066400000000000000000000624131522645447600257010ustar00rootroot00000000000000""" ClickHouse ``JSON`` (a.k.a. ``Object('json')``) column reader. The wire format is the one introduced in ClickHouse 24.8+ and stabilised in 25.x. Both directions are composed out of the existing column readers rather than hand-rolled: * ``DynamicColumn`` reads one dynamic path's body (a SerializationVariant over the declared variant types plus an implicit ``SharedVariant``). * ``ArrayColumn`` + ``TupleColumn`` + ``String`` reads the shared sub-column ``Array(Tuple(String, String))``. * Shared-variant blobs are decoded by walking ``encodeDataType`` and then delegating the value bytes to the appropriate column reader obtained via ``column_by_spec_getter``. The write path emits an ``ObjectSerializationVersion::V2`` header unconditionally; the server transparently falls back to V1 framing when the client revision is too old for V2. """ from .arraycolumn import ArrayColumn from .base import Column from .dynamiccolumn import ( DYNAMIC_V2, SHARED_VARIANT_NAME, DynamicColumn, SharedValueDecoder, VARIANT_MODE_BASIC, _split_tuple_elements, ) from .stringcolumn import ByteString, String from .tuplecolumn import TupleColumn from ..reader import ( read_binary_str, read_binary_uint64, ) from ..util.compat import json from ..varint import read_varint, write_varint from ..writer import write_binary_uint64 # ObjectSerializationVersion values (ClickHouse 25.5). OBJECT_V1 = 0 OBJECT_STRING = 1 OBJECT_V2 = 2 class NewJsonColumn(Column): # pragma: requires-clickhouse-24.8 """ Reader/writer for the ClickHouse ``JSON`` type. SELECT returns nested ``dict`` rows; INSERT accepts ``dict`` or JSON-text ``str``. Wire framing is V1/V2 ``SerializationObject`` on read and V2 on write; the format is composed from :class:`DynamicColumn` + ``Array(Tuple(String, String))`` for shared data rather than hand-rolled. """ py_types = (dict, str) # JSON columns are non-nullable on the wire; supply an empty dict # as the placeholder used by sparse/null helpers in the base # column. null_value = {} # The object prefix (path list + per-path SerializationDynamic # prefixes) is data-dependent; ``write_column`` and the container # columns (Array/Tuple/Map) thread the block's items into # ``write_state_prefix`` so it lands in the prefix stream position # the server expects for nested columns. prefix_needs_items = True def __init__(self, column_by_spec_getter, **kwargs): self.column_by_spec_getter = column_by_spec_getter self._column_kwargs = kwargs self.string_column = String(**kwargs) self.serialization_version = None self._write_paths_state = None self.sorted_dynamic_paths = [] self.dynamic_columns = [] self.shared_data_column = None # One decoder per block. It owns the handler-per-type_spec # cache, the scalar column-reader cache, and the reusable # bytes reader. Both this column's top-level shared paths and # every nested ``DynamicColumn``'s SharedVariant route their # overflow values through the same decoder so all caches # accumulate together. self._shared_value_decoder = SharedValueDecoder( column_by_spec_getter) super(NewJsonColumn, self).__init__(**kwargs) # ------------------------------------------------------------------ # read path # ------------------------------------------------------------------ def read_state_prefix(self, buf): # ObjectStructure stream layout (V1/V2): # UInt64 LE serialization_version # if V1: VarUInt max_dynamic_paths (discarded) # VarUInt dynamic_paths_count # N × String dynamic path names (sorted) # (optional statistics — disabled in native SELECT by default) # Then, per dynamic path: SerializationDynamic state prefix. # Then, shared_data state prefix (no bytes — Array/Tuple/String # do not emit prefixes). version = read_binary_uint64(buf) if version not in (OBJECT_V1, OBJECT_STRING, OBJECT_V2): raise NotImplementedError( "Unsupported JSON serialization version {}".format(version)) self.serialization_version = version if version == OBJECT_STRING: return if version == OBJECT_V1: read_varint(buf) # legacy max_dynamic_paths num_paths = read_varint(buf) self.sorted_dynamic_paths = [ read_binary_str(buf) for _ in range(num_paths) ] self.dynamic_columns = [] for _ in range(num_paths): col = DynamicColumn( self.column_by_spec_getter, shared_value_decoder=self._shared_value_decoder, **self._column_kwargs) col.read_state_prefix(buf) self.dynamic_columns.append(col) self.shared_data_column = self._build_shared_data_column() self.shared_data_column.read_state_prefix(buf) def read_items(self, n_items, buf): if self.serialization_version == OBJECT_STRING: return self._read_items_string(n_items, buf) # Typed paths declared in the JSON column spec (``JSON(name # Int64)``) would be read here in spec order. The current PR # does not parse typed paths out of the column-type string, so # we emulate the original behaviour and skip straight to dynamic # paths. column_per_path_values = [] for col in self.dynamic_columns: column_per_path_values.append(col.read_items(n_items, buf)) shared_rows = self.shared_data_column.read_data(n_items, buf) return self._fold_rows( n_items, column_per_path_values, shared_rows) def _read_items_string(self, n_items, buf): # Each row is one String containing the JSON text. strings = buf.read_strings(n_items, encoding='utf-8') if (self.context.client_settings or {}).get('use_arrow'): # Raw JSON text: the Arrow layer parses it or passes it # through depending on the declared type. return strings return [json.loads(s) if s else {} for s in strings] def _build_shared_data_column(self): kwargs = self._column_kwargs key_column = String(**kwargs) # SharedVariant values are raw bytes (``encodeDataType + # serializeBinary``), not UTF-8 text. value_column = ByteString(**kwargs) tuple_column = TupleColumn( ('path', 'value'), [key_column, value_column], **kwargs) return ArrayColumn(tuple_column, **kwargs) def _fold_rows(self, n_items, per_path_values, shared_rows): rows = [{} for _ in range(n_items)] for path, values in zip(self.sorted_dynamic_paths, per_path_values): for row_idx, value in enumerate(values): if value is not None: rows[row_idx][path] = _tuples_to_lists(value) decode = self._shared_value_decoder.decode for row_idx, entries in enumerate(shared_rows or []): for path, encoded in entries: rows[row_idx][path] = _tuples_to_lists(decode(encoded)) for row in rows: self._denormalize_dotted_paths(row) return rows @staticmethod def _denormalize_dotted_paths(obj): # Convert dotted top-level keys (``"a.b.c"``) into nested dicts. # A scalar already living at a prefix of a dotted key would be # incompatible with the nested layout; the server should never # emit such a conflict for a single JSON row, but raise loudly # rather than silently overwriting if it ever does. for key in list(obj.keys()): parts = key.split('.') if len(parts) <= 1: continue parent = obj for part in parts[:-1]: if part not in parent: parent[part] = {} elif not isinstance(parent[part], dict): raise ValueError( "Cannot denormalise dotted JSON path {!r}: " "prefix {!r} already holds a non-dict value " "{!r}".format(key, part, parent[part])) parent = parent[part] parent[parts[-1]] = obj[key] del obj[key] # ------------------------------------------------------------------ # write path # ------------------------------------------------------------------ def write_state_prefix(self, buf, items=None): if items is None: raise NotImplementedError( 'JSON columns can only be written when the block items ' 'are threaded into write_state_prefix' ) items = [self._normalise_write_item(x) for x in items] self._write_paths_state = self._unfold_json(items, depth=0) self._write_object_state_prefix(self._write_paths_state, buf) def write_items(self, items, buf): # The body is written from the paths computed over the same # items in ``write_state_prefix``; ``items`` only supplies the # row count here. For ``Nullable(JSON)`` the nulls map emitted # by the callers lands between the prefix and this body, # matching the on-wire order the server expects. self._write_values(self._write_paths_state, len(items), buf) def _normalise_write_item(self, item): if item is None: return self.null_value if isinstance(item, str): return json.loads(item) return item def _write_object_state_prefix(self, paths, buf, depth=0): # UInt64 LE: ObjectSerializationVersion::V2 (the server falls # back to V1 itself if its client revision is too old, so we # write V2 unconditionally). write_binary_uint64(OBJECT_V2, buf) self._write_paths(paths, buf) self._write_dynamic_state_prefixes(paths, buf, depth=depth) def _write_paths(self, paths, buf): # VarUInt dynamic_paths_count + N × String path names. write_varint(len(paths), buf) self.string_column.write_items(paths.keys(), buf) def _write_dynamic_state_prefixes(self, paths, buf, depth=0): # SerializationDynamic state prefix per dynamic path: # UInt64 LE DynamicSerializationVersion::V2 # VarUInt num_dynamic_types (excludes SharedVariant) # N × String variant type spec # SerializationVariant prefix: # UInt64 LE discriminators_mode (BASIC) for col in paths.values(): write_binary_uint64(DYNAMIC_V2, buf) write_varint(len(col), buf) self.string_column.write_items(col.keys(), buf) write_binary_uint64(VARIANT_MODE_BASIC, buf) for spec in col: if spec.startswith("Tuple") and "JSON" in spec: self._write_complex_tuple_header( col[spec]["values"], spec, depth + 1, buf) elif spec.startswith("Array") and "JSON" in spec: self._write_complex_array_header( col[spec]["values"], spec, depth + 1, buf) def _write_values(self, paths, rows, buf, depth=0): # SerializationVariant body per dynamic path: # n_items × UInt8 global discriminators # per declared variant in alphabetical order: column data # Followed by the shared-data Array(Tuple(String, String))'s # offsets — all zero because we never overflow into the # SharedVariant on write. for col in paths.values(): buf.write(self._get_row_positions(col, rows)) for spec in col: if spec.startswith("Array"): if "JSON" in spec: self._write_complex_array_values( col[spec]["values"], spec, depth + 1, buf) else: insert = self._preprocess_array( col[spec]["values"], spec[6:-1]) writer = self.column_by_spec_getter(spec) writer.write_data(insert, buf) elif spec.startswith("Tuple"): if "JSON" in spec: self._write_complex_tuple_values( col[spec]["values"], spec, depth + 1, buf) else: writer = self.column_by_spec_getter(spec) writer.write_items(col[spec]["values"], buf) else: writer = self.column_by_spec_getter(spec) writer.write_items(col[spec]["values"], buf) # Write final padding. buf.write(b"\x00" * rows * 8) def _write_complex_tuple_header(self, values, spec, depth, buf): # ``spec`` is ``Tuple(e0, e1, ...)``; split the body on top-level # commas (a naive ``split`` would break on the commas inside a # nested ``Tuple``/``JSON`` element) and emit the state prefix for # every element that contains a JSON sub-column. for i, subspec in enumerate(_split_tuple_elements(spec[6:-1])): if "JSON" not in subspec: continue sub_values = [row[i] for row in values] if subspec.startswith("JSON"): paths = self._unfold_json(sub_values, depth=depth) self._write_object_state_prefix(paths, buf, depth=depth) elif subspec.startswith("Tuple"): self._write_complex_tuple_header( sub_values, subspec, depth, buf) elif subspec.startswith("Array"): self._write_complex_array_header( sub_values, subspec, depth, buf) def _write_complex_array_header(self, values, spec, depth, buf): items = [] for item in values: items += item inner = spec[6:-1] # strip "Array(" ... ")" if inner.startswith("Tuple"): self._write_complex_tuple_header(items, inner, depth, buf) elif inner.startswith("Array"): self._write_complex_array_header(items, inner, depth, buf) else: # Array(JSON) paths = self._unfold_json(items, depth=depth) self._write_object_state_prefix(paths, buf, depth=depth) def _write_complex_tuple_values(self, values, spec, depth, buf): for i, subspec in enumerate(_split_tuple_elements(spec[6:-1])): sub_values = [row[i] for row in values] if subspec.startswith("JSON"): paths = self._unfold_json(sub_values, depth=depth) self._write_values(paths, len(sub_values), buf, depth=depth) elif subspec.startswith("Tuple"): if "JSON" in subspec: self._write_complex_tuple_values( sub_values, subspec, depth, buf) else: writer = self.column_by_spec_getter(subspec) writer.write_items(sub_values, buf) elif subspec.startswith("Array"): if "JSON" in subspec: self._write_complex_array_values( sub_values, subspec, depth, buf) else: insert = self._preprocess_array(sub_values, subspec[6:-1]) writer = self.column_by_spec_getter(subspec) writer.write_data(insert, buf) else: # Simple element, always wrapped in Nullable by # _get_json_value_spec; its writer emits the null map and # values columnar-style across every row. writer = self.column_by_spec_getter(subspec) writer.write_data(sub_values, buf) def _write_complex_array_values(self, values, spec, depth, buf): bound = 0 for v in values: bound = bound + len(v) write_binary_uint64(bound, buf) items = [] for item in values: items += item inner = spec[6:-1] # strip "Array(" ... ")" if inner.startswith("Tuple"): self._write_complex_tuple_values(items, inner, depth, buf) elif inner.startswith("Array"): self._write_complex_array_values(items, inner, depth, buf) else: # Array(JSON) paths = self._unfold_json(items, depth=depth) self._write_values(paths, len(items), buf, depth=depth) def _get_json_value_spec(self, item, depth): """Infer the ClickHouse column spec for a Python value being inserted into a JSON column. ``depth`` shrinks the per-level ``max_dynamic_types`` / ``max_dynamic_paths`` budgets so nested dicts stay within server limits.""" if isinstance(item, int) and not isinstance(item, bool): return "Int64" elif isinstance(item, float): return "Float64" elif isinstance(item, str): return "String" elif isinstance(item, bool): return "Bool" elif isinstance(item, dict): max_types = int(2 ** (4 - depth)) max_paths = int(4 ** (4 - depth)) return ( "JSON(max_dynamic_types={}, " "max_dynamic_paths={})".format(max_types, max_paths) ) elif isinstance(item, list): value_types = [] for entry in item: t = type(entry) if t not in value_types: value_types.append(t) if dict in value_types or list in value_types: result = "Tuple(" unique_specs = [] for entry in item: spec = self._get_json_value_spec(entry, depth) if (not spec.startswith("Array") and not spec.startswith("Tuple") and not spec.startswith("JSON")): result += "Nullable({}), ".format(spec) else: result += "{}, ".format(spec) if spec not in unique_specs: unique_specs.append(spec) if len(unique_specs) == 1: inner = self._get_json_value_spec(item[0], depth=depth) return "Array({})".format(inner) result = result[:-2] + ")" return result else: if str in value_types: return "Array(Nullable(String))" elif float in value_types: if bool not in value_types: return "Array(Nullable(Float64))" else: return "Array(Nullable(String))" elif int in value_types: return "Array(Nullable(Int64))" elif bool in value_types: return "Array(Nullable(Bool))" else: return "Array(Nullable(String))" elif item is None: return "String" def _get_row_positions(self, col, row_count): # Compute each row's global discriminator. ``DataTypeVariant`` # sorts its variant list (which includes the implicit # ``SharedVariant``) by ``getName()`` alphabetically; the global # discriminator index is each variant's position in that sort. sorted_with_shared = sorted( list(col.keys()) + [SHARED_VARIANT_NAME]) spec_to_discriminator = { spec: i for i, spec in enumerate(sorted_with_shared) } result = [255] * row_count for spec, data in col.items(): disc = spec_to_discriminator[spec] for pos in data["positions"]: result[pos] = disc return bytes(result) def _normalize_json(self, obj,): """Flatten a nested dict into a dict of dotted-path leaves, e.g. ``{"a": {"b": 1}}`` → ``{"a.b": 1}``. Each non-dict leaf is returned as ``{"": leaf}`` so callers can compose keys.""" if isinstance(obj, dict): result = {} for k in obj: if obj[k] is not None: obj_res = self._normalize_json(obj[k]) for obj_k in obj_res: result["{}.{}".format(k, obj_k)] = obj_res[obj_k] return result else: return {"": obj} def _unfold_json_item(self, obj, depth, result=None, row_count=0): """Fold one row into the intermediary ``{path: {spec: {values: [...], positions: [...]}}}`` layout that the write path emits to the wire.""" if result is None: result = {} for k in obj: if obj[k] is not None: obj_res = self._normalize_json(obj[k]) for obj_k in obj_res: key = "{}.{}".format(k, obj_k) if key not in result: result[key] = {} spec = self._get_json_value_spec(obj_res[obj_k], depth) if spec not in result[key]: result[key][spec] = { "values": [], "positions": []} result[key][spec]["values"].append(obj_res[obj_k]) result[key][spec]["positions"].append(row_count) return result def _unfold_json(self, items, depth): """Build the intermediary layout for a whole INSERT block by unfolding every input row and sorting paths/specs so the on-wire order matches the server's alphabetical expectation.""" result = {} for row, obj in enumerate(items): result = self._unfold_json_item(obj, depth, result, row) for k in list(result.keys()): result[k[:-1]] = dict(sorted(result[k].items())) del result[k] result = dict(sorted(result.items())) return result def _preprocess_array(self, values, array_type): insert = [] if array_type.startswith("Array"): for item in values: insert.append( self._preprocess_array(item, array_type[6:-1])) return insert if "String" in array_type: for item in values: arr = [] for elem in item: if isinstance(elem, str): arr.append(elem) elif isinstance(elem, bool): arr.append(str(elem).lower()) elif elem is None: arr.append(None) else: arr.append(str(elem)) insert.append(arr) elif "Int64" in array_type: for item in values: arr = [] for elem in item: if elem is None: arr.append(0) else: arr.append(int(elem)) insert.append(arr) elif "Float64" in array_type: for item in values: arr = [] for elem in item: if elem is None: arr.append(0) else: arr.append(float(elem)) insert.append(arr) elif "Bool" in array_type: for item in values: arr = [] for elem in item: if elem is not None: arr.append(bool(elem)) insert.append(arr) else: insert = values return insert # Container types that need recursion in ``_tuples_to_lists``; scalars # (most JSON leaves) short-circuit at the boundary. _TUPLE_TO_LIST_CONTAINERS = (dict, tuple, list) def _tuples_to_lists(value): """ Normalise the Python types a JSON value comes back as. ``Array`` values arrive as lists already; ``Tuple`` values arrive as tuples from :class:`TupleColumn`. The rule below preserves that distinction except when a tuple contains a ``dict`` — those came from a ``Tuple(..., JSON, ...)`` and the user-facing shape has always been a list. Changing it would be an API break for anyone relying on this column today. """ if not isinstance(value, _TUPLE_TO_LIST_CONTAINERS): return value return _tuples_to_lists_inner(value)[0] def _tuples_to_lists_inner(value): """Single-pass transform that also reports whether the result has a ``dict`` anywhere inside, so callers can decide whether a parent tuple should be coerced to a list without re-walking the tree.""" if isinstance(value, dict): out = {} for k, v in value.items(): if isinstance(v, _TUPLE_TO_LIST_CONTAINERS): out[k] = _tuples_to_lists_inner(v)[0] else: out[k] = v return out, True if isinstance(value, (tuple, list)): items = [] has_dict = False for v in value: if isinstance(v, _TUPLE_TO_LIST_CONTAINERS): sub, sub_has_dict = _tuples_to_lists_inner(v) items.append(sub) if sub_has_dict: has_dict = True else: items.append(v) if isinstance(value, list) or has_dict: return items, has_dict return tuple(items), False def create_newjson_column(spec, column_by_spec_getter, column_options): return NewJsonColumn(column_by_spec_getter, **column_options) clickhouse-driver-0.2.11/clickhouse_driver/columns/nothingcolumn.py000066400000000000000000000004031522645447600256530ustar00rootroot00000000000000from .intcolumn import FormatColumn class NothingColumn(FormatColumn): ch_type = 'Nothing' format = 'B' @property def size(self): return 1 def after_read_items(self, items, nulls_map=None): return (None, ) * len(items) clickhouse-driver-0.2.11/clickhouse_driver/columns/nullablecolumn.py000066400000000000000000000002511522645447600260040ustar00rootroot00000000000000 def create_nullable_column(spec, column_by_spec_getter): inner = spec[9:-1] nested = column_by_spec_getter(inner) nested.nullable = True return nested clickhouse-driver-0.2.11/clickhouse_driver/columns/nullcolumn.py000066400000000000000000000005131522645447600251610ustar00rootroot00000000000000from .intcolumn import FormatColumn # TODO: Drop Null column support in future. # Compatibility with old servers. class NullColumn(FormatColumn): ch_type = 'Null' format = 'B' @property def size(self): return 1 def after_read_items(self, items, nulls_map=None): return (None, ) * len(items) clickhouse-driver-0.2.11/clickhouse_driver/columns/numpy/000077500000000000000000000000001522645447600235705ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/columns/numpy/__init__.py000066400000000000000000000000001522645447600256670ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/columns/numpy/base.py000066400000000000000000000032461522645447600250610ustar00rootroot00000000000000import numpy as np import pandas as pd from ..base import Column class NumpyColumn(Column): dtype = None normalize_null_value = True def read_items(self, n_items, buf): data = buf.read(n_items * self.dtype.itemsize) return np.frombuffer(data, self.dtype.newbyteorder('<'), n_items) def write_items(self, items, buf): buf.write(items.astype(self.dtype.newbyteorder('<')).tobytes()) def _write_nulls_map(self, items, buf): s = self.make_null_struct(len(items)) nulls_map = self._get_nulls_map(items) buf.write(s.pack(*nulls_map)) def _get_nulls_map(self, items): return [bool(x) for x in pd.isnull(items)] def _read_nulls_map(self, n_items, buf): # One byte per item on the wire. Vectorized read: consumers # (np.place, np.ma.MaskedArray) treat non-zero bytes as True. return np.frombuffer(buf.read(n_items), dtype=np.uint8, count=n_items) def _read_data(self, n_items, buf, nulls_map=None): items = self.read_items(n_items, buf) if self.after_read_items: return self.after_read_items(items, nulls_map) elif nulls_map is not None: items = np.array(items, dtype=object) np.place(items, nulls_map, None) return items def prepare_items(self, items): nulls_map = pd.isnull(items) # Always replace null values to null_value for proper inserts into # non-nullable columns. if isinstance(items, np.ndarray) and self.normalize_null_value: items = np.array(items) np.place(items, nulls_map, self.null_value) return items clickhouse-driver-0.2.11/clickhouse_driver/columns/numpy/boolcolumn.py000066400000000000000000000002141522645447600263100ustar00rootroot00000000000000import numpy as np from .base import NumpyColumn class NumpyBoolColumn(NumpyColumn): dtype = np.dtype(np.bool_) ch_type = 'Bool' clickhouse-driver-0.2.11/clickhouse_driver/columns/numpy/datecolumn.py000066400000000000000000000007421522645447600263000ustar00rootroot00000000000000import numpy as np from .base import NumpyColumn class NumpyDateColumn(NumpyColumn): dtype = np.dtype(np.uint16) ch_type = 'Date' null_value = np.datetime64(0, 'Y') def read_items(self, n_items, buf): data = super(NumpyDateColumn, self).read_items(n_items, buf) return data.astype('datetime64[D]') def write_items(self, items, buf): super(NumpyDateColumn, self).write_items( items.astype('datetime64[D]'), buf ) clickhouse-driver-0.2.11/clickhouse_driver/columns/numpy/datetimecolumn.py000066400000000000000000000116361522645447600271630ustar00rootroot00000000000000import numpy as np import pandas as pd from pytz import timezone as get_timezone from .base import NumpyColumn from ...util.compat import get_localzone_name_compat class NumpyDateTimeColumnBase(NumpyColumn): datetime_dtype = None null_value = np.datetime64(0, 'Y') def __init__(self, timezone=None, offset_naive=True, local_timezone=None, **kwargs): self.timezone = timezone self.offset_naive = offset_naive self.local_timezone = local_timezone super(NumpyDateTimeColumnBase, self).__init__(**kwargs) def apply_timezones_after_read(self, dt): timezone = self.timezone if self.timezone else self.local_timezone if self.offset_naive and timezone.zone != 'UTC': ts = pd.to_datetime(dt, utc=True).tz_convert(timezone) ts = ts.tz_localize(None) return ts.to_numpy(self.datetime_dtype) return dt def apply_timezones_before_write(self, items): if isinstance(items, pd.DatetimeIndex): ts = items else: timezone = self.timezone if self.timezone else self.local_timezone ts = pd.to_datetime(items) if not getattr(ts.dtype, 'tz', None): ts = ts.tz_localize(timezone) ts = ts.tz_convert('UTC') return ts.tz_localize(None).to_numpy(self.datetime_dtype) def is_items_integer(self, items): return ( isinstance(items, np.ndarray) and np.issubdtype(items.dtype, np.integer) ) class NumpyDateTimeColumn(NumpyDateTimeColumnBase): dtype = np.dtype(np.uint32) datetime_dtype = 'datetime64[s]' def write_items(self, items, buf): # write int 'as is'. if self.is_items_integer(items): super(NumpyDateTimeColumn, self).write_items(items, buf) return items = self.apply_timezones_before_write(items) super(NumpyDateTimeColumn, self).write_items(items, buf) def read_items(self, n_items, buf): items = super(NumpyDateTimeColumn, self).read_items(n_items, buf) return self.apply_timezones_after_read(items.astype('datetime64[s]')) class NumpyDateTime64Column(NumpyDateTimeColumnBase): dtype = np.dtype(np.int64) datetime_dtype = 'datetime64[ns]' max_scale = 9 def __init__(self, scale=0, **kwargs): self.scale = scale super(NumpyDateTime64Column, self).__init__(**kwargs) def read_items(self, n_items, buf): # Clickhouse: t seconds is represented as t * 10^scale. # datetime64[ns]: t seconds is represented as t * 10^9. # Since 0 <= scale <= 9, multiply by the integer 10^(9 - scale). items = super(NumpyDateTime64Column, self).read_items(n_items, buf) tmp = np.copy(items) tmp *= 10 ** (9 - self.scale) dt = tmp.view(dtype='datetime64[ns]') return self.apply_timezones_after_read(dt) def write_items(self, items, buf): # write int 'as is'. if self.is_items_integer(items): super(NumpyDateTime64Column, self).write_items(items, buf) return scale = 10 ** self.scale frac_scale = 10 ** (self.max_scale - self.scale) items = self.apply_timezones_before_write(items) seconds = items.astype('datetime64[s]') microseconds = (items - seconds).astype(dtype='timedelta64[ns]') \ .astype(np.uint32) // frac_scale items = seconds.astype(self.dtype) * scale + microseconds super(NumpyDateTime64Column, self).write_items(items, buf) def create_numpy_datetime_column(spec, column_options, column_classes=None): datetime_column, datetime64_column = column_classes or ( NumpyDateTimeColumn, NumpyDateTime64Column ) if spec.startswith('DateTime64'): cls = datetime64_column spec = spec[11:-1] params = spec.split(',', 1) column_options['scale'] = int(params[0]) if len(params) > 1: spec = params[1].strip() + ')' else: cls = datetime_column spec = spec[9:] context = column_options['context'] tz_name = None offset_naive = True # As Numpy do not use local timezone for converting timestamp to # datetime we need always detect local timezone for manual converting. local_tz_name = get_localzone_name_compat() # Use column's timezone if it's specified. if spec and spec[-1] == ')': tz_name = spec[1:-2] offset_naive = False else: if not context.settings.get('use_client_time_zone', False): remote_timezone = context.server_info.get_timezone() if local_tz_name != remote_timezone: tz_name = remote_timezone timezone = get_timezone(tz_name) if tz_name else None local_timezone = get_timezone(local_tz_name) if local_tz_name else None return cls(timezone=timezone, offset_naive=offset_naive, local_timezone=local_timezone, **column_options) clickhouse-driver-0.2.11/clickhouse_driver/columns/numpy/floatcolumn.py000066400000000000000000000011271522645447600264660ustar00rootroot00000000000000import numpy as np from .base import NumpyColumn # normalize_null_value = False due to float('nan') # With normalization pandas.isnull will threat float('nan') as NULL value. class NumpyFloat32Column(NumpyColumn): dtype = np.dtype(np.float32) ch_type = 'Float32' normalize_null_value = False def _get_nulls_map(self, items): return [x is None for x in items] class NumpyFloat64Column(NumpyColumn): dtype = np.dtype(np.float64) ch_type = 'Float64' normalize_null_value = False def _get_nulls_map(self, items): return [x is None for x in items] clickhouse-driver-0.2.11/clickhouse_driver/columns/numpy/intcolumn.py000066400000000000000000000014301522645447600261500ustar00rootroot00000000000000import numpy as np from .base import NumpyColumn class NumpyInt8Column(NumpyColumn): dtype = np.dtype(np.int8) ch_type = 'Int8' class NumpyUInt8Column(NumpyColumn): dtype = np.dtype(np.uint8) ch_type = 'UInt8' class NumpyInt16Column(NumpyColumn): dtype = np.dtype(np.int16) ch_type = 'Int16' class NumpyUInt16Column(NumpyColumn): dtype = np.dtype(np.uint16) ch_type = 'UInt16' class NumpyInt32Column(NumpyColumn): dtype = np.dtype(np.int32) ch_type = 'Int32' class NumpyUInt32Column(NumpyColumn): dtype = np.dtype(np.uint32) ch_type = 'UInt32' class NumpyInt64Column(NumpyColumn): dtype = np.dtype(np.int64) ch_type = 'Int64' class NumpyUInt64Column(NumpyColumn): dtype = np.dtype(np.uint64) ch_type = 'UInt64' clickhouse-driver-0.2.11/clickhouse_driver/columns/numpy/lowcardinalitycolumn.py000066400000000000000000000064501522645447600304120ustar00rootroot00000000000000from math import log import numpy as np import pandas as pd from ..lowcardinalitycolumn import LowCardinalityColumn from ...reader import read_binary_uint64 from ...writer import write_binary_int64 from .intcolumn import ( NumpyUInt8Column, NumpyUInt16Column, NumpyUInt32Column, NumpyUInt64Column ) class NumpyLowCardinalityColumn(LowCardinalityColumn): int_types = { 0: NumpyUInt8Column, 1: NumpyUInt16Column, 2: NumpyUInt32Column, 3: NumpyUInt64Column } def __init__(self, nested_column, **kwargs): super(NumpyLowCardinalityColumn, self).__init__(nested_column, **kwargs) def _write_data(self, items, buf): # Do not write anything for empty column. # May happen while writing empty arrays. if not len(items): return # Replace nans with defaults if not nullabe. if isinstance(items, np.ndarray) and not self.nested_column.nullable: nulls = pd.isnull(items) items = np.where(nulls, self.nested_column.null_value, items) c = pd.Categorical(items) int_type = int(log(len(c.codes), 2) / 8) int_column = self.int_types[int_type](**self.init_kwargs) serialization_type = self.serialization_type | int_type index = c.categories keys = c.codes if self.nested_column.nullable: # First element represents NULL if column is nullable. index = index.insert(0, self.nested_column.null_value) keys = keys + 1 # Prevent null map writing. Reset nested column nullable flag. self.nested_column.nullable = False write_binary_int64(serialization_type, buf) write_binary_int64(len(index), buf) self.nested_column.write_data(index.to_numpy(items.dtype), buf) write_binary_int64(len(items), buf) int_column.write_items(keys, buf) def _read_data(self, n_items, buf, nulls_map=None): if not n_items: return tuple() serialization_type = read_binary_uint64(buf) # Lowest byte contains info about key type. key_type = serialization_type & 0xf keys_column = self.int_types[key_type](**self.init_kwargs) nullable = self.nested_column.nullable # Prevent null map reading. Reset nested column nullable flag. self.nested_column.nullable = False index_size = read_binary_uint64(buf) index = self.nested_column.read_data(index_size, buf) read_binary_uint64(buf) # number of keys keys = keys_column.read_data(n_items, buf) if nullable: # Shift all codes by one ("No value" code is -1 for pandas # categorical) and drop corresponding first index # this is analog of original operation: # index = (None, ) + index[1:] keys = np.array(keys, dtype='int64') # deal with possible overflow keys = keys - 1 index = index[1:] return pd.Categorical.from_codes(keys, index) def create_numpy_low_cardinality_column(spec, column_by_spec_getter, column_options): inner = spec[15:-1] nested = column_by_spec_getter(inner) return NumpyLowCardinalityColumn(nested, **column_options) clickhouse-driver-0.2.11/clickhouse_driver/columns/numpy/service.py000066400000000000000000000041161522645447600256040ustar00rootroot00000000000000from ..service import aliases from ... import errors from .datecolumn import NumpyDateColumn from .datetimecolumn import create_numpy_datetime_column from .floatcolumn import NumpyFloat32Column, NumpyFloat64Column from .intcolumn import ( NumpyInt8Column, NumpyInt16Column, NumpyInt32Column, NumpyInt64Column, NumpyUInt8Column, NumpyUInt16Column, NumpyUInt32Column, NumpyUInt64Column ) from .boolcolumn import NumpyBoolColumn from .lowcardinalitycolumn import create_numpy_low_cardinality_column from .stringcolumn import create_string_column from .tuplecolumn import create_tuple_column from ..nullablecolumn import create_nullable_column column_by_type = {c.ch_type: c for c in [ NumpyDateColumn, NumpyFloat32Column, NumpyFloat64Column, NumpyInt8Column, NumpyInt16Column, NumpyInt32Column, NumpyInt64Column, NumpyUInt8Column, NumpyUInt16Column, NumpyUInt32Column, NumpyUInt64Column, NumpyBoolColumn ]} def get_numpy_column_by_spec(spec, column_options): def create_column_with_options(x): return get_numpy_column_by_spec(x, column_options) if spec == 'String' or spec.startswith('FixedString'): return create_string_column(spec, column_options) elif spec.startswith('DateTime'): return create_numpy_datetime_column(spec, column_options) elif spec.startswith('Tuple'): return create_tuple_column( spec, create_column_with_options, column_options ) elif spec.startswith('Nullable'): return create_nullable_column(spec, create_column_with_options) elif spec.startswith('LowCardinality'): return create_numpy_low_cardinality_column( spec, create_column_with_options, column_options ) else: for alias, primitive in aliases: if spec.startswith(alias): return create_column_with_options( primitive + spec[len(alias):] ) if spec in column_by_type: cls = column_by_type[spec] return cls(**column_options) raise errors.UnknownTypeError('Unknown type {}'.format(spec)) clickhouse-driver-0.2.11/clickhouse_driver/columns/numpy/stringcolumn.py000066400000000000000000000046071522645447600266750ustar00rootroot00000000000000import numpy as np from ... import defines from .base import NumpyColumn class NumpyStringColumn(NumpyColumn): null_value = '' default_encoding = defines.STRINGS_ENCODING def __init__(self, encoding=default_encoding, **kwargs): self.encoding = encoding super(NumpyStringColumn, self).__init__(**kwargs) def read_items(self, n_items, buf): return np.array( buf.read_strings(n_items, encoding=self.encoding), dtype=self.dtype ) def write_items(self, items, buf): return buf.write_strings(items.tolist(), encoding=self.encoding) class NumpyByteStringColumn(NumpyColumn): null_value = b'' def read_items(self, n_items, buf): return np.array(buf.read_strings(n_items), dtype=self.dtype) def write_items(self, items, buf): return buf.write_strings(items.tolist()) class NumpyFixedString(NumpyStringColumn): def __init__(self, length, **kwargs): self.length = length super(NumpyFixedString, self).__init__(**kwargs) def read_items(self, n_items, buf): return np.array(buf.read_fixed_strings( n_items, self.length, encoding=self.encoding ), dtype=self.dtype) def write_items(self, items, buf): return buf.write_fixed_strings( items.tolist(), self.length, encoding=self.encoding ) class NumpyByteFixedString(NumpyByteStringColumn): def __init__(self, length, **kwargs): self.length = length super(NumpyByteFixedString, self).__init__(**kwargs) def read_items(self, n_items, buf): return np.array( buf.read_fixed_strings(n_items, self.length), dtype=self.dtype ) def write_items(self, items, buf): return buf.write_fixed_strings(items.tolist(), self.length) def create_string_column(spec, column_options): client_settings = column_options['context'].client_settings strings_as_bytes = client_settings['strings_as_bytes'] encoding = client_settings.get( 'strings_encoding', NumpyStringColumn.default_encoding ) if spec == 'String': cls = NumpyByteStringColumn if strings_as_bytes else NumpyStringColumn return cls(encoding=encoding, **column_options) else: length = int(spec[12:-1]) cls = NumpyByteFixedString if strings_as_bytes else NumpyFixedString return cls(length, encoding=encoding, **column_options) clickhouse-driver-0.2.11/clickhouse_driver/columns/numpy/tuplecolumn.py000066400000000000000000000023211522645447600265070ustar00rootroot00000000000000import numpy as np from .base import NumpyColumn from ..util import get_inner_spec, get_inner_columns class TupleColumn(NumpyColumn): def __init__(self, nested_columns, **kwargs): self.nested_columns = nested_columns super(TupleColumn, self).__init__(**kwargs) def write_data(self, items, buf): names = items.dtype.names for i, (x, name) in enumerate(zip(self.nested_columns, names)): x.write_data(items[name], buf) def write_items(self, items, buf): return self.write_data(items, buf) def read_data(self, n_items, buf): data = [x.read_data(n_items, buf) for x in self.nested_columns] dtype = [('f{}'.format(i), x.dtype) for i, x in enumerate(data)] rv = np.empty(n_items, dtype=dtype) for i, x in enumerate(data): rv['f{}'.format(i)] = x return rv def read_items(self, n_items, buf): return self.read_data(n_items, buf) def create_tuple_column(spec, column_by_spec_getter, column_options): inner_spec = get_inner_spec('Tuple', spec) columns = get_inner_columns(inner_spec) return TupleColumn([column_by_spec_getter(x) for x in columns], **column_options) clickhouse-driver-0.2.11/clickhouse_driver/columns/service.py000066400000000000000000000151651522645447600244420ustar00rootroot00000000000000import logging from .. import errors from .arraycolumn import create_array_column from .boolcolumn import BoolColumn from .datecolumn import DateColumn, Date32Column from .datetimecolumn import create_datetime_column from .decimalcolumn import create_decimal_column from . import exceptions as column_exceptions from .enumcolumn import create_enum_column from .floatcolumn import Float32Column, Float64Column from .intcolumn import ( Int8Column, Int16Column, Int32Column, Int64Column, Int128Column, UInt128Column, Int256Column, UInt256Column, UInt8Column, UInt16Column, UInt32Column, UInt64Column ) from .lowcardinalitycolumn import create_low_cardinality_column from .jsoncolumn import create_json_column from .newjsoncolumn import create_newjson_column from .mapcolumn import create_map_column from .nothingcolumn import NothingColumn from .nullcolumn import NullColumn from .nullablecolumn import create_nullable_column from .simpleaggregatefunctioncolumn import ( create_simple_aggregate_function_column ) from .stringcolumn import create_string_column from .tuplecolumn import create_tuple_column from .nestedcolumn import create_nested_column from .uuidcolumn import UUIDColumn from .intervalcolumn import ( IntervalYearColumn, IntervalMonthColumn, IntervalWeekColumn, IntervalDayColumn, IntervalHourColumn, IntervalMinuteColumn, IntervalSecondColumn ) from .ipcolumn import IPv4Column, IPv6Column column_by_type = {c.ch_type: c for c in [ DateColumn, Date32Column, Float32Column, Float64Column, Int8Column, Int16Column, Int32Column, Int64Column, Int128Column, UInt128Column, Int256Column, UInt256Column, UInt8Column, UInt16Column, UInt32Column, UInt64Column, NothingColumn, NullColumn, UUIDColumn, IntervalYearColumn, IntervalMonthColumn, IntervalWeekColumn, IntervalDayColumn, IntervalHourColumn, IntervalMinuteColumn, IntervalSecondColumn, IPv4Column, IPv6Column, BoolColumn ]} logger = logging.getLogger(__name__) aliases = [ # Begin Geo types ('Point', 'Tuple(Float64, Float64)'), ('Ring', 'Array(Point)'), ('Polygon', 'Array(Ring)'), ('MultiPolygon', 'Array(Polygon)') # End Geo types ] def get_column_by_spec(spec, column_options, use_numpy=None): context = column_options['context'] if use_numpy is None: use_numpy = context.client_settings['use_numpy'] if context else False if use_numpy: # Arrow queries use NumPy-derived columns tuned for zero-copy # Arrow assembly (see columns/arrow/). use_arrow = context.client_settings.get('use_arrow', False) \ if context else False try: if use_arrow: from .arrow.service import get_arrow_column_by_spec return get_arrow_column_by_spec(spec, column_options) from .numpy.service import get_numpy_column_by_spec return get_numpy_column_by_spec(spec, column_options) except errors.UnknownTypeError: use_numpy = False logger.warning('NumPy support is not implemented for %s. ' 'Using generic column', spec) def create_column_with_options(x): return get_column_by_spec(x, column_options, use_numpy=use_numpy) if spec == 'String' or spec.startswith('FixedString'): return create_string_column(spec, column_options) elif spec.startswith('Enum'): return create_enum_column(spec, column_options) elif spec.startswith('DateTime'): return create_datetime_column(spec, column_options) elif spec.startswith('Decimal'): return create_decimal_column(spec, column_options) elif spec.startswith('Array'): return create_array_column( spec, create_column_with_options, column_options ) elif spec.startswith('Tuple'): return create_tuple_column( spec, create_column_with_options, column_options ) elif spec.startswith('Nested'): return create_nested_column( spec, create_column_with_options, column_options ) elif spec.startswith('Nullable'): return create_nullable_column(spec, create_column_with_options) elif spec.startswith('LowCardinality'): return create_low_cardinality_column( spec, create_column_with_options, column_options ) elif spec.startswith('SimpleAggregateFunction'): return create_simple_aggregate_function_column( spec, create_column_with_options ) elif spec.startswith('Map'): return create_map_column( spec, create_column_with_options, column_options ) elif spec.startswith("Object('json')"): return create_json_column( spec, create_column_with_options, column_options ) elif spec.startswith("JSON"): return create_newjson_column( spec, create_column_with_options, column_options ) else: for alias, primitive in aliases: if spec.startswith(alias): return create_column_with_options( primitive + spec[len(alias):] ) try: cls = column_by_type[spec] return cls(**column_options) except KeyError: raise errors.UnknownTypeError('Unknown type {}'.format(spec)) def read_column(context, column_spec, n_items, buf, use_numpy=None, has_custom_serialization=False): column_options = { 'context': context, 'has_custom_serialization': has_custom_serialization } col = get_column_by_spec(column_spec, column_options, use_numpy=use_numpy) col.read_state_prefix(buf) return col.read_data(n_items, buf) def write_column(context, column_name, column_spec, items, buf, types_check=False): column_options = { 'context': context, 'types_check': types_check } column = get_column_by_spec(column_spec, column_options) try: column.write_state_prefix(buf, items) column.write_data(items, buf) except column_exceptions.ColumnTypeMismatchException as e: raise errors.TypeMismatchError( 'Type mismatch in VALUES section. ' 'Expected {} got {}: {} for column "{}".'.format( column_spec, type(e.args[0]), e.args[0], column_name ) ) except (column_exceptions.StructPackException, OverflowError) as e: error = e.args[0] raise errors.TypeMismatchError( 'Type mismatch in VALUES section. ' 'Repeat query with types_check=True for detailed info. ' 'Column {}: {}'.format( column_name, str(error) ) ) clickhouse-driver-0.2.11/clickhouse_driver/columns/simpleaggregatefunctioncolumn.py000066400000000000000000000003531522645447600311170ustar00rootroot00000000000000 def create_simple_aggregate_function_column(spec, column_by_spec_getter): # SimpleAggregateFunction(Func, Type) -> Type inner = spec[24:-1].split(',', 1)[1].strip() nested = column_by_spec_getter(inner) return nested clickhouse-driver-0.2.11/clickhouse_driver/columns/stringcolumn.py000066400000000000000000000040131522645447600255140ustar00rootroot00000000000000 from .. import defines from .base import Column class String(Column): ch_type = 'String' py_types = (str, ) null_value = '' default_encoding = defines.STRINGS_ENCODING def __init__(self, encoding=default_encoding, **kwargs): self.encoding = encoding super(String, self).__init__(**kwargs) def write_items(self, items, buf): buf.write_strings(items, encoding=self.encoding) def read_items(self, n_items, buf): return buf.read_strings(n_items, encoding=self.encoding) class ByteString(String): py_types = (bytes, ) null_value = b'' def write_items(self, items, buf): buf.write_strings(items) def read_items(self, n_items, buf): return buf.read_strings(n_items) class FixedString(String): ch_type = 'FixedString' def __init__(self, length, **kwargs): self.length = length super(FixedString, self).__init__(**kwargs) def read_items(self, n_items, buf): return buf.read_fixed_strings( n_items, self.length, encoding=self.encoding ) def write_items(self, items, buf): buf.write_fixed_strings(items, self.length, encoding=self.encoding) class ByteFixedString(FixedString): py_types = (bytearray, bytes) null_value = b'' def read_items(self, n_items, buf): return buf.read_fixed_strings(n_items, self.length) def write_items(self, items, buf): buf.write_fixed_strings(items, self.length) def create_string_column(spec, column_options): client_settings = column_options['context'].client_settings strings_as_bytes = client_settings['strings_as_bytes'] encoding = client_settings.get('strings_encoding', String.default_encoding) if spec == 'String': cls = ByteString if strings_as_bytes else String return cls(encoding=encoding, **column_options) else: length = int(spec[12:-1]) cls = ByteFixedString if strings_as_bytes else FixedString return cls(length, encoding=encoding, **column_options) clickhouse-driver-0.2.11/clickhouse_driver/columns/tuplecolumn.py000066400000000000000000000044401522645447600253430ustar00rootroot00000000000000 from .base import Column from .util import get_inner_spec, get_inner_columns_with_types class TupleColumn(Column): py_types = (list, tuple) def __init__(self, names, nested_columns, **kwargs): self.names = names self.nested_columns = nested_columns client_settings = kwargs['context'].client_settings settings = kwargs['context'].settings self.namedtuple_as_json = ( settings.get('allow_experimental_object_type', False) and client_settings.get('namedtuple_as_json', True) ) super(TupleColumn, self).__init__(**kwargs) self.null_value = tuple(x.null_value for x in nested_columns) self.prefix_needs_items = any( x.prefix_needs_items for x in nested_columns ) def write_data(self, items, buf): items = self.prepare_items(items) items = list(zip(*items)) for i, x in enumerate(self.nested_columns): x.write_data(list(items[i]), buf) def write_items(self, items, buf): return self.write_data(items, buf) def read_data(self, n_items, buf): rv = [x.read_data(n_items, buf) for x in self.nested_columns] rv = list(zip(*rv)) if self.names[0] and self.namedtuple_as_json: return [dict(zip(self.names, x)) for x in rv] else: return rv def read_items(self, n_items, buf): return self.read_data(n_items, buf) def read_state_prefix(self, buf): super(TupleColumn, self).read_state_prefix(buf) for x in self.nested_columns: x.read_state_prefix(buf) def write_state_prefix(self, buf, items=None): super(TupleColumn, self).write_state_prefix(buf) for i, x in enumerate(self.nested_columns): nested_items = None if items is not None and x.prefix_needs_items: nested_items = [item[i] for item in items] x.write_state_prefix(buf, nested_items) def create_tuple_column(spec, column_by_spec_getter, column_options): inner_spec = get_inner_spec('Tuple', spec) columns_with_types = get_inner_columns_with_types(inner_spec) names, types = zip(*columns_with_types) return TupleColumn(names, [column_by_spec_getter(x) for x in types], **column_options) clickhouse-driver-0.2.11/clickhouse_driver/columns/util.py000066400000000000000000000026231522645447600237520ustar00rootroot00000000000000 def get_inner_spec(column_name, spec): brackets = 0 offset = len(column_name) i = offset for i, ch in enumerate(spec[offset:], offset): if ch == '(': brackets += 1 elif ch == ')': brackets -= 1 if brackets == 0: break return spec[offset + 1:i] def get_inner_columns(spec): brackets = 0 column_begin = 0 columns = [] for i, x in enumerate(spec + ','): if x == ',': if brackets == 0: columns.append(spec[column_begin:i]) column_begin = i + 1 elif x == '(': brackets += 1 elif x == ')': brackets -= 1 elif x == ' ': if brackets == 0: column_begin = i + 1 return columns def get_inner_columns_with_types(spec): spec = spec.strip() brackets = 0 prev_comma = 0 prev_space = 0 columns = [] for i, x in enumerate(spec.strip() + ','): if x == ',': if brackets == 0: columns.append(( spec[prev_comma:prev_space].strip(), spec[prev_space:i] )) prev_comma = i + 1 elif x == '(': brackets += 1 elif x == ')': brackets -= 1 elif x == ' ': if brackets == 0: prev_space = i + 1 return columns clickhouse-driver-0.2.11/clickhouse_driver/columns/uuidcolumn.py000066400000000000000000000035111522645447600251560ustar00rootroot00000000000000from uuid import UUID from .base import FormatColumn from .. import errors from ..writer import MAX_UINT64 class UUIDColumn(FormatColumn): ch_type = 'UUID' py_types = (str, UUID) format = 'Q' # UUID is stored by two uint64 numbers. def write_items(self, items, buf): n_items = len(items) uint_64_pairs = [None] * 2 * n_items for i, x in enumerate(items): i2 = 2 * i uint_64_pairs[i2] = (x >> 64) & MAX_UINT64 uint_64_pairs[i2 + 1] = x & MAX_UINT64 s = self.make_struct(2 * n_items) buf.write(s.pack(*uint_64_pairs)) def read_items(self, n_items, buf): # TODO: cythonize s = self.make_struct(2 * n_items) items = s.unpack(buf.read(s.size)) uint_128_items = [None] * n_items for i in range(n_items): i2 = 2 * i uint_128_items[i] = (items[i2] << 64) + items[i2 + 1] return tuple(uint_128_items) def after_read_items(self, items, nulls_map=None): if nulls_map is None: return tuple(UUID(int=item) for item in items) else: return tuple( (None if is_null else UUID(int=items[i])) for i, is_null in enumerate(nulls_map) ) def before_write_items(self, items, nulls_map=None): null_value = self.null_value for i, item in enumerate(items): if nulls_map and nulls_map[i]: items[i] = null_value continue try: if not isinstance(item, UUID): item = UUID(int=item) if item is null_value else UUID(item) except ValueError: raise errors.CannotParseUuidError( "Cannot parse uuid '{}'".format(item) ) items[i] = item.int clickhouse-driver-0.2.11/clickhouse_driver/compression/000077500000000000000000000000001522645447600233015ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/compression/__init__.py000066400000000000000000000015101522645447600254070ustar00rootroot00000000000000import importlib import logging from .. import errors from ..protocol import CompressionMethodByte logger = logging.getLogger(__name__) def get_compressor_cls(alg): try: module = importlib.import_module('.' + alg, __name__) return module.Compressor except ImportError: logger.warning('Unable to import module %s', alg, exc_info=True) raise errors.UnknownCompressionMethod( "Unknown compression method: '{}'".format(alg) ) def get_decompressor_cls(method_type): if method_type == CompressionMethodByte.LZ4: module = importlib.import_module('.lz4', __name__) elif method_type == CompressionMethodByte.ZSTD: module = importlib.import_module('.zstd', __name__) else: raise errors.UnknownCompressionMethod() return module.Decompressor clickhouse-driver-0.2.11/clickhouse_driver/compression/base.py000066400000000000000000000046021522645447600245670ustar00rootroot00000000000000from io import BytesIO from ..reader import read_binary_uint32 from ..writer import write_binary_uint8, write_binary_uint32 from .. import errors try: from clickhouse_cityhash.cityhash import CityHash128 except ImportError: raise RuntimeError( 'Package clickhouse-cityhash is required to use compression' ) class BaseCompressor(object): """ Partial file-like object with write method. """ method = None method_byte = None def __init__(self): self.data = BytesIO() super(BaseCompressor, self).__init__() def get_value(self): value = self.data.getvalue() self.data.seek(0) self.data.truncate() return value def write(self, p_str): self.data.write(p_str) def compress_data(self, data): raise NotImplementedError def get_compressed_data(self, extra_header_size): rv = BytesIO() data = self.get_value() compressed = self.compress_data(data) header_size = extra_header_size + 4 + 4 # sizes write_binary_uint32(header_size + len(compressed), rv) write_binary_uint32(len(data), rv) rv.write(compressed) return rv.getvalue() class BaseDecompressor(object): method = None method_byte = None def __init__(self, real_stream): self.stream = real_stream super(BaseDecompressor, self).__init__() def decompress_data(self, data, uncompressed_size): raise NotImplementedError def check_hash(self, compressed_data, compressed_hash): if CityHash128(compressed_data) != compressed_hash: raise errors.ChecksumDoesntMatchError() def get_decompressed_data(self, method_byte, compressed_hash, extra_header_size): size_with_header = read_binary_uint32(self.stream) compressed_size = size_with_header - extra_header_size - 4 compressed = BytesIO(self.stream.read(compressed_size)) block_check = BytesIO() write_binary_uint8(method_byte, block_check) write_binary_uint32(size_with_header, block_check) block_check.write(compressed.getvalue()) self.check_hash(block_check.getvalue(), compressed_hash) uncompressed_size = read_binary_uint32(compressed) compressed = compressed.read(compressed_size - 4) return self.decompress_data(compressed, uncompressed_size) clickhouse-driver-0.2.11/clickhouse_driver/compression/lz4.py000066400000000000000000000011671522645447600243710ustar00rootroot00000000000000from lz4 import block from .base import BaseCompressor, BaseDecompressor from ..protocol import CompressionMethod, CompressionMethodByte class Compressor(BaseCompressor): method = CompressionMethod.LZ4 method_byte = CompressionMethodByte.LZ4 mode = 'default' def compress_data(self, data): return block.compress(data, store_size=False, mode=self.mode) class Decompressor(BaseDecompressor): method = CompressionMethod.LZ4 method_byte = CompressionMethodByte.LZ4 def decompress_data(self, data, uncompressed_size): return block.decompress(data, uncompressed_size=uncompressed_size) clickhouse-driver-0.2.11/clickhouse_driver/compression/lz4hc.py000066400000000000000000000003031522645447600246730ustar00rootroot00000000000000from .lz4 import Compressor as BaseCompressor, Decompressor as BaseDecompressor class Compressor(BaseCompressor): mode = 'high_compression' class Decompressor(BaseDecompressor): pass clickhouse-driver-0.2.11/clickhouse_driver/compression/zstd.py000066400000000000000000000010231522645447600246330ustar00rootroot00000000000000import zstd from .base import BaseCompressor, BaseDecompressor from ..protocol import CompressionMethod, CompressionMethodByte class Compressor(BaseCompressor): method = CompressionMethod.ZSTD method_byte = CompressionMethodByte.ZSTD def compress_data(self, data): return zstd.compress(data) class Decompressor(BaseDecompressor): method = CompressionMethod.ZSTD method_byte = CompressionMethodByte.ZSTD def decompress_data(self, data, uncompressed_size): return zstd.decompress(data) clickhouse-driver-0.2.11/clickhouse_driver/connection.py000066400000000000000000000723761522645447600234700ustar00rootroot00000000000000import logging import socket import ssl from collections import deque from contextlib import contextmanager from sys import platform from time import time from urllib.parse import urlparse try: import certifi except ImportError: certifi = None from . import defines from . import errors from .block import RowOrientedBlock from .blockstreamprofileinfo import BlockStreamProfileInfo from .bufferedreader import BufferedSocketReader from .bufferedwriter import BufferedSocketWriter from .clientinfo import ClientInfo from .compression import get_compressor_cls from .context import Context from .log import log_block from .progress import Progress from .protocol import Compression, ClientPacketTypes, ServerPacketTypes from .queryprocessingstage import QueryProcessingStage from .reader import read_binary_str, read_binary_uint64 from .readhelpers import read_exception from .settings.writer import write_settings, SettingsFlags from .streams.native import BlockInputStream, BlockOutputStream from .util.compat import threading from .util.escape import escape_params from .varint import write_varint, read_varint from .writer import write_binary_str logger = logging.getLogger(__name__) class Packet(object): def __init__(self): self.type = None self.block = None self.exception = None self.progress = None self.profile_info = None self.multistring_message = None super(Packet, self).__init__() class ServerInfo(object): def __init__(self, name, version_major, version_minor, version_patch, revision, timezone, display_name, used_revision): self.name = name self.version_major = version_major self.version_minor = version_minor self.version_patch = version_patch self.revision = revision self.timezone = timezone self.session_timezone = None self.display_name = display_name self.used_revision = used_revision super(ServerInfo, self).__init__() def get_timezone(self): return self.session_timezone or self.timezone def version_tuple(self): return self.version_major, self.version_minor, self.version_patch def __repr__(self): version = '%s.%s.%s' % ( self.version_major, self.version_minor, self.version_patch ) items = [ ('name', self.name), ('version', version), ('revision', self.revision), ('used revision', self.used_revision), ('timezone', self.timezone), ('display_name', self.display_name) ] params = ', '.join('{}={}'.format(key, value) for key, value in items) return '' % (params) class Connection(object): """ Represents connection between client and ClickHouse server. :param host: host with running ClickHouse server. :param port: port ClickHouse server is bound to. Defaults to ``9000`` if connection is not secured and to ``9440`` if connection is secured. :param database: database connect to. Defaults to ``'default'``. :param user: database user. Defaults to ``'default'``. :param password: user's password. Defaults to ``''`` (no password). :param client_name: this name will appear in server logs. Defaults to ``'python-driver'``. :param connect_timeout: timeout for establishing connection. Defaults to ``10`` seconds. :param send_receive_timeout: timeout for sending and receiving data. Defaults to ``300`` seconds. :param sync_request_timeout: timeout for server ping. Defaults to ``5`` seconds. :param compress_block_size: size of compressed block to send. Defaults to ``1048576``. :param compression: specifies whether or not use compression. Defaults to ``False``. Possible choices: * ``True`` is equivalent to ``'lz4'``. * ``'lz4'``. * ``'lz4hc'`` high-compression variant of ``'lz4'``. * ``'zstd'``. :param secure: establish secure connection. Defaults to ``False``. :param verify: specifies whether a certificate is required and whether it will be validated after connection. Defaults to ``True``. :param ssl_version: see :func:`ssl.wrap_socket` docs. :param ca_certs: see :func:`ssl.wrap_socket` docs. :param ciphers: see :func:`ssl.wrap_socket` docs. :param keyfile: see :func:`ssl.wrap_socket` docs. :param keypass: see :func:`ssl.wrap_socket` docs. :param certfile: see :func:`ssl.wrap_socket` docs. :param check_hostname: see :func:`ssl.wrap_socket` docs. Defaults to ``True``. :param server_hostname: Hostname to use in SSL Wrapper construction. Defaults to `None` which will send the passed host param during SSL initialization. This param may be used when connecting over an SSH tunnel to correctly identify the desired server via SNI. :param alt_hosts: list of alternative hosts for connection. Example: alt_hosts=host1:port1,host2:port2. :param settings_is_important: ``False`` means unknown settings will be ignored, ``True`` means that the query will fail with UNKNOWN_SETTING error. Defaults to ``False``. :param tcp_keepalive: enables `TCP keepalive `_ on established connection. If is set to ``True``` system keepalive settings are used. You can also specify custom keepalive setting with tuple: ``(idle_time_sec, interval_sec, probes)``. Defaults to ``False``. :param client_revision: can be used for client version downgrading. Defaults to ``None``. :param disable_reconnect: disable automatic reconnect in case of failed ``ping``, helpful when every reconnect need to be caught in calling code. Defaults to ``False``. """ def __init__( self, host, port=None, database=defines.DEFAULT_DATABASE, user=defines.DEFAULT_USER, password=defines.DEFAULT_PASSWORD, client_name=defines.CLIENT_NAME, connect_timeout=defines.DBMS_DEFAULT_CONNECT_TIMEOUT_SEC, send_receive_timeout=defines.DBMS_DEFAULT_TIMEOUT_SEC, sync_request_timeout=defines.DBMS_DEFAULT_SYNC_REQUEST_TIMEOUT_SEC, compress_block_size=defines.DEFAULT_COMPRESS_BLOCK_SIZE, compression=False, secure=False, # Secure socket parameters. verify=True, ssl_version=None, ca_certs=None, ciphers=None, keyfile=None, keypass=None, certfile=None, check_hostname=True, server_hostname=None, alt_hosts=None, settings_is_important=False, tcp_keepalive=False, client_revision=None, disable_reconnect=False, ): if secure: default_port = defines.DEFAULT_SECURE_PORT else: default_port = defines.DEFAULT_PORT self.hosts = deque([(host, port or default_port)]) if alt_hosts: for host in alt_hosts.split(','): url = urlparse('clickhouse://' + host) self.hosts.append((url.hostname, url.port or default_port)) self.database = database self.user = user self.password = password self.client_name = defines.DBMS_NAME + ' ' + client_name self.connect_timeout = connect_timeout self.send_receive_timeout = send_receive_timeout self.sync_request_timeout = sync_request_timeout self.settings_is_important = settings_is_important self.tcp_keepalive = tcp_keepalive self.client_revision = min( client_revision or defines.CLIENT_REVISION, defines.CLIENT_REVISION ) self.disable_reconnect = disable_reconnect self.secure_socket = secure self.verify_cert = verify if certifi is not None: ca_certs = ca_certs or certifi.where() ssl_options = {} if ssl_version is not None: ssl_options['ssl_version'] = ssl_version if ca_certs is not None: ssl_options['ca_certs'] = ca_certs if ciphers is not None: ssl_options['ciphers'] = ciphers if keyfile is not None: ssl_options['keyfile'] = keyfile if keypass is not None: ssl_options['keypass'] = keypass if certfile is not None: ssl_options['certfile'] = certfile self.ssl_options = ssl_options self.check_hostname = check_hostname if self.verify_cert else False self.server_hostname = server_hostname # Use LZ4 compression by default. if compression is True: compression = 'lz4' if compression is False: self.compression = Compression.DISABLED self.compressor_cls = None self.compress_block_size = None else: self.compression = Compression.ENABLED self.compressor_cls = get_compressor_cls(compression) self.compress_block_size = compress_block_size self.socket = None self.fin = None self.fout = None self.connected = False self.client_trace_context = None self.server_info = None self.context = Context() # Block writer/reader self.block_in = None self.block_out = None self.block_in_raw = None # log blocks are always not compressed self._lock = threading.Lock() self.is_query_executing = False super(Connection, self).__init__() def __repr__(self): dsn = '%s://%s:***@%s:%s/%s' % ( 'clickhouses' if self.secure_socket else 'clickhouse', self.user, self.host, self.port, self.database ) if self.connected else '(not connected)' return '' % (dsn, self.compression) def get_description(self): return '{}:{}'.format(self.host, self.port) def force_connect(self): self.check_query_execution() if not self.connected: self.connect() elif not self.ping(): if self.disable_reconnect: raise errors.NetworkError( "Connection was closed, reconnect is disabled." ) logger.warning('Connection was closed, reconnecting.') self.connect() def _create_socket(self, host, port): """ Acts like socket.create_connection, but wraps socket with SSL if connection is secure. """ ssl_options = {} if self.secure_socket: if self.verify_cert: cert_reqs = ssl.CERT_REQUIRED else: cert_reqs = ssl.CERT_NONE ssl_options = self.ssl_options.copy() ssl_options['cert_reqs'] = cert_reqs err = None for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): af, socktype, proto, canonname, sa = res sock = None try: sock = socket.socket(af, socktype, proto) sock.settimeout(self.connect_timeout) if self.secure_socket: ssl_context = self._create_ssl_context(ssl_options) sock = ssl_context.wrap_socket( sock, server_hostname=self.server_hostname or host) sock.connect(sa) return sock except socket.error as _: err = _ if sock is not None: sock.close() if err is not None: raise err else: raise socket.error("getaddrinfo returns an empty list") def _create_ssl_context(self, ssl_options): purpose = ssl.Purpose.SERVER_AUTH version = ssl_options.get('ssl_version', ssl.PROTOCOL_TLS_CLIENT) context = ssl.SSLContext(version) context.check_hostname = self.check_hostname if 'ca_certs' in ssl_options: context.load_verify_locations(ssl_options['ca_certs']) elif ssl_options.get('cert_reqs') != ssl.CERT_NONE: context.load_default_certs(purpose) if 'ciphers' in ssl_options: context.set_ciphers(ssl_options['ciphers']) if 'cert_reqs' in ssl_options: context.verify_mode = ssl_options['cert_reqs'] if 'certfile' in ssl_options: keyfile = ssl_options.get('keyfile') keypass = ssl_options.get('keypass') context.load_cert_chain( ssl_options['certfile'], keyfile=keyfile, password=keypass ) return context def _init_connection(self, host, port): self.socket = self._create_socket(host, port) self.connected = True self.host, self.port = host, port self.socket.settimeout(self.send_receive_timeout) # performance tweak self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) if self.tcp_keepalive: self._set_keepalive() self.fin = BufferedSocketReader(self.socket, defines.BUFFER_SIZE) self.fout = BufferedSocketWriter(self.socket, defines.BUFFER_SIZE) self.send_hello() self.receive_hello() revision = self.server_info.used_revision if revision >= defines.DBMS_MIN_PROTOCOL_VERSION_WITH_ADDENDUM: self.send_addendum() self.block_in = self.get_block_in_stream() self.block_in_raw = BlockInputStream(self.fin, self.context) self.block_out = self.get_block_out_stream() def _set_keepalive(self): self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) if not isinstance(self.tcp_keepalive, tuple): return idle_time_sec, interval_sec, probes = self.tcp_keepalive if platform == 'linux' or platform == 'win32': # This should also work for Windows # starting with Windows 10, version 1709. self.socket.setsockopt( socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, idle_time_sec ) self.socket.setsockopt( socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, interval_sec ) self.socket.setsockopt( socket.IPPROTO_TCP, socket.TCP_KEEPCNT, probes ) elif platform == 'darwin': TCP_KEEPALIVE = 0x10 # Only interval is available in mac os. self.socket.setsockopt( socket.IPPROTO_TCP, TCP_KEEPALIVE, interval_sec ) def _format_connection_error(self, e, host, port): err = (e.strerror + ' ') if e.strerror else '' return err + '({}:{})'.format(host, port) def connect(self): if self.connected: self.disconnect() logger.debug( 'Connecting. Database: %s. User: %s', self.database, self.user ) err = None for i in range(len(self.hosts)): host, port = self.hosts[0] logger.debug('Connecting to %s:%s', host, port) try: return self._init_connection(host, port) except socket.timeout as e: self.disconnect() logger.warning( 'Failed to connect to %s:%s', host, port, exc_info=True ) err_str = self._format_connection_error(e, host, port) err = errors.SocketTimeoutError(err_str) except socket.error as e: self.disconnect() logger.warning( 'Failed to connect to %s:%s', host, port, exc_info=True ) err_str = self._format_connection_error(e, host, port) err = errors.NetworkError(err_str) self.hosts.rotate(-1) if err is not None: raise err def reset_state(self): self.host = None self.port = None self.socket = None self.fin = None self.fout = None self.connected = False self.client_trace_context = None self.server_info = None self.block_in = None self.block_in_raw = None self.block_out = None self.is_query_executing = False def disconnect(self): """ Closes connection between server and client. Frees resources: e.g. closes socket. """ if self.connected: # There can be errors on shutdown. # We need to close socket and reset state even if it happens. try: self.socket.shutdown(socket.SHUT_RDWR) except socket.error as e: logger.warning('Error on socket shutdown: %s', e) self.socket.close() # Socket can be constructed but not connected. elif self.socket: self.socket.close() self.reset_state() def send_hello(self): write_varint(ClientPacketTypes.HELLO, self.fout) write_binary_str(self.client_name, self.fout) write_varint(defines.CLIENT_VERSION_MAJOR, self.fout) write_varint(defines.CLIENT_VERSION_MINOR, self.fout) # NOTE For backward compatibility of the protocol, # client cannot send its version_patch. write_varint(self.client_revision, self.fout) write_binary_str(self.database, self.fout) write_binary_str(self.user, self.fout) write_binary_str(self.password, self.fout) self.fout.flush() def receive_hello(self): packet_type = read_varint(self.fin) if packet_type == ServerPacketTypes.HELLO: server_name = read_binary_str(self.fin) server_version_major = read_varint(self.fin) server_version_minor = read_varint(self.fin) server_revision = read_varint(self.fin) used_revision = min(self.client_revision, server_revision) server_timezone = None if used_revision >= \ defines.DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE: server_timezone = read_binary_str(self.fin) server_display_name = '' if used_revision >= \ defines.DBMS_MIN_REVISION_WITH_SERVER_DISPLAY_NAME: server_display_name = read_binary_str(self.fin) server_version_patch = server_revision if used_revision >= \ defines.DBMS_MIN_REVISION_WITH_VERSION_PATCH: server_version_patch = read_varint(self.fin) if used_revision >= defines. \ DBMS_MIN_PROTOCOL_VERSION_WITH_PASSWORD_COMPLEXITY_RULES: rules_size = read_varint(self.fin) for _i in range(rules_size): read_binary_str(self.fin) # original_pattern read_binary_str(self.fin) # exception_message if used_revision >= defines. \ DBMS_MIN_REVISION_WITH_INTERSERVER_SECRET_V2: read_binary_uint64(self.fin) # read_nonce self.server_info = ServerInfo( server_name, server_version_major, server_version_minor, server_version_patch, server_revision, server_timezone, server_display_name, used_revision ) self.context.server_info = self.server_info logger.debug( 'Connected to %s server version %s.%s.%s, revision: %s', server_name, server_version_major, server_version_minor, server_version_patch, server_revision ) elif packet_type == ServerPacketTypes.EXCEPTION: raise self.receive_exception() else: message = self.unexpected_packet_message('Hello or Exception', packet_type) self.disconnect() raise errors.UnexpectedPacketFromServerError(message) def send_addendum(self): revision = self.server_info.used_revision if revision >= defines.DBMS_MIN_PROTOCOL_VERSION_WITH_QUOTA_KEY: write_binary_str( self.context.client_settings['quota_key'], self.fout ) def ping(self): if not self.socket: return None timeout = self.sync_request_timeout with self.timeout_setter(timeout): try: write_varint(ClientPacketTypes.PING, self.fout) self.fout.flush() packet_type = read_varint(self.fin) while packet_type == ServerPacketTypes.PROGRESS: self.receive_progress() packet_type = read_varint(self.fin) if packet_type != ServerPacketTypes.PONG: msg = self.unexpected_packet_message('Pong', packet_type) raise errors.UnexpectedPacketFromServerError(msg) except errors.Error: raise except (socket.error, EOFError) as e: # It's just a warning now. # Current connection will be closed, new will be established. logger.warning( 'Error on %s ping: %s', self.get_description(), e ) return False return True def receive_packet(self): packet = Packet() packet.type = packet_type = read_varint(self.fin) if packet_type == ServerPacketTypes.DATA: packet.block = self.receive_data(may_be_use_numpy=True) elif packet_type == ServerPacketTypes.EXCEPTION: packet.exception = self.receive_exception() elif packet_type == ServerPacketTypes.PROGRESS: packet.progress = self.receive_progress() elif packet_type == ServerPacketTypes.PROFILE_INFO: packet.profile_info = self.receive_profile_info() elif packet_type == ServerPacketTypes.TOTALS: packet.block = self.receive_data() elif packet_type == ServerPacketTypes.EXTREMES: packet.block = self.receive_data() elif packet_type == ServerPacketTypes.LOG: packet.block = self.receive_data(may_be_compressed=False) log_block(packet.block) elif packet_type == ServerPacketTypes.END_OF_STREAM: self.is_query_executing = False pass elif packet_type == ServerPacketTypes.TABLE_COLUMNS: packet.multistring_message = self.receive_multistring_message( packet_type ) elif packet_type == ServerPacketTypes.PART_UUIDS: packet.block = self.receive_data() elif packet_type == ServerPacketTypes.READ_TASK_REQUEST: packet.block = self.receive_data() elif packet_type == ServerPacketTypes.PROFILE_EVENTS: packet.block = self.receive_data(may_be_compressed=False) elif packet_type == ServerPacketTypes.TIMEZONE_UPDATE: timezone = read_binary_str(self.fin) if timezone: logger.info('Server timezone changed to %s', timezone) self.server_info.session_timezone = timezone else: message = 'Unknown packet {} from server {}'.format( packet_type, self.get_description() ) self.disconnect() raise errors.UnknownPacketFromServerError(message) return packet def get_block_in_stream(self): if self.compression: from .streams.compressed import CompressedBlockInputStream return CompressedBlockInputStream(self.fin, self.context) else: return BlockInputStream(self.fin, self.context) def get_block_out_stream(self): if self.compression: from .streams.compressed import CompressedBlockOutputStream return CompressedBlockOutputStream( self.compressor_cls, self.compress_block_size, self.fout, self.context ) else: return BlockOutputStream(self.fout, self.context) def receive_data(self, may_be_compressed=True, may_be_use_numpy=False): revision = self.server_info.used_revision if revision >= defines.DBMS_MIN_REVISION_WITH_TEMPORARY_TABLES: read_binary_str(self.fin) reader = self.block_in if may_be_compressed else self.block_in_raw use_numpy = False if not may_be_use_numpy else None return reader.read(use_numpy=use_numpy) def receive_exception(self): return read_exception(self.fin) def receive_progress(self): progress = Progress() progress.read(self.server_info, self.fin) return progress def receive_profile_info(self): profile_info = BlockStreamProfileInfo() profile_info.read(self.fin) return profile_info def receive_multistring_message(self, packet_type): num = ServerPacketTypes.strings_in_message(packet_type) return [read_binary_str(self.fin) for _i in range(num)] def send_data(self, block, table_name=''): start = time() write_varint(ClientPacketTypes.DATA, self.fout) revision = self.server_info.used_revision if revision >= defines.DBMS_MIN_REVISION_WITH_TEMPORARY_TABLES: write_binary_str(table_name, self.fout) self.block_out.write(block) logger.debug('Block "%s" send time: %f', table_name, time() - start) def send_query(self, query, query_id=None, params=None): if not self.connected: self.connect() write_varint(ClientPacketTypes.QUERY, self.fout) write_binary_str(query_id or '', self.fout) revision = self.server_info.used_revision if revision >= defines.DBMS_MIN_REVISION_WITH_CLIENT_INFO: client_info = ClientInfo(self.client_name, self.context, client_revision=self.client_revision) client_info.query_kind = ClientInfo.QueryKind.INITIAL_QUERY client_info.write(revision, self.fout) settings_as_strings = ( revision >= defines .DBMS_MIN_REVISION_WITH_SETTINGS_SERIALIZED_AS_STRINGS ) settings_flags = 0 if self.settings_is_important: settings_flags |= SettingsFlags.IMPORTANT write_settings(self.context.settings, self.fout, settings_as_strings, settings_flags) if revision >= defines.DBMS_MIN_REVISION_WITH_INTERSERVER_SECRET: write_binary_str('', self.fout) write_varint(QueryProcessingStage.COMPLETE, self.fout) write_varint(self.compression, self.fout) write_binary_str(query, self.fout) if revision >= defines.DBMS_MIN_PROTOCOL_VERSION_WITH_PARAMETERS: if self.context.client_settings['server_side_params']: # Always settings_as_strings = True escaped = escape_params( params or {}, self.context, for_server=True ) else: escaped = {} write_settings(escaped, self.fout, True, SettingsFlags.CUSTOM) logger.debug('Query: %s', query) self.fout.flush() def send_cancel(self): write_varint(ClientPacketTypes.CANCEL, self.fout) self.fout.flush() def send_external_tables(self, tables, types_check=False): for table in tables or []: if not table['structure']: raise ValueError( 'Empty table "{}" structure'.format(table['name']) ) data = table['data'] block_cls = RowOrientedBlock if self.context.client_settings['use_numpy']: from .numpy.block import NumpyColumnOrientedBlock columns = [x[0] for x in table['structure']] data = [data[column].values for column in columns] block_cls = NumpyColumnOrientedBlock block = block_cls(table['structure'], data, types_check=types_check) self.send_data(block, table_name=table['name']) # Empty block, end of data transfer. self.send_data(RowOrientedBlock()) @contextmanager def timeout_setter(self, new_timeout): old_timeout = self.socket.gettimeout() self.socket.settimeout(new_timeout) yield self.socket.settimeout(old_timeout) def unexpected_packet_message(self, expected, packet_type): packet_type = ServerPacketTypes.to_str(packet_type) return ( 'Unexpected packet from server {} (expected {}, got {})' .format(self.get_description(), expected, packet_type) ) def check_query_execution(self): self._lock.acquire(blocking=False) if self.is_query_executing: raise errors.PartiallyConsumedQueryError() self.is_query_executing = True self._lock.release() clickhouse-driver-0.2.11/clickhouse_driver/context.py000066400000000000000000000016151522645447600230010ustar00rootroot00000000000000 class Context(object): def __init__(self): self._server_info = None self._settings = None self._client_settings = None super(Context, self).__init__() @property def server_info(self): return self._server_info @server_info.setter def server_info(self, value): self._server_info = value @property def settings(self): return self._settings.copy() @settings.setter def settings(self, value): self._settings = value.copy() @property def client_settings(self): return self._client_settings.copy() @client_settings.setter def client_settings(self, value): self._client_settings = value.copy() def __repr__(self): return '' % ( self._server_info, self._client_settings, self._settings ) clickhouse-driver-0.2.11/clickhouse_driver/dbapi/000077500000000000000000000000001522645447600220175ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/dbapi/__init__.py000066400000000000000000000033371522645447600241360ustar00rootroot00000000000000from .connection import Connection from .errors import ( Warning, Error, DataError, DatabaseError, ProgrammingError, IntegrityError, InterfaceError, InternalError, NotSupportedError, OperationalError ) from .. import defines apilevel = '2.0' threadsafety = 2 paramstyle = 'pyformat' def connect(dsn=None, host=None, user=defines.DEFAULT_USER, password=defines.DEFAULT_PASSWORD, port=defines.DEFAULT_PORT, database=defines.DEFAULT_DATABASE, **kwargs): """ Create a new database connection. The connection can be specified via DSN: ``conn = connect("clickhouse://localhost/test?param1=value1&...")`` or using database and credentials arguments: ``conn = connect(database="test", user="default", password="default", host="localhost", **kwargs)`` The basic connection parameters are: - *host*: host with running ClickHouse server. - *port*: port ClickHouse server is bound to. - *database*: database connect to. - *user*: database user. - *password*: user's password. See defaults in :data:`~clickhouse_driver.connection.Connection` constructor. DSN or host is required. Any other keyword parameter will be passed to the underlying Connection class. :return: a new connection. """ if dsn is None and host is None: raise ValueError('host or dsn is required') return Connection(dsn=dsn, user=user, password=password, host=host, port=port, database=database, **kwargs) __all__ = [ 'connect', 'Warning', 'Error', 'DataError', 'DatabaseError', 'ProgrammingError', 'IntegrityError', 'InterfaceError', 'InternalError', 'NotSupportedError', 'OperationalError' ] clickhouse-driver-0.2.11/clickhouse_driver/dbapi/connection.py000066400000000000000000000057301522645447600245350ustar00rootroot00000000000000from ..client import Client from .. import defines from .cursor import Cursor from .errors import InterfaceError class Connection(object): """ Creates new Connection for accessing ClickHouse database. Connection is just wrapper for handling multiple cursors (clients) and do not initiate actual connections to the ClickHouse server. See parameters description in :data:`~clickhouse_driver.connection.Connection`. """ def __init__(self, dsn=None, host=None, user=defines.DEFAULT_USER, password=defines.DEFAULT_PASSWORD, port=defines.DEFAULT_PORT, database=defines.DEFAULT_DATABASE, **kwargs): self.cursors = [] self.dsn = dsn self.user = user self.password = password self.host = host self.port = port self.database = database self.connection_kwargs = kwargs self.is_closed = False self._hosts = None super(Connection, self).__init__() def __repr__(self): return ''.format( id(self), self.is_closed ) # Context manager integrations. def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): self.close() def _make_client(self): """ :return: a new Client instance. """ if self.dsn is not None: return Client.from_url(self.dsn) return Client(self.host, port=self.port, user=self.user, password=self.password, database=self.database, **self.connection_kwargs) def close(self): """ Close the connection now. The connection will be unusable from this point forward; an :data:`~clickhouse_driver.dbapi.Error` (or subclass) exception will be raised if any operation is attempted with the connection. The same applies to all cursor objects trying to use the connection. """ for cursor in self.cursors: cursor.close() self.is_closed = True def commit(self): """ Do nothing since ClickHouse has no transactions. """ pass def rollback(self): """ Do nothing since ClickHouse has no transactions. """ pass def cursor(self, cursor_factory=None): """ :param cursor_factory: Argument can be used to create non-standard cursors. :return: a new cursor object using the connection. """ if self.is_closed: raise InterfaceError('connection already closed') client = self._make_client() if self._hosts is None: self._hosts = client.connection.hosts else: client.connection.hosts = self._hosts cursor_factory = cursor_factory or Cursor cursor = cursor_factory(client, self) self.cursors.append(cursor) return cursor clickhouse-driver-0.2.11/clickhouse_driver/dbapi/cursor.py000066400000000000000000000244251522645447600237150ustar00rootroot00000000000000from collections import namedtuple from itertools import islice from ..errors import Error as DriverError from .errors import InterfaceError, OperationalError, ProgrammingError Column = namedtuple( 'Column', 'name type_code display_size internal_size precision scale null_ok' ) class Cursor(object): class States(object): ( NONE, RUNNING, FINISHED, CURSOR_CLOSED ) = range(4) _states = States() def __init__(self, client, connection): self._client = client self._connection = connection self._reset_state() self.arraysize = 1 # Begin non-PEP attributes self._columns_with_types = None # End non-PEP attributes super(Cursor, self).__init__() def __repr__(self): is_closed = self._state == self._states.CURSOR_CLOSED return ''.format( id(self), is_closed ) # Iteration support. def __iter__(self): while True: one = self.fetchone() if one is None: return yield one # Context manager integrations. def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): self.close() @property def description(self): if self._state == self._states.NONE: return None columns = self._columns or [] types = self._types or [] return [ Column(name, type_code, None, None, None, None, True) for name, type_code in zip(columns, types) ] @property def rowcount(self): """ :return: the number of rows that the last .execute*() produced. """ return self._rowcount def close(self): """ Close the cursor now. The cursor will be unusable from this point forward; an :data:`~clickhouse_driver.dbapi.Error` (or subclass) exception will be raised if any operation is attempted with the cursor. """ self._client.disconnect() self._state = self._states.CURSOR_CLOSED try: # cursor can be already closed self._connection.cursors.remove(self) except ValueError: pass def execute(self, operation, parameters=None): """ Prepare and execute a database operation (query or command). :param operation: query or command to execute. :param parameters: sequence or mapping that will be bound to variables in the operation. :return: None """ self._check_cursor_closed() self._begin_query() try: execute, execute_kwargs = self._prepare() response = execute( operation, params=parameters, with_column_types=True, **execute_kwargs ) except DriverError as orig: raise OperationalError(orig) self._process_response(response) self._end_query() def executemany(self, operation, seq_of_parameters): """ Prepare a database operation (query or command) and then execute it against all parameter sequences found in the sequence `seq_of_parameters`. :param operation: query or command to execute. :param seq_of_parameters: sequences or mappings for execution. :return: None """ self._check_cursor_closed() self._begin_query() try: execute, execute_kwargs = self._prepare() response = execute( operation, params=seq_of_parameters, **execute_kwargs ) except DriverError as orig: raise OperationalError(orig) self._process_response(response, executemany=True) self._end_query() def fetchone(self): """ Fetch the next row of a query result set, returning a single sequence, or None when no more data is available. :return: the next row of a query result set or None. """ self._check_query_started() if self._stream_results: return next(self._rows, None) else: if not self._rows: return None return self._rows.pop(0) def fetchmany(self, size=None): """ Fetch the next set of rows of a query result, returning a sequence of sequences (e.g. a list of tuples). An empty sequence is returned when no more rows are available. :param size: amount of rows to return. :return: list of fetched rows or empty list. """ self._check_query_started() if size is None: size = self.arraysize if self._stream_results: if size == -1: return list(self._rows) else: return list(islice(self._rows, size)) if size < 0: rv = self._rows self._rows = [] else: rv = self._rows[:size] self._rows = self._rows[size:] return rv def fetchall(self): """ Fetch all (remaining) rows of a query result, returning them as a sequence of sequences (e.g. a list of tuples). :return: list of fetched rows. """ self._check_query_started() if self._stream_results: return list(self._rows) rv = self._rows self._rows = [] return rv def setinputsizes(self, sizes): # Do nothing. pass def setoutputsize(self, size, column=None): # Do nothing. pass # Begin non-PEP methods @property def columns_with_types(self): """ :return: list of column names with corresponding types of the last .execute*(). E.g. [('x', 'UInt64')]. """ return self._columns_with_types def set_stream_results(self, stream_results, max_row_buffer): """ Toggles results streaming from server. Driver will consume block-by-block of `max_row_buffer` size and yield row-by-row from each block. :param stream_results: enable or disable results streaming. :param max_row_buffer: specifies the maximum number of rows to buffer at a time. :return: None """ self._stream_results = stream_results self._max_row_buffer = max_row_buffer def set_settings(self, settings): """ Specifies settings for cursor. :param settings: dictionary of query settings :return: None """ self._settings = settings def set_types_check(self, types_check): """ Toggles type checking for sequence of INSERT parameters. Disabled by default. :param types_check: new types check value. :return: None """ self._types_check = types_check def set_external_table(self, name, structure, data): """ Adds external table to cursor context. If the same table is specified more than once the last one is used. :param name: name of external table :param structure: list of tuples (name, type) that defines table structure. Example [(x, 'Int32')]. :param data: sequence of rows of tuples or dicts for transmission. :return: None """ self._external_tables[name] = (structure, data) def set_query_id(self, query_id): """ Specifies the query identifier for cursor. :param query_id: the query identifier. :return: None """ self._query_id = query_id # End non-PEP methods # Private methods. def _prepare(self): external_tables = [ {'name': name, 'structure': structure, 'data': data} for name, (structure, data) in self._external_tables.items() ] or None execute = self._client.execute if self._stream_results: execute = self._client.execute_iter self._settings = self._settings or {} self._settings['max_block_size'] = self._max_row_buffer execute_kwargs = { 'settings': self._settings, 'external_tables': external_tables, 'types_check': self._types_check, 'query_id': self._query_id } return execute, execute_kwargs def _process_response(self, response, executemany=False): if executemany: self._rowcount = response response = None if not response or isinstance(response, int): self._columns = self._types = self._rows = [] if isinstance(response, int): self._rowcount = response return if self._stream_results: columns_with_types = next(response) rows = response else: rows, columns_with_types = response self._columns_with_types = columns_with_types # Only SELECT queries have columns_with_types. # DDL and INSERT INTO ... SELECT queries have empty columns header. # We need to obtain rows count only during non-streaming SELECTs. if columns_with_types: self._columns, self._types = zip(*columns_with_types) if not self._stream_results: self._rowcount = len(rows) else: self._columns = self._types = [] self._rows = rows def _reset_state(self): """ Resets query state and get ready for another query. """ self._state = self._states.NONE self._columns = None self._types = None self._rows = None self._rowcount = -1 self._stream_results = False self._max_row_buffer = 0 self._settings = None self._query_id = None self._external_tables = {} self._types_check = False def _begin_query(self): self._state = self._states.RUNNING def _end_query(self): self._state = self._states.FINISHED def _check_cursor_closed(self): if self._state == self._states.CURSOR_CLOSED: raise InterfaceError('cursor already closed') def _check_query_started(self): if self._state == self._states.NONE: raise ProgrammingError('no results to fetch') clickhouse-driver-0.2.11/clickhouse_driver/dbapi/errors.py000066400000000000000000000006701522645447600237100ustar00rootroot00000000000000 class Warning(Exception): pass class Error(Exception): pass class InterfaceError(Error): pass class DatabaseError(Error): pass class InternalError(DatabaseError): pass class OperationalError(DatabaseError): pass class ProgrammingError(DatabaseError): pass class IntegrityError(DatabaseError): pass class DataError(DatabaseError): pass class NotSupportedError(DatabaseError): pass clickhouse-driver-0.2.11/clickhouse_driver/dbapi/extras.py000066400000000000000000000041211522645447600236750ustar00rootroot00000000000000import re from collections import namedtuple from functools import lru_cache from .cursor import Cursor class DictCursor(Cursor): """ A cursor that generates results as :class:`dict`. ``fetch*()`` methods will return dicts instead of tuples. """ def fetchone(self): rv = super(DictCursor, self).fetchone() if rv is not None: rv = dict(zip(self._columns, rv)) return rv def fetchmany(self, size=None): rv = super(DictCursor, self).fetchmany(size=size) return [dict(zip(self._columns, x)) for x in rv] def fetchall(self): rv = super(DictCursor, self).fetchall() return [dict(zip(self._columns, x)) for x in rv] class NamedTupleCursor(Cursor): """ A cursor that generates results as named tuples created by :func:`~collections.namedtuple`. ``fetch*()`` methods will return named tuples instead of regular tuples, so their elements can be accessed both as regular numeric items as well as attributes. """ # ascii except alnum and underscore _re_clean = re.compile( '[' + re.escape(' !"#$%&\'()*+,-./:;<=>?@[\\]^`{|}~') + ']') @classmethod @lru_cache(512) def _make_nt(self, key): fields = [] for s in key: s = self._re_clean.sub('_', s) # Python identifier cannot start with numbers, namedtuple fields # cannot start with underscore. if s[0] == '_' or '0' <= s[0] <= '9': s = 'f' + s fields.append(s) return namedtuple('Record', fields) def fetchone(self): rv = super(NamedTupleCursor, self).fetchone() if rv is not None: nt = self._make_nt(self._columns) rv = nt(*rv) return rv def fetchmany(self, size=None): rv = super(NamedTupleCursor, self).fetchmany(size=size) nt = self._make_nt(self._columns) return [nt(*x) for x in rv] def fetchall(self): rv = super(NamedTupleCursor, self).fetchall() nt = self._make_nt(self._columns) return [nt(*x) for x in rv] clickhouse-driver-0.2.11/clickhouse_driver/defines.py000066400000000000000000000041221522645447600227260ustar00rootroot00000000000000 DEFAULT_DATABASE = '' DEFAULT_USER = 'default' DEFAULT_PASSWORD = '' DEFAULT_PORT = 9000 DEFAULT_SECURE_PORT = 9440 DBMS_MIN_REVISION_WITH_TEMPORARY_TABLES = 50264 DBMS_MIN_REVISION_WITH_TOTAL_ROWS_IN_PROGRESS = 51554 DBMS_MIN_REVISION_WITH_BLOCK_INFO = 51903 # Legacy above. DBMS_MIN_REVISION_WITH_CLIENT_INFO = 54032 DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE = 54058 DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO = 54060 DBMS_MIN_REVISION_WITH_SERVER_DISPLAY_NAME = 54372 DBMS_MIN_REVISION_WITH_VERSION_PATCH = 54401 DBMS_MIN_REVISION_WITH_SERVER_LOGS = 54406 DBMS_MIN_REVISION_WITH_COLUMN_DEFAULTS_METADATA = 54410 DBMS_MIN_REVISION_WITH_CLIENT_WRITE_INFO = 54420 DBMS_MIN_REVISION_WITH_SETTINGS_SERIALIZED_AS_STRINGS = 54429 DBMS_MIN_REVISION_WITH_INTERSERVER_SECRET = 54441 DBMS_MIN_REVISION_WITH_OPENTELEMETRY = 54442 DBMS_MIN_PROTOCOL_VERSION_WITH_DISTRIBUTED_DEPTH = 54448 DBMS_MIN_PROTOCOL_VERSION_WITH_INITIAL_QUERY_START_TIME = 54449 DBMS_MIN_PROTOCOL_VERSION_WITH_INCREMENTAL_PROFILE_EVENTS = 54451 DBMS_MIN_REVISION_WITH_PARALLEL_REPLICAS = 54453 DBMS_MIN_REVISION_WITH_CUSTOM_SERIALIZATION = 54454 DBMS_MIN_PROTOCOL_VERSION_WITH_PROFILE_EVENTS_IN_INSERT = 54456 DBMS_MIN_PROTOCOL_VERSION_WITH_ADDENDUM = 54458 DBMS_MIN_PROTOCOL_VERSION_WITH_QUOTA_KEY = 54458 DBMS_MIN_PROTOCOL_VERSION_WITH_PARAMETERS = 54459 DBMS_MIN_PROTOCOL_VERSION_WITH_SERVER_QUERY_TIME_IN_PROGRESS = 54460 DBMS_MIN_PROTOCOL_VERSION_WITH_PASSWORD_COMPLEXITY_RULES = 54461 DBMS_MIN_REVISION_WITH_INTERSERVER_SECRET_V2 = 54462 DBMS_MIN_PROTOCOL_VERSION_WITH_TOTAL_BYTES_IN_PROGRESS = 54463 DBMS_MIN_PROTOCOL_VERSION_WITH_TIMEZONE_UPDATES = 54464 DBMS_MIN_REVISION_WITH_SYSTEM_KEYWORDS_TABLE = 54468 # Timeouts DBMS_DEFAULT_CONNECT_TIMEOUT_SEC = 10 DBMS_DEFAULT_TIMEOUT_SEC = 300 DBMS_DEFAULT_SYNC_REQUEST_TIMEOUT_SEC = 5 DEFAULT_COMPRESS_BLOCK_SIZE = 1048576 DEFAULT_INSERT_BLOCK_SIZE = 1048576 DBMS_NAME = 'ClickHouse' CLIENT_NAME = 'python-driver' CLIENT_VERSION_MAJOR = 20 CLIENT_VERSION_MINOR = 10 CLIENT_VERSION_PATCH = 2 CLIENT_REVISION = DBMS_MIN_REVISION_WITH_SYSTEM_KEYWORDS_TABLE BUFFER_SIZE = 1048576 STRINGS_ENCODING = 'utf-8' clickhouse-driver-0.2.11/clickhouse_driver/errors.py000066400000000000000000000340071522645447600226320ustar00rootroot00000000000000 class ErrorCodes(object): UNSUPPORTED_METHOD = 1 UNSUPPORTED_PARAMETER = 2 UNEXPECTED_END_OF_FILE = 3 EXPECTED_END_OF_FILE = 4 CANNOT_PARSE_TEXT = 6 INCORRECT_NUMBER_OF_COLUMNS = 7 THERE_IS_NO_COLUMN = 8 SIZES_OF_COLUMNS_DOESNT_MATCH = 9 NOT_FOUND_COLUMN_IN_BLOCK = 10 POSITION_OUT_OF_BOUND = 11 PARAMETER_OUT_OF_BOUND = 12 SIZES_OF_COLUMNS_IN_TUPLE_DOESNT_MATCH = 13 DUPLICATE_COLUMN = 15 NO_SUCH_COLUMN_IN_TABLE = 16 DELIMITER_IN_STRING_LITERAL_DOESNT_MATCH = 17 CANNOT_INSERT_ELEMENT_INTO_CONSTANT_COLUMN = 18 SIZE_OF_FIXED_STRING_DOESNT_MATCH = 19 NUMBER_OF_COLUMNS_DOESNT_MATCH = 20 CANNOT_READ_ALL_DATA_FROM_TAB_SEPARATED_INPUT = 21 CANNOT_PARSE_ALL_VALUE_FROM_TAB_SEPARATED_INPUT = 22 CANNOT_READ_FROM_ISTREAM = 23 CANNOT_WRITE_TO_OSTREAM = 24 CANNOT_PARSE_ESCAPE_SEQUENCE = 25 CANNOT_PARSE_QUOTED_STRING = 26 CANNOT_PARSE_INPUT_ASSERTION_FAILED = 27 CANNOT_PRINT_FLOAT_OR_DOUBLE_NUMBER = 28 CANNOT_PRINT_INTEGER = 29 CANNOT_READ_SIZE_OF_COMPRESSED_CHUNK = 30 CANNOT_READ_COMPRESSED_CHUNK = 31 ATTEMPT_TO_READ_AFTER_EOF = 32 CANNOT_READ_ALL_DATA = 33 TOO_MANY_ARGUMENTS_FOR_FUNCTION = 34 TOO_LESS_ARGUMENTS_FOR_FUNCTION = 35 BAD_ARGUMENTS = 36 UNKNOWN_ELEMENT_IN_AST = 37 CANNOT_PARSE_DATE = 38 TOO_LARGE_SIZE_COMPRESSED = 39 CHECKSUM_DOESNT_MATCH = 40 CANNOT_PARSE_DATETIME = 41 NUMBER_OF_ARGUMENTS_DOESNT_MATCH = 42 ILLEGAL_TYPE_OF_ARGUMENT = 43 ILLEGAL_COLUMN = 44 ILLEGAL_NUMBER_OF_RESULT_COLUMNS = 45 UNKNOWN_FUNCTION = 46 UNKNOWN_IDENTIFIER = 47 NOT_IMPLEMENTED = 48 LOGICAL_ERROR = 49 UNKNOWN_TYPE = 50 EMPTY_LIST_OF_COLUMNS_QUERIED = 51 COLUMN_QUERIED_MORE_THAN_ONCE = 52 TYPE_MISMATCH = 53 STORAGE_DOESNT_ALLOW_PARAMETERS = 54 STORAGE_REQUIRES_PARAMETER = 55 UNKNOWN_STORAGE = 56 TABLE_ALREADY_EXISTS = 57 TABLE_METADATA_ALREADY_EXISTS = 58 ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER = 59 UNKNOWN_TABLE = 60 ONLY_FILTER_COLUMN_IN_BLOCK = 61 SYNTAX_ERROR = 62 UNKNOWN_AGGREGATE_FUNCTION = 63 CANNOT_READ_AGGREGATE_FUNCTION_FROM_TEXT = 64 CANNOT_WRITE_AGGREGATE_FUNCTION_AS_TEXT = 65 NOT_A_COLUMN = 66 ILLEGAL_KEY_OF_AGGREGATION = 67 CANNOT_GET_SIZE_OF_FIELD = 68 ARGUMENT_OUT_OF_BOUND = 69 CANNOT_CONVERT_TYPE = 70 CANNOT_WRITE_AFTER_END_OF_BUFFER = 71 CANNOT_PARSE_NUMBER = 72 UNKNOWN_FORMAT = 73 CANNOT_READ_FROM_FILE_DESCRIPTOR = 74 CANNOT_WRITE_TO_FILE_DESCRIPTOR = 75 CANNOT_OPEN_FILE = 76 CANNOT_CLOSE_FILE = 77 UNKNOWN_TYPE_OF_QUERY = 78 INCORRECT_FILE_NAME = 79 INCORRECT_QUERY = 80 UNKNOWN_DATABASE = 81 DATABASE_ALREADY_EXISTS = 82 DIRECTORY_DOESNT_EXIST = 83 DIRECTORY_ALREADY_EXISTS = 84 FORMAT_IS_NOT_SUITABLE_FOR_INPUT = 85 RECEIVED_ERROR_FROM_REMOTE_IO_SERVER = 86 CANNOT_SEEK_THROUGH_FILE = 87 CANNOT_TRUNCATE_FILE = 88 UNKNOWN_COMPRESSION_METHOD = 89 EMPTY_LIST_OF_COLUMNS_PASSED = 90 SIZES_OF_MARKS_FILES_ARE_INCONSISTENT = 91 EMPTY_DATA_PASSED = 92 UNKNOWN_AGGREGATED_DATA_VARIANT = 93 CANNOT_MERGE_DIFFERENT_AGGREGATED_DATA_VARIANTS = 94 CANNOT_READ_FROM_SOCKET = 95 CANNOT_WRITE_TO_SOCKET = 96 CANNOT_READ_ALL_DATA_FROM_CHUNKED_INPUT = 97 CANNOT_WRITE_TO_EMPTY_BLOCK_OUTPUT_STREAM = 98 UNKNOWN_PACKET_FROM_CLIENT = 99 UNKNOWN_PACKET_FROM_SERVER = 100 UNEXPECTED_PACKET_FROM_CLIENT = 101 UNEXPECTED_PACKET_FROM_SERVER = 102 RECEIVED_DATA_FOR_WRONG_QUERY_ID = 103 TOO_SMALL_BUFFER_SIZE = 104 CANNOT_READ_HISTORY = 105 CANNOT_APPEND_HISTORY = 106 FILE_DOESNT_EXIST = 107 NO_DATA_TO_INSERT = 108 CANNOT_BLOCK_SIGNAL = 109 CANNOT_UNBLOCK_SIGNAL = 110 CANNOT_MANIPULATE_SIGSET = 111 CANNOT_WAIT_FOR_SIGNAL = 112 THERE_IS_NO_SESSION = 113 CANNOT_CLOCK_GETTIME = 114 UNKNOWN_SETTING = 115 THERE_IS_NO_DEFAULT_VALUE = 116 INCORRECT_DATA = 117 ENGINE_REQUIRED = 119 CANNOT_INSERT_VALUE_OF_DIFFERENT_SIZE_INTO_TUPLE = 120 UNKNOWN_SET_DATA_VARIANT = 121 INCOMPATIBLE_COLUMNS = 122 UNKNOWN_TYPE_OF_AST_NODE = 123 INCORRECT_ELEMENT_OF_SET = 124 INCORRECT_RESULT_OF_SCALAR_SUBQUERY = 125 CANNOT_GET_RETURN_TYPE = 126 ILLEGAL_INDEX = 127 TOO_LARGE_ARRAY_SIZE = 128 FUNCTION_IS_SPECIAL = 129 CANNOT_READ_ARRAY_FROM_TEXT = 130 TOO_LARGE_STRING_SIZE = 131 CANNOT_CREATE_TABLE_FROM_METADATA = 132 AGGREGATE_FUNCTION_DOESNT_ALLOW_PARAMETERS = 133 PARAMETERS_TO_AGGREGATE_FUNCTIONS_MUST_BE_LITERALS = 134 ZERO_ARRAY_OR_TUPLE_INDEX = 135 UNKNOWN_ELEMENT_IN_CONFIG = 137 EXCESSIVE_ELEMENT_IN_CONFIG = 138 NO_ELEMENTS_IN_CONFIG = 139 ALL_REQUESTED_COLUMNS_ARE_MISSING = 140 SAMPLING_NOT_SUPPORTED = 141 NOT_FOUND_NODE = 142 FOUND_MORE_THAN_ONE_NODE = 143 FIRST_DATE_IS_BIGGER_THAN_LAST_DATE = 144 UNKNOWN_OVERFLOW_MODE = 145 QUERY_SECTION_DOESNT_MAKE_SENSE = 146 NOT_FOUND_FUNCTION_ELEMENT_FOR_AGGREGATE = 147 NOT_FOUND_RELATION_ELEMENT_FOR_CONDITION = 148 NOT_FOUND_RHS_ELEMENT_FOR_CONDITION = 149 NO_ATTRIBUTES_LISTED = 150 INDEX_OF_COLUMN_IN_SORT_CLAUSE_IS_OUT_OF_RANGE = 151 UNKNOWN_DIRECTION_OF_SORTING = 152 ILLEGAL_DIVISION = 153 AGGREGATE_FUNCTION_NOT_APPLICABLE = 154 UNKNOWN_RELATION = 155 DICTIONARIES_WAS_NOT_LOADED = 156 ILLEGAL_OVERFLOW_MODE = 157 TOO_MANY_ROWS = 158 TIMEOUT_EXCEEDED = 159 TOO_SLOW = 160 TOO_MANY_COLUMNS = 161 TOO_DEEP_SUBQUERIES = 162 TOO_DEEP_PIPELINE = 163 READONLY = 164 TOO_MANY_TEMPORARY_COLUMNS = 165 TOO_MANY_TEMPORARY_NON_CONST_COLUMNS = 166 TOO_DEEP_AST = 167 TOO_BIG_AST = 168 BAD_TYPE_OF_FIELD = 169 BAD_GET = 170 BLOCKS_HAVE_DIFFERENT_STRUCTURE = 171 CANNOT_CREATE_DIRECTORY = 172 CANNOT_ALLOCATE_MEMORY = 173 CYCLIC_ALIASES = 174 CHUNK_NOT_FOUND = 176 DUPLICATE_CHUNK_NAME = 177 MULTIPLE_ALIASES_FOR_EXPRESSION = 178 MULTIPLE_EXPRESSIONS_FOR_ALIAS = 179 THERE_IS_NO_PROFILE = 180 ILLEGAL_FINAL = 181 ILLEGAL_PREWHERE = 182 UNEXPECTED_EXPRESSION = 183 ILLEGAL_AGGREGATION = 184 UNSUPPORTED_MYISAM_BLOCK_TYPE = 185 UNSUPPORTED_COLLATION_LOCALE = 186 COLLATION_COMPARISON_FAILED = 187 UNKNOWN_ACTION = 188 TABLE_MUST_NOT_BE_CREATED_MANUALLY = 189 SIZES_OF_ARRAYS_DOESNT_MATCH = 190 SET_SIZE_LIMIT_EXCEEDED = 191 UNKNOWN_USER = 192 WRONG_PASSWORD = 193 REQUIRED_PASSWORD = 194 IP_ADDRESS_NOT_ALLOWED = 195 UNKNOWN_ADDRESS_PATTERN_TYPE = 196 SERVER_REVISION_IS_TOO_OLD = 197 DNS_ERROR = 198 UNKNOWN_QUOTA = 199 QUOTA_DOESNT_ALLOW_KEYS = 200 QUOTA_EXPIRED = 201 TOO_MANY_SIMULTANEOUS_QUERIES = 202 NO_FREE_CONNECTION = 203 CANNOT_FSYNC = 204 NESTED_TYPE_TOO_DEEP = 205 ALIAS_REQUIRED = 206 AMBIGUOUS_IDENTIFIER = 207 EMPTY_NESTED_TABLE = 208 SOCKET_TIMEOUT = 209 NETWORK_ERROR = 210 EMPTY_QUERY = 211 UNKNOWN_LOAD_BALANCING = 212 UNKNOWN_TOTALS_MODE = 213 CANNOT_STATVFS = 214 NOT_AN_AGGREGATE = 215 QUERY_WITH_SAME_ID_IS_ALREADY_RUNNING = 216 CLIENT_HAS_CONNECTED_TO_WRONG_PORT = 217 TABLE_IS_DROPPED = 218 DATABASE_NOT_EMPTY = 219 DUPLICATE_INTERSERVER_IO_ENDPOINT = 220 NO_SUCH_INTERSERVER_IO_ENDPOINT = 221 ADDING_REPLICA_TO_NON_EMPTY_TABLE = 222 UNEXPECTED_AST_STRUCTURE = 223 REPLICA_IS_ALREADY_ACTIVE = 224 NO_ZOOKEEPER = 225 NO_FILE_IN_DATA_PART = 226 UNEXPECTED_FILE_IN_DATA_PART = 227 BAD_SIZE_OF_FILE_IN_DATA_PART = 228 QUERY_IS_TOO_LARGE = 229 NOT_FOUND_EXPECTED_DATA_PART = 230 TOO_MANY_UNEXPECTED_DATA_PARTS = 231 NO_SUCH_DATA_PART = 232 BAD_DATA_PART_NAME = 233 NO_REPLICA_HAS_PART = 234 DUPLICATE_DATA_PART = 235 ABORTED = 236 NO_REPLICA_NAME_GIVEN = 237 FORMAT_VERSION_TOO_OLD = 238 CANNOT_MUNMAP = 239 CANNOT_MREMAP = 240 MEMORY_LIMIT_EXCEEDED = 241 TABLE_IS_READ_ONLY = 242 NOT_ENOUGH_SPACE = 243 UNEXPECTED_ZOOKEEPER_ERROR = 244 CORRUPTED_DATA = 246 INCORRECT_MARK = 247 INVALID_PARTITION_VALUE = 248 NOT_ENOUGH_BLOCK_NUMBERS = 250 NO_SUCH_REPLICA = 251 TOO_MANY_PARTS = 252 REPLICA_IS_ALREADY_EXIST = 253 NO_ACTIVE_REPLICAS = 254 TOO_MANY_RETRIES_TO_FETCH_PARTS = 255 PARTITION_ALREADY_EXISTS = 256 PARTITION_DOESNT_EXIST = 257 UNION_ALL_RESULT_STRUCTURES_MISMATCH = 258 CLIENT_OUTPUT_FORMAT_SPECIFIED = 260 UNKNOWN_BLOCK_INFO_FIELD = 261 BAD_COLLATION = 262 CANNOT_COMPILE_CODE = 263 INCOMPATIBLE_TYPE_OF_JOIN = 264 NO_AVAILABLE_REPLICA = 265 MISMATCH_REPLICAS_DATA_SOURCES = 266 STORAGE_DOESNT_SUPPORT_PARALLEL_REPLICAS = 267 CPUID_ERROR = 268 INFINITE_LOOP = 269 CANNOT_COMPRESS = 270 CANNOT_DECOMPRESS = 271 AIO_SUBMIT_ERROR = 272 AIO_COMPLETION_ERROR = 273 AIO_READ_ERROR = 274 AIO_WRITE_ERROR = 275 INDEX_NOT_USED = 277 LEADERSHIP_LOST = 278 ALL_CONNECTION_TRIES_FAILED = 279 NO_AVAILABLE_DATA = 280 DICTIONARY_IS_EMPTY = 281 INCORRECT_INDEX = 282 UNKNOWN_DISTRIBUTED_PRODUCT_MODE = 283 UNKNOWN_GLOBAL_SUBQUERIES_METHOD = 284 TOO_LESS_LIVE_REPLICAS = 285 UNSATISFIED_QUORUM_FOR_PREVIOUS_WRITE = 286 UNKNOWN_FORMAT_VERSION = 287 DISTRIBUTED_IN_JOIN_SUBQUERY_DENIED = 288 REPLICA_IS_NOT_IN_QUORUM = 289 LIMIT_EXCEEDED = 290 DATABASE_ACCESS_DENIED = 291 LEADERSHIP_CHANGED = 292 MONGODB_CANNOT_AUTHENTICATE = 293 INVALID_BLOCK_EXTRA_INFO = 294 RECEIVED_EMPTY_DATA = 295 NO_REMOTE_SHARD_FOUND = 296 SHARD_HAS_NO_CONNECTIONS = 297 CANNOT_PIPE = 298 CANNOT_FORK = 299 CANNOT_DLSYM = 300 CANNOT_CREATE_CHILD_PROCESS = 301 CHILD_WAS_NOT_EXITED_NORMALLY = 302 CANNOT_SELECT = 303 CANNOT_WAITPID = 304 TABLE_WAS_NOT_DROPPED = 305 TOO_DEEP_RECURSION = 306 TOO_MANY_BYTES = 307 UNEXPECTED_NODE_IN_ZOOKEEPER = 308 FUNCTION_CANNOT_HAVE_PARAMETERS = 309 INVALID_SHARD_WEIGHT = 317 INVALID_CONFIG_PARAMETER = 318 UNKNOWN_STATUS_OF_INSERT = 319 VALUE_IS_OUT_OF_RANGE_OF_DATA_TYPE = 321 BARRIER_TIMEOUT = 335 UNKNOWN_DATABASE_ENGINE = 336 DDL_GUARD_IS_ACTIVE = 337 UNFINISHED = 341 METADATA_MISMATCH = 342 SUPPORT_IS_DISABLED = 344 TABLE_DIFFERS_TOO_MUCH = 345 CANNOT_CONVERT_CHARSET = 346 CANNOT_LOAD_CONFIG = 347 CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN = 349 INCOMPATIBLE_SOURCE_TABLES = 350 AMBIGUOUS_TABLE_NAME = 351 AMBIGUOUS_COLUMN_NAME = 352 INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE = 353 ZLIB_INFLATE_FAILED = 354 ZLIB_DEFLATE_FAILED = 355 BAD_LAMBDA = 356 RESERVED_IDENTIFIER_NAME = 357 INTO_OUTFILE_NOT_ALLOWED = 358 TABLE_SIZE_EXCEEDS_MAX_DROP_SIZE_LIMIT = 359 CANNOT_CREATE_CHARSET_CONVERTER = 360 SEEK_POSITION_OUT_OF_BOUND = 361 CURRENT_WRITE_BUFFER_IS_EXHAUSTED = 362 CANNOT_CREATE_IO_BUFFER = 363 RECEIVED_ERROR_TOO_MANY_REQUESTS = 364 OUTPUT_IS_NOT_SORTED = 365 SIZES_OF_NESTED_COLUMNS_ARE_INCONSISTENT = 366 TOO_MANY_FETCHES = 367 BAD_CAST = 368 ALL_REPLICAS_ARE_STALE = 369 DATA_TYPE_CANNOT_BE_USED_IN_TABLES = 370 INCONSISTENT_CLUSTER_DEFINITION = 371 SESSION_NOT_FOUND = 372 SESSION_IS_LOCKED = 373 INVALID_SESSION_TIMEOUT = 374 CANNOT_DLOPEN = 375 CANNOT_PARSE_UUID = 376 ILLEGAL_SYNTAX_FOR_DATA_TYPE = 377 DATA_TYPE_CANNOT_HAVE_ARGUMENTS = 378 UNKNOWN_STATUS_OF_DISTRIBUTED_DDL_TASK = 379 CANNOT_KILL = 380 HTTP_LENGTH_REQUIRED = 381 CANNOT_LOAD_CATBOOST_MODEL = 382 CANNOT_APPLY_CATBOOST_MODEL = 383 PART_IS_TEMPORARILY_LOCKED = 384 MULTIPLE_STREAMS_REQUIRED = 385 NO_COMMON_TYPE = 386 EXTERNAL_LOADABLE_ALREADY_EXISTS = 387 CANNOT_ASSIGN_OPTIMIZE = 388 INSERT_WAS_DEDUPLICATED = 389 CANNOT_GET_CREATE_TABLE_QUERY = 390 EXTERNAL_LIBRARY_ERROR = 391 QUERY_IS_PROHIBITED = 392 THERE_IS_NO_QUERY = 393 QUERY_WAS_CANCELLED = 394 FUNCTION_THROW_IF_VALUE_IS_NON_ZERO = 395 TOO_MANY_ROWS_OR_BYTES = 396 QUERY_IS_NOT_SUPPORTED_IN_MATERIALIZED_VIEW = 397 CANNOT_PARSE_DOMAIN_VALUE_FROM_STRING = 441 KEEPER_EXCEPTION = 999 POCO_EXCEPTION = 1000 STD_EXCEPTION = 1001 UNKNOWN_EXCEPTION = 1002 CONDITIONAL_TREE_PARENT_NOT_FOUND = 2001 ILLEGAL_PROJECTION_MANIPULATOR = 2002 class Error(Exception): code = None def __init__(self, message=None): self.message = message super(Error, self).__init__(message) def __str__(self): message = ' ' + self.message if self.message is not None else '' return 'Code: {}.{}'.format(self.code, message) class ServerException(Error): def __init__(self, message, code=None, nested=None): self.message = message self.code = code self.nested = nested super(ServerException, self).__init__(message) def __str__(self): nested = '\nNested: {}'.format(self.nested) if self.nested else '' return 'Code: {}.{}\n{}'.format(self.code, nested, self.message) class LogicalError(Error): code = ErrorCodes.LOGICAL_ERROR class UnknownTypeError(Error): code = ErrorCodes.UNKNOWN_TYPE class ChecksumDoesntMatchError(Error): code = ErrorCodes.CHECKSUM_DOESNT_MATCH class TypeMismatchError(Error): code = ErrorCodes.TYPE_MISMATCH class UnknownCompressionMethod(Error): code = ErrorCodes.UNKNOWN_COMPRESSION_METHOD class TooLargeStringSize(Error): code = ErrorCodes.TOO_LARGE_STRING_SIZE class NetworkError(Error): code = ErrorCodes.NETWORK_ERROR class SocketTimeoutError(Error): code = ErrorCodes.SOCKET_TIMEOUT class UnexpectedPacketFromServerError(Error): code = ErrorCodes.UNEXPECTED_PACKET_FROM_SERVER class UnknownPacketFromServerError(Error): code = ErrorCodes.UNKNOWN_PACKET_FROM_SERVER class CannotParseUuidError(Error): code = ErrorCodes.CANNOT_PARSE_UUID class CannotParseDomainError(Error): code = ErrorCodes.CANNOT_PARSE_DOMAIN_VALUE_FROM_STRING class PartiallyConsumedQueryError(Error): code = -1 def __str__(self): return 'Simultaneous queries on single connection detected' clickhouse-driver-0.2.11/clickhouse_driver/log.py000066400000000000000000000021031522645447600220670ustar00rootroot00000000000000import logging logger = logging.getLogger(__name__) # Keep in sync with ClickHouse priorities # https://github.com/ClickHouse/ClickHouse/blob/master/src/Interpreters/InternalTextLogsQueue.cpp log_priorities = ( 'Unknown', 'Fatal', 'Critical', 'Error', 'Warning', 'Notice', 'Information', 'Debug', 'Trace', 'Test', ) num_priorities = len(log_priorities) def log_block(block): if block is None: return column_names = [x[0] for x in block.columns_with_types] for row in block.get_rows(): row = dict(zip(column_names, row)) if 1 <= row['priority'] <= num_priorities: priority = log_priorities[row['priority']] else: priority = row[0] # thread_number in servers prior 20.x thread_id = row.get('thread_id') or row['thread_number'] logger.info( '[ %s ] [ %s ] {%s} <%s> %s: %s', row['host_name'], thread_id, row['query_id'], priority, row['source'], row['text'] ) clickhouse-driver-0.2.11/clickhouse_driver/numpy/000077500000000000000000000000001522645447600221105ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/numpy/__init__.py000066400000000000000000000000001522645447600242070ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/numpy/block.py000066400000000000000000000002641522645447600235560ustar00rootroot00000000000000import numpy as np from ..block import ColumnOrientedBlock class NumpyColumnOrientedBlock(ColumnOrientedBlock): def transposed(self): return np.transpose(self.data) clickhouse-driver-0.2.11/clickhouse_driver/numpy/helpers.py000066400000000000000000000014431522645447600241260ustar00rootroot00000000000000import numpy as np import pandas as pd from pandas.core.arrays import ExtensionArray def column_chunks(columns, n): for column in columns: if not isinstance( column, (np.ndarray, pd.DatetimeIndex, ExtensionArray) ): raise TypeError( 'Unsupported column type: {}. ' 'ndarray/DatetimeIndex/ExtensionArray is expected.' .format(type(column)) ) # create chunk generator for every column chunked = [ iter(np.array_split(c, len(c) // n) if len(c) > n else [c]) for c in columns ] while True: # get next chunk for every column item = [next(column, []) for column in chunked] if not any(len(x) for x in item): break yield item clickhouse-driver-0.2.11/clickhouse_driver/numpy/result.py000066400000000000000000000067531522645447600240130ustar00rootroot00000000000000from itertools import chain import numpy as np import pandas as pd from pandas.api.types import union_categoricals from ..progress import Progress from ..result import QueryResult class NumpyQueryResult(QueryResult): """ Stores query result from multiple blocks as numpy arrays. """ def store(self, packet): block = getattr(packet, 'block', None) if block is None: return # Header block contains no rows. Pick columns from it. if block.num_rows: if self.columnar: self.data.append(block.get_columns()) else: self.data.extend(block.get_rows()) elif not self.columns_with_types: self.columns_with_types = block.columns_with_types def get_result(self): """ :return: stored query result. """ for packet in self.packet_generator: self.store(packet) if self.columnar: data = [] # Transpose to a list of columns, each column is list of chunks for column_chunks in zip(*self.data): # Concatenate chunks for each column if isinstance(column_chunks[0], np.ndarray): column = np.concatenate(column_chunks) elif isinstance(column_chunks[0], pd.Categorical): column = union_categoricals(column_chunks) else: column = tuple(chain.from_iterable(column_chunks)) data.append(column) else: data = self.data if self.with_column_types: return data, self.columns_with_types else: return data class NumpyProgressQueryResult(NumpyQueryResult): """ Stores query result and progress information from multiple blocks. Provides iteration over query progress. """ def __init__(self, *args, **kwargs): self.progress_totals = Progress() super(NumpyProgressQueryResult, self).__init__(*args, **kwargs) def __iter__(self): return self def __next__(self): while True: packet = next(self.packet_generator) progress_packet = getattr(packet, 'progress', None) if progress_packet: self.progress_totals.increment(progress_packet) return ( self.progress_totals.rows, self.progress_totals.total_rows ) else: self.store(packet) def get_result(self): # Read all progress packets. for _ in self: pass return super(NumpyProgressQueryResult, self).get_result() class NumpyIterQueryResult(object): """ Provides iteration over returned data by chunks (streaming by chunks). """ def __init__( self, packet_generator, with_column_types=False): self.packet_generator = packet_generator self.with_column_types = with_column_types self.first_block = True super(NumpyIterQueryResult, self).__init__() def __iter__(self): return self def __next__(self): packet = next(self.packet_generator) block = getattr(packet, 'block', None) if block is None: return [] if self.first_block and self.with_column_types: self.first_block = False rv = [block.columns_with_types] rv.extend(block.get_rows()) return rv else: return block.get_rows() clickhouse-driver-0.2.11/clickhouse_driver/opentelemetry.py000066400000000000000000000031261522645447600242100ustar00rootroot00000000000000 class OpenTelemetryTraceContext(object): traceparent_tpl = 'xx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx-xx' translation = str.maketrans('1234567890abcdef', 'xxxxxxxxxxxxxxxx') def __init__(self, traceparent, tracestate): # xx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx-xx # ^ ^ ^ ^ # version trace_id span_id flags self.trace_id = None # UUID self.span_id = None # UInt64 self.tracestate = tracestate # String self.trace_flags = None # UInt8 if traceparent is not None: self.parse_traceparent(traceparent) super(OpenTelemetryTraceContext, self).__init__() def parse_traceparent(self, traceparent): traceparent = traceparent.lower() if len(traceparent) != len(self.traceparent_tpl): raise ValueError('unexpected length {}, expected {}'.format( len(traceparent), len(self.traceparent_tpl) )) if traceparent.translate(self.translation) != self.traceparent_tpl: raise ValueError( 'Malformed traceparant header: {}'.format(traceparent) ) parts = traceparent.split('-') version = int(parts[0], 16) if version != 0: raise ValueError( 'unexpected version {}, expected 00'.format(parts[0]) ) self.trace_id = (int(parts[1][16:], 16) << 64) + int(parts[1][:16], 16) self.span_id = int(parts[2], 16) self.trace_flags = int(parts[3], 16) clickhouse-driver-0.2.11/clickhouse_driver/progress.py000066400000000000000000000030461522645447600231610ustar00rootroot00000000000000from . import defines from .varint import read_varint class Progress(object): def __init__(self): self.rows = 0 self.bytes = 0 self.total_rows = 0 # total_rows_to_read self.total_bytes = 0 # total_bytes_to_read self.written_rows = 0 self.written_bytes = 0 self.elapsed_ns = 0 super(Progress, self).__init__() def read(self, server_info, fin): self.rows = read_varint(fin) self.bytes = read_varint(fin) revision = server_info.used_revision if revision >= defines.DBMS_MIN_REVISION_WITH_TOTAL_ROWS_IN_PROGRESS: self.total_rows = read_varint(fin) if revision >= defines. \ DBMS_MIN_PROTOCOL_VERSION_WITH_TOTAL_BYTES_IN_PROGRESS: self.total_bytes = read_varint(fin) if revision >= defines.DBMS_MIN_REVISION_WITH_CLIENT_WRITE_INFO: self.written_rows = read_varint(fin) self.written_bytes = read_varint(fin) if revision >= defines. \ DBMS_MIN_PROTOCOL_VERSION_WITH_SERVER_QUERY_TIME_IN_PROGRESS: self.elapsed_ns = read_varint(fin) def increment(self, another_progress): self.rows += another_progress.rows self.bytes += another_progress.bytes self.total_rows += another_progress.total_rows self.total_bytes += another_progress.total_bytes self.written_rows += another_progress.written_rows self.written_bytes += another_progress.written_bytes self.elapsed_ns += another_progress.elapsed_ns clickhouse-driver-0.2.11/clickhouse_driver/protocol.py000066400000000000000000000056251522645447600231630ustar00rootroot00000000000000 class ClientPacketTypes(object): """ Packet types that client transmits """ # Name, version, revision, default DB HELLO = 0 # Query id, query settings, stage up to which the query must be executed, # whether the compression must be used, query text # (without data for INSERTs). QUERY = 1 # A block of data (compressed or not). DATA = 2 # Cancel the query execution. CANCEL = 3 # Check that connection to the server is alive. PING = 4 # Check status of tables on the server. TABLES_STATUS_REQUEST = 5 _types_str = [ 'Hello', 'Query', 'Data', 'Cancel', 'Ping', 'TablesStatusRequest' ] @classmethod def to_str(cls, packet): try: return cls._types_str[packet] except IndexError: return 'Unknown packet' class ServerPacketTypes(object): """ Packet types that server transmits. """ # Name, version, revision. HELLO = 0 # A block of data (compressed or not). DATA = 1 # The exception during query execution. EXCEPTION = 2 # Query execution progress: rows read, bytes read. PROGRESS = 3 # Ping response PONG = 4 # All packets were transmitted END_OF_STREAM = 5 # Packet with profiling info. PROFILE_INFO = 6 # A block with totals (compressed or not). TOTALS = 7 # A block with minimums and maximums (compressed or not). EXTREMES = 8 # A response to TablesStatus request. TABLES_STATUS_RESPONSE = 9 # System logs of the query execution LOG = 10 # Columns' description for default values calculation TABLE_COLUMNS = 11 # List of unique parts ids. PART_UUIDS = 12 # String (UUID) describes a request for which next task is needed READ_TASK_REQUEST = 13 # Packet with profile events from server. PROFILE_EVENTS = 14 MERGE_TREE_ALL_RANGES_ANNOUNCEMENT = 15 # Request from a MergeTree replica to a coordinator MERGE_TREE_READ_TASK_REQUEST = 16 # Receive server's (session-wide) default timezone TIMEZONE_UPDATE = 17 _types_str = [ 'Hello', 'Data', 'Exception', 'Progress', 'Pong', 'EndOfStream', 'ProfileInfo', 'Totals', 'Extremes', 'TablesStatusResponse', 'Log', 'TableColumns', 'PartUUIDs', 'ReadTaskRequest', 'ProfileEvents', 'MergeTreeAllRangesAnnouncement', 'MergeTreeReadTaskRequest', 'TimezoneUpdate' ] @classmethod def to_str(cls, packet): try: return cls._types_str[packet] except IndexError: return 'Unknown packet' @classmethod def strings_in_message(cls, packet): if packet == cls.TABLE_COLUMNS: return 2 return 0 class Compression(object): DISABLED = 0 ENABLED = 1 class CompressionMethod(object): LZ4 = 1 LZ4HC = 2 ZSTD = 3 class CompressionMethodByte(object): LZ4 = 0x82 ZSTD = 0x90 clickhouse-driver-0.2.11/clickhouse_driver/queryprocessingstage.py000066400000000000000000000002721522645447600256010ustar00rootroot00000000000000 class QueryProcessingStage(object): """ Determines till which state SELECT query should be executed. """ FETCH_COLUMNS = 0 WITH_MERGEABLE_STATE = 1 COMPLETE = 2 clickhouse-driver-0.2.11/clickhouse_driver/reader.py000066400000000000000000000024521522645447600225570ustar00rootroot00000000000000from struct import Struct from .varint import read_varint def read_binary_str(buf): length = read_varint(buf) return read_binary_str_fixed_len(buf, length) def read_binary_bytes(buf): length = read_varint(buf) return read_binary_bytes_fixed_len(buf, length) def read_binary_str_fixed_len(buf, length): return read_binary_bytes_fixed_len(buf, length).decode('utf-8') def read_binary_bytes_fixed_len(buf, length): return buf.read(length) def read_binary_int(buf, fmt): """ Reads int from buffer with provided format. """ # Little endian. s = Struct('<' + fmt) return s.unpack(buf.read(s.size))[0] def read_binary_int8(buf): return read_binary_int(buf, 'b') def read_binary_int16(buf): return read_binary_int(buf, 'h') def read_binary_int32(buf): return read_binary_int(buf, 'i') def read_binary_int64(buf): return read_binary_int(buf, 'q') def read_binary_uint8(buf): return read_binary_int(buf, 'B') def read_binary_uint16(buf): return read_binary_int(buf, 'H') def read_binary_uint32(buf): return read_binary_int(buf, 'I') def read_binary_uint64(buf): return read_binary_int(buf, 'Q') def read_binary_uint128(buf): hi = read_binary_int(buf, 'Q') lo = read_binary_int(buf, 'Q') return (hi << 64) + lo clickhouse-driver-0.2.11/clickhouse_driver/readhelpers.py000066400000000000000000000013151522645447600236100ustar00rootroot00000000000000from .errors import ServerException from .reader import read_binary_str, read_binary_uint8, read_binary_int32 def read_exception(buf, additional_message=None): code = read_binary_int32(buf) name = read_binary_str(buf) message = read_binary_str(buf) stack_trace = read_binary_str(buf) has_nested = bool(read_binary_uint8(buf)) new_message = '' if additional_message: new_message += additional_message + '. ' if name != 'DB::Exception': new_message += name + ". " new_message += message + ". Stack trace:\n\n" + stack_trace nested = None if has_nested: nested = read_exception(buf) return ServerException(new_message, code, nested=nested) clickhouse-driver-0.2.11/clickhouse_driver/result.py000066400000000000000000000100021522645447600226210ustar00rootroot00000000000000from .blockstreamprofileinfo import BlockStreamProfileInfo from .progress import Progress class QueryResult(object): """ Stores query result from multiple blocks. """ def __init__( self, packet_generator, with_column_types=False, columnar=False): self.packet_generator = packet_generator self.with_column_types = with_column_types self.data = [] self.columns_with_types = [] self.columnar = columnar super(QueryResult, self).__init__() def store(self, packet): block = getattr(packet, 'block', None) if block is None: return # Header block contains no rows. Pick columns from it. if block.num_rows: if self.columnar: columns = block.get_columns() if self.data: # Extend corresponding column. for i, column in enumerate(columns): self.data[i].extend(column) else: # Cast tuples to lists for further extending. # Concatenating tuples produce new tuple. It's slow. self.data = [list(c) for c in columns] else: self.data.extend(block.get_rows()) elif not self.columns_with_types: self.columns_with_types = block.columns_with_types def get_result(self): """ :return: stored query result. """ for packet in self.packet_generator: self.store(packet) data = self.data if self.columnar: data = [tuple(c) for c in self.data] if self.with_column_types: return data, self.columns_with_types else: return data class ProgressQueryResult(QueryResult): """ Stores query result and progress information from multiple blocks. Provides iteration over query progress. """ def __init__(self, *args, **kwargs): self.progress_totals = Progress() super(ProgressQueryResult, self).__init__(*args, **kwargs) def __iter__(self): return self def __next__(self): while True: packet = next(self.packet_generator) progress_packet = getattr(packet, 'progress', None) if progress_packet: self.progress_totals.increment(progress_packet) return ( self.progress_totals.rows, self.progress_totals.total_rows ) else: self.store(packet) def get_result(self): # Read all progress packets. for _ in self: pass return super(ProgressQueryResult, self).get_result() class IterQueryResult(object): """ Provides iteration over returned data by chunks (streaming by chunks). """ def __init__( self, packet_generator, with_column_types=False): self.packet_generator = packet_generator self.with_column_types = with_column_types self.first_block = True super(IterQueryResult, self).__init__() def __iter__(self): return self def __next__(self): packet = next(self.packet_generator) block = getattr(packet, 'block', None) if block is None: return [] if self.first_block and self.with_column_types: self.first_block = False rv = [block.columns_with_types] rv.extend(block.get_rows()) return rv else: return block.get_rows() class QueryInfo(object): def __init__(self): self.profile_info = BlockStreamProfileInfo() self.progress = Progress() self.elapsed = 0 def store_profile(self, profile_info): self.profile_info = profile_info def store_progress(self, progress): if self.progress: self.progress.increment(progress) else: self.progress = progress def store_elapsed(self, elapsed): self.elapsed = elapsed clickhouse-driver-0.2.11/clickhouse_driver/settings/000077500000000000000000000000001522645447600226005ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/settings/__init__.py000066400000000000000000000000001522645447600246770ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/settings/available.py000066400000000000000000000403451522645447600251000ustar00rootroot00000000000000from .types import ( SettingUInt64, SettingBool, SettingFloat, SettingString, SettingMaxThreads, SettingChar ) SettingInt64 = SettingUInt64 # Seconds and milliseconds should be set as ints. SettingSeconds = SettingMilliseconds = SettingUInt64 # Server cares about possible choices validation. # See https://github.com/yandex/ClickHouse/blob/master/dbms/src/ # Interpreters/Settings.h for all choices. SettingLoadBalancing = SettingTotalsMode = SettingCompressionMethod = \ SettingDistributedProductMode = SettingGlobalSubqueriesMethod = \ SettingDateTimeInputFormat = \ SettingURI = \ SettingJoinAlgorithm = \ SettingSpecialSort = \ SettingLogQueriesType = \ SettingDefaultDatabaseEngine = \ SettingString settings = { # Settings 'min_compress_block_size': SettingUInt64, 'max_compress_block_size': SettingUInt64, 'max_block_size': SettingUInt64, 'max_insert_block_size': SettingUInt64, 'min_insert_block_size_rows': SettingUInt64, 'min_insert_block_size_bytes': SettingUInt64, 'max_partitions_per_insert_block': SettingUInt64, 'max_threads': SettingMaxThreads, 'max_alter_threads': SettingMaxThreads, 'max_read_buffer_size': SettingUInt64, 'max_distributed_connections': SettingUInt64, 'max_query_size': SettingUInt64, 'interactive_delay': SettingUInt64, 'connect_timeout': SettingSeconds, 'connect_timeout_with_failover_ms': SettingMilliseconds, 'receive_timeout': SettingSeconds, 'send_timeout': SettingSeconds, 'queue_max_wait_ms': SettingMilliseconds, 'poll_interval': SettingUInt64, 'distributed_connections_pool_size': SettingUInt64, 'connections_with_failover_max_tries': SettingUInt64, 'extremes': SettingBool, 'use_uncompressed_cache': SettingBool, 'replace_running_query': SettingBool, 'background_pool_size': SettingUInt64, 'background_schedule_pool_size': SettingUInt64, 'distributed_directory_monitor_sleep_time_ms': SettingMilliseconds, 'distributed_directory_monitor_batch_inserts': SettingBool, 'distributed_directory_monitor_max_sleep_time_ms': SettingMilliseconds, 'optimize_move_to_prewhere': SettingBool, 'optimize_skip_unused_shards': SettingBool, 'optimize_read_in_order': SettingBool, 'optimize_min_equality_disjunction_chain_length': SettingUInt64, 'enable_optimize_predicate_expression': SettingBool, 'replication_alter_partitions_sync': SettingUInt64, 'replication_alter_columns_timeout': SettingUInt64, 'load_balancing': SettingLoadBalancing, 'totals_mode': SettingTotalsMode, 'totals_auto_threshold': SettingFloat, 'compile': SettingBool, 'compile_expressions': SettingBool, 'min_count_to_compile': SettingUInt64, 'group_by_two_level_threshold': SettingUInt64, 'group_by_two_level_threshold_bytes': SettingUInt64, 'distributed_aggregation_memory_efficient': SettingBool, 'aggregation_memory_efficient_merge_threads': SettingUInt64, 'max_parallel_replicas': SettingUInt64, 'parallel_replicas_count': SettingUInt64, 'parallel_replica_offset': SettingUInt64, 'skip_unavailable_shards': SettingBool, 'distributed_group_by_no_merge': SettingBool, 'merge_tree_min_rows_for_concurrent_read': SettingUInt64, 'merge_tree_min_rows_for_seek': SettingUInt64, 'merge_tree_coarse_index_granularity': SettingUInt64, 'merge_tree_max_rows_to_use_cache': SettingUInt64, 'merge_tree_min_bytes_for_concurrent_read': SettingUInt64, 'merge_tree_min_bytes_for_seek': SettingUInt64, 'merge_tree_max_bytes_to_use_cache': SettingUInt64, 'merge_tree_uniform_read_distribution': SettingBool, 'mysql_max_rows_to_insert': SettingUInt64, 'min_bytes_to_use_direct_io': SettingUInt64, 'force_index_by_date': SettingBool, 'force_primary_key': SettingBool, 'mark_cache_min_lifetime': SettingUInt64, 'max_streams_to_max_threads_ratio': SettingFloat, 'network_compression_method': SettingCompressionMethod, 'network_zstd_compression_level': SettingInt64, 'priority': SettingUInt64, 'log_queries': SettingBool, 'log_queries_cut_to_length': SettingUInt64, 'query_profiler_real_time_period_ns': SettingUInt64, 'query_profiler_cpu_time_period_ns': SettingUInt64, 'enable_debug_queries': SettingBool, 'distributed_product_mode': SettingDistributedProductMode, 'max_concurrent_queries_for_user': SettingUInt64, 'insert_deduplicate': SettingBool, 'insert_quorum': SettingUInt64, 'insert_quorum_timeout': SettingMilliseconds, 'select_sequential_consistency': SettingUInt64, 'table_function_remote_max_addresses': SettingUInt64, 'read_backoff_min_latency_ms': SettingMilliseconds, 'read_backoff_max_throughput': SettingUInt64, 'read_backoff_min_interval_between_events_ms': SettingMilliseconds, 'read_backoff_min_events': SettingUInt64, 'memory_tracker_fault_probability': SettingFloat, 'enable_http_compression': SettingBool, 'http_zlib_compression_level': SettingInt64, 'http_native_compression_disable_checksumming_on_decompress': SettingBool, 'count_distinct_implementation': SettingString, 'add_http_cors_header': SettingBool, 'input_format_skip_unknown_fields': SettingBool, 'input_format_import_nested_json': SettingBool, 'input_format_values_interpret_expressions': SettingBool, 'input_format_with_names_use_header': SettingBool, 'input_format_defaults_for_omitted_fields': SettingBool, 'input_format_null_as_default': SettingBool, 'input_format_values_deduce_templates_of_expressions': SettingBool, 'input_format_values_accurate_types_of_literals': SettingBool, 'input_format_allow_errors_num': SettingUInt64, 'input_format_allow_errors_ratio': SettingFloat, 'input_format_csv_unquoted_null_literal_as_null': SettingBool, 'output_format_write_statistics': SettingBool, 'output_format_json_quote_64bit_integers': SettingBool, 'output_format_json_quote_denormals': SettingBool, 'output_format_json_escape_forward_slashes': SettingBool, 'output_format_pretty_max_rows': SettingUInt64, 'output_format_pretty_max_column_pad_width': SettingUInt64, 'output_format_pretty_color': SettingBool, 'output_format_parquet_row_group_size': SettingUInt64, 'use_client_time_zone': SettingBool, 'send_progress_in_http_headers': SettingBool, 'http_headers_progress_interval_ms': SettingUInt64, 'fsync_metadata': SettingBool, 'join_use_nulls': SettingBool, 'join_default_strictness': SettingString, 'preferred_block_size_bytes': SettingUInt64, 'max_replica_delay_for_distributed_queries': SettingUInt64, 'fallback_to_stale_replicas_for_distributed_queries': SettingBool, 'preferred_max_column_in_block_size_bytes': SettingUInt64, 'insert_distributed_sync': SettingBool, 'insert_distributed_timeout': SettingUInt64, 'distributed_ddl_task_timeout': SettingInt64, 'stream_flush_interval_ms': SettingMilliseconds, 'format_schema': SettingString, 'insert_allow_materialized_columns': SettingBool, 'http_connection_timeout': SettingSeconds, 'http_send_timeout': SettingSeconds, 'http_receive_timeout': SettingSeconds, 'optimize_throw_if_noop': SettingBool, 'use_index_for_in_with_subqueries': SettingBool, 'empty_result_for_aggregation_by_empty_set': SettingBool, 'allow_distributed_ddl': SettingBool, 'odbc_max_field_size': SettingUInt64, # Limits 'max_rows_to_read': SettingUInt64, 'max_bytes_to_read': SettingUInt64, 'read_overflow_mode': SettingString, 'max_rows_to_group_by': SettingUInt64, 'group_by_overflow_mode': SettingString, 'max_bytes_before_external_group_by': SettingUInt64, 'max_rows_to_sort': SettingUInt64, 'max_bytes_to_sort': SettingUInt64, 'sort_overflow_mode': SettingString, 'max_bytes_before_external_sort': SettingUInt64, 'max_bytes_before_remerge_sort': SettingUInt64, 'max_result_rows': SettingUInt64, 'max_result_bytes': SettingUInt64, 'result_overflow_mode': SettingString, 'max_execution_time': SettingSeconds, 'timeout_overflow_mode': SettingString, 'min_execution_speed': SettingUInt64, 'timeout_before_checking_execution_speed': SettingSeconds, 'max_columns_to_read': SettingUInt64, 'max_temporary_columns': SettingUInt64, 'max_temporary_non_const_columns': SettingUInt64, 'max_subquery_depth': SettingUInt64, 'max_pipeline_depth': SettingUInt64, 'max_ast_depth': SettingUInt64, 'max_ast_elements': SettingUInt64, 'max_expanded_ast_elements': SettingUInt64, 'readonly': SettingUInt64, 'max_rows_in_set': SettingUInt64, 'max_bytes_in_set': SettingUInt64, 'set_overflow_mode': SettingString, 'max_rows_in_join': SettingUInt64, 'max_bytes_in_join': SettingUInt64, 'join_overflow_mode': SettingString, 'max_rows_to_transfer': SettingUInt64, 'max_bytes_to_transfer': SettingUInt64, 'transfer_overflow_mode': SettingString, 'max_rows_in_distinct': SettingUInt64, 'max_bytes_in_distinct': SettingUInt64, 'distinct_overflow_mode': SettingString, 'max_memory_usage': SettingUInt64, 'max_memory_usage_for_user': SettingUInt64, 'max_memory_usage_for_all_queries': SettingUInt64, 'max_network_bandwidth': SettingUInt64, 'max_network_bytes': SettingUInt64, 'max_network_bandwidth_for_user': SettingUInt64, 'max_network_bandwidth_for_all_users': SettingUInt64, 'max_streams_multiplier_for_merge_tables': SettingFloat, 'max_http_get_redirects': SettingUInt64, 'max_execution_speed': SettingUInt64, 'max_execution_speed_bytes': SettingUInt64, 'format_csv_delimiter': SettingChar, 'format_csv_allow_single_quotes': SettingBool, 'format_csv_allow_double_quotes': SettingBool, 'format_template_resultset': SettingString, 'format_template_row': SettingString, 'format_template_rows_between_delimiter': SettingString, 'format_custom_escaping_rule': SettingString, 'format_custom_field_delimiter': SettingString, 'format_custom_row_before_delimiter': SettingString, 'format_custom_row_after_delimiter': SettingString, 'format_custom_row_between_delimiter': SettingString, 'format_custom_result_before_delimiter': SettingString, 'format_custom_result_after_delimiter': SettingString, 'enable_conditional_computation': SettingUInt64, 'date_time_input_format': SettingDateTimeInputFormat, 'log_profile_events': SettingBool, 'log_query_settings': SettingBool, 'log_query_threads': SettingBool, 'send_logs_level': SettingString, 'low_cardinality_max_dictionary_size': SettingUInt64, 'low_cardinality_use_single_dictionary_for_part': SettingBool, 'decimal_check_overflow': SettingBool, 'prefer_localhost_replica': SettingBool, 'max_fetch_partition_retries_count': SettingUInt64, 'asterisk_left_columns_only': SettingBool, 'http_max_multipart_form_data_size': SettingUInt64, 'calculate_text_stack_trace': SettingBool, 'parallel_view_processing': SettingBool, 'allow_experimental_low_cardinality_type': SettingBool, 'allow_experimental_decimal_type': SettingBool, 'allow_suspicious_low_cardinality_types': SettingBool, 'allow_experimental_multiple_joins_emulation': SettingBool, 'allow_experimental_cross_to_join_conversion': SettingBool, 'allow_experimental_data_skipping_indices': SettingBool, 'allow_hyperscan': SettingBool, 'allow_simdjson': SettingBool, 'allow_introspection_functions': SettingBool, 'allow_drop_detached': SettingBool, 'allow_experimental_live_view': SettingBool, 'allow_ddl': SettingBool, 'partial_merge_join': SettingBool, 'partial_merge_join_optimizations': SettingBool, 'partial_merge_join_rows_in_right_blocks': SettingUInt64, 'partial_merge_join_rows_in_left_blocks': SettingFloat, 'distributed_replica_error_half_life': SettingSeconds, 'distributed_replica_error_cap': SettingUInt64, 'min_free_disk_space_for_temporary_data': SettingUInt64, 'tcp_keep_alive_timeout': SettingSeconds, 'connection_pool_max_wait_ms': SettingMilliseconds, 'kafka_max_wait_ms': SettingMilliseconds, 'idle_connection_timeout': SettingUInt64, 's3_min_upload_part_size': SettingUInt64, 'any_join_distinct_right_table_keys': SettingBool, 'join_any_take_last_row': SettingBool, 'stream_poll_timeout_ms': SettingMilliseconds, 'joined_subquery_requires_alias': SettingBool, 'enable_unaligned_array_join': SettingBool, 'low_cardinality_allow_in_native_format': SettingBool, 'external_table_functions_use_nulls': SettingBool, 'experimental_use_processors': SettingBool, 'check_query_single_value_result': SettingBool, 'live_view_heartbeat_interval': SettingSeconds, 'temporary_live_view_timeout': SettingSeconds, 'max_live_view_insert_blocks_before_refresh': SettingUInt64, 'max_insert_threads': SettingUInt64, 'replace_running_query_max_wait_ms': SettingMilliseconds, 'background_move_pool_size': SettingUInt64, 'min_count_to_compile_expression': SettingUInt64, 'force_optimize_skip_unused_shards': SettingUInt64, 'input_format_parallel_parsing': SettingBool, 'min_chunk_bytes_for_parallel_parsing': SettingUInt64, 'min_bytes_to_use_mmap_io': SettingUInt64, 'os_thread_priority': SettingInt64, 'input_format_tsv_empty_as_default': SettingBool, 'input_format_avro_schema_registry_url': SettingString, 'output_format_avro_codec': SettingString, 'output_format_avro_sync_interval': SettingUInt64, 'min_execution_speed_bytes': SettingUInt64, 'default_max_bytes_in_join': SettingUInt64, 'enable_optimize_predicate_expression_to_final_subquery': SettingBool, 'cancel_http_readonly_queries_on_client_close': SettingBool, 'enable_scalar_subquery_optimization': SettingBool, 'optimize_trivial_count_query': SettingBool, 'mutations_sync': SettingUInt64, 'optimize_if_chain_to_miltiif': SettingBool, 'max_parser_depth': SettingUInt64, 'max_joined_block_size_rows': SettingUInt64, 'connect_timeout_with_failover_secure_ms': SettingMilliseconds, 'parallel_distributed_insert_select': SettingBool, 'force_optimize_skip_unused_shards_no_nested': SettingBool, 'format_avro_schema_registry_url': SettingURI, 'output_format_tsv_crlf_end_of_line': SettingBool, 'join_algorithm': SettingJoinAlgorithm, 'memory_profiler_step': SettingUInt64, 'output_format_csv_crlf_end_of_line': SettingBool, 'allow_experimental_alter_materialized_view_structure': SettingBool, 'enable_early_constant_folding': SettingBool, 'deduplicate_blocks_in_dependent_materialized_views': SettingBool, 'use_compact_format_in_distributed_parts_names': SettingBool, 'multiple_joins_rewriter_version': SettingUInt64, 'min_insert_block_size_rows_for_materialized_views': SettingUInt64, 'min_insert_block_size_bytes_for_materialized_views': SettingUInt64, 'max_final_threads': SettingUInt64, 'background_buffer_flush_schedule_pool_size': SettingUInt64, 'background_distributed_schedule_pool_size': SettingUInt64, 'special_sort': SettingSpecialSort, 'optimize_distributed_group_by_sharding_key': SettingBool, 'log_queries_min_type': SettingLogQueriesType, 'allow_suspicious_codecs': SettingBool, 'metrics_perf_events_enabled': SettingBool, 'metrics_perf_events_list': SettingString, 'join_on_disk_max_files_to_merge': SettingUInt64, 'temporary_files_codec': SettingString, 'max_untracked_memory': SettingUInt64, 'memory_profiler_sample_probability': SettingFloat, 'optimize_aggregation_in_order': SettingBool, 'default_database_engine': SettingDefaultDatabaseEngine, 'allow_experimental_database_atomic': SettingBool, 'show_table_uuid_in_table_create_query_if_not_nil': SettingBool, 'optimize_arithmetic_operations_in_aggregate_functions': SettingBool, 'validate_polygons': SettingBool, 'transform_null_in': SettingBool, 'allow_nondeterministic_mutations': SettingBool, 'lock_acquire_timeout': SettingSeconds, 'materialize_ttl_after_modify': SettingBool, 'allow_experimental_geo_types': SettingBool, 'output_format_pretty_max_value_width': SettingUInt64, 'format_regexp': SettingString, 'format_regexp_escaping_rule': SettingString, 'format_regexp_skip_unmatched': SettingBool, 'output_format_enable_streaming': SettingBool, } clickhouse-driver-0.2.11/clickhouse_driver/settings/types.py000066400000000000000000000021241522645447600243150ustar00rootroot00000000000000from ..util.helpers import asbool from ..varint import write_varint from ..writer import write_binary_str class SettingType(object): @classmethod def write(cls, value, buf): raise NotImplementedError class SettingUInt64(SettingType): @classmethod def write(cls, value, buf): write_varint(int(value), buf) class SettingBool(SettingType): @classmethod def write(cls, value, buf): write_varint(asbool(value), buf) class SettingString(SettingType): @classmethod def write(cls, value, buf): write_binary_str(value, buf) class SettingChar(SettingType): @classmethod def write(cls, value, buf): write_binary_str(value[0], buf) class SettingFloat(SettingType): @classmethod def write(cls, value, buf): """ Float is written in string representation. """ write_binary_str(str(value), buf) class SettingMaxThreads(SettingUInt64): @classmethod def write(cls, value, buf): if value == 'auto': value = 0 super(SettingMaxThreads, cls).write(value, buf) clickhouse-driver-0.2.11/clickhouse_driver/settings/writer.py000066400000000000000000000021131522645447600244630ustar00rootroot00000000000000import logging from ..writer import write_binary_str, write_binary_uint8 from .available import settings as available_settings logger = logging.getLogger(__name__) class SettingsFlags: IMPORTANT = 0x1 CUSTOM = 0x2 def write_settings(settings, buf, settings_as_strings, flags): for setting, value in (settings or {}).items(): # If the server support settings as string we do not need to know # anything about them, so we can write any setting. if settings_as_strings: write_binary_str(setting, buf) write_binary_uint8(flags, buf) write_binary_str(str(value), buf) else: # If the server requires string in binary, # then they cannot be written without type. setting_writer = available_settings.get(setting) if not setting_writer: logger.warning('Unknown setting %s. Skipping', setting) continue write_binary_str(setting, buf) setting_writer.write(value, buf) write_binary_str('', buf) # end of settings clickhouse-driver-0.2.11/clickhouse_driver/streams/000077500000000000000000000000001522645447600224165ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/streams/__init__.py000066400000000000000000000000001522645447600245150ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/streams/compressed.py000066400000000000000000000054611522645447600251420ustar00rootroot00000000000000from io import BytesIO try: from clickhouse_cityhash.cityhash import CityHash128 except ImportError: raise RuntimeError( 'Package clickhouse-cityhash is required to use compression' ) from .native import BlockOutputStream, BlockInputStream from ..bufferedreader import CompressedBufferedReader from ..bufferedwriter import CompressedBufferedWriter from ..compression import get_decompressor_cls from ..defines import BUFFER_SIZE from ..reader import read_binary_uint8, read_binary_uint128 from ..writer import write_binary_uint8, write_binary_uint128 class CompressedBlockOutputStream(BlockOutputStream): def __init__(self, compressor_cls, compress_block_size, fout, context): self.compressor_cls = compressor_cls self.compress_block_size = compress_block_size self.raw_fout = fout self.compressor = self.compressor_cls() self.fout = CompressedBufferedWriter(self.compressor, BUFFER_SIZE) super(CompressedBlockOutputStream, self).__init__(self.fout, context) def get_compressed_hash(self, data): return CityHash128(data) def finalize(self): self.fout.flush() compressed = self.get_compressed() compressed_size = len(compressed) compressed_hash = self.get_compressed_hash(compressed) write_binary_uint128(compressed_hash, self.raw_fout) block_size = self.compress_block_size i = 0 while i < compressed_size: self.raw_fout.write(compressed[i:i + block_size]) i += block_size self.raw_fout.flush() def get_compressed(self): compressed = BytesIO() if self.compressor.method_byte is not None: write_binary_uint8(self.compressor.method_byte, compressed) extra_header_size = 1 # method else: extra_header_size = 0 data = self.compressor.get_compressed_data(extra_header_size) compressed.write(data) return compressed.getvalue() class CompressedBlockInputStream(BlockInputStream): def __init__(self, fin, context): self.raw_fin = fin fin = CompressedBufferedReader(self.read_block, BUFFER_SIZE) super(CompressedBlockInputStream, self).__init__(fin, context) def get_compressed_hash(self, data): return CityHash128(data) def read_block(self): compressed_hash = read_binary_uint128(self.raw_fin) method_byte = read_binary_uint8(self.raw_fin) decompressor_cls = get_decompressor_cls(method_byte) decompressor = decompressor_cls(self.raw_fin) if decompressor.method_byte is not None: extra_header_size = 1 # method else: extra_header_size = 0 return decompressor.get_decompressed_data( method_byte, compressed_hash, extra_header_size ) clickhouse-driver-0.2.11/clickhouse_driver/streams/native.py000066400000000000000000000066451522645447600242710ustar00rootroot00000000000000import logging from ..block import ColumnOrientedBlock, BlockInfo from ..columns.service import read_column, write_column from ..reader import read_binary_str, read_binary_uint8 from ..varint import write_varint, read_varint from ..writer import write_binary_str, write_binary_uint8 from .. import defines logger = logging.getLogger(__name__) class BlockOutputStream(object): def __init__(self, fout, context): self.fout = fout self.context = context super(BlockOutputStream, self).__init__() def write(self, block): revision = self.context.server_info.used_revision if revision >= defines.DBMS_MIN_REVISION_WITH_BLOCK_INFO: block.info.write(self.fout) # We write transposed data. n_columns = block.num_columns n_rows = block.num_rows write_varint(n_columns, self.fout) write_varint(n_rows, self.fout) for i, (col_name, col_type) in enumerate(block.columns_with_types): write_binary_str(col_name, self.fout) write_binary_str(col_type, self.fout) if n_columns: try: items = block.get_column_by_index(i) except IndexError: raise ValueError('Different rows length') if revision >= \ defines.DBMS_MIN_REVISION_WITH_CUSTOM_SERIALIZATION: # We write always sparse data without custom serialization. write_binary_uint8(0, self.fout) logger.debug('Writing column %s', col_name) write_column(self.context, col_name, col_type, items, self.fout, types_check=block.types_check) self.finalize() def finalize(self): self.fout.flush() class BlockInputStream(object): def __init__(self, fin, context): self.fin = fin self.context = context super(BlockInputStream, self).__init__() def read(self, use_numpy=None): info = BlockInfo() revision = self.context.server_info.used_revision if revision >= defines.DBMS_MIN_REVISION_WITH_BLOCK_INFO: info.read(self.fin) n_columns = read_varint(self.fin) n_rows = read_varint(self.fin) data, names, types = [], [], [] for i in range(n_columns): column_name = read_binary_str(self.fin) column_type = read_binary_str(self.fin) names.append(column_name) types.append(column_type) has_custom_serialization = False if revision >= defines.DBMS_MIN_REVISION_WITH_CUSTOM_SERIALIZATION: has_custom_serialization = bool(read_binary_uint8(self.fin)) if n_rows: logger.debug('Reading column %s', column_name) column = read_column( self.context, column_type, n_rows, self.fin, use_numpy=use_numpy, has_custom_serialization=has_custom_serialization ) data.append(column) if self.context.client_settings['use_numpy']: from ..numpy.block import NumpyColumnOrientedBlock block_cls = NumpyColumnOrientedBlock else: block_cls = ColumnOrientedBlock block = block_cls( columns_with_types=list(zip(names, types)), data=data, info=info, ) return block clickhouse-driver-0.2.11/clickhouse_driver/util/000077500000000000000000000000001522645447600217155ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/util/__init__.py000066400000000000000000000000001522645447600240140ustar00rootroot00000000000000clickhouse-driver-0.2.11/clickhouse_driver/util/compat.py000066400000000000000000000015541522645447600235570ustar00rootroot00000000000000 # Drop this when minimum supported version will be 3.7. try: import threading except ImportError: import dummy_threading as threading # noqa: F401 import json # noqa: F401 try: import orjson as json # noqa: F811 except ImportError: pass try: import ujson as json # noqa: F811,F401 except ImportError: pass try: # since tzlocal 4.0+ # this will avoid warning for get_localzone().key from tzlocal import get_localzone_name def get_localzone_name_compat(): try: return get_localzone_name() except Exception: return None except ImportError: from tzlocal import get_localzone def get_localzone_name_compat(): try: return get_localzone().key except AttributeError: return get_localzone().zone except Exception: return None clickhouse-driver-0.2.11/clickhouse_driver/util/escape.py000066400000000000000000000046051522645447600235340ustar00rootroot00000000000000from datetime import date, datetime, time from enum import Enum from functools import wraps from uuid import UUID from pytz import timezone escape_chars_map = { "\b": "\\b", "\f": "\\f", "\r": "\\r", "\n": "\\n", "\t": "\\t", "\0": "\\0", "\a": "\\a", "\v": "\\v", "\\": "\\\\", "'": "\\'" } def escape_datetime(item, context): server_tz = timezone(context.server_info.get_timezone()) if item.tzinfo is not None: item = item.astimezone(server_tz) return "'%s'" % item.strftime('%Y-%m-%d %H:%M:%S') def maybe_enquote_for_server(f): @wraps(f) def wrapper(*args, **kwargs): rv = f(*args, **kwargs) if kwargs.get('for_server'): is_str = isinstance(rv, str) if not is_str or (is_str and not rv.startswith("'")): rv = "'%s'" % rv return rv return wrapper @maybe_enquote_for_server def escape_param(item, context, for_server=False): if item is None: return 'NULL' elif isinstance(item, datetime): return escape_datetime(item, context) elif isinstance(item, date): return "'%s'" % item.strftime('%Y-%m-%d') elif isinstance(item, time): return "'%s'" % item.strftime('%H:%M:%S') elif isinstance(item, str): # We need double escaping for server-side parameters. if for_server: item = ''.join(escape_chars_map.get(c, c) for c in item) return "'%s'" % ''.join(escape_chars_map.get(c, c) for c in item) elif isinstance(item, (list, tuple)): brackets = '[%s]' if isinstance(item, list) else '(%s)' rv = brackets % ', '.join( str(escape_param(x, context)) for x in item ) # Server expects the whole collection literal as an escaped # string (Field dump format), not a bare [...] or (...). if for_server: # pragma: requires-clickhouse-22.8 rv = "'%s'" % ''.join(escape_chars_map.get(c, c) for c in rv) return rv elif isinstance(item, Enum): return escape_param(item.value, context, for_server=for_server) elif isinstance(item, UUID): return "'%s'" % str(item) else: return item def escape_params(params, context, for_server=False): escaped = {} for key, value in params.items(): escaped[key] = escape_param(value, context, for_server=for_server) return escaped clickhouse-driver-0.2.11/clickhouse_driver/util/helpers.py000066400000000000000000000107361522645447600237400ustar00rootroot00000000000000import ssl from itertools import islice, tee from urllib.parse import urlparse, parse_qs, unquote def chunks(seq, n): # islice is MUCH slower than slice for lists and tuples. if isinstance(seq, (list, tuple)): i = 0 item = seq[i:i+n] while item: yield list(item) i += n item = seq[i:i+n] else: it = iter(seq) item = list(islice(it, n)) while item: yield item item = list(islice(it, n)) def pairwise(iterable): a, b = tee(iterable) next(b, None) return zip(a, b) def column_chunks(columns, n): for column in columns: if not isinstance(column, (list, tuple)): raise TypeError( 'Unsupported column type: {}. list or tuple is expected.' .format(type(column)) ) # create chunk generator for every column g = [chunks(column, n) for column in columns] while True: # get next chunk for every column item = [next(column, []) for column in g] if not any(item): break yield item # from paste.deploy.converters def asbool(obj): if isinstance(obj, str): obj = obj.strip().lower() if obj in ['true', 'yes', 'on', 'y', 't', '1']: return True elif obj in ['false', 'no', 'off', 'n', 'f', '0']: return False else: raise ValueError('String is not true/false: %r' % obj) return bool(obj) def parse_url(url): """ Parses url into host and kwargs suitable for further Client construction. Return host and kwargs. For example:: clickhouse://[user:password]@localhost:9000/default clickhouses://[user:password]@localhost:9440/default Three URL schemes are supported: * clickhouse:// creates a normal TCP socket connection * clickhouses:// creates a SSL wrapped TCP socket connection Any additional querystring arguments will be passed along to the Connection class's initializer. """ url = urlparse(url) settings = {} kwargs = {} host = url.hostname if url.port is not None: kwargs['port'] = url.port path = url.path.replace('/', '', 1) if path: kwargs['database'] = path if url.username is not None: kwargs['user'] = unquote(url.username) if url.password is not None: kwargs['password'] = unquote(url.password) if url.scheme == 'clickhouses': kwargs['secure'] = True compression_algs = {'lz4', 'lz4hc', 'zstd'} timeouts = { 'connect_timeout', 'send_receive_timeout', 'sync_request_timeout' } for name, value in parse_qs(url.query).items(): if not value or not len(value): continue value = value[0] if name == 'compression': value = value.lower() if value in compression_algs: kwargs[name] = value else: kwargs[name] = asbool(value) elif name == 'secure': kwargs[name] = asbool(value) elif name == 'use_numpy': settings[name] = asbool(value) elif name == 'round_robin': kwargs[name] = asbool(value) elif name == 'client_name': kwargs[name] = value elif name in timeouts: kwargs[name] = float(value) elif name == 'compress_block_size': kwargs[name] = int(value) elif name == 'settings_is_important': kwargs[name] = asbool(value) elif name == 'tcp_keepalive': try: kwargs[name] = asbool(value) except ValueError: parts = value.split(',') kwargs[name] = ( int(parts[0]), int(parts[1]), int(parts[2]) ) elif name == 'client_revision': kwargs[name] = int(value) # ssl elif name == 'verify': kwargs[name] = asbool(value) elif name == 'check_hostname': kwargs[name] = asbool(value) elif name == 'ssl_version': kwargs[name] = getattr(ssl, value) elif name in ['ca_certs', 'ciphers', 'keyfile', 'keypass', 'certfile', 'server_hostname']: kwargs[name] = value elif name == 'alt_hosts': kwargs['alt_hosts'] = value else: settings[name] = value if settings: kwargs['settings'] = settings return host, kwargs clickhouse-driver-0.2.11/clickhouse_driver/varint.c000066400000000000000000013142751522645447600224240ustar00rootroot00000000000000/* Generated by Cython 3.2.0 */ #ifndef PY_SSIZE_T_CLEAN #define PY_SSIZE_T_CLEAN #endif /* PY_SSIZE_T_CLEAN */ /* InitLimitedAPI */ #if defined(Py_LIMITED_API) #if !defined(CYTHON_LIMITED_API) #define CYTHON_LIMITED_API 1 #endif #elif defined(CYTHON_LIMITED_API) #ifdef _MSC_VER #pragma message ("Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead.") #else #warning Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead. #endif #endif #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x03080000 #error Cython requires Python 3.8+. #else #define __PYX_ABI_VERSION "3_2_0" #define CYTHON_HEX_VERSION 0x030200F0 #define CYTHON_FUTURE_DIVISION 1 /* CModulePreamble */ #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(_WIN32) && !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #define __PYX_COMMA , #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #define __PYX_LIMITED_VERSION_HEX PY_VERSION_HEX #if defined(GRAALVM_PYTHON) /* For very preliminary testing purposes. Most variables are set the same as PyPy. The existence of this section does not imply that anything works or is even tested */ #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 1 #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_ASSUME_SAFE_SIZE #define CYTHON_ASSUME_SAFE_SIZE 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #undef CYTHON_USE_SYS_MONITORING #define CYTHON_USE_SYS_MONITORING 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #undef CYTHON_USE_AM_SEND #define CYTHON_USE_AM_SEND 0 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 1 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #undef CYTHON_USE_FREELISTS #define CYTHON_USE_FREELISTS 0 #undef CYTHON_IMMORTAL_CONSTANTS #define CYTHON_IMMORTAL_CONSTANTS 0 #elif defined(PYPY_VERSION) #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #ifndef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #endif #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #ifndef CYTHON_ASSUME_SAFE_SIZE #define CYTHON_ASSUME_SAFE_SIZE 1 #endif #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #if PY_VERSION_HEX < 0x03090000 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT) #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #undef CYTHON_USE_SYS_MONITORING #define CYTHON_USE_SYS_MONITORING 0 #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE (PYPY_VERSION_NUM >= 0x07030C00) #endif #undef CYTHON_USE_AM_SEND #define CYTHON_USE_AM_SEND 0 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_NUM >= 0x07031100) #endif #undef CYTHON_USE_FREELISTS #define CYTHON_USE_FREELISTS 0 #undef CYTHON_IMMORTAL_CONSTANTS #define CYTHON_IMMORTAL_CONSTANTS 0 #elif defined(CYTHON_LIMITED_API) #ifdef Py_LIMITED_API #undef __PYX_LIMITED_VERSION_HEX #define __PYX_LIMITED_VERSION_HEX Py_LIMITED_API #endif #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 1 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 1 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #ifndef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #endif #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0 #endif #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_ASSUME_SAFE_SIZE #define CYTHON_ASSUME_SAFE_SIZE 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL (__PYX_LIMITED_VERSION_HEX >= 0x030C0000) #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #ifndef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #endif #undef CYTHON_USE_SYS_MONITORING #define CYTHON_USE_SYS_MONITORING 0 #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #endif #ifndef CYTHON_USE_AM_SEND #define CYTHON_USE_AM_SEND (__PYX_LIMITED_VERSION_HEX >= 0x030A0000) #endif #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #ifndef CYTHON_USE_FREELISTS #define CYTHON_USE_FREELISTS 1 #endif #undef CYTHON_IMMORTAL_CONSTANTS #define CYTHON_IMMORTAL_CONSTANTS 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 0 #ifdef Py_GIL_DISABLED #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 1 #else #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0 #endif #if PY_VERSION_HEX < 0x030A0000 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #elif !defined(CYTHON_USE_TYPE_SLOTS) #define CYTHON_USE_TYPE_SLOTS 1 #endif #ifndef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #endif #ifndef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 1 #endif #ifndef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #elif !defined(CYTHON_USE_PYLIST_INTERNALS) #define CYTHON_USE_PYLIST_INTERNALS 1 #endif #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING || PY_VERSION_HEX >= 0x030B00A2 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #elif !defined(CYTHON_USE_UNICODE_WRITER) #define CYTHON_USE_UNICODE_WRITER 1 #endif #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1 #elif !defined(CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS) #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_ASSUME_SAFE_SIZE #define CYTHON_ASSUME_SAFE_SIZE 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #ifndef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 1 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #elif !defined(CYTHON_FAST_GIL) #define CYTHON_FAST_GIL (PY_VERSION_HEX < 0x030C00A6) #endif #ifndef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 1 #endif #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #ifndef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #endif #ifndef CYTHON_USE_SYS_MONITORING #define CYTHON_USE_SYS_MONITORING (PY_VERSION_HEX >= 0x030d00B1) #endif #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 1 #endif #ifndef CYTHON_USE_AM_SEND #define CYTHON_USE_AM_SEND 1 #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #elif !defined(CYTHON_USE_DICT_VERSIONS) #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX < 0x030C00A5 && !CYTHON_USE_MODULE_STATE) #endif #ifndef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 1 #endif #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 1 #endif #ifndef CYTHON_USE_FREELISTS #define CYTHON_USE_FREELISTS (!CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) #endif #if defined(CYTHON_IMMORTAL_CONSTANTS) && PY_VERSION_HEX < 0x030C0000 #undef CYTHON_IMMORTAL_CONSTANTS #define CYTHON_IMMORTAL_CONSTANTS 0 // definitely won't work #elif !defined(CYTHON_IMMORTAL_CONSTANTS) #define CYTHON_IMMORTAL_CONSTANTS (PY_VERSION_HEX >= 0x030C0000 && !CYTHON_USE_MODULE_STATE && CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) #endif #endif #ifndef CYTHON_COMPRESS_STRINGS #define CYTHON_COMPRESS_STRINGS 1 #endif #ifndef CYTHON_FAST_PYCCALL #define CYTHON_FAST_PYCCALL CYTHON_FAST_PYCALL #endif #ifndef CYTHON_VECTORCALL #if CYTHON_COMPILING_IN_LIMITED_API #define CYTHON_VECTORCALL (__PYX_LIMITED_VERSION_HEX >= 0x030C0000) #else #define CYTHON_VECTORCALL (CYTHON_FAST_PYCCALL) #endif #endif #if CYTHON_USE_PYLONG_INTERNALS #undef SHIFT #undef BASE #undef MASK #ifdef SIZEOF_VOID_P enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; #endif #endif #ifndef __has_attribute #define __has_attribute(x) 0 #endif #ifndef __has_cpp_attribute #define __has_cpp_attribute(x) 0 #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #ifndef CYTHON_UNUSED #if defined(__cplusplus) /* for clang __has_cpp_attribute(maybe_unused) is true even before C++17 * but leads to warnings with -pedantic, since it is a C++17 feature */ #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) #if __has_cpp_attribute(maybe_unused) #define CYTHON_UNUSED [[maybe_unused]] #endif #endif #endif #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_UNUSED_VAR # if defined(__cplusplus) template void CYTHON_UNUSED_VAR( const T& ) { } # else # define CYTHON_UNUSED_VAR(x) (void)(x) # endif #endif #ifndef CYTHON_MAYBE_UNUSED_VAR #define CYTHON_MAYBE_UNUSED_VAR(x) CYTHON_UNUSED_VAR(x) #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif #ifndef CYTHON_USE_CPP_STD_MOVE #if defined(__cplusplus) && (\ __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)) #define CYTHON_USE_CPP_STD_MOVE 1 #else #define CYTHON_USE_CPP_STD_MOVE 0 #endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #include typedef uintptr_t __pyx_uintptr_t; #ifndef CYTHON_FALLTHROUGH #if defined(__cplusplus) /* for clang __has_cpp_attribute(fallthrough) is true even before C++17 * but leads to warnings with -pedantic, since it is a C++17 feature */ #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) #if __has_cpp_attribute(fallthrough) #define CYTHON_FALLTHROUGH [[fallthrough]] #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_cpp_attribute(clang::fallthrough) #define CYTHON_FALLTHROUGH [[clang::fallthrough]] #elif __has_cpp_attribute(gnu::fallthrough) #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] #endif #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_attribute(fallthrough) #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) #else #define CYTHON_FALLTHROUGH #endif #endif #if defined(__clang__) && defined(__apple_build_version__) #if __apple_build_version__ < 7000000 #undef CYTHON_FALLTHROUGH #define CYTHON_FALLTHROUGH #endif #endif #endif #ifndef Py_UNREACHABLE #define Py_UNREACHABLE() assert(0); abort() #endif #ifdef __cplusplus template struct __PYX_IS_UNSIGNED_IMPL {static const bool value = T(0) < T(-1);}; #define __PYX_IS_UNSIGNED(type) (__PYX_IS_UNSIGNED_IMPL::value) #else #define __PYX_IS_UNSIGNED(type) (((type)-1) > 0) #endif #if CYTHON_COMPILING_IN_PYPY == 1 #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX < 0x030A0000) #else #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX < 0x03090000) #endif #define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer)) /* CInitCode */ #ifndef CYTHON_INLINE #if defined(__clang__) #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) #elif defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #endif /* PythonCompatibility */ #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_DefaultClassType PyType_Type #if CYTHON_COMPILING_IN_LIMITED_API #ifndef CO_OPTIMIZED static int CO_OPTIMIZED; #endif #ifndef CO_NEWLOCALS static int CO_NEWLOCALS; #endif #ifndef CO_VARARGS static int CO_VARARGS; #endif #ifndef CO_VARKEYWORDS static int CO_VARKEYWORDS; #endif #ifndef CO_ASYNC_GENERATOR static int CO_ASYNC_GENERATOR; #endif #ifndef CO_GENERATOR static int CO_GENERATOR; #endif #ifndef CO_COROUTINE static int CO_COROUTINE; #endif #else #ifndef CO_COROUTINE #define CO_COROUTINE 0x80 #endif #ifndef CO_ASYNC_GENERATOR #define CO_ASYNC_GENERATOR 0x200 #endif #endif static int __Pyx_init_co_variables(void); #if PY_VERSION_HEX >= 0x030900A4 || defined(Py_IS_TYPE) #define __Pyx_IS_TYPE(ob, type) Py_IS_TYPE(ob, type) #else #define __Pyx_IS_TYPE(ob, type) (((const PyObject*)ob)->ob_type == (type)) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_Is) #define __Pyx_Py_Is(x, y) Py_Is(x, y) #else #define __Pyx_Py_Is(x, y) ((x) == (y)) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsNone) #define __Pyx_Py_IsNone(ob) Py_IsNone(ob) #else #define __Pyx_Py_IsNone(ob) __Pyx_Py_Is((ob), Py_None) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsTrue) #define __Pyx_Py_IsTrue(ob) Py_IsTrue(ob) #else #define __Pyx_Py_IsTrue(ob) __Pyx_Py_Is((ob), Py_True) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsFalse) #define __Pyx_Py_IsFalse(ob) Py_IsFalse(ob) #else #define __Pyx_Py_IsFalse(ob) __Pyx_Py_Is((ob), Py_False) #endif #define __Pyx_NoneAsNull(obj) (__Pyx_Py_IsNone(obj) ? NULL : (obj)) #if PY_VERSION_HEX >= 0x030900F0 && !CYTHON_COMPILING_IN_PYPY #define __Pyx_PyObject_GC_IsFinalized(o) PyObject_GC_IsFinalized(o) #else #define __Pyx_PyObject_GC_IsFinalized(o) _PyGC_FINALIZED(o) #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #ifndef Py_TPFLAGS_SEQUENCE #define Py_TPFLAGS_SEQUENCE 0 #endif #ifndef Py_TPFLAGS_MAPPING #define Py_TPFLAGS_MAPPING 0 #endif #ifndef Py_TPFLAGS_IMMUTABLETYPE #define Py_TPFLAGS_IMMUTABLETYPE (1UL << 8) #endif #ifndef Py_TPFLAGS_DISALLOW_INSTANTIATION #define Py_TPFLAGS_DISALLOW_INSTANTIATION (1UL << 7) #endif #ifndef METH_STACKLESS #define METH_STACKLESS 0 #endif #ifndef METH_FASTCALL #ifndef METH_FASTCALL #define METH_FASTCALL 0x80 #endif typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames); #else #if PY_VERSION_HEX >= 0x030d00A4 # define __Pyx_PyCFunctionFast PyCFunctionFast # define __Pyx_PyCFunctionFastWithKeywords PyCFunctionFastWithKeywords #else # define __Pyx_PyCFunctionFast _PyCFunctionFast # define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords #endif #endif #if CYTHON_METH_FASTCALL #define __Pyx_METH_FASTCALL METH_FASTCALL #define __Pyx_PyCFunction_FastCall __Pyx_PyCFunctionFast #define __Pyx_PyCFunction_FastCallWithKeywords __Pyx_PyCFunctionFastWithKeywords #else #define __Pyx_METH_FASTCALL METH_VARARGS #define __Pyx_PyCFunction_FastCall PyCFunction #define __Pyx_PyCFunction_FastCallWithKeywords PyCFunctionWithKeywords #endif #if CYTHON_VECTORCALL #define __pyx_vectorcallfunc vectorcallfunc #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET PY_VECTORCALL_ARGUMENTS_OFFSET #define __Pyx_PyVectorcall_NARGS(n) PyVectorcall_NARGS((size_t)(n)) #else #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET 0 #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(n)) #endif #if PY_VERSION_HEX >= 0x030900B1 #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_CheckExact(func) #else #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_Check(func) #endif #define __Pyx_CyOrPyCFunction_Check(func) PyCFunction_Check(func) #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) (((PyCFunctionObject*)(func))->m_ml->ml_meth) #elif !CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(func) #endif #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CyOrPyCFunction_GET_FLAGS(func) (((PyCFunctionObject*)(func))->m_ml->ml_flags) static CYTHON_INLINE PyObject* __Pyx_CyOrPyCFunction_GET_SELF(PyObject *func) { return (__Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_STATIC) ? NULL : ((PyCFunctionObject*)func)->m_self; } #endif static CYTHON_INLINE int __Pyx__IsSameCFunction(PyObject *func, void (*cfunc)(void)) { #if CYTHON_COMPILING_IN_LIMITED_API return PyCFunction_Check(func) && PyCFunction_GetFunction(func) == (PyCFunction) cfunc; #else return PyCFunction_Check(func) && PyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; #endif } #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCFunction(func, cfunc) #if PY_VERSION_HEX < 0x03090000 || (CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000) #define __Pyx_PyType_FromModuleAndSpec(m, s, b) ((void)m, PyType_FromSpecWithBases(s, b)) typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *); #else #define __Pyx_PyType_FromModuleAndSpec(m, s, b) PyType_FromModuleAndSpec(m, s, b) #define __Pyx_PyCMethod PyCMethod #endif #ifndef METH_METHOD #define METH_METHOD 0x200 #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) #define PyObject_Malloc(s) PyMem_Malloc(s) #define PyObject_Free(p) PyMem_Free(p) #define PyObject_Realloc(p) PyMem_Realloc(p) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyFrame_SetLineNumber(frame, lineno) #elif CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) GraalPyFrame_SetLineNumber((frame), (lineno)) #elif CYTHON_COMPILING_IN_GRAAL #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) _PyFrame_SetLineNumber((frame), (lineno)) #else #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyThreadState_Current PyThreadState_Get() #elif !CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_Current PyThreadState_GET() #elif PY_VERSION_HEX >= 0x030d00A1 #define __Pyx_PyThreadState_Current PyThreadState_GetUnchecked() #else #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() #endif #if CYTHON_USE_MODULE_STATE static CYTHON_INLINE void *__Pyx__PyModule_GetState(PyObject *op) { void *result; result = PyModule_GetState(op); if (!result) Py_FatalError("Couldn't find the module state"); return result; } #define __Pyx_PyModule_GetState(o) (__pyx_mstatetype *)__Pyx__PyModule_GetState(o) #else #define __Pyx_PyModule_GetState(op) ((void)op,__pyx_mstate_global) #endif #define __Pyx_PyObject_GetSlot(obj, name, func_ctype) __Pyx_PyType_GetSlot(Py_TYPE((PyObject *) obj), name, func_ctype) #define __Pyx_PyObject_TryGetSlot(obj, name, func_ctype) __Pyx_PyType_TryGetSlot(Py_TYPE(obj), name, func_ctype) #define __Pyx_PyObject_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(Py_TYPE(obj), sub, name, func_ctype) #define __Pyx_PyObject_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSubSlot(Py_TYPE(obj), sub, name, func_ctype) #if CYTHON_USE_TYPE_SLOTS #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((type)->name) #define __Pyx_PyType_TryGetSlot(type, name, func_ctype) __Pyx_PyType_GetSlot(type, name, func_ctype) #define __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype) (((type)->sub) ? ((type)->sub->name) : NULL) #define __Pyx_PyType_TryGetSubSlot(type, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype) #else #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((func_ctype) PyType_GetSlot((type), Py_##name)) #define __Pyx_PyType_TryGetSlot(type, name, func_ctype)\ ((__PYX_LIMITED_VERSION_HEX >= 0x030A0000 ||\ (PyType_GetFlags(type) & Py_TPFLAGS_HEAPTYPE) || __Pyx_get_runtime_version() >= 0x030A0000) ?\ __Pyx_PyType_GetSlot(type, name, func_ctype) : NULL) #define __Pyx_PyType_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSlot(obj, name, func_ctype) #define __Pyx_PyType_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSlot(obj, name, func_ctype) #endif #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) #else #define __Pyx_PyDict_NewPresized(n) PyDict_New() #endif #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_UNICODE_INTERNALS #define __Pyx_PyDict_GetItemStrWithError(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) { PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name); if (res == NULL) PyErr_Clear(); return res; } #elif !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000 #define __Pyx_PyDict_GetItemStrWithError PyDict_GetItemWithError #define __Pyx_PyDict_GetItemStr PyDict_GetItem #else static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, PyObject *name) { #if CYTHON_COMPILING_IN_PYPY return PyDict_GetItem(dict, name); #else PyDictEntry *ep; PyDictObject *mp = (PyDictObject*) dict; long hash = ((PyStringObject *) name)->ob_shash; assert(hash != -1); ep = (mp->ma_lookup)(mp, name, hash); if (ep == NULL) { return NULL; } return ep->me_value; #endif } #define __Pyx_PyDict_GetItemStr PyDict_GetItem #endif #if CYTHON_USE_TYPE_SLOTS #define __Pyx_PyType_GetFlags(tp) (((PyTypeObject *)tp)->tp_flags) #define __Pyx_PyType_HasFeature(type, feature) ((__Pyx_PyType_GetFlags(type) & (feature)) != 0) #else #define __Pyx_PyType_GetFlags(tp) (PyType_GetFlags((PyTypeObject *)tp)) #define __Pyx_PyType_HasFeature(type, feature) PyType_HasFeature(type, feature) #endif #define __Pyx_PyObject_GetIterNextFunc(iterator) __Pyx_PyObject_GetSlot(iterator, tp_iternext, iternextfunc) #if CYTHON_USE_TYPE_SPECS #define __Pyx_PyHeapTypeObject_GC_Del(obj) {\ PyTypeObject *type = Py_TYPE((PyObject*)obj);\ assert(__Pyx_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE));\ PyObject_GC_Del(obj);\ Py_DECREF(type);\ } #else #define __Pyx_PyHeapTypeObject_GC_Del(obj) PyObject_GC_Del(obj) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_ReadChar(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((void)u, 1114111U) #define __Pyx_PyUnicode_KIND(u) ((void)u, (0)) #define __Pyx_PyUnicode_DATA(u) ((void*)u) #define __Pyx_PyUnicode_READ(k, d, i) ((void)k, PyUnicode_ReadChar((PyObject*)(d), i)) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GetLength(u)) #else #if PY_VERSION_HEX >= 0x030C0000 #define __Pyx_PyUnicode_READY(op) (0) #else #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #endif #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) #define __Pyx_PyUnicode_KIND(u) ((int)PyUnicode_KIND(u)) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, (Py_UCS4) ch) #if PY_VERSION_HEX >= 0x030C0000 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) #else #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) #else #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) #endif #endif #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY #if !defined(PyUnicode_DecodeUnicodeEscape) #define PyUnicode_DecodeUnicodeEscape(s, size, errors) PyUnicode_Decode(s, size, "unicode_escape", errors) #endif #if !defined(PyUnicode_Contains) #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #if !defined(PyByteArray_Check) #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) #endif #if !defined(PyObject_Format) #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) #endif #endif #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 #define __Pyx_PySequence_ListKeepNew(obj)\ (likely(PyList_CheckExact(obj) && PyUnstable_Object_IsUniquelyReferenced(obj)) ? __Pyx_NewRef(obj) : PySequence_List(obj)) #elif CYTHON_COMPILING_IN_CPYTHON #define __Pyx_PySequence_ListKeepNew(obj)\ (likely(PyList_CheckExact(obj) && Py_REFCNT(obj) == 1) ? __Pyx_NewRef(obj) : PySequence_List(obj)) #else #define __Pyx_PySequence_ListKeepNew(obj) PySequence_List(obj) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) __Pyx_IS_TYPE(obj, &PySet_Type) #endif #if PY_VERSION_HEX >= 0x030900A4 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) #else #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) #endif enum __Pyx_ReferenceSharing { __Pyx_ReferenceSharing_DefinitelyUnique, // We created it so we know it's unshared - no need to check __Pyx_ReferenceSharing_OwnStrongReference, __Pyx_ReferenceSharing_FunctionArgument, __Pyx_ReferenceSharing_SharedReference, // Never trust it to be unshared because it's a global or similar }; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && PY_VERSION_HEX >= 0x030E0000 #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing)\ (sharing == __Pyx_ReferenceSharing_DefinitelyUnique ? 1 :\ (sharing == __Pyx_ReferenceSharing_FunctionArgument ? PyUnstable_Object_IsUniqueReferencedTemporary(o) :\ (sharing == __Pyx_ReferenceSharing_OwnStrongReference ? PyUnstable_Object_IsUniquelyReferenced(o) : 0))) #elif (CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)sharing), Py_REFCNT(o) == 1) #else #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)o), ((void)sharing), 0) #endif #if CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyList_GetItemRef(o, i) PyList_GetItemRef(o, i) #elif CYTHON_COMPILING_IN_LIMITED_API || !CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PyList_GetItemRef(o, i) (likely((i) >= 0) ? PySequence_GetItem(o, i) : (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) #else #define __Pyx_PyList_GetItemRef(o, i) PySequence_ITEM(o, i) #endif #elif CYTHON_COMPILING_IN_LIMITED_API || !CYTHON_ASSUME_SAFE_MACROS #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyList_GetItemRef(o, i) PyList_GetItemRef(o, i) #else #define __Pyx_PyList_GetItemRef(o, i) __Pyx_XNewRef(PyList_GetItem(o, i)) #endif #else #define __Pyx_PyList_GetItemRef(o, i) __Pyx_NewRef(PyList_GET_ITEM(o, i)) #endif #if CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS && !CYTHON_COMPILING_IN_LIMITED_API && CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PyList_GetItemRefFast(o, i, unsafe_shared) (__Pyx_IS_UNIQUELY_REFERENCED(o, unsafe_shared) ?\ __Pyx_NewRef(PyList_GET_ITEM(o, i)) : __Pyx_PyList_GetItemRef(o, i)) #else #define __Pyx_PyList_GetItemRefFast(o, i, unsafe_shared) __Pyx_PyList_GetItemRef(o, i) #endif #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyDict_GetItemRef(dict, key, result) PyDict_GetItemRef(dict, key, result) #elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) { *result = PyObject_GetItem(dict, key); if (*result == NULL) { if (PyErr_ExceptionMatches(PyExc_KeyError)) { PyErr_Clear(); return 0; } return -1; } return 1; } #else static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) { *result = PyDict_GetItemWithError(dict, key); if (*result == NULL) { return PyErr_Occurred() ? -1 : 0; } Py_INCREF(*result); return 1; } #endif #if defined(CYTHON_DEBUG_VISIT_CONST) && CYTHON_DEBUG_VISIT_CONST #define __Pyx_VISIT_CONST(obj) Py_VISIT(obj) #else #define __Pyx_VISIT_CONST(obj) #endif #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PySequence_ITEM(o, i) PySequence_ITEM(o, i) #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) #define __Pyx_PyTuple_SET_ITEM(o, i, v) (PyTuple_SET_ITEM(o, i, v), (0)) #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GET_ITEM(o, i) #define __Pyx_PyList_SET_ITEM(o, i, v) (PyList_SET_ITEM(o, i, v), (0)) #define __Pyx_PyList_GET_ITEM(o, i) PyList_GET_ITEM(o, i) #else #define __Pyx_PySequence_ITEM(o, i) PySequence_GetItem(o, i) #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) #define __Pyx_PyTuple_SET_ITEM(o, i, v) PyTuple_SetItem(o, i, v) #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GetItem(o, i) #define __Pyx_PyList_SET_ITEM(o, i, v) PyList_SetItem(o, i, v) #define __Pyx_PyList_GET_ITEM(o, i) PyList_GetItem(o, i) #endif #if CYTHON_ASSUME_SAFE_SIZE #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_GET_SIZE(o) #define __Pyx_PyList_GET_SIZE(o) PyList_GET_SIZE(o) #define __Pyx_PySet_GET_SIZE(o) PySet_GET_SIZE(o) #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o) #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_GET_SIZE(o) #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GET_LENGTH(o) #else #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_Size(o) #define __Pyx_PyList_GET_SIZE(o) PyList_Size(o) #define __Pyx_PySet_GET_SIZE(o) PySet_Size(o) #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_Size(o) #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_Size(o) #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GetLength(o) #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_InternFromString) #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #define __Pyx_PyLong_FromHash_t PyLong_FromSsize_t #define __Pyx_PyLong_AsHash_t __Pyx_PyIndex_AsSsize_t #if __PYX_LIMITED_VERSION_HEX >= 0x030A0000 #define __Pyx_PySendResult PySendResult #else typedef enum { PYGEN_RETURN = 0, PYGEN_ERROR = -1, PYGEN_NEXT = 1, } __Pyx_PySendResult; #endif #if CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX < 0x030A00A3 typedef __Pyx_PySendResult (*__Pyx_pyiter_sendfunc)(PyObject *iter, PyObject *value, PyObject **result); #else #define __Pyx_pyiter_sendfunc sendfunc #endif #if !CYTHON_USE_AM_SEND #define __PYX_HAS_PY_AM_SEND 0 #elif __PYX_LIMITED_VERSION_HEX >= 0x030A0000 #define __PYX_HAS_PY_AM_SEND 1 #else #define __PYX_HAS_PY_AM_SEND 2 // our own backported implementation #endif #if __PYX_HAS_PY_AM_SEND < 2 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #else typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; __Pyx_pyiter_sendfunc am_send; } __Pyx_PyAsyncMethodsStruct; #define __Pyx_SlotTpAsAsync(s) ((PyAsyncMethods*)(s)) #endif #if CYTHON_USE_AM_SEND && PY_VERSION_HEX < 0x030A00F0 #define __Pyx_TPFLAGS_HAVE_AM_SEND (1UL << 21) #else #define __Pyx_TPFLAGS_HAVE_AM_SEND (0) #endif #if PY_VERSION_HEX >= 0x03090000 #define __Pyx_PyInterpreterState_Get() PyInterpreterState_Get() #else #define __Pyx_PyInterpreterState_Get() PyThreadState_Get()->interp #endif #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030A0000 #ifdef __cplusplus extern "C" #endif PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize); #endif #if CYTHON_COMPILING_IN_LIMITED_API static int __Pyx_init_co_variable(PyObject *inspect, const char* name, int *write_to) { int value; PyObject *py_value = PyObject_GetAttrString(inspect, name); if (!py_value) return 0; value = (int) PyLong_AsLong(py_value); Py_DECREF(py_value); *write_to = value; return value != -1 || !PyErr_Occurred(); } static int __Pyx_init_co_variables(void) { PyObject *inspect; int result; inspect = PyImport_ImportModule("inspect"); result = #if !defined(CO_OPTIMIZED) __Pyx_init_co_variable(inspect, "CO_OPTIMIZED", &CO_OPTIMIZED) && #endif #if !defined(CO_NEWLOCALS) __Pyx_init_co_variable(inspect, "CO_NEWLOCALS", &CO_NEWLOCALS) && #endif #if !defined(CO_VARARGS) __Pyx_init_co_variable(inspect, "CO_VARARGS", &CO_VARARGS) && #endif #if !defined(CO_VARKEYWORDS) __Pyx_init_co_variable(inspect, "CO_VARKEYWORDS", &CO_VARKEYWORDS) && #endif #if !defined(CO_ASYNC_GENERATOR) __Pyx_init_co_variable(inspect, "CO_ASYNC_GENERATOR", &CO_ASYNC_GENERATOR) && #endif #if !defined(CO_GENERATOR) __Pyx_init_co_variable(inspect, "CO_GENERATOR", &CO_GENERATOR) && #endif #if !defined(CO_COROUTINE) __Pyx_init_co_variable(inspect, "CO_COROUTINE", &CO_COROUTINE) && #endif 1; Py_DECREF(inspect); return result ? 0 : -1; } #else static int __Pyx_init_co_variables(void) { return 0; // It's a limited API-only feature } #endif /* MathInitCode */ #if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS) #ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES #endif #endif #include #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) #define __Pyx_truncl trunc #else #define __Pyx_truncl truncl #endif #ifndef CYTHON_CLINE_IN_TRACEBACK_RUNTIME #define CYTHON_CLINE_IN_TRACEBACK_RUNTIME 0 #endif #ifndef CYTHON_CLINE_IN_TRACEBACK #define CYTHON_CLINE_IN_TRACEBACK CYTHON_CLINE_IN_TRACEBACK_RUNTIME #endif #if CYTHON_CLINE_IN_TRACEBACK #define __PYX_MARK_ERR_POS(f_index, lineno) { __pyx_filename = __pyx_f[f_index]; (void) __pyx_filename; __pyx_lineno = lineno; (void) __pyx_lineno; __pyx_clineno = __LINE__; (void) __pyx_clineno; } #else #define __PYX_MARK_ERR_POS(f_index, lineno) { __pyx_filename = __pyx_f[f_index]; (void) __pyx_filename; __pyx_lineno = lineno; (void) __pyx_lineno; (void) __pyx_clineno; } #endif #define __PYX_ERR(f_index, lineno, Ln_error) \ { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } #ifdef CYTHON_EXTERN_C #undef __PYX_EXTERN_C #define __PYX_EXTERN_C CYTHON_EXTERN_C #elif defined(__PYX_EXTERN_C) #ifdef _MSC_VER #pragma message ("Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.") #else #warning Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead. #endif #else #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__clickhouse_driver__varint #define __PYX_HAVE_API__clickhouse_driver__varint /* Early includes */ #include #include #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyFloat_FromString(obj) PyFloat_FromString(obj) #else #define __Pyx_PyFloat_FromString(obj) PyFloat_FromString(obj, NULL) #endif #include #if PY_MAJOR_VERSION <= 2 #define PyDict_GetItemWithError _PyDict_GetItemWithError #endif #if PY_VERSION_HEX < 0x030d0000 static CYTHON_INLINE int __Pyx_PyWeakref_GetRef(PyObject *ref, PyObject **pobj) { PyObject *obj = PyWeakref_GetObject(ref); if (obj == NULL) { // SystemError if ref is NULL *pobj = NULL; return -1; } if (obj == Py_None) { *pobj = NULL; return 0; } Py_INCREF(obj); *pobj = obj; return 1; } #else #define __Pyx_PyWeakref_GetRef PyWeakref_GetRef #endif #include "pythread.h" #if (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030600) && !defined(PyContextVar_Get) #define PyContextVar_Get(var, d, v) ((d) ? ((void)(var), Py_INCREF(d), (v)[0] = (d), 0) : ((v)[0] = NULL, 0) ) #endif #ifdef _OPENMP #include #endif /* _OPENMP */ #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0 #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { return (size_t) i < (size_t) limit; } #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s); static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char*); #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyByteArray_AsString(s) PyByteArray_AS_STRING(s) #else #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AsString(s)) #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AsString(s)) #define __Pyx_PyByteArray_AsString(s) PyByteArray_AsString(s) #endif #define __Pyx_PyObject_AsWritableString(s) ((char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) #define __Pyx_PyUnicode_FromOrdinal(o) PyUnicode_FromOrdinal((int)o) #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode static CYTHON_INLINE PyObject *__Pyx_NewRef(PyObject *obj) { #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_NewRef) return Py_NewRef(obj); #else Py_INCREF(obj); return obj; #endif } static CYTHON_INLINE PyObject *__Pyx_XNewRef(PyObject *obj) { #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_XNewRef) return Py_XNewRef(obj); #else Py_XINCREF(obj); return obj; #endif } static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b); static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x); #define __Pyx_PySequence_Tuple(obj)\ (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t); static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AS_DOUBLE(x) #else #define __Pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AsDouble(x) #endif #define __Pyx_PyFloat_AsFloat(x) ((float) __Pyx_PyFloat_AsDouble(x)) #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) #if CYTHON_USE_PYLONG_INTERNALS #if PY_VERSION_HEX >= 0x030C00A7 #ifndef _PyLong_SIGN_MASK #define _PyLong_SIGN_MASK 3 #endif #ifndef _PyLong_NON_SIZE_BITS #define _PyLong_NON_SIZE_BITS 3 #endif #define __Pyx_PyLong_Sign(x) (((PyLongObject*)x)->long_value.lv_tag & _PyLong_SIGN_MASK) #define __Pyx_PyLong_IsNeg(x) ((__Pyx_PyLong_Sign(x) & 2) != 0) #define __Pyx_PyLong_IsNonNeg(x) (!__Pyx_PyLong_IsNeg(x)) #define __Pyx_PyLong_IsZero(x) (__Pyx_PyLong_Sign(x) & 1) #define __Pyx_PyLong_IsPos(x) (__Pyx_PyLong_Sign(x) == 0) #define __Pyx_PyLong_CompactValueUnsigned(x) (__Pyx_PyLong_Digits(x)[0]) #define __Pyx_PyLong_DigitCount(x) ((Py_ssize_t) (((PyLongObject*)x)->long_value.lv_tag >> _PyLong_NON_SIZE_BITS)) #define __Pyx_PyLong_SignedDigitCount(x)\ ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * __Pyx_PyLong_DigitCount(x)) #if defined(PyUnstable_Long_IsCompact) && defined(PyUnstable_Long_CompactValue) #define __Pyx_PyLong_IsCompact(x) PyUnstable_Long_IsCompact((PyLongObject*) x) #define __Pyx_PyLong_CompactValue(x) PyUnstable_Long_CompactValue((PyLongObject*) x) #else #define __Pyx_PyLong_IsCompact(x) (((PyLongObject*)x)->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS)) #define __Pyx_PyLong_CompactValue(x) ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_Digits(x)[0]) #endif typedef Py_ssize_t __Pyx_compact_pylong; typedef size_t __Pyx_compact_upylong; #else #define __Pyx_PyLong_IsNeg(x) (Py_SIZE(x) < 0) #define __Pyx_PyLong_IsNonNeg(x) (Py_SIZE(x) >= 0) #define __Pyx_PyLong_IsZero(x) (Py_SIZE(x) == 0) #define __Pyx_PyLong_IsPos(x) (Py_SIZE(x) > 0) #define __Pyx_PyLong_CompactValueUnsigned(x) ((Py_SIZE(x) == 0) ? 0 : __Pyx_PyLong_Digits(x)[0]) #define __Pyx_PyLong_DigitCount(x) __Pyx_sst_abs(Py_SIZE(x)) #define __Pyx_PyLong_SignedDigitCount(x) Py_SIZE(x) #define __Pyx_PyLong_IsCompact(x) (Py_SIZE(x) == 0 || Py_SIZE(x) == 1 || Py_SIZE(x) == -1) #define __Pyx_PyLong_CompactValue(x)\ ((Py_SIZE(x) == 0) ? (sdigit) 0 : ((Py_SIZE(x) < 0) ? -(sdigit)__Pyx_PyLong_Digits(x)[0] : (sdigit)__Pyx_PyLong_Digits(x)[0])) typedef sdigit __Pyx_compact_pylong; typedef digit __Pyx_compact_upylong; #endif #if PY_VERSION_HEX >= 0x030C00A5 #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->long_value.ob_digit) #else #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->ob_digit) #endif #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #elif __PYX_DEFAULT_STRING_ENCODING_IS_ASCII #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeASCII(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ /* PretendToInitialize */ #ifdef __cplusplus #if __cplusplus > 201103L #include #endif template static void __Pyx_pretend_to_initialize(T* ptr) { #if __cplusplus > 201103L if ((std::is_trivially_default_constructible::value)) #endif *ptr = T(); (void)ptr; } #else static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } #endif #if !CYTHON_USE_MODULE_STATE static PyObject *__pyx_m = NULL; #endif static int __pyx_lineno; static int __pyx_clineno = 0; static const char * const __pyx_cfilenm = __FILE__; static const char *__pyx_filename; /* #### Code section: filename_table ### */ static const char* const __pyx_f[] = { "clickhouse_driver/varint.pyx", "cpython/contextvars.pxd", "cpython/type.pxd", "cpython/bool.pxd", "cpython/complex.pxd", }; /* #### Code section: utility_code_proto_before_types ### */ /* Atomics.proto */ #include #ifndef CYTHON_ATOMICS #define CYTHON_ATOMICS 1 #endif #define __PYX_CYTHON_ATOMICS_ENABLED() CYTHON_ATOMICS #define __PYX_GET_CYTHON_COMPILING_IN_CPYTHON_FREETHREADING() CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #define __pyx_atomic_int_type int #define __pyx_nonatomic_int_type int #if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\ (__STDC_VERSION__ >= 201112L) &&\ !defined(__STDC_NO_ATOMICS__)) #include #elif CYTHON_ATOMICS && (defined(__cplusplus) && (\ (__cplusplus >= 201103L) ||\ (defined(_MSC_VER) && _MSC_VER >= 1700))) #include #endif #if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\ (__STDC_VERSION__ >= 201112L) &&\ !defined(__STDC_NO_ATOMICS__) &&\ ATOMIC_INT_LOCK_FREE == 2) #undef __pyx_atomic_int_type #define __pyx_atomic_int_type atomic_int #define __pyx_atomic_ptr_type atomic_uintptr_t #define __pyx_nonatomic_ptr_type uintptr_t #define __pyx_atomic_incr_relaxed(value) atomic_fetch_add_explicit(value, 1, memory_order_relaxed) #define __pyx_atomic_incr_acq_rel(value) atomic_fetch_add_explicit(value, 1, memory_order_acq_rel) #define __pyx_atomic_decr_acq_rel(value) atomic_fetch_sub_explicit(value, 1, memory_order_acq_rel) #define __pyx_atomic_sub(value, arg) atomic_fetch_sub(value, arg) #define __pyx_atomic_int_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired) #define __pyx_atomic_load(value) atomic_load(value) #define __pyx_atomic_store(value, new_value) atomic_store(value, new_value) #define __pyx_atomic_pointer_load_relaxed(value) atomic_load_explicit(value, memory_order_relaxed) #define __pyx_atomic_pointer_load_acquire(value) atomic_load_explicit(value, memory_order_acquire) #define __pyx_atomic_pointer_exchange(value, new_value) atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value) #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired) #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER) #pragma message ("Using standard C atomics") #elif defined(__PYX_DEBUG_ATOMICS) #warning "Using standard C atomics" #endif #elif CYTHON_ATOMICS && (defined(__cplusplus) && (\ (__cplusplus >= 201103L) ||\ \ (defined(_MSC_VER) && _MSC_VER >= 1700)) &&\ ATOMIC_INT_LOCK_FREE == 2) #undef __pyx_atomic_int_type #define __pyx_atomic_int_type std::atomic_int #define __pyx_atomic_ptr_type std::atomic_uintptr_t #define __pyx_nonatomic_ptr_type uintptr_t #define __pyx_atomic_incr_relaxed(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_relaxed) #define __pyx_atomic_incr_acq_rel(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_acq_rel) #define __pyx_atomic_decr_acq_rel(value) std::atomic_fetch_sub_explicit(value, 1, std::memory_order_acq_rel) #define __pyx_atomic_sub(value, arg) std::atomic_fetch_sub(value, arg) #define __pyx_atomic_int_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired) #define __pyx_atomic_load(value) std::atomic_load(value) #define __pyx_atomic_store(value, new_value) std::atomic_store(value, new_value) #define __pyx_atomic_pointer_load_relaxed(value) std::atomic_load_explicit(value, std::memory_order_relaxed) #define __pyx_atomic_pointer_load_acquire(value) std::atomic_load_explicit(value, std::memory_order_acquire) #define __pyx_atomic_pointer_exchange(value, new_value) std::atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value) #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired) #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER) #pragma message ("Using standard C++ atomics") #elif defined(__PYX_DEBUG_ATOMICS) #warning "Using standard C++ atomics" #endif #elif CYTHON_ATOMICS && (__GNUC__ >= 5 || (__GNUC__ == 4 &&\ (__GNUC_MINOR__ > 1 ||\ (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ >= 2)))) #define __pyx_atomic_ptr_type void* #define __pyx_nonatomic_ptr_type void* #define __pyx_atomic_incr_relaxed(value) __sync_fetch_and_add(value, 1) #define __pyx_atomic_incr_acq_rel(value) __sync_fetch_and_add(value, 1) #define __pyx_atomic_decr_acq_rel(value) __sync_fetch_and_sub(value, 1) #define __pyx_atomic_sub(value, arg) __sync_fetch_and_sub(value, arg) static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) { __pyx_nonatomic_int_type old = __sync_val_compare_and_swap(value, *expected, desired); int result = old == *expected; *expected = old; return result; } #define __pyx_atomic_load(value) __sync_fetch_and_add(value, 0) #define __pyx_atomic_store(value, new_value) __sync_lock_test_and_set(value, new_value) #define __pyx_atomic_pointer_load_relaxed(value) __sync_fetch_and_add(value, 0) #define __pyx_atomic_pointer_load_acquire(value) __sync_fetch_and_add(value, 0) #define __pyx_atomic_pointer_exchange(value, new_value) __sync_lock_test_and_set(value, (__pyx_atomic_ptr_type)new_value) static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) { __pyx_nonatomic_ptr_type old = __sync_val_compare_and_swap(value, *expected, desired); int result = old == *expected; *expected = old; return result; } #ifdef __PYX_DEBUG_ATOMICS #warning "Using GNU atomics" #endif #elif CYTHON_ATOMICS && defined(_MSC_VER) #include #undef __pyx_atomic_int_type #define __pyx_atomic_int_type long #define __pyx_atomic_ptr_type void* #undef __pyx_nonatomic_int_type #define __pyx_nonatomic_int_type long #define __pyx_nonatomic_ptr_type void* #pragma intrinsic (_InterlockedExchangeAdd, _InterlockedExchange, _InterlockedCompareExchange, _InterlockedCompareExchangePointer, _InterlockedExchangePointer) #define __pyx_atomic_incr_relaxed(value) _InterlockedExchangeAdd(value, 1) #define __pyx_atomic_incr_acq_rel(value) _InterlockedExchangeAdd(value, 1) #define __pyx_atomic_decr_acq_rel(value) _InterlockedExchangeAdd(value, -1) #define __pyx_atomic_sub(value, arg) _InterlockedExchangeAdd(value, -arg) static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) { __pyx_nonatomic_int_type old = _InterlockedCompareExchange(value, desired, *expected); int result = old == *expected; *expected = old; return result; } #define __pyx_atomic_load(value) _InterlockedExchangeAdd(value, 0) #define __pyx_atomic_store(value, new_value) _InterlockedExchange(value, new_value) #define __pyx_atomic_pointer_load_relaxed(value) *(void * volatile *)value #define __pyx_atomic_pointer_load_acquire(value) _InterlockedCompareExchangePointer(value, 0, 0) #define __pyx_atomic_pointer_exchange(value, new_value) _InterlockedExchangePointer(value, (__pyx_atomic_ptr_type)new_value) static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) { __pyx_atomic_ptr_type old = _InterlockedCompareExchangePointer(value, desired, *expected); int result = old == *expected; *expected = old; return result; } #ifdef __PYX_DEBUG_ATOMICS #pragma message ("Using MSVC atomics") #endif #else #undef CYTHON_ATOMICS #define CYTHON_ATOMICS 0 #ifdef __PYX_DEBUG_ATOMICS #warning "Not using atomics" #endif #endif /* CriticalSectionsDefinition.proto */ #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #define __Pyx_PyCriticalSection void* #define __Pyx_PyCriticalSection2 void* #define __Pyx_PyCriticalSection_End(cs) #define __Pyx_PyCriticalSection2_End(cs) #else #define __Pyx_PyCriticalSection PyCriticalSection #define __Pyx_PyCriticalSection2 PyCriticalSection2 #define __Pyx_PyCriticalSection_End PyCriticalSection_End #define __Pyx_PyCriticalSection2_End PyCriticalSection2_End #endif /* CriticalSections.proto */ #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #define __Pyx_PyCriticalSection_Begin(cs, arg) (void)(cs) #define __Pyx_PyCriticalSection2_Begin(cs, arg1, arg2) (void)(cs) #else #define __Pyx_PyCriticalSection_Begin PyCriticalSection_Begin #define __Pyx_PyCriticalSection2_Begin PyCriticalSection2_Begin #endif #if PY_VERSION_HEX < 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_BEGIN_CRITICAL_SECTION(o) { #define __Pyx_END_CRITICAL_SECTION() } #else #define __Pyx_BEGIN_CRITICAL_SECTION Py_BEGIN_CRITICAL_SECTION #define __Pyx_END_CRITICAL_SECTION Py_END_CRITICAL_SECTION #endif /* IncludeStructmemberH.proto */ #include /* #### Code section: numeric_typedefs ### */ /* #### Code section: complex_type_declarations ### */ /* #### Code section: type_declarations ### */ /*--- Type declarations ---*/ struct __pyx_opt_args_7cpython_11contextvars_get_value; struct __pyx_opt_args_7cpython_11contextvars_get_value_no_default; /* "cpython/contextvars.pxd":116 * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline object get_value(var, default_value=None): # <<<<<<<<<<<<<< * """Return a new reference to the value of the context variable, * or the default value of the context variable, */ struct __pyx_opt_args_7cpython_11contextvars_get_value { int __pyx_n; PyObject *default_value; }; /* "cpython/contextvars.pxd":134 * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline object get_value_no_default(var, default_value=None): # <<<<<<<<<<<<<< * """Return a new reference to the value of the context variable, * or the provided default value if no such value was found. */ struct __pyx_opt_args_7cpython_11contextvars_get_value_no_default { int __pyx_n; PyObject *default_value; }; /* #### Code section: utility_code_proto ### */ /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, Py_ssize_t); void (*DECREF)(void*, PyObject*, Py_ssize_t); void (*GOTREF)(void*, PyObject*, Py_ssize_t); void (*GIVEREF)(void*, PyObject*, Py_ssize_t); void* (*SetupContext)(const char*, Py_ssize_t, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\ } #define __Pyx_RefNannyFinishContextNogil() {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __Pyx_RefNannyFinishContext();\ PyGILState_Release(__pyx_gilstate_save);\ } #define __Pyx_RefNannyFinishContextNogil() {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __Pyx_RefNannyFinishContext();\ PyGILState_Release(__pyx_gilstate_save);\ } #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_XINCREF(r) do { if((r) == NULL); else {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) == NULL); else {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) == NULL); else {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) == NULL); else {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContextNogil() #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_Py_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; Py_XDECREF(tmp);\ } while (0) #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) /* TupleAndListFromArray.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n); #endif #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_METH_FASTCALL static CYTHON_INLINE PyObject* __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n); #endif /* IncludeStringH.proto */ #include /* BytesEquals.proto */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /* UnicodeEquals.proto */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /* fastcall.proto */ #if CYTHON_AVOID_BORROWED_REFS #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_PySequence_ITEM(args, i) #elif CYTHON_ASSUME_SAFE_MACROS #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_NewRef(__Pyx_PyTuple_GET_ITEM(args, i)) #else #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_XNewRef(PyTuple_GetItem(args, i)) #endif #define __Pyx_NumKwargs_VARARGS(kwds) PyDict_Size(kwds) #define __Pyx_KwValues_VARARGS(args, nargs) NULL #define __Pyx_GetKwValue_VARARGS(kw, kwvalues, s) __Pyx_PyDict_GetItemStrWithError(kw, s) #define __Pyx_KwargsAsDict_VARARGS(kw, kwvalues) PyDict_Copy(kw) #if CYTHON_METH_FASTCALL #define __Pyx_ArgRef_FASTCALL(args, i) __Pyx_NewRef(args[i]) #define __Pyx_NumKwargs_FASTCALL(kwds) __Pyx_PyTuple_GET_SIZE(kwds) #define __Pyx_KwValues_FASTCALL(args, nargs) ((args) + (nargs)) static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues); #else #define __Pyx_KwargsAsDict_FASTCALL(kw, kwvalues) _PyStack_AsDict(kwvalues, kw) #endif #else #define __Pyx_ArgRef_FASTCALL __Pyx_ArgRef_VARARGS #define __Pyx_NumKwargs_FASTCALL __Pyx_NumKwargs_VARARGS #define __Pyx_KwValues_FASTCALL __Pyx_KwValues_VARARGS #define __Pyx_GetKwValue_FASTCALL __Pyx_GetKwValue_VARARGS #define __Pyx_KwargsAsDict_FASTCALL __Pyx_KwargsAsDict_VARARGS #endif #define __Pyx_ArgsSlice_VARARGS(args, start, stop) PyTuple_GetSlice(args, start, stop) #if CYTHON_METH_FASTCALL || (CYTHON_COMPILING_IN_CPYTHON && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) __Pyx_PyTuple_FromArray(args + start, stop - start) #else #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) PyTuple_GetSlice(args, start, stop) #endif /* py_dict_items.proto */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d); /* CallCFunction.proto */ #define __Pyx_CallCFunction(cfunc, self, args)\ ((PyCFunction)(void(*)(void))(cfunc)->func)(self, args) #define __Pyx_CallCFunctionWithKeywords(cfunc, self, args, kwargs)\ ((PyCFunctionWithKeywords)(void(*)(void))(cfunc)->func)(self, args, kwargs) #define __Pyx_CallCFunctionFast(cfunc, self, args, nargs)\ ((__Pyx_PyCFunctionFast)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs) #define __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, nargs, kwnames)\ ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs, kwnames) /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif /* PyObjectCallMethO.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); #endif /* PyObjectFastCall.proto */ #define __Pyx_PyObject_FastCall(func, args, nargs) __Pyx_PyObject_FastCallDict(func, args, (size_t)(nargs), NULL) static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs); /* PyObjectCallOneArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); /* PyObjectGetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif /* UnpackUnboundCMethod.proto */ typedef struct { PyObject *type; PyObject **method_name; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && CYTHON_ATOMICS __pyx_atomic_int_type initialized; #endif PyCFunction func; PyObject *method; int flag; } __Pyx_CachedCFunction; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING static CYTHON_INLINE int __Pyx_CachedCFunction_GetAndSetInitializing(__Pyx_CachedCFunction *cfunc) { #if !CYTHON_ATOMICS return 1; #else __pyx_nonatomic_int_type expected = 0; if (__pyx_atomic_int_cmp_exchange(&cfunc->initialized, &expected, 1)) { return 0; } return expected; #endif } static CYTHON_INLINE void __Pyx_CachedCFunction_SetFinishedInitializing(__Pyx_CachedCFunction *cfunc) { #if CYTHON_ATOMICS __pyx_atomic_store(&cfunc->initialized, 2); #endif } #else #define __Pyx_CachedCFunction_GetAndSetInitializing(cfunc) 2 #define __Pyx_CachedCFunction_SetFinishedInitializing(cfunc) #endif /* CallUnboundCMethod0.proto */ CYTHON_UNUSED static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self); #else #define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self) #endif /* py_dict_values.proto */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d); /* OwnedDictNext.proto */ #if CYTHON_AVOID_BORROWED_REFS static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue); #else CYTHON_INLINE static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue); #endif /* RaiseDoubleKeywords.proto */ static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /* ParseKeywordsImpl.export */ static int __Pyx_ParseKeywordsTuple( PyObject *kwds, PyObject * const *kwvalues, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs ); static int __Pyx_ParseKeywordDictToDict( PyObject *kwds, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name ); static int __Pyx_ParseKeywordDict( PyObject *kwds, PyObject ** const argnames[], PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs ); /* CallUnboundCMethod2.proto */ CYTHON_UNUSED static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2); #else #define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2) __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2) #endif /* ParseKeywords.proto */ static CYTHON_INLINE int __Pyx_ParseKeywords( PyObject *kwds, PyObject *const *kwvalues, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs ); /* RaiseArgTupleInvalid.proto */ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /* PyObjectFastCallMethod.proto */ #if CYTHON_VECTORCALL && PY_VERSION_HEX >= 0x03090000 #define __Pyx_PyObject_FastCallMethod(name, args, nargsf) PyObject_VectorcallMethod(name, args, nargsf, NULL) #else static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const *args, size_t nargsf); #endif /* TypeImport.proto */ #ifndef __PYX_HAVE_RT_ImportType_proto_3_2_0 #define __PYX_HAVE_RT_ImportType_proto_3_2_0 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #include #endif #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || __cplusplus >= 201103L #define __PYX_GET_STRUCT_ALIGNMENT_3_2_0(s) alignof(s) #else #define __PYX_GET_STRUCT_ALIGNMENT_3_2_0(s) sizeof(void*) #endif enum __Pyx_ImportType_CheckSize_3_2_0 { __Pyx_ImportType_CheckSize_Error_3_2_0 = 0, __Pyx_ImportType_CheckSize_Warn_3_2_0 = 1, __Pyx_ImportType_CheckSize_Ignore_3_2_0 = 2 }; static PyTypeObject *__Pyx_ImportType_3_2_0(PyObject* module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_2_0 check_size); #endif /* dict_setdefault.proto */ static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value); /* LimitedApiGetTypeDict.proto */ #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp); #endif /* SetItemOnTypeDict.proto */ static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v); #define __Pyx_SetItemOnTypeDict(tp, k, v) __Pyx__SetItemOnTypeDict((PyTypeObject*)tp, k, v) /* FixUpExtensionType.proto */ static CYTHON_INLINE int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type); /* AddModuleRef.proto */ #if ((CYTHON_COMPILING_IN_CPYTHON_FREETHREADING ) ||\ __PYX_LIMITED_VERSION_HEX < 0x030d0000) static PyObject *__Pyx_PyImport_AddModuleRef(const char *name); #else #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name) #endif /* FetchSharedCythonModule.proto */ static PyObject *__Pyx_FetchSharedCythonABIModule(void); /* FetchCommonType.proto */ static PyTypeObject* __Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases); /* CommonTypesMetaclass.proto */ static int __pyx_CommonTypesMetaclass_init(PyObject *module); #define __Pyx_CommonTypesMetaclass_USED /* CallTypeTraverse.proto */ #if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000) #define __Pyx_call_type_traverse(o, always_call, visit, arg) 0 #else static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg); #endif /* PyMethodNew.proto */ static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ); /* PyVectorcallFastCallDict.proto */ #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw); #endif /* CythonFunctionShared.proto */ #define __Pyx_CyFunction_USED #define __Pyx_CYFUNCTION_STATICMETHOD 0x01 #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 #define __Pyx_CYFUNCTION_CCLASS 0x04 #define __Pyx_CYFUNCTION_COROUTINE 0x08 #define __Pyx_CyFunction_GetClosure(f)\ (((__pyx_CyFunctionObject *) (f))->func_closure) #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_GetClassObj(f)\ (((__pyx_CyFunctionObject *) (f))->func_classobj) #else #define __Pyx_CyFunction_GetClassObj(f)\ ((PyObject*) ((PyCMethodObject *) (f))->mm_class) #endif #define __Pyx_CyFunction_SetClassObj(f, classobj)\ __Pyx__CyFunction_SetClassObj((__pyx_CyFunctionObject *) (f), (classobj)) #define __Pyx_CyFunction_Defaults(type, f)\ ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) typedef struct { #if CYTHON_COMPILING_IN_LIMITED_API PyObject_HEAD PyObject *func; #elif PY_VERSION_HEX < 0x030900B1 PyCFunctionObject func; #else PyCMethodObject func; #endif #if CYTHON_COMPILING_IN_LIMITED_API && CYTHON_METH_FASTCALL __pyx_vectorcallfunc func_vectorcall; #endif #if CYTHON_COMPILING_IN_LIMITED_API PyObject *func_weakreflist; #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API PyObject *func_dict; #endif PyObject *func_name; PyObject *func_qualname; PyObject *func_doc; PyObject *func_globals; PyObject *func_code; PyObject *func_closure; #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API PyObject *func_classobj; #endif PyObject *defaults; int flags; PyObject *defaults_tuple; PyObject *defaults_kwdict; PyObject *(*defaults_getter)(PyObject *); PyObject *func_annotations; PyObject *func_is_coroutine; } __pyx_CyFunctionObject; #undef __Pyx_CyOrPyCFunction_Check #define __Pyx_CyFunction_Check(obj) __Pyx_TypeCheck(obj, __pyx_mstate_global->__pyx_CyFunctionType) #define __Pyx_CyOrPyCFunction_Check(obj) __Pyx_TypeCheck2(obj, __pyx_mstate_global->__pyx_CyFunctionType, &PyCFunction_Type) #define __Pyx_CyFunction_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_mstate_global->__pyx_CyFunctionType) static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)); #undef __Pyx_IsSameCFunction #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCyOrCFunction(func, cfunc) static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject *globals, PyObject* code); static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj); static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, PyObject *tuple); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, PyObject *dict); static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, PyObject *dict); static int __pyx_CyFunction_init(PyObject *module); #if CYTHON_METH_FASTCALL static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_func_vectorcall(f) (((__pyx_CyFunctionObject*)f)->func_vectorcall) #else #define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall) #endif #endif /* CythonFunction.proto */ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject *globals, PyObject* code); /* PyDictVersioning.proto */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ (version_var) = __PYX_GET_DICT_VERSION(dict);\ (cache_var) = (value); #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ (VAR) = __Pyx_XNewRef(__pyx_dict_cached_value);\ } else {\ (VAR) = __pyx_dict_cached_value = (LOOKUP);\ __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ }\ } static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); #else #define __PYX_GET_DICT_VERSION(dict) (0) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); #endif /* PyErrExceptionMatches.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); #else #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) #endif /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; #if PY_VERSION_HEX >= 0x030C00A6 #define __Pyx_PyErr_Occurred() (__pyx_tstate->current_exception != NULL) #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->current_exception ? (PyObject*) Py_TYPE(__pyx_tstate->current_exception) : (PyObject*) NULL) #else #define __Pyx_PyErr_Occurred() (__pyx_tstate->curexc_type != NULL) #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->curexc_type) #endif #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign #define __Pyx_PyErr_Occurred() (PyErr_Occurred() != NULL) #define __Pyx_PyErr_CurrentExceptionType() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A6 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) #else #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #endif #else #define __Pyx_PyErr_Clear() PyErr_Clear() #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) #endif /* PyObjectGetAttrStrNoError.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name); /* CLineInTraceback.proto */ #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); #else #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) #endif /* CodeObjectCache.proto */ #if CYTHON_COMPILING_IN_LIMITED_API typedef PyObject __Pyx_CachedCodeObjectType; #else typedef PyCodeObject __Pyx_CachedCodeObjectType; #endif typedef struct { __Pyx_CachedCodeObjectType* code_object; int code_line; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_atomic_int_type accessor_count; #endif }; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object); /* AddTraceback.proto */ static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); /* GCCDiagnostics.proto */ #if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #define __Pyx_HAS_GCC_DIAGNOSTIC #endif /* CIntFromPy.proto */ static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyLong_As_unsigned_PY_LONG_LONG(PyObject *); /* PyObjectVectorCallKwBuilder.proto */ CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n); #if CYTHON_VECTORCALL #if PY_VERSION_HEX >= 0x03090000 #define __Pyx_Object_Vectorcall_CallFromBuilder PyObject_Vectorcall #else #define __Pyx_Object_Vectorcall_CallFromBuilder _PyObject_Vectorcall #endif #define __Pyx_MakeVectorcallBuilderKwds(n) PyTuple_New(n) static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n); static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n); #else #define __Pyx_Object_Vectorcall_CallFromBuilder __Pyx_PyObject_FastCallDict #define __Pyx_MakeVectorcallBuilderKwds(n) __Pyx_PyDict_NewPresized(n) #define __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n) PyDict_SetItem(builder, key, value) #define __Pyx_VectorcallBuilder_AddArgStr(key, value, builder, args, n) PyDict_SetItemString(builder, key, value) #endif /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value); /* FormatTypeName.proto */ #if CYTHON_COMPILING_IN_LIMITED_API typedef PyObject *__Pyx_TypeName; #define __Pyx_FMT_TYPENAME "%U" #define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj) #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyType_GetFullyQualifiedName PyType_GetFullyQualifiedName #else static __Pyx_TypeName __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp); #endif #else // !LIMITED_API typedef const char *__Pyx_TypeName; #define __Pyx_FMT_TYPENAME "%.200s" #define __Pyx_PyType_GetFullyQualifiedName(tp) ((tp)->tp_name) #define __Pyx_DECREF_TypeName(obj) #endif /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *); /* FastTypeChecks.proto */ #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) #define __Pyx_TypeCheck2(obj, type1, type2) __Pyx_IsAnySubtype2(Py_TYPE(obj), (PyTypeObject *)type1, (PyTypeObject *)type2) static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); #else #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_TypeCheck2(obj, type1, type2) (PyObject_TypeCheck(obj, (PyTypeObject *)type1) || PyObject_TypeCheck(obj, (PyTypeObject *)type2)) #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2) { return PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2); } #endif #define __Pyx_PyErr_ExceptionMatches2(err1, err2) __Pyx_PyErr_GivenExceptionMatches2(__Pyx_PyErr_CurrentExceptionType(), err1, err2) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) #ifdef PyExceptionInstance_Check #define __Pyx_PyBaseException_Check(obj) PyExceptionInstance_Check(obj) #else #define __Pyx_PyBaseException_Check(obj) __Pyx_TypeCheck(obj, PyExc_BaseException) #endif /* GetRuntimeVersion.proto */ #if __PYX_LIMITED_VERSION_HEX < 0x030b0000 static unsigned long __Pyx_cached_runtime_version = 0; static void __Pyx_init_runtime_version(void); #else #define __Pyx_init_runtime_version() #endif static unsigned long __Pyx_get_runtime_version(void); /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer); /* DecompressString.proto */ static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo); /* MultiPhaseInitModuleState.proto */ #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE static PyObject *__Pyx_State_FindModule(void*); static int __Pyx_State_AddModule(PyObject* module, void*); static int __Pyx_State_RemoveModule(void*); #elif CYTHON_USE_MODULE_STATE #define __Pyx_State_FindModule PyState_FindModule #define __Pyx_State_AddModule PyState_AddModule #define __Pyx_State_RemoveModule PyState_RemoveModule #endif /* #### Code section: module_declarations ### */ /* CythonABIVersion.proto */ #if CYTHON_COMPILING_IN_LIMITED_API #if CYTHON_METH_FASTCALL #define __PYX_FASTCALL_ABI_SUFFIX "_fastcall" #else #define __PYX_FASTCALL_ABI_SUFFIX #endif #define __PYX_LIMITED_ABI_SUFFIX "limited" __PYX_FASTCALL_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX #else #define __PYX_LIMITED_ABI_SUFFIX #endif #if __PYX_HAS_PY_AM_SEND == 1 #define __PYX_AM_SEND_ABI_SUFFIX #elif __PYX_HAS_PY_AM_SEND == 2 #define __PYX_AM_SEND_ABI_SUFFIX "amsendbackport" #else #define __PYX_AM_SEND_ABI_SUFFIX "noamsend" #endif #ifndef __PYX_MONITORING_ABI_SUFFIX #define __PYX_MONITORING_ABI_SUFFIX #endif #if CYTHON_USE_TP_FINALIZE #define __PYX_TP_FINALIZE_ABI_SUFFIX #else #define __PYX_TP_FINALIZE_ABI_SUFFIX "nofinalize" #endif #if CYTHON_USE_FREELISTS || !defined(__Pyx_AsyncGen_USED) #define __PYX_FREELISTS_ABI_SUFFIX #else #define __PYX_FREELISTS_ABI_SUFFIX "nofreelists" #endif #define CYTHON_ABI __PYX_ABI_VERSION __PYX_LIMITED_ABI_SUFFIX __PYX_MONITORING_ABI_SUFFIX __PYX_TP_FINALIZE_ABI_SUFFIX __PYX_FREELISTS_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX #define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI #define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "." #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4real_real(PyComplexObject *__pyx_v_self); /* proto*/ #endif #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4imag_imag(PyComplexObject *__pyx_v_self); /* proto*/ #endif /* Module declarations from "cpython.version" */ /* Module declarations from "__builtin__" */ /* Module declarations from "cpython.type" */ /* Module declarations from "libc.string" */ /* Module declarations from "libc.stdio" */ /* Module declarations from "cpython.object" */ /* Module declarations from "cpython.ref" */ /* Module declarations from "cpython.exc" */ /* Module declarations from "cpython.module" */ /* Module declarations from "cpython.mem" */ /* Module declarations from "cpython.tuple" */ /* Module declarations from "cpython.list" */ /* Module declarations from "cpython.sequence" */ /* Module declarations from "cpython.mapping" */ /* Module declarations from "cpython.iterator" */ /* Module declarations from "cpython.number" */ /* Module declarations from "__builtin__" */ /* Module declarations from "cpython.bool" */ /* Module declarations from "cpython.long" */ /* Module declarations from "cpython.float" */ /* Module declarations from "cython" */ /* Module declarations from "__builtin__" */ /* Module declarations from "cpython.complex" */ /* Module declarations from "libc.stddef" */ /* Module declarations from "cpython.unicode" */ /* Module declarations from "cpython.pyport" */ /* Module declarations from "cpython.dict" */ /* Module declarations from "cpython.instance" */ /* Module declarations from "cpython.function" */ /* Module declarations from "cpython.method" */ /* Module declarations from "cpython.weakref" */ /* Module declarations from "cpython.getargs" */ /* Module declarations from "cpython.pythread" */ /* Module declarations from "cpython.pystate" */ /* Module declarations from "cpython.set" */ /* Module declarations from "cpython.buffer" */ /* Module declarations from "cpython.bytes" */ /* Module declarations from "cpython.pycapsule" */ /* Module declarations from "cpython.contextvars" */ /* Module declarations from "cpython" */ /* Module declarations from "clickhouse_driver.varint" */ /* #### Code section: typeinfo ### */ /* #### Code section: before_global_var ### */ #define __Pyx_MODULE_NAME "clickhouse_driver.varint" extern int __pyx_module_is_main_clickhouse_driver__varint; int __pyx_module_is_main_clickhouse_driver__varint = 0; /* Implementation of "clickhouse_driver.varint" */ /* #### Code section: global_var ### */ /* #### Code section: string_decls ### */ /* #### Code section: decls ### */ static PyObject *__pyx_pf_17clickhouse_driver_6varint_make_varint(CYTHON_UNUSED PyObject *__pyx_self, unsigned PY_LONG_LONG __pyx_v_number); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_6varint_2write_varint(CYTHON_UNUSED PyObject *__pyx_self, unsigned PY_LONG_LONG __pyx_v_number, PyObject *__pyx_v_buf); /* proto */ static PyObject *__pyx_pf_17clickhouse_driver_6varint_4read_varint(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_f); /* proto */ /* #### Code section: late_includes ### */ /* #### Code section: module_state ### */ /* SmallCodeConfig */ #ifndef CYTHON_SMALL_CODE #if defined(__clang__) #define CYTHON_SMALL_CODE #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) #define CYTHON_SMALL_CODE __attribute__((cold)) #else #define CYTHON_SMALL_CODE #endif #endif typedef struct { PyObject *__pyx_d; PyObject *__pyx_b; PyObject *__pyx_cython_runtime; PyObject *__pyx_empty_tuple; PyObject *__pyx_empty_bytes; PyObject *__pyx_empty_unicode; PyTypeObject *__pyx_ptype_7cpython_4type_type; PyTypeObject *__pyx_ptype_7cpython_4bool_bool; PyTypeObject *__pyx_ptype_7cpython_7complex_complex; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop; __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_values; PyObject *__pyx_codeobj_tab[3]; PyObject *__pyx_string_tab[34]; /* #### Code section: module_state_contents ### */ /* CommonTypesMetaclass.module_state_decls */ PyTypeObject *__pyx_CommonTypesMetaclassType; /* CachedMethodType.module_state_decls */ #if CYTHON_COMPILING_IN_LIMITED_API PyObject *__Pyx_CachedMethodType; #endif /* CythonFunctionShared.module_state_decls */ PyTypeObject *__pyx_CyFunctionType; /* CodeObjectCache.module_state_decls */ struct __Pyx_CodeObjectCache __pyx_code_cache; /* #### Code section: module_state_end ### */ } __pyx_mstatetype; #if CYTHON_USE_MODULE_STATE #ifdef __cplusplus namespace { extern struct PyModuleDef __pyx_moduledef; } /* anonymous namespace */ #else static struct PyModuleDef __pyx_moduledef; #endif #define __pyx_mstate_global (__Pyx_PyModule_GetState(__Pyx_State_FindModule(&__pyx_moduledef))) #define __pyx_m (__Pyx_State_FindModule(&__pyx_moduledef)) #else static __pyx_mstatetype __pyx_mstate_global_static = #ifdef __cplusplus {}; #else {0}; #endif static __pyx_mstatetype * const __pyx_mstate_global = &__pyx_mstate_global_static; #endif /* #### Code section: constant_name_defines ### */ #define __pyx_kp_u_ __pyx_string_tab[0] #define __pyx_kp_u_clickhouse_driver_varint_pyx __pyx_string_tab[1] #define __pyx_n_u_Pyx_PyDict_NextRef __pyx_string_tab[2] #define __pyx_n_u_asyncio_coroutines __pyx_string_tab[3] #define __pyx_n_u_buf __pyx_string_tab[4] #define __pyx_n_u_clickhouse_driver_varint __pyx_string_tab[5] #define __pyx_n_u_cline_in_traceback __pyx_string_tab[6] #define __pyx_n_u_f __pyx_string_tab[7] #define __pyx_n_u_func __pyx_string_tab[8] #define __pyx_n_u_i __pyx_string_tab[9] #define __pyx_n_u_is_coroutine __pyx_string_tab[10] #define __pyx_n_u_items __pyx_string_tab[11] #define __pyx_n_u_main __pyx_string_tab[12] #define __pyx_n_u_make_varint __pyx_string_tab[13] #define __pyx_n_u_module __pyx_string_tab[14] #define __pyx_n_u_name __pyx_string_tab[15] #define __pyx_n_u_num_buf __pyx_string_tab[16] #define __pyx_n_u_number __pyx_string_tab[17] #define __pyx_n_u_pop __pyx_string_tab[18] #define __pyx_n_u_qualname __pyx_string_tab[19] #define __pyx_n_u_read_one __pyx_string_tab[20] #define __pyx_n_u_read_varint __pyx_string_tab[21] #define __pyx_n_u_result __pyx_string_tab[22] #define __pyx_n_u_set_name __pyx_string_tab[23] #define __pyx_n_u_setdefault __pyx_string_tab[24] #define __pyx_n_u_shift __pyx_string_tab[25] #define __pyx_n_u_test __pyx_string_tab[26] #define __pyx_n_u_to_write __pyx_string_tab[27] #define __pyx_n_u_values __pyx_string_tab[28] #define __pyx_n_u_write __pyx_string_tab[29] #define __pyx_n_u_write_varint __pyx_string_tab[30] #define __pyx_kp_b_iso88591_Q_7_A_1_1_1E_A_1E_AXYa __pyx_string_tab[31] #define __pyx_kp_b_iso88591_Q_7_A_1_1_1E_A_1E_vQ_q __pyx_string_tab[32] #define __pyx_kp_b_iso88591_q_q_HA_2RvS_2Rq_1 __pyx_string_tab[33] /* #### Code section: module_state_clear ### */ #if CYTHON_USE_MODULE_STATE static CYTHON_SMALL_CODE int __pyx_m_clear(PyObject *m) { __pyx_mstatetype *clear_module_state = __Pyx_PyModule_GetState(m); if (!clear_module_state) return 0; Py_CLEAR(clear_module_state->__pyx_d); Py_CLEAR(clear_module_state->__pyx_b); Py_CLEAR(clear_module_state->__pyx_cython_runtime); Py_CLEAR(clear_module_state->__pyx_empty_tuple); Py_CLEAR(clear_module_state->__pyx_empty_bytes); Py_CLEAR(clear_module_state->__pyx_empty_unicode); #if CYTHON_PEP489_MULTI_PHASE_INIT __Pyx_State_RemoveModule(NULL); #endif Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_4type_type); Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_4bool_bool); Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_7complex_complex); for (int i=0; i<3; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); } for (int i=0; i<34; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); } /* #### Code section: module_state_clear_contents ### */ /* CommonTypesMetaclass.module_state_clear */ Py_CLEAR(clear_module_state->__pyx_CommonTypesMetaclassType); /* CythonFunctionShared.module_state_clear */ Py_CLEAR(clear_module_state->__pyx_CyFunctionType); /* #### Code section: module_state_clear_end ### */ return 0; } #endif /* #### Code section: module_state_traverse ### */ #if CYTHON_USE_MODULE_STATE static CYTHON_SMALL_CODE int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) { __pyx_mstatetype *traverse_module_state = __Pyx_PyModule_GetState(m); if (!traverse_module_state) return 0; Py_VISIT(traverse_module_state->__pyx_d); Py_VISIT(traverse_module_state->__pyx_b); Py_VISIT(traverse_module_state->__pyx_cython_runtime); __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_tuple); __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_bytes); __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_unicode); Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_4type_type); Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_4bool_bool); Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_7complex_complex); for (int i=0; i<3; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); } for (int i=0; i<34; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); } /* #### Code section: module_state_traverse_contents ### */ /* CommonTypesMetaclass.module_state_traverse */ Py_VISIT(traverse_module_state->__pyx_CommonTypesMetaclassType); /* CythonFunctionShared.module_state_traverse */ Py_VISIT(traverse_module_state->__pyx_CyFunctionType); /* #### Code section: module_state_traverse_end ### */ return 0; } #endif /* #### Code section: module_code ### */ /* "cpython/complex.pxd":20 * * # unavailable in limited API * @property # <<<<<<<<<<<<<< * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double real(self) noexcept: */ #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4real_real(PyComplexObject *__pyx_v_self) { double __pyx_r; /* "cpython/complex.pxd":23 * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double real(self) noexcept: * return self.cval.real # <<<<<<<<<<<<<< * * # unavailable in limited API */ __pyx_r = __pyx_v_self->cval.real; goto __pyx_L0; /* "cpython/complex.pxd":20 * * # unavailable in limited API * @property # <<<<<<<<<<<<<< * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double real(self) noexcept: */ /* function exit code */ __pyx_L0:; return __pyx_r; } #endif /*!(#if !CYTHON_COMPILING_IN_LIMITED_API)*/ /* "cpython/complex.pxd":26 * * # unavailable in limited API * @property # <<<<<<<<<<<<<< * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double imag(self) noexcept: */ #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE double __pyx_f_7cpython_7complex_7complex_4imag_imag(PyComplexObject *__pyx_v_self) { double __pyx_r; /* "cpython/complex.pxd":29 * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double imag(self) noexcept: * return self.cval.imag # <<<<<<<<<<<<<< * * # PyTypeObject PyComplex_Type */ __pyx_r = __pyx_v_self->cval.imag; goto __pyx_L0; /* "cpython/complex.pxd":26 * * # unavailable in limited API * @property # <<<<<<<<<<<<<< * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline double imag(self) noexcept: */ /* function exit code */ __pyx_L0:; return __pyx_r; } #endif /*!(#if !CYTHON_COMPILING_IN_LIMITED_API)*/ /* "cpython/contextvars.pxd":115 * * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") # <<<<<<<<<<<<<< * cdef inline object get_value(var, default_value=None): * """Return a new reference to the value of the context variable, */ #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE PyObject *__pyx_f_7cpython_11contextvars_get_value(PyObject *__pyx_v_var, struct __pyx_opt_args_7cpython_11contextvars_get_value *__pyx_optional_args) { /* "cpython/contextvars.pxd":116 * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline object get_value(var, default_value=None): # <<<<<<<<<<<<<< * """Return a new reference to the value of the context variable, * or the default value of the context variable, */ PyObject *__pyx_v_default_value = ((PyObject *)Py_None); PyObject *__pyx_v_value; PyObject *__pyx_v_pyvalue = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_value", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_default_value = __pyx_optional_args->default_value; } } /* "cpython/contextvars.pxd":121 * or None if no such value or default was found. * """ * cdef PyObject *value = NULL # <<<<<<<<<<<<<< * PyContextVar_Get(var, NULL, &value) * if value is NULL: */ __pyx_v_value = NULL; /* "cpython/contextvars.pxd":122 * """ * cdef PyObject *value = NULL * PyContextVar_Get(var, NULL, &value) # <<<<<<<<<<<<<< * if value is NULL: * # context variable does not have a default */ __pyx_t_1 = PyContextVar_Get(__pyx_v_var, NULL, (&__pyx_v_value)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(1, 122, __pyx_L1_error) /* "cpython/contextvars.pxd":123 * cdef PyObject *value = NULL * PyContextVar_Get(var, NULL, &value) * if value is NULL: # <<<<<<<<<<<<<< * # context variable does not have a default * pyvalue = default_value */ __pyx_t_2 = (__pyx_v_value == NULL); if (__pyx_t_2) { /* "cpython/contextvars.pxd":125 * if value is NULL: * # context variable does not have a default * pyvalue = default_value # <<<<<<<<<<<<<< * else: * # value or default value of context variable */ __Pyx_INCREF(__pyx_v_default_value); __pyx_v_pyvalue = __pyx_v_default_value; /* "cpython/contextvars.pxd":123 * cdef PyObject *value = NULL * PyContextVar_Get(var, NULL, &value) * if value is NULL: # <<<<<<<<<<<<<< * # context variable does not have a default * pyvalue = default_value */ goto __pyx_L3; } /* "cpython/contextvars.pxd":128 * else: * # value or default value of context variable * pyvalue = value # <<<<<<<<<<<<<< * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' * return pyvalue */ /*else*/ { __pyx_t_3 = ((PyObject *)__pyx_v_value); __Pyx_INCREF(__pyx_t_3); __pyx_v_pyvalue = __pyx_t_3; __pyx_t_3 = 0; /* "cpython/contextvars.pxd":129 * # value or default value of context variable * pyvalue = value * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' # <<<<<<<<<<<<<< * return pyvalue * */ Py_XDECREF(__pyx_v_value); } __pyx_L3:; /* "cpython/contextvars.pxd":130 * pyvalue = value * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' * return pyvalue # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_pyvalue); __pyx_r = __pyx_v_pyvalue; goto __pyx_L0; /* "cpython/contextvars.pxd":115 * * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") # <<<<<<<<<<<<<< * cdef inline object get_value(var, default_value=None): * """Return a new reference to the value of the context variable, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("cpython.contextvars.get_value", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_pyvalue); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /*!(#if !CYTHON_COMPILING_IN_LIMITED_API)*/ /* "cpython/contextvars.pxd":133 * * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") # <<<<<<<<<<<<<< * cdef inline object get_value_no_default(var, default_value=None): * """Return a new reference to the value of the context variable, */ #if !CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE PyObject *__pyx_f_7cpython_11contextvars_get_value_no_default(PyObject *__pyx_v_var, struct __pyx_opt_args_7cpython_11contextvars_get_value_no_default *__pyx_optional_args) { /* "cpython/contextvars.pxd":134 * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") * cdef inline object get_value_no_default(var, default_value=None): # <<<<<<<<<<<<<< * """Return a new reference to the value of the context variable, * or the provided default value if no such value was found. */ PyObject *__pyx_v_default_value = ((PyObject *)Py_None); PyObject *__pyx_v_value; PyObject *__pyx_v_pyvalue = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_value_no_default", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_default_value = __pyx_optional_args->default_value; } } /* "cpython/contextvars.pxd":140 * Ignores the default value of the context variable, if any. * """ * cdef PyObject *value = NULL # <<<<<<<<<<<<<< * PyContextVar_Get(var, default_value, &value) * # value of context variable or 'default_value' */ __pyx_v_value = NULL; /* "cpython/contextvars.pxd":141 * """ * cdef PyObject *value = NULL * PyContextVar_Get(var, default_value, &value) # <<<<<<<<<<<<<< * # value of context variable or 'default_value' * pyvalue = value */ __pyx_t_1 = PyContextVar_Get(__pyx_v_var, ((PyObject *)__pyx_v_default_value), (&__pyx_v_value)); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(1, 141, __pyx_L1_error) /* "cpython/contextvars.pxd":143 * PyContextVar_Get(var, default_value, &value) * # value of context variable or 'default_value' * pyvalue = value # <<<<<<<<<<<<<< * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' * return pyvalue */ __pyx_t_2 = ((PyObject *)__pyx_v_value); __Pyx_INCREF(__pyx_t_2); __pyx_v_pyvalue = __pyx_t_2; __pyx_t_2 = 0; /* "cpython/contextvars.pxd":144 * # value of context variable or 'default_value' * pyvalue = value * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' # <<<<<<<<<<<<<< * return pyvalue */ Py_XDECREF(__pyx_v_value); /* "cpython/contextvars.pxd":145 * pyvalue = value * Py_XDECREF(value) # PyContextVar_Get() returned an owned reference as 'PyObject*' * return pyvalue # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_pyvalue); __pyx_r = __pyx_v_pyvalue; goto __pyx_L0; /* "cpython/contextvars.pxd":133 * * * @_cython.c_compile_guard("!CYTHON_COMPILING_IN_LIMITED_API") # <<<<<<<<<<<<<< * cdef inline object get_value_no_default(var, default_value=None): * """Return a new reference to the value of the context variable, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("cpython.contextvars.get_value_no_default", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_pyvalue); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } #endif /*!(#if !CYTHON_COMPILING_IN_LIMITED_API)*/ /* "clickhouse_driver/varint.pyx":4 * * * def make_varint(unsigned long long number): # <<<<<<<<<<<<<< * """ * Writes integer of variable length using LEB128. */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_6varint_1make_varint(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_17clickhouse_driver_6varint_make_varint, "\n Writes integer of variable length using LEB128.\n "); static PyMethodDef __pyx_mdef_17clickhouse_driver_6varint_1make_varint = {"make_varint", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_6varint_1make_varint, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_17clickhouse_driver_6varint_make_varint}; static PyObject *__pyx_pw_17clickhouse_driver_6varint_1make_varint(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { unsigned PY_LONG_LONG __pyx_v_number; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("make_varint (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_number,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 4, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "make_varint", 0) < (0)) __PYX_ERR(0, 4, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("make_varint", 1, 1, 1, i); __PYX_ERR(0, 4, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4, __pyx_L3_error) } __pyx_v_number = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(values[0]); if (unlikely((__pyx_v_number == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 4, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("make_varint", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 4, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.varint.make_varint", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_6varint_make_varint(__pyx_self, __pyx_v_number); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_6varint_make_varint(CYTHON_UNUSED PyObject *__pyx_self, unsigned PY_LONG_LONG __pyx_v_number) { unsigned char __pyx_v_to_write; unsigned char __pyx_v_i; unsigned char __pyx_v_num_buf[32]; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("make_varint", 0); /* "clickhouse_driver/varint.pyx":8 * Writes integer of variable length using LEB128. * """ * cdef unsigned char to_write, i = 0 # <<<<<<<<<<<<<< * # unsigned PY_LONG_LONG checks integer on function call and * # raises OverflowError if integer overflows unsigned PY_LONG_LONG. */ __pyx_v_i = 0; /* "clickhouse_driver/varint.pyx":14 * cdef unsigned char num_buf[32] * * while True: # <<<<<<<<<<<<<< * to_write = number & 0x7f * number >>= 7 */ while (1) { /* "clickhouse_driver/varint.pyx":15 * * while True: * to_write = number & 0x7f # <<<<<<<<<<<<<< * number >>= 7 * if number: */ __pyx_v_to_write = (__pyx_v_number & 0x7f); /* "clickhouse_driver/varint.pyx":16 * while True: * to_write = number & 0x7f * number >>= 7 # <<<<<<<<<<<<<< * if number: * num_buf[i] = to_write | 0x80 */ __pyx_v_number = (__pyx_v_number >> 7); /* "clickhouse_driver/varint.pyx":17 * to_write = number & 0x7f * number >>= 7 * if number: # <<<<<<<<<<<<<< * num_buf[i] = to_write | 0x80 * i += 1 */ __pyx_t_1 = (__pyx_v_number != 0); if (__pyx_t_1) { /* "clickhouse_driver/varint.pyx":18 * number >>= 7 * if number: * num_buf[i] = to_write | 0x80 # <<<<<<<<<<<<<< * i += 1 * else: */ (__pyx_v_num_buf[__pyx_v_i]) = (__pyx_v_to_write | 0x80); /* "clickhouse_driver/varint.pyx":19 * if number: * num_buf[i] = to_write | 0x80 * i += 1 # <<<<<<<<<<<<<< * else: * num_buf[i] = to_write */ __pyx_v_i = (__pyx_v_i + 1); /* "clickhouse_driver/varint.pyx":17 * to_write = number & 0x7f * number >>= 7 * if number: # <<<<<<<<<<<<<< * num_buf[i] = to_write | 0x80 * i += 1 */ goto __pyx_L5; } /* "clickhouse_driver/varint.pyx":21 * i += 1 * else: * num_buf[i] = to_write # <<<<<<<<<<<<<< * i += 1 * break */ /*else*/ { (__pyx_v_num_buf[__pyx_v_i]) = __pyx_v_to_write; /* "clickhouse_driver/varint.pyx":22 * else: * num_buf[i] = to_write * i += 1 # <<<<<<<<<<<<<< * break * */ __pyx_v_i = (__pyx_v_i + 1); /* "clickhouse_driver/varint.pyx":23 * num_buf[i] = to_write * i += 1 * break # <<<<<<<<<<<<<< * * return PyBytes_FromStringAndSize(num_buf, i) */ goto __pyx_L4_break; } __pyx_L5:; } __pyx_L4_break:; /* "clickhouse_driver/varint.pyx":25 * break * * return PyBytes_FromStringAndSize(num_buf, i) # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = PyBytes_FromStringAndSize(((char *)__pyx_v_num_buf), __pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "clickhouse_driver/varint.pyx":4 * * * def make_varint(unsigned long long number): # <<<<<<<<<<<<<< * """ * Writes integer of variable length using LEB128. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("clickhouse_driver.varint.make_varint", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/varint.pyx":28 * * * def write_varint(unsigned long long number, buf): # <<<<<<<<<<<<<< * """ * Writes integer of variable length using LEB128. */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_6varint_3write_varint(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_17clickhouse_driver_6varint_2write_varint, "\n Writes integer of variable length using LEB128.\n "); static PyMethodDef __pyx_mdef_17clickhouse_driver_6varint_3write_varint = {"write_varint", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_6varint_3write_varint, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_17clickhouse_driver_6varint_2write_varint}; static PyObject *__pyx_pw_17clickhouse_driver_6varint_3write_varint(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { unsigned PY_LONG_LONG __pyx_v_number; PyObject *__pyx_v_buf = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[2] = {0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_varint (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_number,&__pyx_mstate_global->__pyx_n_u_buf,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 28, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 2: values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 28, __pyx_L3_error) CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 28, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "write_varint", 0) < (0)) __PYX_ERR(0, 28, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 2; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("write_varint", 1, 2, 2, i); __PYX_ERR(0, 28, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 28, __pyx_L3_error) values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 28, __pyx_L3_error) } __pyx_v_number = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(values[0]); if (unlikely((__pyx_v_number == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 28, __pyx_L3_error) __pyx_v_buf = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("write_varint", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 28, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.varint.write_varint", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_6varint_2write_varint(__pyx_self, __pyx_v_number, __pyx_v_buf); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_6varint_2write_varint(CYTHON_UNUSED PyObject *__pyx_self, unsigned PY_LONG_LONG __pyx_v_number, PyObject *__pyx_v_buf) { unsigned char __pyx_v_to_write; unsigned char __pyx_v_i; unsigned char __pyx_v_num_buf[32]; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; size_t __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write_varint", 0); /* "clickhouse_driver/varint.pyx":32 * Writes integer of variable length using LEB128. * """ * cdef unsigned char to_write, i = 0 # <<<<<<<<<<<<<< * # unsigned PY_LONG_LONG checks integer on function call and * # raises OverflowError if integer overflows unsigned PY_LONG_LONG. */ __pyx_v_i = 0; /* "clickhouse_driver/varint.pyx":38 * cdef unsigned char num_buf[32] * * while True: # <<<<<<<<<<<<<< * to_write = number & 0x7f * number >>= 7 */ while (1) { /* "clickhouse_driver/varint.pyx":39 * * while True: * to_write = number & 0x7f # <<<<<<<<<<<<<< * number >>= 7 * if number: */ __pyx_v_to_write = (__pyx_v_number & 0x7f); /* "clickhouse_driver/varint.pyx":40 * while True: * to_write = number & 0x7f * number >>= 7 # <<<<<<<<<<<<<< * if number: * num_buf[i] = to_write | 0x80 */ __pyx_v_number = (__pyx_v_number >> 7); /* "clickhouse_driver/varint.pyx":41 * to_write = number & 0x7f * number >>= 7 * if number: # <<<<<<<<<<<<<< * num_buf[i] = to_write | 0x80 * i += 1 */ __pyx_t_1 = (__pyx_v_number != 0); if (__pyx_t_1) { /* "clickhouse_driver/varint.pyx":42 * number >>= 7 * if number: * num_buf[i] = to_write | 0x80 # <<<<<<<<<<<<<< * i += 1 * else: */ (__pyx_v_num_buf[__pyx_v_i]) = (__pyx_v_to_write | 0x80); /* "clickhouse_driver/varint.pyx":43 * if number: * num_buf[i] = to_write | 0x80 * i += 1 # <<<<<<<<<<<<<< * else: * num_buf[i] = to_write */ __pyx_v_i = (__pyx_v_i + 1); /* "clickhouse_driver/varint.pyx":41 * to_write = number & 0x7f * number >>= 7 * if number: # <<<<<<<<<<<<<< * num_buf[i] = to_write | 0x80 * i += 1 */ goto __pyx_L5; } /* "clickhouse_driver/varint.pyx":45 * i += 1 * else: * num_buf[i] = to_write # <<<<<<<<<<<<<< * i += 1 * break */ /*else*/ { (__pyx_v_num_buf[__pyx_v_i]) = __pyx_v_to_write; /* "clickhouse_driver/varint.pyx":46 * else: * num_buf[i] = to_write * i += 1 # <<<<<<<<<<<<<< * break * */ __pyx_v_i = (__pyx_v_i + 1); /* "clickhouse_driver/varint.pyx":47 * num_buf[i] = to_write * i += 1 * break # <<<<<<<<<<<<<< * * buf.write(PyBytes_FromStringAndSize(num_buf, i)) */ goto __pyx_L4_break; } __pyx_L5:; } __pyx_L4_break:; /* "clickhouse_driver/varint.pyx":49 * break * * buf.write(PyBytes_FromStringAndSize(num_buf, i)) # <<<<<<<<<<<<<< * * */ __pyx_t_3 = __pyx_v_buf; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = PyBytes_FromStringAndSize(((char *)__pyx_v_num_buf), __pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = 0; { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_4}; __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_write, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/varint.pyx":28 * * * def write_varint(unsigned long long number, buf): # <<<<<<<<<<<<<< * """ * Writes integer of variable length using LEB128. */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("clickhouse_driver.varint.write_varint", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "clickhouse_driver/varint.pyx":52 * * * def read_varint(f): # <<<<<<<<<<<<<< * """ * Reads integer of variable length using LEB128. */ /* Python wrapper */ static PyObject *__pyx_pw_17clickhouse_driver_6varint_5read_varint(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_17clickhouse_driver_6varint_4read_varint, "\n Reads integer of variable length using LEB128.\n "); static PyMethodDef __pyx_mdef_17clickhouse_driver_6varint_5read_varint = {"read_varint", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_17clickhouse_driver_6varint_5read_varint, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_17clickhouse_driver_6varint_4read_varint}; static PyObject *__pyx_pw_17clickhouse_driver_6varint_5read_varint(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_f = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_varint (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_SIZE __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_f,0}; const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0; if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 52, __pyx_L3_error) if (__pyx_kwds_len > 0) { switch (__pyx_nargs) { case 1: values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 52, __pyx_L3_error) CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } const Py_ssize_t kwd_pos_args = __pyx_nargs; if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "read_varint", 0) < (0)) __PYX_ERR(0, 52, __pyx_L3_error) for (Py_ssize_t i = __pyx_nargs; i < 1; i++) { if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("read_varint", 1, 1, 1, i); __PYX_ERR(0, 52, __pyx_L3_error) } } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0); if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 52, __pyx_L3_error) } __pyx_v_f = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("read_varint", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 52, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_AddTraceback("clickhouse_driver.varint.read_varint", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_17clickhouse_driver_6varint_4read_varint(__pyx_self, __pyx_v_f); /* function exit code */ for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { Py_XDECREF(values[__pyx_temp]); } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_17clickhouse_driver_6varint_4read_varint(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_f) { unsigned char __pyx_v_shift; unsigned PY_LONG_LONG __pyx_v_i; unsigned PY_LONG_LONG __pyx_v_result; PyObject *__pyx_v_read_one = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; size_t __pyx_t_4; unsigned PY_LONG_LONG __pyx_t_5; int __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_varint", 0); /* "clickhouse_driver/varint.pyx":56 * Reads integer of variable length using LEB128. * """ * cdef unsigned char shift = 0 # <<<<<<<<<<<<<< * cdef unsigned long long i, result = 0 * */ __pyx_v_shift = 0; /* "clickhouse_driver/varint.pyx":57 * """ * cdef unsigned char shift = 0 * cdef unsigned long long i, result = 0 # <<<<<<<<<<<<<< * * read_one = f.read_one */ __pyx_v_result = 0; /* "clickhouse_driver/varint.pyx":59 * cdef unsigned long long i, result = 0 * * read_one = f.read_one # <<<<<<<<<<<<<< * * while True: */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_mstate_global->__pyx_n_u_read_one); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_read_one = __pyx_t_1; __pyx_t_1 = 0; /* "clickhouse_driver/varint.pyx":61 * read_one = f.read_one * * while True: # <<<<<<<<<<<<<< * i = read_one() * result |= (i & 0x7f) << shift */ while (1) { /* "clickhouse_driver/varint.pyx":62 * * while True: * i = read_one() # <<<<<<<<<<<<<< * result |= (i & 0x7f) << shift * shift += 7 */ __pyx_t_2 = NULL; __Pyx_INCREF(__pyx_v_read_one); __pyx_t_3 = __pyx_v_read_one; __pyx_t_4 = 1; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); assert(__pyx_t_2); PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx__function); __Pyx_DECREF_SET(__pyx_t_3, __pyx__function); __pyx_t_4 = 0; } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_t_5 = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_5 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_i = __pyx_t_5; /* "clickhouse_driver/varint.pyx":63 * while True: * i = read_one() * result |= (i & 0x7f) << shift # <<<<<<<<<<<<<< * shift += 7 * if i < 0x80: */ __pyx_v_result = (__pyx_v_result | ((__pyx_v_i & 0x7f) << __pyx_v_shift)); /* "clickhouse_driver/varint.pyx":64 * i = read_one() * result |= (i & 0x7f) << shift * shift += 7 # <<<<<<<<<<<<<< * if i < 0x80: * break */ __pyx_v_shift = (__pyx_v_shift + 7); /* "clickhouse_driver/varint.pyx":65 * result |= (i & 0x7f) << shift * shift += 7 * if i < 0x80: # <<<<<<<<<<<<<< * break * */ __pyx_t_6 = (__pyx_v_i < 0x80); if (__pyx_t_6) { /* "clickhouse_driver/varint.pyx":66 * shift += 7 * if i < 0x80: * break # <<<<<<<<<<<<<< * * return result */ goto __pyx_L4_break; /* "clickhouse_driver/varint.pyx":65 * result |= (i & 0x7f) << shift * shift += 7 * if i < 0x80: # <<<<<<<<<<<<<< * break * */ } } __pyx_L4_break:; /* "clickhouse_driver/varint.pyx":68 * break * * return result # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyLong_From_unsigned_PY_LONG_LONG(__pyx_v_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "clickhouse_driver/varint.pyx":52 * * * def read_varint(f): # <<<<<<<<<<<<<< * """ * Reads integer of variable length using LEB128. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("clickhouse_driver.varint.read_varint", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_read_one); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* #### Code section: module_exttypes ### */ static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; /* #### Code section: initfunc_declarations ### */ static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate); /*proto*/ /* #### Code section: init_module ### */ static int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); /*--- Global init code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); /*--- Variable export code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); /*--- Function export code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); /*--- Type init code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); /*--- Type import code ---*/ __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_mstate->__pyx_ptype_7cpython_4type_type = __Pyx_ImportType_3_2_0(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 sizeof(PyTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyTypeObject), #elif CYTHON_COMPILING_IN_LIMITED_API 0, 0, #else sizeof(PyHeapTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyHeapTypeObject), #endif __Pyx_ImportType_CheckSize_Warn_3_2_0); if (!__pyx_mstate->__pyx_ptype_7cpython_4type_type) __PYX_ERR(2, 9, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_mstate->__pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType_3_2_0(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "bool", #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 sizeof(PyLongObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyLongObject), #elif CYTHON_COMPILING_IN_LIMITED_API 0, 0, #else sizeof(PyLongObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyLongObject), #endif __Pyx_ImportType_CheckSize_Warn_3_2_0); if (!__pyx_mstate->__pyx_ptype_7cpython_4bool_bool) __PYX_ERR(3, 8, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_mstate->__pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType_3_2_0(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "complex", #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 sizeof(PyComplexObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyComplexObject), #elif CYTHON_COMPILING_IN_LIMITED_API 0, 0, #else sizeof(PyComplexObject), __PYX_GET_STRUCT_ALIGNMENT_3_2_0(PyComplexObject), #endif __Pyx_ImportType_CheckSize_Warn_3_2_0); if (!__pyx_mstate->__pyx_ptype_7cpython_7complex_complex) __PYX_ERR(4, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); /*--- Variable import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); /*--- Function import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } #if CYTHON_PEP489_MULTI_PHASE_INIT static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ static int __pyx_pymod_exec_varint(PyObject* module); /*proto*/ static PyModuleDef_Slot __pyx_moduledef_slots[] = { {Py_mod_create, (void*)__pyx_pymod_create}, {Py_mod_exec, (void*)__pyx_pymod_exec_varint}, #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING {Py_mod_gil, Py_MOD_GIL_USED}, #endif #if PY_VERSION_HEX >= 0x030C0000 && CYTHON_USE_MODULE_STATE {Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED}, #endif {0, NULL} }; #endif #ifdef __cplusplus namespace { struct PyModuleDef __pyx_moduledef = #else static struct PyModuleDef __pyx_moduledef = #endif { PyModuleDef_HEAD_INIT, "varint", 0, /* m_doc */ #if CYTHON_USE_MODULE_STATE sizeof(__pyx_mstatetype), /* m_size */ #else (CYTHON_PEP489_MULTI_PHASE_INIT) ? 0 : -1, /* m_size */ #endif __pyx_methods /* m_methods */, #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_moduledef_slots, /* m_slots */ #else NULL, /* m_reload */ #endif #if CYTHON_USE_MODULE_STATE __pyx_m_traverse, /* m_traverse */ __pyx_m_clear, /* m_clear */ NULL /* m_free */ #else NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ #endif }; #ifdef __cplusplus } /* anonymous namespace */ #endif /* PyModInitFuncType */ #ifndef CYTHON_NO_PYINIT_EXPORT #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC #else #ifdef __cplusplus #define __Pyx_PyMODINIT_FUNC extern "C" PyObject * #else #define __Pyx_PyMODINIT_FUNC PyObject * #endif #endif __Pyx_PyMODINIT_FUNC PyInit_varint(void) CYTHON_SMALL_CODE; /*proto*/ __Pyx_PyMODINIT_FUNC PyInit_varint(void) #if CYTHON_PEP489_MULTI_PHASE_INIT { return PyModuleDef_Init(&__pyx_moduledef); } /* ModuleCreationPEP489 */ #if CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\ || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000)) static PY_INT64_T __Pyx_GetCurrentInterpreterId(void) { { PyObject *module = PyImport_ImportModule("_interpreters"); // 3.13+ I think if (!module) { PyErr_Clear(); // just try the 3.8-3.12 version module = PyImport_ImportModule("_xxsubinterpreters"); if (!module) goto bad; } PyObject *current = PyObject_CallMethod(module, "get_current", NULL); Py_DECREF(module); if (!current) goto bad; if (PyTuple_Check(current)) { PyObject *new_current = PySequence_GetItem(current, 0); Py_DECREF(current); current = new_current; if (!new_current) goto bad; } long long as_c_int = PyLong_AsLongLong(current); Py_DECREF(current); return as_c_int; } bad: PySys_WriteStderr("__Pyx_GetCurrentInterpreterId failed. Try setting the C define CYTHON_PEP489_MULTI_PHASE_INIT=0\n"); return -1; } #endif #if !CYTHON_USE_MODULE_STATE static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { static PY_INT64_T main_interpreter_id = -1; #if CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000 PY_INT64_T current_id = GraalPyInterpreterState_GetIDFromThreadState(PyThreadState_Get()); #elif CYTHON_COMPILING_IN_GRAAL PY_INT64_T current_id = PyInterpreterState_GetIDFromThreadState(PyThreadState_Get()); #elif CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\ || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000)) PY_INT64_T current_id = __Pyx_GetCurrentInterpreterId(); #elif CYTHON_COMPILING_IN_LIMITED_API PY_INT64_T current_id = PyInterpreterState_GetID(PyInterpreterState_Get()); #else PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); #endif if (unlikely(current_id == -1)) { return -1; } if (main_interpreter_id == -1) { main_interpreter_id = current_id; return 0; } else if (unlikely(main_interpreter_id != current_id)) { PyErr_SetString( PyExc_ImportError, "Interpreter change detected - this module can only be loaded into one interpreter per process."); return -1; } return 0; } #endif static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { PyObject *value = PyObject_GetAttrString(spec, from_name); int result = 0; if (likely(value)) { if (allow_none || value != Py_None) { result = PyDict_SetItemString(moddict, to_name, value); } Py_DECREF(value); } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Clear(); } else { result = -1; } return result; } static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def) { PyObject *module = NULL, *moddict, *modname; CYTHON_UNUSED_VAR(def); #if !CYTHON_USE_MODULE_STATE if (__Pyx_check_single_interpreter()) return NULL; #endif if (__pyx_m) return __Pyx_NewRef(__pyx_m); modname = PyObject_GetAttrString(spec, "name"); if (unlikely(!modname)) goto bad; module = PyModule_NewObject(modname); Py_DECREF(modname); if (unlikely(!module)) goto bad; moddict = PyModule_GetDict(module); if (unlikely(!moddict)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; return module; bad: Py_XDECREF(module); return NULL; } static CYTHON_SMALL_CODE int __pyx_pymod_exec_varint(PyObject *__pyx_pyinit_module) #endif { int stringtab_initialized = 0; #if CYTHON_USE_MODULE_STATE int pystate_addmodule_run = 0; #endif __pyx_mstatetype *__pyx_mstate = NULL; PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #if CYTHON_PEP489_MULTI_PHASE_INIT if (__pyx_m) { if (__pyx_m == __pyx_pyinit_module) return 0; PyErr_SetString(PyExc_RuntimeError, "Module 'varint' has already been imported. Re-initialisation is not supported."); return -1; } #else if (__pyx_m) return __Pyx_NewRef(__pyx_m); #endif /*--- Module creation code ---*/ #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_t_1 = __pyx_pyinit_module; Py_INCREF(__pyx_t_1); #else __pyx_t_1 = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) #endif #if CYTHON_USE_MODULE_STATE { int add_module_result = __Pyx_State_AddModule(__pyx_t_1, &__pyx_moduledef); __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to "varint" pseudovariable */ if (unlikely((add_module_result < 0))) __PYX_ERR(0, 1, __pyx_L1_error) pystate_addmodule_run = 1; } #else __pyx_m = __pyx_t_1; #endif #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING PyUnstable_Module_SetGIL(__pyx_m, Py_MOD_GIL_USED); #endif __pyx_mstate = __pyx_mstate_global; CYTHON_UNUSED_VAR(__pyx_t_1); __pyx_mstate->__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_mstate->__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_mstate->__pyx_d); __pyx_mstate->__pyx_b = __Pyx_PyImport_AddModuleRef(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_mstate->__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_mstate->__pyx_cython_runtime = __Pyx_PyImport_AddModuleRef("cython_runtime"); if (unlikely(!__pyx_mstate->__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_mstate->__pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error) /* ImportRefnannyAPI */ #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("PyInit_varint", 0); __Pyx_init_runtime_version(); if (__Pyx_check_binary_version(__PYX_LIMITED_VERSION_HEX, __Pyx_get_runtime_version(), CYTHON_COMPILING_IN_LIMITED_API) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_mstate->__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_mstate->__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_mstate->__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_mstate->__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Library function declarations ---*/ /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) stringtab_initialized = 1; if (__Pyx_InitGlobals() < (0)) __PYX_ERR(0, 1, __pyx_L1_error) if (__pyx_module_is_main_clickhouse_driver__varint) { if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_name, __pyx_mstate_global->__pyx_n_u_main) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) } { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) if (!PyDict_GetItemString(modules, "clickhouse_driver.varint")) { if (unlikely((PyDict_SetItemString(modules, "clickhouse_driver.varint", __pyx_m) < 0))) __PYX_ERR(0, 1, __pyx_L1_error) } } /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_CreateCodeObjects(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Global type/function init code ---*/ (void)__Pyx_modinit_global_init_code(__pyx_mstate); (void)__Pyx_modinit_variable_export_code(__pyx_mstate); (void)__Pyx_modinit_function_export_code(__pyx_mstate); (void)__Pyx_modinit_type_init_code(__pyx_mstate); if (unlikely((__Pyx_modinit_type_import_code(__pyx_mstate) < 0))) __PYX_ERR(0, 1, __pyx_L1_error) (void)__Pyx_modinit_variable_import_code(__pyx_mstate); (void)__Pyx_modinit_function_import_code(__pyx_mstate); /*--- Execution code ---*/ /* "clickhouse_driver/varint.pyx":4 * * * def make_varint(unsigned long long number): # <<<<<<<<<<<<<< * """ * Writes integer of variable length using LEB128. */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_6varint_1make_varint, 0, __pyx_mstate_global->__pyx_n_u_make_varint, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_varint, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_make_varint, __pyx_t_2) < (0)) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/varint.pyx":28 * * * def write_varint(unsigned long long number, buf): # <<<<<<<<<<<<<< * """ * Writes integer of variable length using LEB128. */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_6varint_3write_varint, 0, __pyx_mstate_global->__pyx_n_u_write_varint, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_varint, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_write_varint, __pyx_t_2) < (0)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/varint.pyx":52 * * * def read_varint(f): # <<<<<<<<<<<<<< * """ * Reads integer of variable length using LEB128. */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_17clickhouse_driver_6varint_5read_varint, 0, __pyx_mstate_global->__pyx_n_u_read_varint, NULL, __pyx_mstate_global->__pyx_n_u_clickhouse_driver_varint, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[2])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000 PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2); #endif if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_read_varint, __pyx_t_2) < (0)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "clickhouse_driver/varint.pyx":1 * from cpython cimport PyBytes_FromStringAndSize # <<<<<<<<<<<<<< * * */ __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_test, __pyx_t_2) < (0)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); if (__pyx_m) { if (__pyx_mstate->__pyx_d && stringtab_initialized) { __Pyx_AddTraceback("init clickhouse_driver.varint", __pyx_clineno, __pyx_lineno, __pyx_filename); } #if !CYTHON_USE_MODULE_STATE Py_CLEAR(__pyx_m); #else Py_DECREF(__pyx_m); if (pystate_addmodule_run) { PyObject *tp, *value, *tb; PyErr_Fetch(&tp, &value, &tb); PyState_RemoveModule(&__pyx_moduledef); PyErr_Restore(tp, value, tb); } #endif } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init clickhouse_driver.varint"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if CYTHON_PEP489_MULTI_PHASE_INIT return (__pyx_m != NULL) ? 0 : -1; #else return __pyx_m; #endif } /* #### Code section: pystring_table ### */ /* #### Code section: cached_builtins ### */ static int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate) { CYTHON_UNUSED_VAR(__pyx_mstate); /* Cached unbound methods */ __pyx_mstate->__pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type; __pyx_mstate->__pyx_umethod_PyDict_Type_items.method_name = &__pyx_mstate->__pyx_n_u_items; __pyx_mstate->__pyx_umethod_PyDict_Type_pop.type = (PyObject*)&PyDict_Type; __pyx_mstate->__pyx_umethod_PyDict_Type_pop.method_name = &__pyx_mstate->__pyx_n_u_pop; __pyx_mstate->__pyx_umethod_PyDict_Type_values.type = (PyObject*)&PyDict_Type; __pyx_mstate->__pyx_umethod_PyDict_Type_values.method_name = &__pyx_mstate->__pyx_n_u_values; return 0; } /* #### Code section: cached_constants ### */ static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) { __Pyx_RefNannyDeclarations CYTHON_UNUSED_VAR(__pyx_mstate); __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); __Pyx_RefNannyFinishContext(); return 0; } /* #### Code section: init_constants ### */ static int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate) { CYTHON_UNUSED_VAR(__pyx_mstate); { const struct { const unsigned int length: 7; } index[] = {{1},{28},{20},{18},{3},{24},{18},{1},{8},{1},{13},{5},{8},{11},{10},{8},{7},{6},{3},{12},{8},{11},{6},{12},{10},{5},{8},{8},{6},{5},{12},{82},{86},{66}}; #if (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (409 bytes) */ const char* const cstring = "BZh91AY&SY\212\372\220 \000\000;\177\373\347\357\250 U\301\260\200\246Ax`\277o\377\340@@@@@@@@@@@\000@\0000\001Y\265\254\303QLz\210\365\030\232h\003@\000\000\001\240\032\031\242\rL\246\321\r\"i\344\364\241\350L\214\020\000\032\032=\010z\236\211\350$\222b\223\365M\351OP\014CC@\000\032\000\001\2107\252H\264\270q\342\311\211eFY\"\334\306\242x\213_\324\205i\242E)\014?9F4{\302\265A\207\005H\250\233\026\032\225\027%\361\223\031I\211\223.,\333eN(\340N5\022\304&\266.v2\303\004T\352\247o\363R\2622!Z@!\005Q\251\013\364\202\241E\016\353\277\024\023\002c`\3070h^\"fj\377\216v\203\017\266\\\226 \252\241\264\240\310\010J\356\007\324\366$\300\336P5\361\210\007\343\236\020K\302\324\007pl\335ukp\221BU\234\204\003\036\246\311\316\031\2403\223\2413\236O\216\010\032\254'\336t\356?^\262\302\302Mz86\266\316Q\"\031\314\241b\257\207\004\340\270s\010\204P**1Js\276\206\254\234# \340am)%<\033\2278\202\033\002o\244R8dl\300J\242\300R\025\016\367F\251\361\320\006\2540?\222\274\303\016\246\002\035@.P\201\370{\010\366\230\007\305\207\321\02419\037\231\023VB\242*@\231\306\214*G5DHQ3\306Y\207\370\273\222)\302\204\204W\324\201\000"; PyObject *data = __Pyx_DecompressString(cstring, 409, 2); if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error) const char* const bytes = __Pyx_PyBytes_AsString(data); #if !CYTHON_ASSUME_SAFE_MACROS if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } #endif #elif (CYTHON_COMPRESS_STRINGS) != 0 /* compression: zlib (347 bytes) */ const char* const cstring = "x\332\255\2171O\302@\024\307!\001\255\241j\210\223\233!F\2350\2608\032\022M\234\014\340\242\323\313\321\276\206\013\355\225\336\365\252l\214\035;v\354\310\310\350\307`\274\221\217\300G\360\321\022\027Wo\370\377\377\357\335\345\367\336=:>wf\323P+\004W\362\004\345}\302$\027qw\276\370\002\030\222\014\027O\334\211\341\025\277\3421zL-\204\303\303\256\023\312P\307\\\240\232h\357\017\244[A\250/\020\270\200X2\007'\314\231y\000\236\026\016\000\007\256\340\027\302c\014\024@\300\350-\351\014\241\002P\021\272\332G\240#X@.t\0004\221l\202r\036\316\001\"\315\374\352N\"s!\024Xz\005\220\250\264O\030\205\361\001@\311\245oPWM\271GW1\252\275\206\360)i\215\204\371\032U\031K9p\226\365\235Uk\336\024\243\235]k\036\031\353\"{\310;\371`\037z\306j\245=cS\312\236\363\313\242S\014\214\335\316\332\333C\247]V\306>\3356Z\233\326u1(\336W\037k\366?\304\343e\222\2166g\267E\264\262\326'\337\355\212z\225G\246q\267\252o\033\347i\224\2215\215e\247/YI\357g\343,\311\337\212\272\261\366\024\032\325O\307iT-\230\366~\000\372\346\312\014"; PyObject *data = __Pyx_DecompressString(cstring, 347, 1); if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error) const char* const bytes = __Pyx_PyBytes_AsString(data); #if !CYTHON_ASSUME_SAFE_MACROS if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } #endif #else /* compression: none (530 bytes) */ const char* const bytes = "?clickhouse_driver/varint.pyx__Pyx_PyDict_NextRefasyncio.coroutinesbufclickhouse_driver.varintcline_in_tracebackf__func__i_is_coroutineitems__main__make_varint__module____name__num_bufnumberpop__qualname__read_oneread_varintresult__set_name__setdefaultshift__test__to_writevalueswritewrite_varint\200\001\360\010\000\005&\240Q\360\014\000\005\006\330\010\023\2207\230\"\230A\330\010\023\2201\330\010\013\2101\330\014\023\2201\220E\230\031\240\"\240A\330\014\021\220\021\340\014\023\2201\220E\230\021\330\014\021\220\021\330\014\r\340\004\013\320\013$\240A\240X\250Y\260a\200\001\360\010\000\005&\240Q\360\014\000\005\006\330\010\023\2207\230\"\230A\330\010\023\2201\330\010\013\2101\330\014\023\2201\220E\230\031\240\"\240A\330\014\021\220\021\340\014\023\2201\220E\230\021\330\014\021\220\021\330\014\r\340\004\007\200v\210Q\320\016'\240q\250\010\260\t\270\021\200\001\360\010\000\005 \230q\330\004(\250\001\340\004\017\210q\220\001\340\004\005\330\010\014\210H\220A\330\010\023\2202\220R\220v\230S\240\001\330\010\021\220\021\330\010\013\2102\210R\210q\330\014\r\340\004\013\2101"; PyObject *data = NULL; CYTHON_UNUSED_VAR(__Pyx_DecompressString); #endif PyObject **stringtab = __pyx_mstate->__pyx_string_tab; Py_ssize_t pos = 0; for (int i = 0; i < 31; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyUnicode_DecodeUTF8(bytes + pos, bytes_length, NULL); if (likely(string) && i >= 2) PyUnicode_InternInPlace(&string); if (unlikely(!string)) { Py_XDECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } stringtab[i] = string; pos += bytes_length; } for (int i = 31; i < 34; i++) { Py_ssize_t bytes_length = index[i].length; PyObject *string = PyBytes_FromStringAndSize(bytes + pos, bytes_length); stringtab[i] = string; pos += bytes_length; if (unlikely(!string)) { Py_XDECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) } } Py_XDECREF(data); for (Py_ssize_t i = 0; i < 34; i++) { if (unlikely(PyObject_Hash(stringtab[i]) == -1)) { __PYX_ERR(0, 1, __pyx_L1_error) } } #if CYTHON_IMMORTAL_CONSTANTS { PyObject **table = stringtab + 31; for (Py_ssize_t i=0; i<3; ++i) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL); #else Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT); #endif } } #endif } return 0; __pyx_L1_error:; return -1; } /* #### Code section: init_codeobjects ### */ typedef struct { unsigned int argcount : 2; unsigned int num_posonly_args : 1; unsigned int num_kwonly_args : 1; unsigned int nlocals : 3; unsigned int flags : 10; unsigned int first_line : 6; } __Pyx_PyCode_New_function_description; /* NewCodeObj.proto */ static PyObject* __Pyx_PyCode_New( const __Pyx_PyCode_New_function_description descr, PyObject * const *varnames, PyObject *filename, PyObject *funcname, PyObject *line_table, PyObject *tuple_dedup_map ); static int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate) { PyObject* tuple_dedup_map = PyDict_New(); if (unlikely(!tuple_dedup_map)) return -1; { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 4}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_number, __pyx_mstate->__pyx_n_u_to_write, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_num_buf}; __pyx_mstate_global->__pyx_codeobj_tab[0] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_varint_pyx, __pyx_mstate->__pyx_n_u_make_varint, __pyx_mstate->__pyx_kp_b_iso88591_Q_7_A_1_1_1E_A_1E_AXYa, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[0])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 5, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 28}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_number, __pyx_mstate->__pyx_n_u_buf, __pyx_mstate->__pyx_n_u_to_write, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_num_buf}; __pyx_mstate_global->__pyx_codeobj_tab[1] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_varint_pyx, __pyx_mstate->__pyx_n_u_write_varint, __pyx_mstate->__pyx_kp_b_iso88591_Q_7_A_1_1_1E_A_1E_vQ_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[1])) goto bad; } { const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 5, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 52}; PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_f, __pyx_mstate->__pyx_n_u_shift, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_read_one}; __pyx_mstate_global->__pyx_codeobj_tab[2] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_clickhouse_driver_varint_pyx, __pyx_mstate->__pyx_n_u_read_varint, __pyx_mstate->__pyx_kp_b_iso88591_q_q_HA_2RvS_2Rq_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[2])) goto bad; } Py_DECREF(tuple_dedup_map); return 0; bad: Py_DECREF(tuple_dedup_map); return -1; } /* #### Code section: init_globals ### */ static int __Pyx_InitGlobals(void) { /* PythonCompatibility.init */ if (likely(__Pyx_init_co_variables() == 0)); else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) /* CommonTypesMetaclass.init */ if (likely(__pyx_CommonTypesMetaclass_init(__pyx_m) == 0)); else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) /* CachedMethodType.init */ #if CYTHON_COMPILING_IN_LIMITED_API { PyObject *typesModule=NULL; typesModule = PyImport_ImportModule("types"); if (typesModule) { __pyx_mstate_global->__Pyx_CachedMethodType = PyObject_GetAttrString(typesModule, "MethodType"); Py_DECREF(typesModule); } } // error handling follows #endif if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) /* CythonFunctionShared.init */ if (likely(__pyx_CyFunction_init(__pyx_m) == 0)); else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } /* #### Code section: cleanup_globals ### */ /* #### Code section: cleanup_module ### */ /* #### Code section: main_method ### */ /* #### Code section: utility_code_pragmas ### */ #ifdef _MSC_VER #pragma warning( push ) /* Warning 4127: conditional expression is constant * Cython uses constant conditional expressions to allow in inline functions to be optimized at * compile-time, so this warning is not useful */ #pragma warning( disable : 4127 ) #endif /* #### Code section: utility_code_def ### */ /* --- Runtime support code --- */ /* Refnanny */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule(modname); if (!m) goto end; p = PyObject_GetAttrString(m, "RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif /* TupleAndListFromArray */ #if !CYTHON_COMPILING_IN_CPYTHON && CYTHON_METH_FASTCALL static CYTHON_INLINE PyObject * __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n) { PyObject *res; Py_ssize_t i; if (n <= 0) { return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple); } res = PyTuple_New(n); if (unlikely(res == NULL)) return NULL; for (i = 0; i < n; i++) { if (unlikely(__Pyx_PyTuple_SET_ITEM(res, i, src[i]) < (0))) { Py_DECREF(res); return NULL; } Py_INCREF(src[i]); } return res; } #elif CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE void __Pyx_copy_object_array(PyObject *const *CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) { PyObject *v; Py_ssize_t i; for (i = 0; i < length; i++) { v = dest[i] = src[i]; Py_INCREF(v); } } static CYTHON_INLINE PyObject * __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n) { PyObject *res; if (n <= 0) { return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple); } res = PyTuple_New(n); if (unlikely(res == NULL)) return NULL; __Pyx_copy_object_array(src, ((PyTupleObject*)res)->ob_item, n); return res; } static CYTHON_INLINE PyObject * __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n) { PyObject *res; if (n <= 0) { return PyList_New(0); } res = PyList_New(n); if (unlikely(res == NULL)) return NULL; __Pyx_copy_object_array(src, ((PyListObject*)res)->ob_item, n); return res; } #endif /* BytesEquals */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL ||\ !(CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS) return PyObject_RichCompareBool(s1, s2, equals); #else if (s1 == s2) { return (equals == Py_EQ); } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { const char *ps1, *ps2; Py_ssize_t length = PyBytes_GET_SIZE(s1); if (length != PyBytes_GET_SIZE(s2)) return (equals == Py_NE); ps1 = PyBytes_AS_STRING(s1); ps2 = PyBytes_AS_STRING(s2); if (ps1[0] != ps2[0]) { return (equals == Py_NE); } else if (length == 1) { return (equals == Py_EQ); } else { int result; #if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000) Py_hash_t hash1, hash2; hash1 = ((PyBytesObject*)s1)->ob_shash; hash2 = ((PyBytesObject*)s2)->ob_shash; if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { return (equals == Py_NE); } #endif result = memcmp(ps1, ps2, (size_t)length); return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { return (equals == Py_NE); } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { return (equals == Py_NE); } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } #endif } /* UnicodeEquals */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL return PyObject_RichCompareBool(s1, s2, equals); #else int s1_is_unicode, s2_is_unicode; if (s1 == s2) { goto return_eq; } s1_is_unicode = PyUnicode_CheckExact(s1); s2_is_unicode = PyUnicode_CheckExact(s2); if (s1_is_unicode & s2_is_unicode) { Py_ssize_t length, length2; int kind; void *data1, *data2; #if !CYTHON_COMPILING_IN_LIMITED_API if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0)) return -1; #endif length = __Pyx_PyUnicode_GET_LENGTH(s1); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(length < 0)) return -1; #endif length2 = __Pyx_PyUnicode_GET_LENGTH(s2); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(length2 < 0)) return -1; #endif if (length != length2) { goto return_ne; } #if CYTHON_USE_UNICODE_INTERNALS { Py_hash_t hash1, hash2; hash1 = ((PyASCIIObject*)s1)->hash; hash2 = ((PyASCIIObject*)s2)->hash; if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { goto return_ne; } } #endif kind = __Pyx_PyUnicode_KIND(s1); if (kind != __Pyx_PyUnicode_KIND(s2)) { goto return_ne; } data1 = __Pyx_PyUnicode_DATA(s1); data2 = __Pyx_PyUnicode_DATA(s2); if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) { goto return_ne; } else if (length == 1) { goto return_eq; } else { int result = memcmp(data1, data2, (size_t)(length * kind)); return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & s2_is_unicode) { goto return_ne; } else if ((s2 == Py_None) & s1_is_unicode) { goto return_ne; } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } return_eq: return (equals == Py_EQ); return_ne: return (equals == Py_NE); #endif } /* fastcall */ #if CYTHON_METH_FASTCALL static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s) { Py_ssize_t i, n = __Pyx_PyTuple_GET_SIZE(kwnames); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(n == -1)) return NULL; #endif for (i = 0; i < n; i++) { PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely(!namei)) return NULL; #endif if (s == namei) return kwvalues[i]; } for (i = 0; i < n; i++) { PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely(!namei)) return NULL; #endif int eq = __Pyx_PyUnicode_Equals(s, namei, Py_EQ); if (unlikely(eq != 0)) { if (unlikely(eq < 0)) return NULL; return kwvalues[i]; } } return NULL; } #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues) { Py_ssize_t i, nkwargs; PyObject *dict; #if !CYTHON_ASSUME_SAFE_SIZE nkwargs = PyTuple_Size(kwnames); if (unlikely(nkwargs < 0)) return NULL; #else nkwargs = PyTuple_GET_SIZE(kwnames); #endif dict = PyDict_New(); if (unlikely(!dict)) return NULL; for (i=0; itp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) return NULL; result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectCallMethO */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { PyObject *self, *result; PyCFunction cfunc; cfunc = __Pyx_CyOrPyCFunction_GET_FUNCTION(func); self = __Pyx_CyOrPyCFunction_GET_SELF(func); if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) return NULL; result = cfunc(self, arg); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectFastCall */ #if PY_VERSION_HEX < 0x03090000 || CYTHON_COMPILING_IN_LIMITED_API static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs) { PyObject *argstuple; PyObject *result = 0; size_t i; argstuple = PyTuple_New((Py_ssize_t)nargs); if (unlikely(!argstuple)) return NULL; for (i = 0; i < nargs; i++) { Py_INCREF(args[i]); if (__Pyx_PyTuple_SET_ITEM(argstuple, (Py_ssize_t)i, args[i]) != (0)) goto bad; } result = __Pyx_PyObject_Call(func, argstuple, kwargs); bad: Py_DECREF(argstuple); return result; } #endif #if CYTHON_VECTORCALL && !CYTHON_COMPILING_IN_LIMITED_API #if PY_VERSION_HEX < 0x03090000 #define __Pyx_PyVectorcall_Function(callable) _PyVectorcall_Function(callable) #elif CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE vectorcallfunc __Pyx_PyVectorcall_Function(PyObject *callable) { PyTypeObject *tp = Py_TYPE(callable); #if defined(__Pyx_CyFunction_USED) if (__Pyx_CyFunction_CheckExact(callable)) { return __Pyx_CyFunction_func_vectorcall(callable); } #endif if (!PyType_HasFeature(tp, Py_TPFLAGS_HAVE_VECTORCALL)) { return NULL; } assert(PyCallable_Check(callable)); Py_ssize_t offset = tp->tp_vectorcall_offset; assert(offset > 0); vectorcallfunc ptr; memcpy(&ptr, (char *) callable + offset, sizeof(ptr)); return ptr; } #else #define __Pyx_PyVectorcall_Function(callable) PyVectorcall_Function(callable) #endif #endif static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject *const *args, size_t _nargs, PyObject *kwargs) { Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs); #if CYTHON_COMPILING_IN_CPYTHON if (nargs == 0 && kwargs == NULL) { if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_NOARGS)) return __Pyx_PyObject_CallMethO(func, NULL); } else if (nargs == 1 && kwargs == NULL) { if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_O)) return __Pyx_PyObject_CallMethO(func, args[0]); } #endif if (kwargs == NULL) { #if CYTHON_VECTORCALL #if CYTHON_COMPILING_IN_LIMITED_API return PyObject_Vectorcall(func, args, _nargs, NULL); #else vectorcallfunc f = __Pyx_PyVectorcall_Function(func); if (f) { return f(func, args, _nargs, NULL); } #endif #endif } if (nargs == 0) { return __Pyx_PyObject_Call(func, __pyx_mstate_global->__pyx_empty_tuple, kwargs); } #if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API return PyObject_VectorcallDict(func, args, (size_t)nargs, kwargs); #else return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs); #endif } /* PyObjectCallOneArg */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *args[2] = {NULL, arg}; return __Pyx_PyObject_FastCall(func, args+1, 1 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } /* PyObjectGetAttrStr */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); return PyObject_GetAttr(obj, attr_name); } #endif /* UnpackUnboundCMethod */ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000 static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *args, PyObject *kwargs) { PyObject *result; PyObject *selfless_args = PyTuple_GetSlice(args, 1, PyTuple_Size(args)); if (unlikely(!selfless_args)) return NULL; result = PyObject_Call(method, selfless_args, kwargs); Py_DECREF(selfless_args); return result; } #elif CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03090000 static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { return _PyObject_Vectorcall (method, args ? args+1 : NULL, nargs ? nargs-1 : 0, kwnames); } #else static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { return #if PY_VERSION_HEX < 0x03090000 _PyObject_Vectorcall #else PyObject_Vectorcall #endif (method, args ? args+1 : NULL, nargs ? (size_t) nargs-1 : 0, kwnames); } #endif static PyMethodDef __Pyx_UnboundCMethod_Def = { "CythonUnboundCMethod", __PYX_REINTERPRET_FUNCION(PyCFunction, __Pyx_SelflessCall), #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000 METH_VARARGS | METH_KEYWORDS, #else METH_FASTCALL | METH_KEYWORDS, #endif NULL }; static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) { PyObject *method, *result=NULL; method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name); if (unlikely(!method)) return -1; result = method; #if CYTHON_COMPILING_IN_CPYTHON if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type))) { PyMethodDescrObject *descr = (PyMethodDescrObject*) method; target->func = descr->d_method->ml_meth; target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS); } else #endif #if CYTHON_COMPILING_IN_PYPY #else if (PyCFunction_Check(method)) #endif { PyObject *self; int self_found; #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY self = PyObject_GetAttrString(method, "__self__"); if (!self) { PyErr_Clear(); } #else self = PyCFunction_GET_SELF(method); #endif self_found = (self && self != Py_None); #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY Py_XDECREF(self); #endif if (self_found) { PyObject *unbound_method = PyCFunction_New(&__Pyx_UnboundCMethod_Def, method); if (unlikely(!unbound_method)) return -1; Py_DECREF(method); result = unbound_method; } } #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING if (unlikely(target->method)) { Py_DECREF(result); } else #endif target->method = result; return 0; } /* CallUnboundCMethod0 */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) { int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc); if (likely(was_initialized == 2 && cfunc->func)) { if (likely(cfunc->flag == METH_NOARGS)) return __Pyx_CallCFunction(cfunc, self, NULL); if (likely(cfunc->flag == METH_FASTCALL)) return __Pyx_CallCFunctionFast(cfunc, self, NULL, 0); if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS)) return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, NULL, 0, NULL); if (likely(cfunc->flag == (METH_VARARGS | METH_KEYWORDS))) return __Pyx_CallCFunctionWithKeywords(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple, NULL); if (cfunc->flag == METH_VARARGS) return __Pyx_CallCFunction(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple); return __Pyx__CallUnboundCMethod0(cfunc, self); } #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING else if (unlikely(was_initialized == 1)) { __Pyx_CachedCFunction tmp_cfunc = { #ifndef __cplusplus 0 #endif }; tmp_cfunc.type = cfunc->type; tmp_cfunc.method_name = cfunc->method_name; return __Pyx__CallUnboundCMethod0(&tmp_cfunc, self); } #endif PyObject *result = __Pyx__CallUnboundCMethod0(cfunc, self); __Pyx_CachedCFunction_SetFinishedInitializing(cfunc); return result; } #endif static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) { PyObject *result; if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; result = __Pyx_PyObject_CallOneArg(cfunc->method, self); return result; } /* py_dict_items */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) { return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_items, d); } /* py_dict_values */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d) { return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_values, d); } /* OwnedDictNext */ #if CYTHON_AVOID_BORROWED_REFS static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue) { PyObject *next = NULL; if (!*ppos) { if (pvalue) { PyObject *dictview = pkey ? __Pyx_PyDict_Items(p) : __Pyx_PyDict_Values(p); if (unlikely(!dictview)) goto bad; *ppos = PyObject_GetIter(dictview); Py_DECREF(dictview); } else { *ppos = PyObject_GetIter(p); } if (unlikely(!*ppos)) goto bad; } next = PyIter_Next(*ppos); if (!next) { if (PyErr_Occurred()) goto bad; return 0; } if (pkey && pvalue) { *pkey = __Pyx_PySequence_ITEM(next, 0); if (unlikely(*pkey)) goto bad; *pvalue = __Pyx_PySequence_ITEM(next, 1); if (unlikely(*pvalue)) goto bad; Py_DECREF(next); } else if (pkey) { *pkey = next; } else { assert(pvalue); *pvalue = next; } return 1; bad: Py_XDECREF(next); #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000 PyErr_FormatUnraisable("Exception ignored in __Pyx_PyDict_NextRef"); #else PyErr_WriteUnraisable(__pyx_mstate_global->__pyx_n_u_Pyx_PyDict_NextRef); #endif if (pkey) *pkey = NULL; if (pvalue) *pvalue = NULL; return 0; } #else // !CYTHON_AVOID_BORROWED_REFS static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue) { int result = PyDict_Next(p, ppos, pkey, pvalue); if (likely(result == 1)) { if (pkey) Py_INCREF(*pkey); if (pvalue) Py_INCREF(*pvalue); } return result; } #endif /* RaiseDoubleKeywords */ static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { PyErr_Format(PyExc_TypeError, "%s() got multiple values for keyword argument '%U'", func_name, kw_name); } /* CallUnboundCMethod2 */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) { int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc); if (likely(was_initialized == 2 && cfunc->func)) { PyObject *args[2] = {arg1, arg2}; if (cfunc->flag == METH_FASTCALL) { return __Pyx_CallCFunctionFast(cfunc, self, args, 2); } if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS)) return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, 2, NULL); } #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING else if (unlikely(was_initialized == 1)) { __Pyx_CachedCFunction tmp_cfunc = { #ifndef __cplusplus 0 #endif }; tmp_cfunc.type = cfunc->type; tmp_cfunc.method_name = cfunc->method_name; return __Pyx__CallUnboundCMethod2(&tmp_cfunc, self, arg1, arg2); } #endif PyObject *result = __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2); __Pyx_CachedCFunction_SetFinishedInitializing(cfunc); return result; } #endif static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){ if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; #if CYTHON_COMPILING_IN_CPYTHON if (cfunc->func && (cfunc->flag & METH_VARARGS)) { PyObject *result = NULL; PyObject *args = PyTuple_New(2); if (unlikely(!args)) return NULL; Py_INCREF(arg1); PyTuple_SET_ITEM(args, 0, arg1); Py_INCREF(arg2); PyTuple_SET_ITEM(args, 1, arg2); if (cfunc->flag & METH_KEYWORDS) result = __Pyx_CallCFunctionWithKeywords(cfunc, self, args, NULL); else result = __Pyx_CallCFunction(cfunc, self, args); Py_DECREF(args); return result; } #endif { PyObject *args[4] = {NULL, self, arg1, arg2}; return __Pyx_PyObject_FastCall(cfunc->method, args+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } } /* ParseKeywordsImpl */ static int __Pyx_ValidateDuplicatePosArgs( PyObject *kwds, PyObject ** const argnames[], PyObject ** const *first_kw_arg, const char* function_name) { PyObject ** const *name = argnames; while (name != first_kw_arg) { PyObject *key = **name; int found = PyDict_Contains(kwds, key); if (unlikely(found)) { if (found == 1) __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; } name++; } return 0; bad: return -1; } #if CYTHON_USE_UNICODE_INTERNALS static CYTHON_INLINE int __Pyx_UnicodeKeywordsEqual(PyObject *s1, PyObject *s2) { int kind; Py_ssize_t len = PyUnicode_GET_LENGTH(s1); if (len != PyUnicode_GET_LENGTH(s2)) return 0; kind = PyUnicode_KIND(s1); if (kind != PyUnicode_KIND(s2)) return 0; const void *data1 = PyUnicode_DATA(s1); const void *data2 = PyUnicode_DATA(s2); return (memcmp(data1, data2, (size_t) len * (size_t) kind) == 0); } #endif static int __Pyx_MatchKeywordArg_str( PyObject *key, PyObject ** const argnames[], PyObject ** const *first_kw_arg, size_t *index_found, const char *function_name) { PyObject ** const *name; #if CYTHON_USE_UNICODE_INTERNALS Py_hash_t key_hash = ((PyASCIIObject*)key)->hash; if (unlikely(key_hash == -1)) { key_hash = PyObject_Hash(key); if (unlikely(key_hash == -1)) goto bad; } #endif name = first_kw_arg; while (*name) { PyObject *name_str = **name; #if CYTHON_USE_UNICODE_INTERNALS if (key_hash == ((PyASCIIObject*)name_str)->hash && __Pyx_UnicodeKeywordsEqual(name_str, key)) { *index_found = (size_t) (name - argnames); return 1; } #else #if CYTHON_ASSUME_SAFE_SIZE if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key)) #endif { int cmp = PyUnicode_Compare(name_str, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { *index_found = (size_t) (name - argnames); return 1; } } #endif name++; } name = argnames; while (name != first_kw_arg) { PyObject *name_str = **name; #if CYTHON_USE_UNICODE_INTERNALS if (unlikely(key_hash == ((PyASCIIObject*)name_str)->hash)) { if (__Pyx_UnicodeKeywordsEqual(name_str, key)) goto arg_passed_twice; } #else #if CYTHON_ASSUME_SAFE_SIZE if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key)) #endif { if (unlikely(name_str == key)) goto arg_passed_twice; int cmp = PyUnicode_Compare(name_str, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) goto arg_passed_twice; } #endif name++; } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; bad: return -1; } static int __Pyx_MatchKeywordArg_nostr( PyObject *key, PyObject ** const argnames[], PyObject ** const *first_kw_arg, size_t *index_found, const char *function_name) { PyObject ** const *name; if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type; name = first_kw_arg; while (*name) { int cmp = PyObject_RichCompareBool(**name, key, Py_EQ); if (cmp == 1) { *index_found = (size_t) (name - argnames); return 1; } if (unlikely(cmp == -1)) goto bad; name++; } name = argnames; while (name != first_kw_arg) { int cmp = PyObject_RichCompareBool(**name, key, Py_EQ); if (unlikely(cmp != 0)) { if (cmp == 1) goto arg_passed_twice; else goto bad; } name++; } return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); goto bad; bad: return -1; } static CYTHON_INLINE int __Pyx_MatchKeywordArg( PyObject *key, PyObject ** const argnames[], PyObject ** const *first_kw_arg, size_t *index_found, const char *function_name) { return likely(PyUnicode_CheckExact(key)) ? __Pyx_MatchKeywordArg_str(key, argnames, first_kw_arg, index_found, function_name) : __Pyx_MatchKeywordArg_nostr(key, argnames, first_kw_arg, index_found, function_name); } static void __Pyx_RejectUnknownKeyword( PyObject *kwds, PyObject ** const argnames[], PyObject ** const *first_kw_arg, const char *function_name) { #if CYTHON_AVOID_BORROWED_REFS PyObject *pos = NULL; #else Py_ssize_t pos = 0; #endif PyObject *key = NULL; __Pyx_BEGIN_CRITICAL_SECTION(kwds); while ( #if CYTHON_AVOID_BORROWED_REFS __Pyx_PyDict_NextRef(kwds, &pos, &key, NULL) #else PyDict_Next(kwds, &pos, &key, NULL) #endif ) { PyObject** const *name = first_kw_arg; while (*name && (**name != key)) name++; if (!*name) { size_t index_found = 0; int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name); if (cmp != 1) { if (cmp == 0) { PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%U'", function_name, key); } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(key); #endif break; } } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(key); #endif } __Pyx_END_CRITICAL_SECTION(); #if CYTHON_AVOID_BORROWED_REFS Py_XDECREF(pos); #endif assert(PyErr_Occurred()); } static int __Pyx_ParseKeywordDict( PyObject *kwds, PyObject ** const argnames[], PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs) { PyObject** const *name; PyObject** const *first_kw_arg = argnames + num_pos_args; Py_ssize_t extracted = 0; #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments) if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1; #endif name = first_kw_arg; while (*name && num_kwargs > extracted) { PyObject * key = **name; PyObject *value; int found = 0; #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 found = PyDict_GetItemRef(kwds, key, &value); #else value = PyDict_GetItemWithError(kwds, key); if (value) { Py_INCREF(value); found = 1; } else { if (unlikely(PyErr_Occurred())) goto bad; } #endif if (found) { if (unlikely(found < 0)) goto bad; values[name-argnames] = value; extracted++; } name++; } if (num_kwargs > extracted) { if (ignore_unknown_kwargs) { if (unlikely(__Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name) == -1)) goto bad; } else { __Pyx_RejectUnknownKeyword(kwds, argnames, first_kw_arg, function_name); goto bad; } } return 0; bad: return -1; } static int __Pyx_ParseKeywordDictToDict( PyObject *kwds, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject** const *name; PyObject** const *first_kw_arg = argnames + num_pos_args; Py_ssize_t len; #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments) if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1; #endif if (PyDict_Update(kwds2, kwds) < 0) goto bad; name = first_kw_arg; while (*name) { PyObject *key = **name; PyObject *value; #if !CYTHON_COMPILING_IN_LIMITED_API && (PY_VERSION_HEX >= 0x030d00A2 || defined(PyDict_Pop)) int found = PyDict_Pop(kwds2, key, &value); if (found) { if (unlikely(found < 0)) goto bad; values[name-argnames] = value; } #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000 int found = PyDict_GetItemRef(kwds2, key, &value); if (found) { if (unlikely(found < 0)) goto bad; values[name-argnames] = value; if (unlikely(PyDict_DelItem(kwds2, key) < 0)) goto bad; } #else #if CYTHON_COMPILING_IN_CPYTHON value = _PyDict_Pop(kwds2, key, kwds2); #else value = __Pyx_CallUnboundCMethod2(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_pop, kwds2, key, kwds2); #endif if (value == kwds2) { Py_DECREF(value); } else { if (unlikely(!value)) goto bad; values[name-argnames] = value; } #endif name++; } len = PyDict_Size(kwds2); if (len > 0) { return __Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name); } else if (unlikely(len == -1)) { goto bad; } return 0; bad: return -1; } static int __Pyx_ParseKeywordsTuple( PyObject *kwds, PyObject * const *kwvalues, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs) { PyObject *key = NULL; PyObject** const * name; PyObject** const *first_kw_arg = argnames + num_pos_args; for (Py_ssize_t pos = 0; pos < num_kwargs; pos++) { #if CYTHON_AVOID_BORROWED_REFS key = __Pyx_PySequence_ITEM(kwds, pos); #else key = __Pyx_PyTuple_GET_ITEM(kwds, pos); #endif #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely(!key)) goto bad; #endif name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { PyObject *value = kwvalues[pos]; values[name-argnames] = __Pyx_NewRef(value); } else { size_t index_found = 0; int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name); if (cmp == 1) { PyObject *value = kwvalues[pos]; values[index_found] = __Pyx_NewRef(value); } else { if (unlikely(cmp == -1)) goto bad; if (kwds2) { PyObject *value = kwvalues[pos]; if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else if (!ignore_unknown_kwargs) { goto invalid_keyword; } } } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(key); key = NULL; #endif } return 0; invalid_keyword: PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%U'", function_name, key); goto bad; bad: #if CYTHON_AVOID_BORROWED_REFS Py_XDECREF(key); #endif return -1; } /* ParseKeywords */ static int __Pyx_ParseKeywords( PyObject *kwds, PyObject * const *kwvalues, PyObject ** const argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, Py_ssize_t num_kwargs, const char* function_name, int ignore_unknown_kwargs) { if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds))) return __Pyx_ParseKeywordsTuple(kwds, kwvalues, argnames, kwds2, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs); else if (kwds2) return __Pyx_ParseKeywordDictToDict(kwds, argnames, kwds2, values, num_pos_args, function_name); else return __Pyx_ParseKeywordDict(kwds, argnames, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs); } /* RaiseArgTupleInvalid */ static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found) { Py_ssize_t num_expected; const char *more_or_less; if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; } else { num_expected = num_max; more_or_less = "at most"; } if (exact) { more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } /* PyObjectFastCallMethod */ #if !CYTHON_VECTORCALL || PY_VERSION_HEX < 0x03090000 static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const *args, size_t nargsf) { PyObject *result; PyObject *attr = PyObject_GetAttr(args[0], name); if (unlikely(!attr)) return NULL; result = __Pyx_PyObject_FastCall(attr, args+1, nargsf - 1); Py_DECREF(attr); return result; } #endif /* TypeImport */ #ifndef __PYX_HAVE_RT_ImportType_3_2_0 #define __PYX_HAVE_RT_ImportType_3_2_0 static PyTypeObject *__Pyx_ImportType_3_2_0(PyObject *module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_2_0 check_size) { PyObject *result = 0; Py_ssize_t basicsize; Py_ssize_t itemsize; #if defined(Py_LIMITED_API) || (defined(CYTHON_COMPILING_IN_LIMITED_API) && CYTHON_COMPILING_IN_LIMITED_API) PyObject *py_basicsize; PyObject *py_itemsize; #endif result = PyObject_GetAttrString(module, class_name); if (!result) goto bad; if (!PyType_Check(result)) { PyErr_Format(PyExc_TypeError, "%.200s.%.200s is not a type object", module_name, class_name); goto bad; } #if !( defined(Py_LIMITED_API) || (defined(CYTHON_COMPILING_IN_LIMITED_API) && CYTHON_COMPILING_IN_LIMITED_API) ) basicsize = ((PyTypeObject *)result)->tp_basicsize; itemsize = ((PyTypeObject *)result)->tp_itemsize; #else if (size == 0) { return (PyTypeObject *)result; } py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); if (!py_basicsize) goto bad; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = 0; if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; py_itemsize = PyObject_GetAttrString(result, "__itemsize__"); if (!py_itemsize) goto bad; itemsize = PyLong_AsSsize_t(py_itemsize); Py_DECREF(py_itemsize); py_itemsize = 0; if (itemsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; #endif if (itemsize) { if (size % alignment) { alignment = size % alignment; } if (itemsize < (Py_ssize_t)alignment) itemsize = (Py_ssize_t)alignment; } if ((size_t)(basicsize + itemsize) < size) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", module_name, class_name, size, basicsize+itemsize); goto bad; } if (check_size == __Pyx_ImportType_CheckSize_Error_3_2_0 && ((size_t)basicsize > size || (size_t)(basicsize + itemsize) < size)) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd-%zd from PyObject", module_name, class_name, size, basicsize, basicsize+itemsize); goto bad; } else if (check_size == __Pyx_ImportType_CheckSize_Warn_3_2_0 && (size_t)basicsize > size) { if (PyErr_WarnFormat(NULL, 0, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", module_name, class_name, size, basicsize) < 0) { goto bad; } } return (PyTypeObject *)result; bad: Py_XDECREF(result); return NULL; } #endif /* dict_setdefault */ static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value) { PyObject* value; #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX >= 0x030C0000 PyObject *args[] = {d, key, default_value}; value = PyObject_VectorcallMethod(__pyx_mstate_global->__pyx_n_u_setdefault, args, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); #elif CYTHON_COMPILING_IN_LIMITED_API value = PyObject_CallMethodObjArgs(d, __pyx_mstate_global->__pyx_n_u_setdefault, key, default_value, NULL); #elif PY_VERSION_HEX >= 0x030d0000 PyDict_SetDefaultRef(d, key, default_value, &value); #else value = PyDict_SetDefault(d, key, default_value); if (unlikely(!value)) return NULL; Py_INCREF(value); #endif return value; } /* LimitedApiGetTypeDict */ #if CYTHON_COMPILING_IN_LIMITED_API static Py_ssize_t __Pyx_GetTypeDictOffset(void) { PyObject *tp_dictoffset_o; Py_ssize_t tp_dictoffset; tp_dictoffset_o = PyObject_GetAttrString((PyObject*)(&PyType_Type), "__dictoffset__"); if (unlikely(!tp_dictoffset_o)) return -1; tp_dictoffset = PyLong_AsSsize_t(tp_dictoffset_o); Py_DECREF(tp_dictoffset_o); if (unlikely(tp_dictoffset == 0)) { PyErr_SetString( PyExc_TypeError, "'type' doesn't have a dictoffset"); return -1; } else if (unlikely(tp_dictoffset < 0)) { PyErr_SetString( PyExc_TypeError, "'type' has an unexpected negative dictoffset. " "Please report this as Cython bug"); return -1; } return tp_dictoffset; } static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp) { static Py_ssize_t tp_dictoffset = 0; if (unlikely(tp_dictoffset == 0)) { tp_dictoffset = __Pyx_GetTypeDictOffset(); if (unlikely(tp_dictoffset == -1 && PyErr_Occurred())) { tp_dictoffset = 0; // try again next time? return NULL; } } return *(PyObject**)((char*)tp + tp_dictoffset); } #endif /* SetItemOnTypeDict */ static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v) { int result; PyObject *tp_dict; #if CYTHON_COMPILING_IN_LIMITED_API tp_dict = __Pyx_GetTypeDict(tp); if (unlikely(!tp_dict)) return -1; #else tp_dict = tp->tp_dict; #endif result = PyDict_SetItem(tp_dict, k, v); if (likely(!result)) { PyType_Modified(tp); if (unlikely(PyObject_HasAttr(v, __pyx_mstate_global->__pyx_n_u_set_name))) { PyObject *setNameResult = PyObject_CallMethodObjArgs(v, __pyx_mstate_global->__pyx_n_u_set_name, (PyObject *) tp, k, NULL); if (!setNameResult) return -1; Py_DECREF(setNameResult); } } return result; } /* FixUpExtensionType */ static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type) { #if __PYX_LIMITED_VERSION_HEX > 0x030900B1 CYTHON_UNUSED_VAR(spec); CYTHON_UNUSED_VAR(type); CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict); #else const PyType_Slot *slot = spec->slots; int changed = 0; #if !CYTHON_COMPILING_IN_LIMITED_API while (slot && slot->slot && slot->slot != Py_tp_members) slot++; if (slot && slot->slot == Py_tp_members) { #if !CYTHON_COMPILING_IN_CPYTHON const #endif // !CYTHON_COMPILING_IN_CPYTHON) PyMemberDef *memb = (PyMemberDef*) slot->pfunc; while (memb && memb->name) { if (memb->name[0] == '_' && memb->name[1] == '_') { if (strcmp(memb->name, "__weaklistoffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); type->tp_weaklistoffset = memb->offset; changed = 1; } else if (strcmp(memb->name, "__dictoffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); type->tp_dictoffset = memb->offset; changed = 1; } #if CYTHON_METH_FASTCALL else if (strcmp(memb->name, "__vectorcalloffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); type->tp_vectorcall_offset = memb->offset; changed = 1; } #endif // CYTHON_METH_FASTCALL #if !CYTHON_COMPILING_IN_PYPY else if (strcmp(memb->name, "__module__") == 0) { PyObject *descr; assert(memb->type == T_OBJECT); assert(memb->flags == 0 || memb->flags == READONLY); descr = PyDescr_NewMember(type, memb); if (unlikely(!descr)) return -1; int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr); Py_DECREF(descr); if (unlikely(set_item_result < 0)) { return -1; } changed = 1; } #endif // !CYTHON_COMPILING_IN_PYPY } memb++; } } #endif // !CYTHON_COMPILING_IN_LIMITED_API #if !CYTHON_COMPILING_IN_PYPY slot = spec->slots; while (slot && slot->slot && slot->slot != Py_tp_getset) slot++; if (slot && slot->slot == Py_tp_getset) { PyGetSetDef *getset = (PyGetSetDef*) slot->pfunc; while (getset && getset->name) { if (getset->name[0] == '_' && getset->name[1] == '_' && strcmp(getset->name, "__module__") == 0) { PyObject *descr = PyDescr_NewGetSet(type, getset); if (unlikely(!descr)) return -1; #if CYTHON_COMPILING_IN_LIMITED_API PyObject *pyname = PyUnicode_FromString(getset->name); if (unlikely(!pyname)) { Py_DECREF(descr); return -1; } int set_item_result = __Pyx_SetItemOnTypeDict(type, pyname, descr); Py_DECREF(pyname); #else CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict); int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr); #endif Py_DECREF(descr); if (unlikely(set_item_result < 0)) { return -1; } changed = 1; } ++getset; } } #else CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict); #endif // !CYTHON_COMPILING_IN_PYPY if (changed) PyType_Modified(type); #endif // PY_VERSION_HEX > 0x030900B1 return 0; } /* AddModuleRef */ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING static PyObject *__Pyx_PyImport_AddModuleObjectRef(PyObject *name) { PyObject *module_dict = PyImport_GetModuleDict(); PyObject *m; if (PyMapping_GetOptionalItem(module_dict, name, &m) < 0) { return NULL; } if (m != NULL && PyModule_Check(m)) { return m; } Py_XDECREF(m); m = PyModule_NewObject(name); if (m == NULL) return NULL; if (PyDict_CheckExact(module_dict)) { PyObject *new_m; (void)PyDict_SetDefaultRef(module_dict, name, m, &new_m); Py_DECREF(m); return new_m; } else { if (PyObject_SetItem(module_dict, name, m) != 0) { Py_DECREF(m); return NULL; } return m; } } static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) { PyObject *py_name = PyUnicode_FromString(name); if (!py_name) return NULL; PyObject *module = __Pyx_PyImport_AddModuleObjectRef(py_name); Py_DECREF(py_name); return module; } #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000 #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name) #else static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) { PyObject *module = PyImport_AddModule(name); Py_XINCREF(module); return module; } #endif /* FetchSharedCythonModule */ static PyObject *__Pyx_FetchSharedCythonABIModule(void) { return __Pyx_PyImport_AddModuleRef(__PYX_ABI_MODULE_NAME); } /* FetchCommonType */ #if __PYX_LIMITED_VERSION_HEX < 0x030C0000 static PyObject* __Pyx_PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) { PyObject *result = __Pyx_PyType_FromModuleAndSpec(module, spec, bases); if (result && metaclass) { PyObject *old_tp = (PyObject*)Py_TYPE(result); Py_INCREF((PyObject*)metaclass); #if __PYX_LIMITED_VERSION_HEX >= 0x03090000 Py_SET_TYPE(result, metaclass); #else result->ob_type = metaclass; #endif Py_DECREF(old_tp); } return result; } #else #define __Pyx_PyType_FromMetaclass(me, mo, s, b) PyType_FromMetaclass(me, mo, s, b) #endif static int __Pyx_VerifyCachedType(PyObject *cached_type, const char *name, Py_ssize_t expected_basicsize) { Py_ssize_t basicsize; if (!PyType_Check(cached_type)) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s is not a type object", name); return -1; } if (expected_basicsize == 0) { return 0; // size is inherited, nothing useful to check } #if CYTHON_COMPILING_IN_LIMITED_API PyObject *py_basicsize; py_basicsize = PyObject_GetAttrString(cached_type, "__basicsize__"); if (unlikely(!py_basicsize)) return -1; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = NULL; if (unlikely(basicsize == (Py_ssize_t)-1) && PyErr_Occurred()) return -1; #else basicsize = ((PyTypeObject*) cached_type)->tp_basicsize; #endif if (basicsize != expected_basicsize) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s has the wrong size, try recompiling", name); return -1; } return 0; } static PyTypeObject *__Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) { PyObject *abi_module = NULL, *cached_type = NULL, *abi_module_dict, *new_cached_type, *py_object_name; int get_item_ref_result; const char* object_name = strrchr(spec->name, '.'); object_name = object_name ? object_name+1 : spec->name; py_object_name = PyUnicode_FromString(object_name); if (!py_object_name) return NULL; abi_module = __Pyx_FetchSharedCythonABIModule(); if (!abi_module) goto done; abi_module_dict = PyModule_GetDict(abi_module); if (!abi_module_dict) goto done; get_item_ref_result = __Pyx_PyDict_GetItemRef(abi_module_dict, py_object_name, &cached_type); if (get_item_ref_result == 1) { if (__Pyx_VerifyCachedType( cached_type, object_name, spec->basicsize) < 0) { goto bad; } goto done; } else if (unlikely(get_item_ref_result == -1)) { goto bad; } cached_type = __Pyx_PyType_FromMetaclass( metaclass, CYTHON_USE_MODULE_STATE ? module : abi_module, spec, bases); if (unlikely(!cached_type)) goto bad; if (unlikely(__Pyx_fix_up_extension_type_from_spec(spec, (PyTypeObject *) cached_type) < 0)) goto bad; new_cached_type = __Pyx_PyDict_SetDefault(abi_module_dict, py_object_name, cached_type); if (unlikely(new_cached_type != cached_type)) { if (unlikely(!new_cached_type)) goto bad; Py_DECREF(cached_type); cached_type = new_cached_type; if (__Pyx_VerifyCachedType( cached_type, object_name, spec->basicsize) < 0) { goto bad; } goto done; } else { Py_DECREF(new_cached_type); } done: Py_XDECREF(abi_module); Py_DECREF(py_object_name); assert(cached_type == NULL || PyType_Check(cached_type)); return (PyTypeObject *) cached_type; bad: Py_XDECREF(cached_type); cached_type = NULL; goto done; } /* CommonTypesMetaclass */ static PyObject* __pyx_CommonTypesMetaclass_get_module(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED void* context) { return PyUnicode_FromString(__PYX_ABI_MODULE_NAME); } #if __PYX_LIMITED_VERSION_HEX < 0x030A0000 static PyObject* __pyx_CommonTypesMetaclass_call(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *args, CYTHON_UNUSED PyObject *kwds) { PyErr_SetString(PyExc_TypeError, "Cannot instantiate Cython internal types"); return NULL; } static int __pyx_CommonTypesMetaclass_setattr(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *attr, CYTHON_UNUSED PyObject *value) { PyErr_SetString(PyExc_TypeError, "Cython internal types are immutable"); return -1; } #endif static PyGetSetDef __pyx_CommonTypesMetaclass_getset[] = { {"__module__", __pyx_CommonTypesMetaclass_get_module, NULL, NULL, NULL}, {0, 0, 0, 0, 0} }; static PyType_Slot __pyx_CommonTypesMetaclass_slots[] = { {Py_tp_getset, (void *)__pyx_CommonTypesMetaclass_getset}, #if __PYX_LIMITED_VERSION_HEX < 0x030A0000 {Py_tp_call, (void*)__pyx_CommonTypesMetaclass_call}, {Py_tp_new, (void*)__pyx_CommonTypesMetaclass_call}, {Py_tp_setattro, (void*)__pyx_CommonTypesMetaclass_setattr}, #endif {0, 0} }; static PyType_Spec __pyx_CommonTypesMetaclass_spec = { __PYX_TYPE_MODULE_PREFIX "_common_types_metatype", 0, 0, Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_DEFAULT, __pyx_CommonTypesMetaclass_slots }; static int __pyx_CommonTypesMetaclass_init(PyObject *module) { __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module); PyObject *bases = PyTuple_Pack(1, &PyType_Type); if (unlikely(!bases)) { return -1; } mstate->__pyx_CommonTypesMetaclassType = __Pyx_FetchCommonTypeFromSpec(NULL, module, &__pyx_CommonTypesMetaclass_spec, bases); Py_DECREF(bases); if (unlikely(mstate->__pyx_CommonTypesMetaclassType == NULL)) { return -1; } return 0; } /* CallTypeTraverse */ #if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000) #else static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg) { #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x03090000 if (__Pyx_get_runtime_version() < 0x03090000) return 0; #endif if (!always_call) { PyTypeObject *base = __Pyx_PyObject_GetSlot(o, tp_base, PyTypeObject*); unsigned long flags = PyType_GetFlags(base); if (flags & Py_TPFLAGS_HEAPTYPE) { return 0; } } Py_VISIT((PyObject*)Py_TYPE(o)); return 0; } #endif /* PyMethodNew */ #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) { PyObject *result; CYTHON_UNUSED_VAR(typ); if (!self) return __Pyx_NewRef(func); #if __PYX_LIMITED_VERSION_HEX >= 0x030C0000 { PyObject *args[] = {func, self}; result = PyObject_Vectorcall(__pyx_mstate_global->__Pyx_CachedMethodType, args, 2, NULL); } #else result = PyObject_CallFunctionObjArgs(__pyx_mstate_global->__Pyx_CachedMethodType, func, self, NULL); #endif return result; } #else static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) { CYTHON_UNUSED_VAR(typ); if (!self) return __Pyx_NewRef(func); return PyMethod_New(func, self); } #endif /* PyVectorcallFastCallDict */ #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL static PyObject *__Pyx_PyVectorcall_FastCallDict_kw(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw) { PyObject *res = NULL; PyObject *kwnames; PyObject **newargs; PyObject **kwvalues; Py_ssize_t i; #if CYTHON_AVOID_BORROWED_REFS PyObject *pos; #else Py_ssize_t pos; #endif size_t j; PyObject *key, *value; unsigned long keys_are_strings; #if !CYTHON_ASSUME_SAFE_SIZE Py_ssize_t nkw = PyDict_Size(kw); if (unlikely(nkw == -1)) return NULL; #else Py_ssize_t nkw = PyDict_GET_SIZE(kw); #endif newargs = (PyObject **)PyMem_Malloc((nargs + (size_t)nkw) * sizeof(args[0])); if (unlikely(newargs == NULL)) { PyErr_NoMemory(); return NULL; } for (j = 0; j < nargs; j++) newargs[j] = args[j]; kwnames = PyTuple_New(nkw); if (unlikely(kwnames == NULL)) { PyMem_Free(newargs); return NULL; } kwvalues = newargs + nargs; pos = 0; i = 0; keys_are_strings = Py_TPFLAGS_UNICODE_SUBCLASS; while (__Pyx_PyDict_NextRef(kw, &pos, &key, &value)) { keys_are_strings &= #if CYTHON_COMPILING_IN_LIMITED_API PyType_GetFlags(Py_TYPE(key)); #else Py_TYPE(key)->tp_flags; #endif #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely(PyTuple_SetItem(kwnames, i, key) < 0)) goto cleanup; #else PyTuple_SET_ITEM(kwnames, i, key); #endif kwvalues[i] = value; i++; } if (unlikely(!keys_are_strings)) { PyErr_SetString(PyExc_TypeError, "keywords must be strings"); goto cleanup; } res = vc(func, newargs, nargs, kwnames); cleanup: #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(pos); #endif Py_DECREF(kwnames); for (i = 0; i < nkw; i++) Py_DECREF(kwvalues[i]); PyMem_Free(newargs); return res; } static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw) { Py_ssize_t kw_size = likely(kw == NULL) ? 0 : #if !CYTHON_ASSUME_SAFE_SIZE PyDict_Size(kw); #else PyDict_GET_SIZE(kw); #endif if (kw_size == 0) { return vc(func, args, nargs, NULL); } #if !CYTHON_ASSUME_SAFE_SIZE else if (unlikely(kw_size == -1)) { return NULL; } #endif return __Pyx_PyVectorcall_FastCallDict_kw(func, vc, args, nargs, kw); } #endif /* CythonFunctionShared */ #if CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE int __Pyx__IsSameCyOrCFunctionNoMethod(PyObject *func, void (*cfunc)(void)) { if (__Pyx_CyFunction_Check(func)) { return PyCFunction_GetFunction(((__pyx_CyFunctionObject*)func)->func) == (PyCFunction) cfunc; } else if (PyCFunction_Check(func)) { return PyCFunction_GetFunction(func) == (PyCFunction) cfunc; } return 0; } static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) { if ((PyObject*)Py_TYPE(func) == __pyx_mstate_global->__Pyx_CachedMethodType) { int result; PyObject *newFunc = PyObject_GetAttr(func, __pyx_mstate_global->__pyx_n_u_func); if (unlikely(!newFunc)) { PyErr_Clear(); // It's only an optimization, so don't throw an error return 0; } result = __Pyx__IsSameCyOrCFunctionNoMethod(newFunc, cfunc); Py_DECREF(newFunc); return result; } return __Pyx__IsSameCyOrCFunctionNoMethod(func, cfunc); } #else static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) { if (PyMethod_Check(func)) { func = PyMethod_GET_FUNCTION(func); } return __Pyx_CyOrPyCFunction_Check(func) && __Pyx_CyOrPyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; } #endif static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) { #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API __Pyx_Py_XDECREF_SET( __Pyx_CyFunction_GetClassObj(f), ((classobj) ? __Pyx_NewRef(classobj) : NULL)); #else __Pyx_Py_XDECREF_SET( ((PyCMethodObject *) (f))->mm_class, (PyTypeObject*)((classobj) ? __Pyx_NewRef(classobj) : NULL)); #endif } static PyObject * __Pyx_CyFunction_get_doc_locked(__pyx_CyFunctionObject *op) { if (unlikely(op->func_doc == NULL)) { #if CYTHON_COMPILING_IN_LIMITED_API op->func_doc = PyObject_GetAttrString(op->func, "__doc__"); if (unlikely(!op->func_doc)) return NULL; #else if (((PyCFunctionObject*)op)->m_ml->ml_doc) { op->func_doc = PyUnicode_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc); if (unlikely(op->func_doc == NULL)) return NULL; } else { Py_INCREF(Py_None); return Py_None; } #endif } Py_INCREF(op->func_doc); return op->func_doc; } static PyObject * __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, void *closure) { PyObject *result; CYTHON_UNUSED_VAR(closure); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_doc_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); if (value == NULL) { value = Py_None; } Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->func_doc, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_name_locked(__pyx_CyFunctionObject *op) { if (unlikely(op->func_name == NULL)) { #if CYTHON_COMPILING_IN_LIMITED_API op->func_name = PyObject_GetAttrString(op->func, "__name__"); #else op->func_name = PyUnicode_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name); #endif if (unlikely(op->func_name == NULL)) return NULL; } Py_INCREF(op->func_name); return op->func_name; } static PyObject * __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, void *context) { PyObject *result = NULL; CYTHON_UNUSED_VAR(context); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_name_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(value == NULL || !PyUnicode_Check(value))) { PyErr_SetString(PyExc_TypeError, "__name__ must be set to a string object"); return -1; } Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->func_name, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); PyObject *result; __Pyx_BEGIN_CRITICAL_SECTION(op); Py_INCREF(op->func_qualname); result = op->func_qualname; __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(value == NULL || !PyUnicode_Check(value))) { PyErr_SetString(PyExc_TypeError, "__qualname__ must be set to a string object"); return -1; } Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->func_qualname, value); __Pyx_END_CRITICAL_SECTION(); return 0; } #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 static PyObject * __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(op->func_dict == NULL)) { op->func_dict = PyDict_New(); if (unlikely(op->func_dict == NULL)) return NULL; } Py_INCREF(op->func_dict); return op->func_dict; } #endif static PyObject * __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); Py_INCREF(op->func_globals); return op->func_globals; } static PyObject * __Pyx_CyFunction_get_closure(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(op); CYTHON_UNUSED_VAR(context); Py_INCREF(Py_None); return Py_None; } static PyObject * __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, void *context) { PyObject* result = (op->func_code) ? op->func_code : Py_None; CYTHON_UNUSED_VAR(context); Py_INCREF(result); return result; } static int __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { int result = 0; PyObject *res = op->defaults_getter((PyObject *) op); if (unlikely(!res)) return -1; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS op->defaults_tuple = PyTuple_GET_ITEM(res, 0); Py_INCREF(op->defaults_tuple); op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); Py_INCREF(op->defaults_kwdict); #else op->defaults_tuple = __Pyx_PySequence_ITEM(res, 0); if (unlikely(!op->defaults_tuple)) result = -1; else { op->defaults_kwdict = __Pyx_PySequence_ITEM(res, 1); if (unlikely(!op->defaults_kwdict)) result = -1; } #endif Py_DECREF(res); return result; } static int __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value) { value = Py_None; } else if (unlikely(value != Py_None && !PyTuple_Check(value))) { PyErr_SetString(PyExc_TypeError, "__defaults__ must be set to a tuple object"); return -1; } PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__defaults__ will not " "currently affect the values used in function calls", 1); Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->defaults_tuple, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_defaults_locked(__pyx_CyFunctionObject *op) { PyObject* result = op->defaults_tuple; if (unlikely(!result)) { if (op->defaults_getter) { if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL; result = op->defaults_tuple; } else { result = Py_None; } } Py_INCREF(result); return result; } static PyObject * __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, void *context) { PyObject* result = NULL; CYTHON_UNUSED_VAR(context); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_defaults_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value) { value = Py_None; } else if (unlikely(value != Py_None && !PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "__kwdefaults__ must be set to a dict object"); return -1; } PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__kwdefaults__ will not " "currently affect the values used in function calls", 1); Py_INCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->defaults_kwdict, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_kwdefaults_locked(__pyx_CyFunctionObject *op) { PyObject* result = op->defaults_kwdict; if (unlikely(!result)) { if (op->defaults_getter) { if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL; result = op->defaults_kwdict; } else { result = Py_None; } } Py_INCREF(result); return result; } static PyObject * __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, void *context) { PyObject* result; CYTHON_UNUSED_VAR(context); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_kwdefaults_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static int __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value || value == Py_None) { value = NULL; } else if (unlikely(!PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "__annotations__ must be set to a dict object"); return -1; } Py_XINCREF(value); __Pyx_BEGIN_CRITICAL_SECTION(op); __Pyx_Py_XDECREF_SET(op->func_annotations, value); __Pyx_END_CRITICAL_SECTION(); return 0; } static PyObject * __Pyx_CyFunction_get_annotations_locked(__pyx_CyFunctionObject *op) { PyObject* result = op->func_annotations; if (unlikely(!result)) { result = PyDict_New(); if (unlikely(!result)) return NULL; op->func_annotations = result; } Py_INCREF(result); return result; } static PyObject * __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, void *context) { PyObject *result; CYTHON_UNUSED_VAR(context); __Pyx_BEGIN_CRITICAL_SECTION(op); result = __Pyx_CyFunction_get_annotations_locked(op); __Pyx_END_CRITICAL_SECTION(); return result; } static PyObject * __Pyx_CyFunction_get_is_coroutine_value(__pyx_CyFunctionObject *op) { int is_coroutine = op->flags & __Pyx_CYFUNCTION_COROUTINE; if (is_coroutine) { PyObject *is_coroutine_value, *module, *fromlist, *marker = __pyx_mstate_global->__pyx_n_u_is_coroutine; fromlist = PyList_New(1); if (unlikely(!fromlist)) return NULL; Py_INCREF(marker); #if CYTHON_ASSUME_SAFE_MACROS PyList_SET_ITEM(fromlist, 0, marker); #else if (unlikely(PyList_SetItem(fromlist, 0, marker) < 0)) { Py_DECREF(marker); Py_DECREF(fromlist); return NULL; } #endif module = PyImport_ImportModuleLevelObject(__pyx_mstate_global->__pyx_n_u_asyncio_coroutines, NULL, NULL, fromlist, 0); Py_DECREF(fromlist); if (unlikely(!module)) goto ignore; is_coroutine_value = __Pyx_PyObject_GetAttrStr(module, marker); Py_DECREF(module); if (likely(is_coroutine_value)) { return is_coroutine_value; } ignore: PyErr_Clear(); } return __Pyx_PyBool_FromLong(is_coroutine); } static PyObject * __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) { PyObject *result; CYTHON_UNUSED_VAR(context); if (op->func_is_coroutine) { return __Pyx_NewRef(op->func_is_coroutine); } result = __Pyx_CyFunction_get_is_coroutine_value(op); if (unlikely(!result)) return NULL; __Pyx_BEGIN_CRITICAL_SECTION(op); if (op->func_is_coroutine) { Py_DECREF(result); result = __Pyx_NewRef(op->func_is_coroutine); } else { op->func_is_coroutine = __Pyx_NewRef(result); } __Pyx_END_CRITICAL_SECTION(); return result; } static void __Pyx_CyFunction_raise_argument_count_error(__pyx_CyFunctionObject *func, const char* message, Py_ssize_t size) { #if CYTHON_COMPILING_IN_LIMITED_API PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL); if (!py_name) return; PyErr_Format(PyExc_TypeError, "%.200S() %s (%" CYTHON_FORMAT_SSIZE_T "d given)", py_name, message, size); Py_DECREF(py_name); #else const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name; PyErr_Format(PyExc_TypeError, "%.200s() %s (%" CYTHON_FORMAT_SSIZE_T "d given)", name, message, size); #endif } static void __Pyx_CyFunction_raise_type_error(__pyx_CyFunctionObject *func, const char* message) { #if CYTHON_COMPILING_IN_LIMITED_API PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL); if (!py_name) return; PyErr_Format(PyExc_TypeError, "%.200S() %s", py_name, message); Py_DECREF(py_name); #else const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name; PyErr_Format(PyExc_TypeError, "%.200s() %s", name, message); #endif } #if CYTHON_COMPILING_IN_LIMITED_API static PyObject * __Pyx_CyFunction_get_module(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); return PyObject_GetAttrString(op->func, "__module__"); } static int __Pyx_CyFunction_set_module(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); return PyObject_SetAttrString(op->func, "__module__", value); } #endif static PyGetSetDef __pyx_CyFunction_getsets[] = { {"func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {"__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {"func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {"__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {"__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 {"func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0}, {"__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0}, #else {"func_dict", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0}, {"__dict__", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0}, #endif {"func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {"__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {"func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {"__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {"func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {"__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {"func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {"__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {"__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, {"__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, {"_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0}, #if CYTHON_COMPILING_IN_LIMITED_API {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0}, #endif {0, 0, 0, 0, 0} }; static PyMemberDef __pyx_CyFunction_members[] = { #if !CYTHON_COMPILING_IN_LIMITED_API {"__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0}, #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API {"__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict), READONLY, 0}, #endif #if CYTHON_METH_FASTCALL #if CYTHON_COMPILING_IN_LIMITED_API {"__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall), READONLY, 0}, #else {"__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0}, #endif #if CYTHON_COMPILING_IN_LIMITED_API {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist), READONLY, 0}, #else {"__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0}, #endif #endif {0, 0, 0, 0, 0} }; static PyObject * __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, PyObject *args) { PyObject *result = NULL; CYTHON_UNUSED_VAR(args); __Pyx_BEGIN_CRITICAL_SECTION(m); Py_INCREF(m->func_qualname); result = m->func_qualname; __Pyx_END_CRITICAL_SECTION(); return result; } static PyMethodDef __pyx_CyFunction_methods[] = { {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, {0, 0, 0, 0} }; #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) #else #define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist) #endif static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { #if !CYTHON_COMPILING_IN_LIMITED_API PyCFunctionObject *cf = (PyCFunctionObject*) op; #endif if (unlikely(op == NULL)) return NULL; #if CYTHON_COMPILING_IN_LIMITED_API op->func = PyCFunction_NewEx(ml, (PyObject*)op, module); if (unlikely(!op->func)) return NULL; #endif op->flags = flags; __Pyx_CyFunction_weakreflist(op) = NULL; #if !CYTHON_COMPILING_IN_LIMITED_API cf->m_ml = ml; cf->m_self = (PyObject *) op; #endif Py_XINCREF(closure); op->func_closure = closure; #if !CYTHON_COMPILING_IN_LIMITED_API Py_XINCREF(module); cf->m_module = module; #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API op->func_dict = NULL; #endif op->func_name = NULL; Py_INCREF(qualname); op->func_qualname = qualname; op->func_doc = NULL; #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API op->func_classobj = NULL; #else ((PyCMethodObject*)op)->mm_class = NULL; #endif op->func_globals = globals; Py_INCREF(op->func_globals); Py_XINCREF(code); op->func_code = code; op->defaults = NULL; op->defaults_tuple = NULL; op->defaults_kwdict = NULL; op->defaults_getter = NULL; op->func_annotations = NULL; op->func_is_coroutine = NULL; #if CYTHON_METH_FASTCALL switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) { case METH_NOARGS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_NOARGS; break; case METH_O: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_O; break; case METH_METHOD | METH_FASTCALL | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD; break; case METH_FASTCALL | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS; break; case METH_VARARGS | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = NULL; break; default: PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction"); Py_DECREF(op); return NULL; } #endif return (PyObject *) op; } static int __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) { Py_CLEAR(m->func_closure); #if CYTHON_COMPILING_IN_LIMITED_API Py_CLEAR(m->func); #else Py_CLEAR(((PyCFunctionObject*)m)->m_module); #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API Py_CLEAR(m->func_dict); #elif PY_VERSION_HEX < 0x030d0000 _PyObject_ClearManagedDict((PyObject*)m); #else PyObject_ClearManagedDict((PyObject*)m); #endif Py_CLEAR(m->func_name); Py_CLEAR(m->func_qualname); Py_CLEAR(m->func_doc); Py_CLEAR(m->func_globals); Py_CLEAR(m->func_code); #if !CYTHON_COMPILING_IN_LIMITED_API #if PY_VERSION_HEX < 0x030900B1 Py_CLEAR(__Pyx_CyFunction_GetClassObj(m)); #else { PyObject *cls = (PyObject*) ((PyCMethodObject *) (m))->mm_class; ((PyCMethodObject *) (m))->mm_class = NULL; Py_XDECREF(cls); } #endif #endif Py_CLEAR(m->defaults_tuple); Py_CLEAR(m->defaults_kwdict); Py_CLEAR(m->func_annotations); Py_CLEAR(m->func_is_coroutine); Py_CLEAR(m->defaults); return 0; } static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m) { if (__Pyx_CyFunction_weakreflist(m) != NULL) PyObject_ClearWeakRefs((PyObject *) m); __Pyx_CyFunction_clear(m); __Pyx_PyHeapTypeObject_GC_Del(m); } static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) { PyObject_GC_UnTrack(m); __Pyx__CyFunction_dealloc(m); } static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) { { int e = __Pyx_call_type_traverse((PyObject*)m, 1, visit, arg); if (e) return e; } Py_VISIT(m->func_closure); #if CYTHON_COMPILING_IN_LIMITED_API Py_VISIT(m->func); #else Py_VISIT(((PyCFunctionObject*)m)->m_module); #endif #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API Py_VISIT(m->func_dict); #else { int e = #if PY_VERSION_HEX < 0x030d0000 _PyObject_VisitManagedDict #else PyObject_VisitManagedDict #endif ((PyObject*)m, visit, arg); if (e != 0) return e; } #endif __Pyx_VISIT_CONST(m->func_name); __Pyx_VISIT_CONST(m->func_qualname); Py_VISIT(m->func_doc); Py_VISIT(m->func_globals); __Pyx_VISIT_CONST(m->func_code); #if !CYTHON_COMPILING_IN_LIMITED_API Py_VISIT(__Pyx_CyFunction_GetClassObj(m)); #endif Py_VISIT(m->defaults_tuple); Py_VISIT(m->defaults_kwdict); Py_VISIT(m->func_is_coroutine); Py_VISIT(m->defaults); return 0; } static PyObject* __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) { PyObject *repr; __Pyx_BEGIN_CRITICAL_SECTION(op); repr = PyUnicode_FromFormat("", op->func_qualname, (void *)op); __Pyx_END_CRITICAL_SECTION(); return repr; } static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { #if CYTHON_COMPILING_IN_LIMITED_API PyObject *f = ((__pyx_CyFunctionObject*)func)->func; PyCFunction meth; int flags; meth = PyCFunction_GetFunction(f); if (unlikely(!meth)) return NULL; flags = PyCFunction_GetFlags(f); if (unlikely(flags < 0)) return NULL; #else PyCFunctionObject* f = (PyCFunctionObject*)func; PyCFunction meth = f->m_ml->ml_meth; int flags = f->m_ml->ml_flags; #endif Py_ssize_t size; switch (flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { case METH_VARARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) return (*meth)(self, arg); break; case METH_VARARGS | METH_KEYWORDS: return (*(PyCFunctionWithKeywords)(void(*)(void))meth)(self, arg, kw); case METH_NOARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { #if CYTHON_ASSUME_SAFE_SIZE size = PyTuple_GET_SIZE(arg); #else size = PyTuple_Size(arg); if (unlikely(size < 0)) return NULL; #endif if (likely(size == 0)) return (*meth)(self, NULL); __Pyx_CyFunction_raise_argument_count_error( (__pyx_CyFunctionObject*)func, "takes no arguments", size); return NULL; } break; case METH_O: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { #if CYTHON_ASSUME_SAFE_SIZE size = PyTuple_GET_SIZE(arg); #else size = PyTuple_Size(arg); if (unlikely(size < 0)) return NULL; #endif if (likely(size == 1)) { PyObject *result, *arg0; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS arg0 = PyTuple_GET_ITEM(arg, 0); #else arg0 = __Pyx_PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; #endif result = (*meth)(self, arg0); #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) Py_DECREF(arg0); #endif return result; } __Pyx_CyFunction_raise_argument_count_error( (__pyx_CyFunctionObject*)func, "takes exactly one argument", size); return NULL; } break; default: PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction"); return NULL; } __Pyx_CyFunction_raise_type_error( (__pyx_CyFunctionObject*)func, "takes no keyword arguments"); return NULL; } static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *self, *result; #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)func)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)func)->m_self; #endif result = __Pyx_CyFunction_CallMethod(func, self, arg, kw); return result; } static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { PyObject *result; __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc); if (vc) { #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw); #else (void) &__Pyx_PyVectorcall_FastCallDict; return PyVectorcall_Call(func, args, kw); #endif } #endif if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { Py_ssize_t argc; PyObject *new_args; PyObject *self; #if CYTHON_ASSUME_SAFE_SIZE argc = PyTuple_GET_SIZE(args); #else argc = PyTuple_Size(args); if (unlikely(argc < 0)) return NULL; #endif new_args = PyTuple_GetSlice(args, 1, argc); if (unlikely(!new_args)) return NULL; self = PyTuple_GetItem(args, 0); if (unlikely(!self)) { Py_DECREF(new_args); PyErr_Format(PyExc_TypeError, "unbound method %.200S() needs an argument", cyfunc->func_qualname); return NULL; } result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); Py_DECREF(new_args); } else { result = __Pyx_CyFunction_Call(func, args, kw); } return result; } #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(__pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames) { int ret = 0; if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { if (unlikely(nargs < 1)) { __Pyx_CyFunction_raise_type_error( cyfunc, "needs an argument"); return -1; } ret = 1; } if (unlikely(kwnames) && unlikely(__Pyx_PyTuple_GET_SIZE(kwnames))) { __Pyx_CyFunction_raise_type_error( cyfunc, "takes no keyword arguments"); return -1; } return ret; } static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); PyObject *self; #if CYTHON_COMPILING_IN_LIMITED_API PyCFunction meth = PyCFunction_GetFunction(cyfunc->func); if (unlikely(!meth)) return NULL; #else PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth; #endif switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)cyfunc)->m_self; #endif break; default: return NULL; } if (unlikely(nargs != 0)) { __Pyx_CyFunction_raise_argument_count_error( cyfunc, "takes no arguments", nargs); return NULL; } return meth(self, NULL); } static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); PyObject *self; #if CYTHON_COMPILING_IN_LIMITED_API PyCFunction meth = PyCFunction_GetFunction(cyfunc->func); if (unlikely(!meth)) return NULL; #else PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth; #endif switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)cyfunc)->m_self; #endif break; default: return NULL; } if (unlikely(nargs != 1)) { __Pyx_CyFunction_raise_argument_count_error( cyfunc, "takes exactly one argument", nargs); return NULL; } return meth(self, args[0]); } static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); PyObject *self; #if CYTHON_COMPILING_IN_LIMITED_API PyCFunction meth = PyCFunction_GetFunction(cyfunc->func); if (unlikely(!meth)) return NULL; #else PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth; #endif switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)cyfunc)->m_self; #endif break; default: return NULL; } return ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))meth)(self, args, nargs, kwnames); } static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; PyTypeObject *cls = (PyTypeObject *) __Pyx_CyFunction_GetClassObj(cyfunc); Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); PyObject *self; #if CYTHON_COMPILING_IN_LIMITED_API PyCFunction meth = PyCFunction_GetFunction(cyfunc->func); if (unlikely(!meth)) return NULL; #else PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth; #endif switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)cyfunc)->m_self; #endif break; default: return NULL; } #if PY_VERSION_HEX < 0x030e00A6 size_t nargs_value = (size_t) nargs; #else Py_ssize_t nargs_value = nargs; #endif return ((__Pyx_PyCMethod)(void(*)(void))meth)(self, cls, args, nargs_value, kwnames); } #endif static PyType_Slot __pyx_CyFunctionType_slots[] = { {Py_tp_dealloc, (void *)__Pyx_CyFunction_dealloc}, {Py_tp_repr, (void *)__Pyx_CyFunction_repr}, {Py_tp_call, (void *)__Pyx_CyFunction_CallAsMethod}, {Py_tp_traverse, (void *)__Pyx_CyFunction_traverse}, {Py_tp_clear, (void *)__Pyx_CyFunction_clear}, {Py_tp_methods, (void *)__pyx_CyFunction_methods}, {Py_tp_members, (void *)__pyx_CyFunction_members}, {Py_tp_getset, (void *)__pyx_CyFunction_getsets}, {Py_tp_descr_get, (void *)__Pyx_PyMethod_New}, {0, 0}, }; static PyType_Spec __pyx_CyFunctionType_spec = { __PYX_TYPE_MODULE_PREFIX "cython_function_or_method", sizeof(__pyx_CyFunctionObject), 0, #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR Py_TPFLAGS_METHOD_DESCRIPTOR | #endif #if CYTHON_METH_FASTCALL #if defined(Py_TPFLAGS_HAVE_VECTORCALL) Py_TPFLAGS_HAVE_VECTORCALL | #elif defined(_Py_TPFLAGS_HAVE_VECTORCALL) _Py_TPFLAGS_HAVE_VECTORCALL | #endif #endif // CYTHON_METH_FASTCALL #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API Py_TPFLAGS_MANAGED_DICT | #endif Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, __pyx_CyFunctionType_slots }; static int __pyx_CyFunction_init(PyObject *module) { __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module); mstate->__pyx_CyFunctionType = __Pyx_FetchCommonTypeFromSpec( mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_CyFunctionType_spec, NULL); if (unlikely(mstate->__pyx_CyFunctionType == NULL)) { return -1; } return 0; } static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults = PyObject_CallObject((PyObject*)defaults_type, NULL); // _PyObject_New(defaults_type); if (unlikely(!m->defaults)) return NULL; return m->defaults; } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_tuple = tuple; Py_INCREF(tuple); } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_kwdict = dict; Py_INCREF(dict); } static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->func_annotations = dict; Py_INCREF(dict); } /* CythonFunction */ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { PyObject *op = __Pyx_CyFunction_Init( PyObject_GC_New(__pyx_CyFunctionObject, __pyx_mstate_global->__pyx_CyFunctionType), ml, flags, qualname, closure, module, globals, code ); if (likely(op)) { PyObject_GC_Track(op); } return op; } /* PyDictVersioning */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { PyObject *dict = Py_TYPE(obj)->tp_dict; return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; } static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { PyObject **dictptr = NULL; Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; if (offset) { #if CYTHON_COMPILING_IN_CPYTHON dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); #else dictptr = _PyObject_GetDictPtr(obj); #endif } return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; } static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { PyObject *dict = Py_TYPE(obj)->tp_dict; if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) return 0; return obj_dict_version == __Pyx_get_object_dict_version(obj); } #endif /* PyErrExceptionMatches */ #if CYTHON_FAST_THREAD_STATE static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(tuple); for (i=0; i= 0x030C00A6 PyObject *current_exception = tstate->current_exception; if (unlikely(!current_exception)) return 0; exc_type = (PyObject*) Py_TYPE(current_exception); if (exc_type == err) return 1; #else exc_type = tstate->curexc_type; if (exc_type == err) return 1; if (unlikely(!exc_type)) return 0; #endif #if CYTHON_AVOID_BORROWED_REFS Py_INCREF(exc_type); #endif if (unlikely(PyTuple_Check(err))) { result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); } else { result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err); } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(exc_type); #endif return result; } #endif /* PyErrFetchRestore */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyObject *tmp_value; assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value))); if (value) { #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb)) #endif PyException_SetTraceback(value, tb); } tmp_value = tstate->current_exception; tstate->current_exception = value; Py_XDECREF(tmp_value); Py_XDECREF(type); Py_XDECREF(tb); #else PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #endif } static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyObject* exc_value; exc_value = tstate->current_exception; tstate->current_exception = 0; *value = exc_value; *type = NULL; *tb = NULL; if (exc_value) { *type = (PyObject*) Py_TYPE(exc_value); Py_INCREF(*type); #if CYTHON_COMPILING_IN_CPYTHON *tb = ((PyBaseExceptionObject*) exc_value)->traceback; Py_XINCREF(*tb); #else *tb = PyException_GetTraceback(exc_value); #endif } #else *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #endif } #endif /* PyObjectGetAttrStrNoError */ #if __PYX_LIMITED_VERSION_HEX < 0x030d0000 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) __Pyx_PyErr_Clear(); } #endif static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { PyObject *result; #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000 (void) PyObject_GetOptionalAttr(obj, attr_name, &result); return result; #else #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); } #endif result = __Pyx_PyObject_GetAttrStr(obj, attr_name); if (unlikely(!result)) { __Pyx_PyObject_GetAttrStr_ClearAttributeError(); } return result; #endif } /* CLineInTraceback */ #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000 #define __Pyx_PyProbablyModule_GetDict(o) __Pyx_XNewRef(PyModule_GetDict(o)) #elif !CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_CPYTHON_FREETHREADING #define __Pyx_PyProbablyModule_GetDict(o) PyObject_GenericGetDict(o, NULL); #else PyObject* __Pyx_PyProbablyModule_GetDict(PyObject *o) { PyObject **dict_ptr = _PyObject_GetDictPtr(o); return dict_ptr ? __Pyx_XNewRef(*dict_ptr) : NULL; } #endif static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) { PyObject *use_cline = NULL; PyObject *ptype, *pvalue, *ptraceback; PyObject *cython_runtime_dict; CYTHON_MAYBE_UNUSED_VAR(tstate); if (unlikely(!__pyx_mstate_global->__pyx_cython_runtime)) { return c_line; } __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); cython_runtime_dict = __Pyx_PyProbablyModule_GetDict(__pyx_mstate_global->__pyx_cython_runtime); if (likely(cython_runtime_dict)) { __PYX_PY_DICT_LOOKUP_IF_MODIFIED( use_cline, cython_runtime_dict, __Pyx_PyDict_SetDefault(cython_runtime_dict, __pyx_mstate_global->__pyx_n_u_cline_in_traceback, Py_False)) } if (use_cline == NULL || use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { c_line = 0; } Py_XDECREF(use_cline); Py_XDECREF(cython_runtime_dict); __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); return c_line; } #endif /* CodeObjectCache */ static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static __Pyx_CachedCodeObjectType *__pyx__find_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line) { __Pyx_CachedCodeObjectType* code_object; int pos; if (unlikely(!code_line) || unlikely(!code_cache->entries)) { return NULL; } pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line); if (unlikely(pos >= code_cache->count) || unlikely(code_cache->entries[pos].code_line != code_line)) { return NULL; } code_object = code_cache->entries[pos].code_object; Py_INCREF(code_object); return code_object; } static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS (void)__pyx__find_code_object; return NULL; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just miss. #else struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_nonatomic_int_type old_count = __pyx_atomic_incr_acq_rel(&code_cache->accessor_count); if (old_count < 0) { __pyx_atomic_decr_acq_rel(&code_cache->accessor_count); return NULL; } #endif __Pyx_CachedCodeObjectType *result = __pyx__find_code_object(code_cache, code_line); #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_atomic_decr_acq_rel(&code_cache->accessor_count); #endif return result; #endif } static void __pyx__insert_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line, __Pyx_CachedCodeObjectType* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = code_cache->entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { code_cache->entries = entries; code_cache->max_count = 64; code_cache->count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line); if ((pos < code_cache->count) && unlikely(code_cache->entries[pos].code_line == code_line)) { __Pyx_CachedCodeObjectType* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_INCREF(code_object); Py_DECREF(tmp); return; } if (code_cache->count == code_cache->max_count) { int new_max = code_cache->max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( code_cache->entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } code_cache->entries = entries; code_cache->max_count = new_max; } for (i=code_cache->count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; code_cache->count++; Py_INCREF(code_object); } static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object) { #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS (void)__pyx__insert_code_object; return; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just fail. #else struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache; #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_nonatomic_int_type expected = 0; if (!__pyx_atomic_int_cmp_exchange(&code_cache->accessor_count, &expected, INT_MIN)) { return; } #endif __pyx__insert_code_object(code_cache, code_line, code_object); #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING __pyx_atomic_sub(&code_cache->accessor_count, INT_MIN); #endif #endif } /* AddTraceback */ #include "compile.h" #include "frameobject.h" #include "traceback.h" #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION) #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif #include "internal/pycore_frame.h" #endif #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict, PyObject *firstlineno, PyObject *name) { PyObject *replace = NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL; replace = PyObject_GetAttrString(code, "replace"); if (likely(replace)) { PyObject *result = PyObject_Call(replace, __pyx_mstate_global->__pyx_empty_tuple, scratch_dict); Py_DECREF(replace); return result; } PyErr_Clear(); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL; PyObject *replace = NULL, *getframe = NULL, *frame = NULL; PyObject *exc_type, *exc_value, *exc_traceback; int success = 0; if (c_line) { c_line = __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line); } PyErr_Fetch(&exc_type, &exc_value, &exc_traceback); code_object = __pyx_find_code_object(c_line ? -c_line : py_line); if (!code_object) { code_object = Py_CompileString("_getframe()", filename, Py_eval_input); if (unlikely(!code_object)) goto bad; py_py_line = PyLong_FromLong(py_line); if (unlikely(!py_py_line)) goto bad; if (c_line) { py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); } else { py_funcname = PyUnicode_FromString(funcname); } if (unlikely(!py_funcname)) goto bad; dict = PyDict_New(); if (unlikely(!dict)) goto bad; { PyObject *old_code_object = code_object; code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname); Py_DECREF(old_code_object); } if (unlikely(!code_object)) goto bad; __pyx_insert_code_object(c_line ? -c_line : py_line, code_object); } else { dict = PyDict_New(); } getframe = PySys_GetObject("_getframe"); if (unlikely(!getframe)) goto bad; if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad; frame = PyEval_EvalCode(code_object, dict, dict); if (unlikely(!frame) || frame == Py_None) goto bad; success = 1; bad: PyErr_Restore(exc_type, exc_value, exc_traceback); Py_XDECREF(code_object); Py_XDECREF(py_py_line); Py_XDECREF(py_funcname); Py_XDECREF(dict); Py_XDECREF(replace); if (success) { PyTraceBack_Here( (struct _frame*)frame); } Py_XDECREF(frame); } #else static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = NULL; PyObject *py_funcname = NULL; if (c_line) { py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); if (!py_funcname) goto bad; funcname = PyUnicode_AsUTF8(py_funcname); if (!funcname) goto bad; } py_code = PyCode_NewEmpty(filename, funcname, py_line); Py_XDECREF(py_funcname); return py_code; bad: Py_XDECREF(py_funcname); return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject *ptype, *pvalue, *ptraceback; if (c_line) { c_line = __Pyx_CLineForTraceback(tstate, c_line); } py_code = __pyx_find_code_object(c_line ? -c_line : py_line); if (!py_code) { __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) { /* If the code object creation fails, then we should clear the fetched exception references and propagate the new exception */ Py_XDECREF(ptype); Py_XDECREF(pvalue); Py_XDECREF(ptraceback); goto bad; } __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); } py_frame = PyFrame_New( tstate, /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_mstate_global->__pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } #endif /* CIntFromPyVerify */ #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } /* CIntFromPy */ static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyLong_As_unsigned_PY_LONG_LONG(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) -1, const_zero = (unsigned PY_LONG_LONG) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (unlikely(!PyLong_Check(x))) { unsigned PY_LONG_LONG val; PyObject *tmp = __Pyx_PyNumber_Long(x); if (!tmp) return (unsigned PY_LONG_LONG) -1; val = __Pyx_PyLong_As_unsigned_PY_LONG_LONG(tmp); Py_DECREF(tmp); return val; } if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) >= 2 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); } } break; case 3: if ((8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) >= 3 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); } } break; case 4: if ((8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) >= 4 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (unsigned PY_LONG_LONG) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned long, PyLong_AsUnsignedLong(x)) } else if ((sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case 2: if ((8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) ((((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case -3: if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case 3: if ((8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) ((((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case -4: if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; case 4: if ((8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT)) { return (unsigned PY_LONG_LONG) ((((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]))); } } break; } } #endif if ((sizeof(unsigned PY_LONG_LONG) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, long, PyLong_AsLong(x)) } else if ((sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { unsigned PY_LONG_LONG val; int ret = -1; #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API Py_ssize_t bytes_copied = PyLong_AsNativeBytes( x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0)); if (unlikely(bytes_copied == -1)) { } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) { goto raise_overflow; } else { ret = 0; } #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)x, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *v; PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (likely(PyLong_CheckExact(x))) { v = __Pyx_NewRef(x); } else { v = PyNumber_Long(x); if (unlikely(!v)) return (unsigned PY_LONG_LONG) -1; assert(PyLong_CheckExact(v)); } { int result = PyObject_RichCompareBool(v, Py_False, Py_LT); if (unlikely(result < 0)) { Py_DECREF(v); return (unsigned PY_LONG_LONG) -1; } is_negative = result == 1; } if (is_unsigned && unlikely(is_negative)) { Py_DECREF(v); goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); Py_DECREF(v); if (unlikely(!stepval)) return (unsigned PY_LONG_LONG) -1; } else { stepval = v; } v = NULL; val = (unsigned PY_LONG_LONG) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(unsigned PY_LONG_LONG) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; long idigit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; val |= ((unsigned PY_LONG_LONG) idigit) << bits; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; } Py_DECREF(shift); shift = NULL; Py_DECREF(mask); mask = NULL; { long idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(unsigned PY_LONG_LONG) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((unsigned PY_LONG_LONG) idigit) << bits; } if (!is_unsigned) { if (unlikely(val & (((unsigned PY_LONG_LONG) 1) << (sizeof(unsigned PY_LONG_LONG) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif if (unlikely(ret)) return (unsigned PY_LONG_LONG) -1; return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned PY_LONG_LONG"); return (unsigned PY_LONG_LONG) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to unsigned PY_LONG_LONG"); return (unsigned PY_LONG_LONG) -1; } /* PyObjectVectorCallKwBuilder */ #if CYTHON_VECTORCALL static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) { (void)__Pyx_PyObject_FastCallDict; if (__Pyx_PyTuple_SET_ITEM(builder, n, key) != (0)) return -1; Py_INCREF(key); args[n] = value; return 0; } CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) { (void)__Pyx_VectorcallBuilder_AddArgStr; if (unlikely(!PyUnicode_Check(key))) { PyErr_SetString(PyExc_TypeError, "keywords must be strings"); return -1; } return __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n); } static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n) { PyObject *pyKey = PyUnicode_FromString(key); if (!pyKey) return -1; return __Pyx_VectorcallBuilder_AddArg(pyKey, value, builder, args, n); } #else // CYTHON_VECTORCALL CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, CYTHON_UNUSED PyObject **args, CYTHON_UNUSED int n) { if (unlikely(!PyUnicode_Check(key))) { PyErr_SetString(PyExc_TypeError, "keywords must be strings"); return -1; } return PyDict_SetItem(builder, key, value); } #endif /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) -1, const_zero = (unsigned PY_LONG_LONG) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(unsigned PY_LONG_LONG) < sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #if !CYTHON_COMPILING_IN_PYPY } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(unsigned PY_LONG_LONG) <= sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4 if (is_unsigned) { return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1); } else { return PyLong_FromNativeBytes(bytes, sizeof(value), -1); } #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 int one = 1; int little = (int)*(unsigned char *)&one; return _PyLong_FromByteArray(bytes, sizeof(unsigned PY_LONG_LONG), little, !is_unsigned); #else int one = 1; int little = (int)*(unsigned char *)&one; PyObject *from_bytes, *result = NULL, *kwds = NULL; PyObject *py_bytes = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(unsigned PY_LONG_LONG)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; { PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str }; if (!is_unsigned) { kwds = __Pyx_MakeVectorcallBuilderKwds(1); if (!kwds) goto limited_bad; if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad; } result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds); } limited_bad: Py_XDECREF(kwds); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* FormatTypeName */ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000 static __Pyx_TypeName __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp) { PyObject *module = NULL, *name = NULL, *result = NULL; #if __PYX_LIMITED_VERSION_HEX < 0x030b0000 name = __Pyx_PyObject_GetAttrStr((PyObject *)tp, __pyx_mstate_global->__pyx_n_u_qualname); #else name = PyType_GetQualName(tp); #endif if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) goto bad; module = __Pyx_PyObject_GetAttrStr((PyObject *)tp, __pyx_mstate_global->__pyx_n_u_module); if (unlikely(module == NULL) || unlikely(!PyUnicode_Check(module))) goto bad; if (PyUnicode_CompareWithASCIIString(module, "builtins") == 0) { result = name; name = NULL; goto done; } result = PyUnicode_FromFormat("%U.%U", module, name); if (unlikely(result == NULL)) goto bad; done: Py_XDECREF(name); Py_XDECREF(module); return result; bad: PyErr_Clear(); if (name) { result = name; name = NULL; } else { result = __Pyx_NewRef(__pyx_mstate_global->__pyx_kp_u_); } goto done; } #endif /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #if !CYTHON_COMPILING_IN_PYPY } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(long) <= sizeof(long)) { return PyLong_FromLong((long) value); } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); } } { unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4 if (is_unsigned) { return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1); } else { return PyLong_FromNativeBytes(bytes, sizeof(value), -1); } #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 int one = 1; int little = (int)*(unsigned char *)&one; return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); #else int one = 1; int little = (int)*(unsigned char *)&one; PyObject *from_bytes, *result = NULL, *kwds = NULL; PyObject *py_bytes = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(long)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; { PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str }; if (!is_unsigned) { kwds = __Pyx_MakeVectorcallBuilderKwds(1); if (!kwds) goto limited_bad; if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad; } result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds); } limited_bad: Py_XDECREF(kwds); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* CIntFromPy */ static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (unlikely(!PyLong_Check(x))) { long val; PyObject *tmp = __Pyx_PyNumber_Long(x); if (!tmp) return (long) -1; val = __Pyx_PyLong_As_long(tmp); Py_DECREF(tmp); return val; } if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(long) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } } #endif if ((sizeof(long) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { long val; int ret = -1; #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API Py_ssize_t bytes_copied = PyLong_AsNativeBytes( x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0)); if (unlikely(bytes_copied == -1)) { } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) { goto raise_overflow; } else { ret = 0; } #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)x, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *v; PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (likely(PyLong_CheckExact(x))) { v = __Pyx_NewRef(x); } else { v = PyNumber_Long(x); if (unlikely(!v)) return (long) -1; assert(PyLong_CheckExact(v)); } { int result = PyObject_RichCompareBool(v, Py_False, Py_LT); if (unlikely(result < 0)) { Py_DECREF(v); return (long) -1; } is_negative = result == 1; } if (is_unsigned && unlikely(is_negative)) { Py_DECREF(v); goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); Py_DECREF(v); if (unlikely(!stepval)) return (long) -1; } else { stepval = v; } v = NULL; val = (long) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; long idigit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; val |= ((long) idigit) << bits; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; } Py_DECREF(shift); shift = NULL; Py_DECREF(mask); mask = NULL; { long idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((long) idigit) << bits; } if (!is_unsigned) { if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif if (unlikely(ret)) return (long) -1; return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } /* CIntFromPy */ static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const int neg_one = (int) -1, const_zero = (int) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (unlikely(!PyLong_Check(x))) { int val; PyObject *tmp = __Pyx_PyNumber_Long(x); if (!tmp) return (int) -1; val = __Pyx_PyLong_As_int(tmp); Py_DECREF(tmp); return val; } if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(int) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } } #endif if ((sizeof(int) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) } } { int val; int ret = -1; #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API Py_ssize_t bytes_copied = PyLong_AsNativeBytes( x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0)); if (unlikely(bytes_copied == -1)) { } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) { goto raise_overflow; } else { ret = 0; } #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)x, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *v; PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (likely(PyLong_CheckExact(x))) { v = __Pyx_NewRef(x); } else { v = PyNumber_Long(x); if (unlikely(!v)) return (int) -1; assert(PyLong_CheckExact(v)); } { int result = PyObject_RichCompareBool(v, Py_False, Py_LT); if (unlikely(result < 0)) { Py_DECREF(v); return (int) -1; } is_negative = result == 1; } if (is_unsigned && unlikely(is_negative)) { Py_DECREF(v); goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); Py_DECREF(v); if (unlikely(!stepval)) return (int) -1; } else { stepval = v; } v = NULL; val = (int) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; long idigit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; val |= ((int) idigit) << bits; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; } Py_DECREF(shift); shift = NULL; Py_DECREF(mask); mask = NULL; { long idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((int) idigit) << bits; } if (!is_unsigned) { if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif if (unlikely(ret)) return (int) -1; return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } /* FastTypeChecks */ #if CYTHON_COMPILING_IN_CPYTHON static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { while (a) { a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*); if (a == b) return 1; } return b == &PyBaseObject_Type; } static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (a == b) return 1; mro = a->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(a, b); } static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (cls == a || cls == b) return 1; mro = cls->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { PyObject *base = PyTuple_GET_ITEM(mro, i); if (base == (PyObject *)a || base == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b); } static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { if (exc_type1) { return __Pyx_IsAnySubtype2((PyTypeObject*)err, (PyTypeObject*)exc_type1, (PyTypeObject*)exc_type2); } else { return __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); } } static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; assert(PyExceptionClass_Check(exc_type)); n = PyTuple_GET_SIZE(tuple); for (i=0; i>= 8; ++i; } __Pyx_cached_runtime_version = version; } } #endif static unsigned long __Pyx_get_runtime_version(void) { #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000 return Py_Version & ~0xFFUL; #else return __Pyx_cached_runtime_version; #endif } /* CheckBinaryVersion */ static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) { const unsigned long MAJOR_MINOR = 0xFFFF0000UL; if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR)) return 0; if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR))) return 1; { char message[200]; PyOS_snprintf(message, sizeof(message), "compile time Python version %d.%d " "of module '%.100s' " "%s " "runtime version %d.%d", (int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF), __Pyx_MODULE_NAME, (allow_newer) ? "was newer than" : "does not match", (int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF) ); return PyErr_WarnEx(NULL, message, 1); } } /* NewCodeObj */ #if CYTHON_COMPILING_IN_LIMITED_API static PyObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f, PyObject *code, PyObject *c, PyObject* n, PyObject *v, PyObject *fv, PyObject *cell, PyObject* fn, PyObject *name, int fline, PyObject *lnos) { PyObject *exception_table = NULL; PyObject *types_module=NULL, *code_type=NULL, *result=NULL; #if __PYX_LIMITED_VERSION_HEX < 0x030b0000 PyObject *version_info; PyObject *py_minor_version = NULL; #endif long minor_version = 0; PyObject *type, *value, *traceback; PyErr_Fetch(&type, &value, &traceback); #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000 minor_version = 11; #else if (!(version_info = PySys_GetObject("version_info"))) goto end; if (!(py_minor_version = PySequence_GetItem(version_info, 1))) goto end; minor_version = PyLong_AsLong(py_minor_version); Py_DECREF(py_minor_version); if (minor_version == -1 && PyErr_Occurred()) goto end; #endif if (!(types_module = PyImport_ImportModule("types"))) goto end; if (!(code_type = PyObject_GetAttrString(types_module, "CodeType"))) goto end; if (minor_version <= 7) { (void)p; result = PyObject_CallFunction(code_type, "iiiiiOOOOOOiOOO", a, k, l, s, f, code, c, n, v, fn, name, fline, lnos, fv, cell); } else if (minor_version <= 10) { result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOiOOO", a,p, k, l, s, f, code, c, n, v, fn, name, fline, lnos, fv, cell); } else { if (!(exception_table = PyBytes_FromStringAndSize(NULL, 0))) goto end; result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOOiOOOO", a,p, k, l, s, f, code, c, n, v, fn, name, name, fline, lnos, exception_table, fv, cell); } end: Py_XDECREF(code_type); Py_XDECREF(exception_table); Py_XDECREF(types_module); if (type) { PyErr_Restore(type, value, traceback); } return result; } #elif PY_VERSION_HEX >= 0x030B0000 static PyCodeObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f, PyObject *code, PyObject *c, PyObject* n, PyObject *v, PyObject *fv, PyObject *cell, PyObject* fn, PyObject *name, int fline, PyObject *lnos) { PyCodeObject *result; result = #if PY_VERSION_HEX >= 0x030C0000 PyUnstable_Code_NewWithPosOnlyArgs #else PyCode_NewWithPosOnlyArgs #endif (a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, name, fline, lnos, __pyx_mstate_global->__pyx_empty_bytes); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030c00A1 if (likely(result)) result->_co_firsttraceable = 0; #endif return result; } #elif !CYTHON_COMPILING_IN_PYPY #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #else #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #endif static PyObject* __Pyx_PyCode_New( const __Pyx_PyCode_New_function_description descr, PyObject * const *varnames, PyObject *filename, PyObject *funcname, PyObject *line_table, PyObject *tuple_dedup_map ) { PyObject *code_obj = NULL, *varnames_tuple_dedup = NULL, *code_bytes = NULL; Py_ssize_t var_count = (Py_ssize_t) descr.nlocals; PyObject *varnames_tuple = PyTuple_New(var_count); if (unlikely(!varnames_tuple)) return NULL; for (Py_ssize_t i=0; i < var_count; i++) { Py_INCREF(varnames[i]); if (__Pyx_PyTuple_SET_ITEM(varnames_tuple, i, varnames[i]) != (0)) goto done; } #if CYTHON_COMPILING_IN_LIMITED_API varnames_tuple_dedup = PyDict_GetItem(tuple_dedup_map, varnames_tuple); if (!varnames_tuple_dedup) { if (unlikely(PyDict_SetItem(tuple_dedup_map, varnames_tuple, varnames_tuple) < 0)) goto done; varnames_tuple_dedup = varnames_tuple; } #else varnames_tuple_dedup = PyDict_SetDefault(tuple_dedup_map, varnames_tuple, varnames_tuple); if (unlikely(!varnames_tuple_dedup)) goto done; #endif #if CYTHON_AVOID_BORROWED_REFS Py_INCREF(varnames_tuple_dedup); #endif if (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table != NULL && !CYTHON_COMPILING_IN_GRAAL) { Py_ssize_t line_table_length = __Pyx_PyBytes_GET_SIZE(line_table); #if !CYTHON_ASSUME_SAFE_SIZE if (unlikely(line_table_length == -1)) goto done; #endif Py_ssize_t code_len = (line_table_length * 2 + 4) & ~3LL; code_bytes = PyBytes_FromStringAndSize(NULL, code_len); if (unlikely(!code_bytes)) goto done; char* c_code_bytes = PyBytes_AsString(code_bytes); if (unlikely(!c_code_bytes)) goto done; memset(c_code_bytes, 0, (size_t) code_len); } code_obj = (PyObject*) __Pyx__PyCode_New( (int) descr.argcount, (int) descr.num_posonly_args, (int) descr.num_kwonly_args, (int) descr.nlocals, 0, (int) descr.flags, code_bytes ? code_bytes : __pyx_mstate_global->__pyx_empty_bytes, __pyx_mstate_global->__pyx_empty_tuple, __pyx_mstate_global->__pyx_empty_tuple, varnames_tuple_dedup, __pyx_mstate_global->__pyx_empty_tuple, __pyx_mstate_global->__pyx_empty_tuple, filename, funcname, (int) descr.first_line, (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table) ? line_table : __pyx_mstate_global->__pyx_empty_bytes ); done: Py_XDECREF(code_bytes); #if CYTHON_AVOID_BORROWED_REFS Py_XDECREF(varnames_tuple_dedup); #endif Py_DECREF(varnames_tuple); return code_obj; } /* DecompressString */ static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo) { PyObject *module, *decompress, *compressed_bytes, *decompressed; const char* module_name = algo == 3 ? "compression.zstd" : algo == 2 ? "bz2" : "zlib"; PyObject *methodname = PyUnicode_FromString("decompress"); if (unlikely(!methodname)) return NULL; #if __PYX_LIMITED_VERSION_HEX >= 0x030e0000 if (algo == 3) { PyObject *fromlist = Py_BuildValue("[O]", methodname); if (unlikely(!fromlist)) return NULL; module = PyImport_ImportModuleLevel("compression.zstd", NULL, NULL, fromlist, 0); Py_DECREF(fromlist); } else #endif module = PyImport_ImportModule(module_name); if (unlikely(!module)) goto import_failed; decompress = PyObject_GetAttr(module, methodname); if (unlikely(!decompress)) goto import_failed; { #ifdef __cplusplus char *memview_bytes = const_cast(s); #else #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wcast-qual" #elif !defined(__INTEL_COMPILER) && defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-qual" #endif char *memview_bytes = (char*) s; #if defined(__clang__) #pragma clang diagnostic pop #elif !defined(__INTEL_COMPILER) && defined(__GNUC__) #pragma GCC diagnostic pop #endif #endif #if CYTHON_COMPILING_IN_LIMITED_API && !defined(PyBUF_READ) int memview_flags = 0x100; #else int memview_flags = PyBUF_READ; #endif compressed_bytes = PyMemoryView_FromMemory(memview_bytes, length, memview_flags); } if (unlikely(!compressed_bytes)) { Py_DECREF(decompress); goto bad; } decompressed = PyObject_CallFunctionObjArgs(decompress, compressed_bytes, NULL); Py_DECREF(compressed_bytes); Py_DECREF(decompress); Py_DECREF(module); Py_DECREF(methodname); return decompressed; import_failed: PyErr_Format(PyExc_ImportError, "Failed to import '%.20s.decompress' - cannot initialise module strings. " "String compression was configured with the C macro 'CYTHON_COMPRESS_STRINGS=%d'.", module_name, algo); bad: Py_XDECREF(module); Py_DECREF(methodname); return NULL; } #include static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s) { size_t len = strlen(s); if (unlikely(len > (size_t) PY_SSIZE_T_MAX)) { PyErr_SetString(PyExc_OverflowError, "byte string is too long"); return -1; } return (Py_ssize_t) len; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { Py_ssize_t len = __Pyx_ssize_strlen(c_str); if (unlikely(len < 0)) return NULL; return __Pyx_PyUnicode_FromStringAndSize(c_str, len); } static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char* c_str) { Py_ssize_t len = __Pyx_ssize_strlen(c_str); if (unlikely(len < 0)) return NULL; return PyByteArray_FromStringAndSize(c_str, len); } static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if CYTHON_COMPILING_IN_LIMITED_API { const char* result; Py_ssize_t unicode_length; CYTHON_MAYBE_UNUSED_VAR(unicode_length); // only for __PYX_DEFAULT_STRING_ENCODING_IS_ASCII #if __PYX_LIMITED_VERSION_HEX < 0x030A0000 if (unlikely(PyArg_Parse(o, "s#", &result, length) < 0)) return NULL; #else result = PyUnicode_AsUTF8AndSize(o, length); #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII unicode_length = PyUnicode_GetLength(o); if (unlikely(unicode_length < 0)) return NULL; if (unlikely(unicode_length != *length)) { PyUnicode_AsASCIIString(o); return NULL; } #endif return result; } #else #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (likely(PyUnicode_IS_ASCII(o))) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif #endif } #endif static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 if (PyUnicode_Check(o)) { return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif if (PyByteArray_Check(o)) { #if (CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS) || (CYTHON_COMPILING_IN_PYPY && (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))) *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); #else *length = PyByteArray_Size(o); if (*length == -1) return NULL; return PyByteArray_AsString(o); #endif } else { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { int retval; if (unlikely(!x)) return -1; retval = __Pyx_PyObject_IsTrue(x); Py_DECREF(x); return retval; } static PyObject* __Pyx_PyNumber_LongWrongResultType(PyObject* result) { __Pyx_TypeName result_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(result)); if (PyLong_Check(result)) { if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, "__int__ returned non-int (type " __Pyx_FMT_TYPENAME "). " "The ability to return an instance of a strict subclass of int is deprecated, " "and may be removed in a future version of Python.", result_type_name)) { __Pyx_DECREF_TypeName(result_type_name); Py_DECREF(result); return NULL; } __Pyx_DECREF_TypeName(result_type_name); return result; } PyErr_Format(PyExc_TypeError, "__int__ returned non-int (type " __Pyx_FMT_TYPENAME ")", result_type_name); __Pyx_DECREF_TypeName(result_type_name); Py_DECREF(result); return NULL; } static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; #endif PyObject *res = NULL; if (likely(PyLong_Check(x))) return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS m = Py_TYPE(x)->tp_as_number; if (likely(m && m->nb_int)) { res = m->nb_int(x); } #else if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { res = PyNumber_Long(x); } #endif if (likely(res)) { if (unlikely(!PyLong_CheckExact(res))) { return __Pyx_PyNumber_LongWrongResultType(res); } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS if (likely(__Pyx_PyLong_IsCompact(b))) { return __Pyx_PyLong_CompactValue(b); } else { const digit* digits = __Pyx_PyLong_Digits(b); const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(b); switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyLong_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) { if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) { return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o); } else { Py_ssize_t ival; PyObject *x; x = PyNumber_Index(o); if (!x) return -1; ival = PyLong_AsLong(x); Py_DECREF(x); return ival; } } static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b) { CYTHON_UNUSED_VAR(b); return __Pyx_NewRef(Py_None); } static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { return __Pyx_NewRef(b ? Py_True: Py_False); } static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t ival) { return PyLong_FromSize_t(ival); } /* MultiPhaseInitModuleState */ #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE #ifndef CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE #if (CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX >= 0x030C0000) #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 1 #else #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 0 #endif #endif #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE && !CYTHON_ATOMICS #error "Module state with PEP489 requires atomics. Currently that's one of\ C11, C++11, gcc atomic intrinsics or MSVC atomic intrinsics" #endif #if !CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE #define __Pyx_ModuleStateLookup_Lock() #define __Pyx_ModuleStateLookup_Unlock() #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000 static PyMutex __Pyx_ModuleStateLookup_mutex = {0}; #define __Pyx_ModuleStateLookup_Lock() PyMutex_Lock(&__Pyx_ModuleStateLookup_mutex) #define __Pyx_ModuleStateLookup_Unlock() PyMutex_Unlock(&__Pyx_ModuleStateLookup_mutex) #elif defined(__cplusplus) && __cplusplus >= 201103L #include static std::mutex __Pyx_ModuleStateLookup_mutex; #define __Pyx_ModuleStateLookup_Lock() __Pyx_ModuleStateLookup_mutex.lock() #define __Pyx_ModuleStateLookup_Unlock() __Pyx_ModuleStateLookup_mutex.unlock() #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201112L) && !defined(__STDC_NO_THREADS__) #include static mtx_t __Pyx_ModuleStateLookup_mutex; static once_flag __Pyx_ModuleStateLookup_mutex_once_flag = ONCE_FLAG_INIT; static void __Pyx_ModuleStateLookup_initialize_mutex(void) { mtx_init(&__Pyx_ModuleStateLookup_mutex, mtx_plain); } #define __Pyx_ModuleStateLookup_Lock()\ call_once(&__Pyx_ModuleStateLookup_mutex_once_flag, __Pyx_ModuleStateLookup_initialize_mutex);\ mtx_lock(&__Pyx_ModuleStateLookup_mutex) #define __Pyx_ModuleStateLookup_Unlock() mtx_unlock(&__Pyx_ModuleStateLookup_mutex) #elif defined(HAVE_PTHREAD_H) #include static pthread_mutex_t __Pyx_ModuleStateLookup_mutex = PTHREAD_MUTEX_INITIALIZER; #define __Pyx_ModuleStateLookup_Lock() pthread_mutex_lock(&__Pyx_ModuleStateLookup_mutex) #define __Pyx_ModuleStateLookup_Unlock() pthread_mutex_unlock(&__Pyx_ModuleStateLookup_mutex) #elif defined(_WIN32) #include // synchapi.h on its own doesn't work static SRWLOCK __Pyx_ModuleStateLookup_mutex = SRWLOCK_INIT; #define __Pyx_ModuleStateLookup_Lock() AcquireSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex) #define __Pyx_ModuleStateLookup_Unlock() ReleaseSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex) #else #error "No suitable lock available for CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE.\ Requires C standard >= C11, or C++ standard >= C++11,\ or pthreads, or the Windows 32 API, or Python >= 3.13." #endif typedef struct { int64_t id; PyObject *module; } __Pyx_InterpreterIdAndModule; typedef struct { char interpreter_id_as_index; Py_ssize_t count; Py_ssize_t allocated; __Pyx_InterpreterIdAndModule table[1]; } __Pyx_ModuleStateLookupData; #define __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE 32 #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE static __pyx_atomic_int_type __Pyx_ModuleStateLookup_read_counter = 0; #endif #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE static __pyx_atomic_ptr_type __Pyx_ModuleStateLookup_data = 0; #else static __Pyx_ModuleStateLookupData* __Pyx_ModuleStateLookup_data = NULL; #endif static __Pyx_InterpreterIdAndModule* __Pyx_State_FindModuleStateLookupTableLowerBound( __Pyx_InterpreterIdAndModule* table, Py_ssize_t count, int64_t interpreterId) { __Pyx_InterpreterIdAndModule* begin = table; __Pyx_InterpreterIdAndModule* end = begin + count; if (begin->id == interpreterId) { return begin; } while ((end - begin) > __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) { __Pyx_InterpreterIdAndModule* halfway = begin + (end - begin)/2; if (halfway->id == interpreterId) { return halfway; } if (halfway->id < interpreterId) { begin = halfway; } else { end = halfway; } } for (; begin < end; ++begin) { if (begin->id >= interpreterId) return begin; } return begin; } static PyObject *__Pyx_State_FindModule(CYTHON_UNUSED void* dummy) { int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get()); if (interpreter_id == -1) return NULL; #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __Pyx_ModuleStateLookupData* data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data); { __pyx_atomic_incr_acq_rel(&__Pyx_ModuleStateLookup_read_counter); if (likely(data)) { __Pyx_ModuleStateLookupData* new_data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_acquire(&__Pyx_ModuleStateLookup_data); if (likely(data == new_data)) { goto read_finished; } } __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter); __Pyx_ModuleStateLookup_Lock(); __pyx_atomic_incr_relaxed(&__Pyx_ModuleStateLookup_read_counter); data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data); __Pyx_ModuleStateLookup_Unlock(); } read_finished:; #else __Pyx_ModuleStateLookupData* data = __Pyx_ModuleStateLookup_data; #endif __Pyx_InterpreterIdAndModule* found = NULL; if (unlikely(!data)) goto end; if (data->interpreter_id_as_index) { if (interpreter_id < data->count) { found = data->table+interpreter_id; } } else { found = __Pyx_State_FindModuleStateLookupTableLowerBound( data->table, data->count, interpreter_id); } end: { PyObject *result=NULL; if (found && found->id == interpreter_id) { result = found->module; } #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter); #endif return result; } } #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE static void __Pyx_ModuleStateLookup_wait_until_no_readers(void) { while (__pyx_atomic_load(&__Pyx_ModuleStateLookup_read_counter) != 0); } #else #define __Pyx_ModuleStateLookup_wait_until_no_readers() #endif static int __Pyx_State_AddModuleInterpIdAsIndex(__Pyx_ModuleStateLookupData **old_data, PyObject* module, int64_t interpreter_id) { Py_ssize_t to_allocate = (*old_data)->allocated; while (to_allocate <= interpreter_id) { if (to_allocate == 0) to_allocate = 1; else to_allocate *= 2; } __Pyx_ModuleStateLookupData *new_data = *old_data; if (to_allocate != (*old_data)->allocated) { new_data = (__Pyx_ModuleStateLookupData *)realloc( *old_data, sizeof(__Pyx_ModuleStateLookupData)+(to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule)); if (!new_data) { PyErr_NoMemory(); return -1; } for (Py_ssize_t i = new_data->allocated; i < to_allocate; ++i) { new_data->table[i].id = i; new_data->table[i].module = NULL; } new_data->allocated = to_allocate; } new_data->table[interpreter_id].module = module; if (new_data->count < interpreter_id+1) { new_data->count = interpreter_id+1; } *old_data = new_data; return 0; } static void __Pyx_State_ConvertFromInterpIdAsIndex(__Pyx_ModuleStateLookupData *data) { __Pyx_InterpreterIdAndModule *read = data->table; __Pyx_InterpreterIdAndModule *write = data->table; __Pyx_InterpreterIdAndModule *end = read + data->count; for (; readmodule) { write->id = read->id; write->module = read->module; ++write; } } data->count = write - data->table; for (; writeid = 0; write->module = NULL; } data->interpreter_id_as_index = 0; } static int __Pyx_State_AddModule(PyObject* module, CYTHON_UNUSED void* dummy) { int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get()); if (interpreter_id == -1) return -1; int result = 0; __Pyx_ModuleStateLookup_Lock(); #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __Pyx_ModuleStateLookupData *old_data = (__Pyx_ModuleStateLookupData *) __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0); #else __Pyx_ModuleStateLookupData *old_data = __Pyx_ModuleStateLookup_data; #endif __Pyx_ModuleStateLookupData *new_data = old_data; if (!new_data) { new_data = (__Pyx_ModuleStateLookupData *)calloc(1, sizeof(__Pyx_ModuleStateLookupData)); if (!new_data) { result = -1; PyErr_NoMemory(); goto end; } new_data->allocated = 1; new_data->interpreter_id_as_index = 1; } __Pyx_ModuleStateLookup_wait_until_no_readers(); if (new_data->interpreter_id_as_index) { if (interpreter_id < __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) { result = __Pyx_State_AddModuleInterpIdAsIndex(&new_data, module, interpreter_id); goto end; } __Pyx_State_ConvertFromInterpIdAsIndex(new_data); } { Py_ssize_t insert_at = 0; { __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound( new_data->table, new_data->count, interpreter_id); assert(lower_bound); insert_at = lower_bound - new_data->table; if (unlikely(insert_at < new_data->count && lower_bound->id == interpreter_id)) { lower_bound->module = module; goto end; // already in table, nothing more to do } } if (new_data->count+1 >= new_data->allocated) { Py_ssize_t to_allocate = (new_data->count+1)*2; new_data = (__Pyx_ModuleStateLookupData*)realloc( new_data, sizeof(__Pyx_ModuleStateLookupData) + (to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule)); if (!new_data) { result = -1; new_data = old_data; PyErr_NoMemory(); goto end; } new_data->allocated = to_allocate; } ++new_data->count; int64_t last_id = interpreter_id; PyObject *last_module = module; for (Py_ssize_t i=insert_at; icount; ++i) { int64_t current_id = new_data->table[i].id; new_data->table[i].id = last_id; last_id = current_id; PyObject *current_module = new_data->table[i].module; new_data->table[i].module = last_module; last_module = current_module; } } end: #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, new_data); #else __Pyx_ModuleStateLookup_data = new_data; #endif __Pyx_ModuleStateLookup_Unlock(); return result; } static int __Pyx_State_RemoveModule(CYTHON_UNUSED void* dummy) { int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get()); if (interpreter_id == -1) return -1; __Pyx_ModuleStateLookup_Lock(); #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __Pyx_ModuleStateLookupData *data = (__Pyx_ModuleStateLookupData *) __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0); #else __Pyx_ModuleStateLookupData *data = __Pyx_ModuleStateLookup_data; #endif if (data->interpreter_id_as_index) { if (interpreter_id < data->count) { data->table[interpreter_id].module = NULL; } goto done; } { __Pyx_ModuleStateLookup_wait_until_no_readers(); __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound( data->table, data->count, interpreter_id); if (!lower_bound) goto done; if (lower_bound->id != interpreter_id) goto done; __Pyx_InterpreterIdAndModule *end = data->table+data->count; for (;lower_boundid = (lower_bound+1)->id; lower_bound->module = (lower_bound+1)->module; } } --data->count; if (data->count == 0) { free(data); data = NULL; } done: #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, data); #else __Pyx_ModuleStateLookup_data = data; #endif __Pyx_ModuleStateLookup_Unlock(); return 0; } #endif /* #### Code section: utility_code_pragmas_end ### */ #ifdef _MSC_VER #pragma warning( pop ) #endif /* #### Code section: end ### */ #endif /* Py_PYTHON_H */ clickhouse-driver-0.2.11/clickhouse_driver/varint.pyx000066400000000000000000000033171522645447600230110ustar00rootroot00000000000000from cpython cimport PyBytes_FromStringAndSize def make_varint(unsigned long long number): """ Writes integer of variable length using LEB128. """ cdef unsigned char to_write, i = 0 # unsigned PY_LONG_LONG checks integer on function call and # raises OverflowError if integer overflows unsigned PY_LONG_LONG. # Long enough for handling unsigned PY_LONG_LONG. cdef unsigned char num_buf[32] while True: to_write = number & 0x7f number >>= 7 if number: num_buf[i] = to_write | 0x80 i += 1 else: num_buf[i] = to_write i += 1 break return PyBytes_FromStringAndSize(num_buf, i) def write_varint(unsigned long long number, buf): """ Writes integer of variable length using LEB128. """ cdef unsigned char to_write, i = 0 # unsigned PY_LONG_LONG checks integer on function call and # raises OverflowError if integer overflows unsigned PY_LONG_LONG. # Long enough for handling unsigned PY_LONG_LONG. cdef unsigned char num_buf[32] while True: to_write = number & 0x7f number >>= 7 if number: num_buf[i] = to_write | 0x80 i += 1 else: num_buf[i] = to_write i += 1 break buf.write(PyBytes_FromStringAndSize(num_buf, i)) def read_varint(f): """ Reads integer of variable length using LEB128. """ cdef unsigned char shift = 0 cdef unsigned long long i, result = 0 read_one = f.read_one while True: i = read_one() result |= (i & 0x7f) << shift shift += 7 if i < 0x80: break return result clickhouse-driver-0.2.11/clickhouse_driver/writer.py000066400000000000000000000024061522645447600226300ustar00rootroot00000000000000import struct from .varint import write_varint MAX_UINT64 = (1 << 64) - 1 MAX_INT64 = (1 << 63) - 1 def _byte(b): return bytes((b, )) def write_binary_str(text, buf): text = text.encode('utf-8') write_binary_bytes(text, buf) def write_binary_bytes(text, buf): write_varint(len(text), buf) buf.write(text) def write_binary_int(number, buf, fmt): """ Writes int from buffer with provided format. """ fmt = '<' + fmt buf.write(struct.pack(fmt, number)) def write_binary_int8(number, buf): write_binary_int(number, buf, 'b') def write_binary_int16(number, buf): write_binary_int(number, buf, 'h') def write_binary_int32(number, buf): write_binary_int(number, buf, 'i') def write_binary_int64(number, buf): write_binary_int(number, buf, 'q') def write_binary_uint8(number, buf): write_binary_int(number, buf, 'B') def write_binary_uint16(number, buf): write_binary_int(number, buf, 'H') def write_binary_uint32(number, buf): write_binary_int(number, buf, 'I') def write_binary_uint64(number, buf): write_binary_int(number, buf, 'Q') def write_binary_uint128(number, buf): fmt = '> 64) & MAX_UINT64, number & MAX_UINT64) buf.write(packed) clickhouse-driver-0.2.11/coverage_excludes.py000066400000000000000000000032161522645447600212770ustar00rootroot00000000000000""" Coverage.py plugin: exclude version-gated lines that the current matrix entry cannot reach. Lines tagged ``# pragma: requires-clickhouse-X.Y`` are excluded when ``$CLICKHOUSE_VERSION`` is older than ``X.Y``. Both ``coverage run`` and ``coveralls`` reload ``.coveragerc`` in separate processes; placing the logic in a plugin lets the same exclusion list reach both. With ``$CLICKHOUSE_VERSION`` unset the plugin is a no-op, so local runs measure every line. """ import os import pathlib import re from coverage import CoveragePlugin _PRAGMA = re.compile(r'pragma: requires-clickhouse-(\d+\.\d+)') def _tuple(version): return tuple(int(part) for part in version.split('.')) class VersionGatedExcludes(CoveragePlugin): def configure(self, config): target = os.getenv('CLICKHOUSE_VERSION', '') if not target: return target_t = _tuple(target) root = pathlib.Path(__file__).parent / 'clickhouse_driver' if not root.exists(): return versions = set() for path in root.rglob('*.py'): versions.update( _PRAGMA.findall(path.read_text(encoding='utf-8'))) excludes = list(config.get_option('report:exclude_lines') or []) for version in sorted(versions, key=_tuple): if _tuple(version) > target_t: pattern = 'pragma: requires-clickhouse-{}'.format( re.escape(version)) if pattern not in excludes: excludes.append(pattern) config.set_option('report:exclude_lines', excludes) def coverage_init(reg, options): reg.add_configurer(VersionGatedExcludes()) clickhouse-driver-0.2.11/docs/000077500000000000000000000000001522645447600161645ustar00rootroot00000000000000clickhouse-driver-0.2.11/docs/Makefile000066400000000000000000000011071522645447600176230ustar00rootroot00000000000000# Minimal makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = -W SPHINXBUILD = sphinx-build SOURCEDIR = . BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) .PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)clickhouse-driver-0.2.11/docs/_static/000077500000000000000000000000001522645447600176125ustar00rootroot00000000000000clickhouse-driver-0.2.11/docs/_static/css/000077500000000000000000000000001522645447600204025ustar00rootroot00000000000000clickhouse-driver-0.2.11/docs/_static/css/custom.css000066400000000000000000000004371522645447600224320ustar00rootroot00000000000000 table.table-small-text { font-size: small; } table.table-center-header thead tr th { text-align: center; } table.table-right-text-align-results tbody tr td { text-align: right; } table.table-right-text-align-results tbody tr td:first-child { text-align: inherit; } clickhouse-driver-0.2.11/docs/_static/mymarilyn-icon.png000066400000000000000000000017341522645447600232740ustar00rootroot00000000000000‰PNG  IHDR@@% æ‰ pHYs  šœtIMEâ 9ŸÎó¸{IDAThÞí™KLAÇwgv”Fi‹(( D"zЋÞ0‘D¢1!ÑÈM ¢GƒXNò4AÁˆD=èÅ7_sVíÄäåËË++6nܤÓ%eYžœœ|ápœ9]=66=_¾Nx½^¥ý ³Ó`4fggOMMimX–E±¦úLkK B(A§3•š ‹ŠAq„Bæê•Æ‹µu<ÏG[Ƙ¦éipwWwaAAW�%55cÁrhhhGööh ˜v– 4�eYû5ɲì”ßÇqÚÝC!­7†yëtîÙµ{£†í-1™DQ é”$ÉÒm±>{ HJJÒf2N[G–e›ÕÖÓcy~EJŠÖÒh4ò¼ßn³GÕÇ�*¯hmm ü<¹•«VVVUíÌÍ bŽãnÞh¹P[çñ¸•½^¬¸¸°è°B㌵ë¢çŽãÊO–ÝhjBš—Áçõu´µoÞ²%--MûÚt´·›Ž—ˆâ/U‚ ˜>\–¼lCV–zÉŠ’d³ZçDÀŸÓi§ÓÙÒÜvèúÕk è�n÷·Ò’a-ê/áŸarrræÊðº·w¦!Ë£GÚÊõýÀàï‘£022òÍíVn3Œ±Á``Y6Jü~>â¨_mó¼?B?6:ª^ÇÂ�¸ŸG³ùEd–uã|”R ¥¨'ˆ"€ ˆ"€ þ&¼,ÔD?r²  iZ±‰ü¯Ö´5˜_6«U-a‡‡?F˜ÿÜáP‹²wýý,ûúú$IR —Ë…þ÷î›e%@ �@ „ç;e‹Œ«ÔP¹ªIEND®B`‚clickhouse-driver-0.2.11/docs/_templates/000077500000000000000000000000001522645447600203215ustar00rootroot00000000000000clickhouse-driver-0.2.11/docs/_templates/layout.html000066400000000000000000000002421522645447600225220ustar00rootroot00000000000000{% extends "!layout.html" %} {% block extrahead %} {% endblock %} clickhouse-driver-0.2.11/docs/api.rst000066400000000000000000000014501522645447600174670ustar00rootroot00000000000000.. _api: API === .. module:: clickhouse_driver This part of the documentation covers basic classes of the driver: Client, Connection and others. .. _api-client: Client ------ .. autoclass:: Client :members: :inherited-members: Connection ---------- .. autoclass:: clickhouse_driver.connection.Connection :members: :inherited-members: .. _query-result: QueryResult ----------- .. autoclass:: clickhouse_driver.result.QueryResult :members: :inherited-members: .. _progress-query-result: ProgressQueryResult ------------------- .. autoclass:: clickhouse_driver.result.ProgressQueryResult :members: :inherited-members: .. _iter-query-result: IterQueryResult --------------- .. autoclass:: clickhouse_driver.result.IterQueryResult :members: :inherited-members: clickhouse-driver-0.2.11/docs/changelog.rst000066400000000000000000000002111522645447600206370ustar00rootroot00000000000000Changelog ========= Changelog is available in `github repo `_. clickhouse-driver-0.2.11/docs/conf.py000066400000000000000000000133151522645447600174660ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # # import os # import sys # sys.path.insert(0, os.path.abspath('.')) from clickhouse_driver import __version__, VERSION # -- Project information ----------------------------------------------------- project = u'clickhouse-driver' copyright = u'2017-2022, clickhouse-driver authors' author = u'clickhouse-driver authors' # The short X.Y version version = '.'.join(str(x) for x in VERSION[:2]) # The full version, including alpha/beta/rc tags release = __version__ # -- General configuration --------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. # # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.intersphinx' ] intersphinx_mapping = { 'python3': ('http://docs.python.org/3', None), 'python2': ('http://docs.python.org/2', None), } # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] source_suffix = '.rst' # The master toctree document. master_doc = 'index' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = 'en' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. exclude_patterns = [u'_build'] # The name of the Pygments (syntax highlighting) style to use. pygments_style = None # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = 'alabaster' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # # html_theme_options = {} # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_favicon = "_static/mymarilyn-icon.png" html_logo = "" html_static_path = ['_static'] html_theme_options = { "description": "Python driver for ClickHouse", "github_user": "mymarilyn", "github_repo": "clickhouse-driver", "fixed_sidebar": True, "sidebar_width": '300px', "page_width": '1000px' } html_css_files = [ 'css/custom.css', ] # Custom sidebar templates, must be a dictionary that maps document names # to template names. # # The default sidebars (for documents that don't match any pattern) are # defined by theme itself. Builtin themes are using these templates by # default: ``['localtoc.html', 'relations.html', 'sourcelink.html', # 'searchbox.html']``. # # html_sidebars = {} # -- Options for HTMLHelp output --------------------------------------------- # Output file base name for HTML help builder. htmlhelp_basename = 'clickhouse-driverdoc' # -- Options for LaTeX output ------------------------------------------------ latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # # 'preamble': '', # Latex figure (float) alignment # # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, 'clickhouse-driver.tex', u'clickhouse-driver Documentation', author, 'manual'), ] # -- Options for manual page output ------------------------------------------ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ (master_doc, 'clickhouse-driver', u'clickhouse-driver Documentation', [author], 1) ] # -- Options for Texinfo output ---------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'clickhouse-driver', u'clickhouse-driver Documentation', author, 'clickhouse-driver', 'One line description of project.', 'Miscellaneous'), ] # -- Options for Epub output ------------------------------------------------- # Bibliographic Dublin Core info. epub_title = project # The unique identifier of the text. This can be a ISBN number # or the project homepage. # # epub_identifier = '' # A unique identification for the text. # # epub_uid = '' # A list of files that should not be packed into the epub file. epub_exclude_files = ['search.html'] clickhouse-driver-0.2.11/docs/contents.rst.inc000066400000000000000000000032671522645447600213330ustar00rootroot00000000000000User's Guide ------------ This part of the documentation focuses on step-by-step instructions for development with clickhouse-driver. Clickhouse-driver is designed to communicate with ClickHouse server from Python over native protocol. ClickHouse server provides two protocols for communication: * HTTP protocol (port 8123 by default); * Native (TCP) protocol (port 9000 by default). Each protocol has own advantages and disadvantages. Here we focus on advantages of native protocol: * Native protocol is more configurable by various settings. * Binary data transfer is more compact than text data. * Building python types from binary data is more effective than from text data. * LZ4 compression is `faster than gzip `_. Gzip compression is used in HTTP protocol. * Query profile info is available over native protocol. We can read rows before limit metric for example. Once again: clickhouse-driver uses native protocol (port 9000). There is an asynchronous wrapper for clickhouse-driver: aioch. It's available `here `_. .. toctree:: :maxdepth: 2 installation quickstart features types performance misc unsupportedserverversions API Reference ------------- If you are looking for information on a specific function, class or method, this part of the documentation is for you. .. toctree:: :maxdepth: 2 api dbapi Additional Notes ---------------- Legal information, changelog and contributing are here for the interested. .. toctree:: :maxdepth: 2 development changelog license contributing clickhouse-driver-0.2.11/docs/contributing.rst000066400000000000000000000000411522645447600214200ustar00rootroot00000000000000.. include:: ../CONTRIBUTING.rst clickhouse-driver-0.2.11/docs/dbapi.rst000066400000000000000000000011161522645447600177740ustar00rootroot00000000000000.. _dbapi: DB API 2.0 ========== This part of the documentation covers driver DB API. .. automodule:: clickhouse_driver.dbapi :members: :inherited-members: .. _dbapi-connection: Connection ---------- .. autoclass:: clickhouse_driver.dbapi.connection.Connection :members: :inherited-members: .. _dbapi-cursor: Cursor ------ .. autoclass:: clickhouse_driver.dbapi.cursor.Cursor :members: :inherited-members: Extras ------ .. _dbapi-extras: .. autoclass:: clickhouse_driver.dbapi.extras.DictCursor .. autoclass:: clickhouse_driver.dbapi.extras.NamedTupleCursor clickhouse-driver-0.2.11/docs/development.rst000066400000000000000000000045161522645447600212460ustar00rootroot00000000000000.. _development: Development =========== Test configuration ------------------ In ``setup.cfg`` you can find ClickHouse server port, credentials, logging level and another options than can be tuned during local testing. Running tests locally --------------------- Install desired Python version with system package manager/pyenv/another manager. Install test requirements and build package: .. code-block:: bash python testsrequire.py && python setup.py develop You should install cython if you want to change ``*.pyx`` files: .. code-block:: bash pip install cython ClickHouse on host machine ^^^^^^^^^^^^^^^^^^^^^^^^^^ Install desired versions of ``clickhouse-server`` and ``clickhouse-client`` on your machine. Run tests: .. code-block:: bash py.test -v ClickHouse in docker ^^^^^^^^^^^^^^^^^^^^ Create container desired version of ``clickhouse-server``: .. code-block:: bash docker run --rm -e "TZ=Europe/Moscow" -p 127.0.0.1:9000:9000 -p 127.0.0.1:9440:9440 --name test-clickhouse-server clickhouse/clickhouse-server:$VERSION Create container with the same version of ``clickhouse-client``: .. code-block:: bash docker run --rm --entrypoint "/bin/sh" --name test-clickhouse-client --link test-clickhouse-server:clickhouse-server clickhouse/clickhouse-client:$VERSION -c 'while :; do sleep 1; done' Create ``clickhouse-client`` script on your host machine: .. code-block:: bash echo -e '#!/bin/bash\n\ndocker exec -e "`env | grep ^TZ=`" test-clickhouse-client clickhouse-client "$@"' | sudo tee /usr/local/bin/clickhouse-client > /dev/null sudo chmod +x /usr/local/bin/clickhouse-client After it container ``test-clickhouse-client`` will communicate with ``test-clickhouse-server`` transparently from host machine. Set ``host=clickhouse-server`` in ``setup.cfg``. Add entry in hosts file: .. code-block:: bash echo '127.0.0.1 clickhouse-server' | sudo tee -a /etc/hosts > /dev/null Set ``TZ=UTC`` and run tests: .. code-block:: bash export TZ=UTC py.test -v GitHub Actions in forked repository ----------------------------------- Workflows in forked repositories can be used for running tests. Workflows don't run in forked repositories by default. You must enable GitHub Actions in the **Actions** tab of the forked repository. clickhouse-driver-0.2.11/docs/features.rst000066400000000000000000000626011522645447600205410ustar00rootroot00000000000000.. _features: Features ======== - Compression support: * `LZ4/LZ4HC `_ * `ZSTD `_ - TLS support (since server version 1.1.54304). .. _external-tables: External data for query processing ---------------------------------- You can pass `external data `_ alongside with query: .. code-block:: python >>> tables = [{ ... 'name': 'ext', ... 'structure': [('x', 'Int32'), ('y', 'Array(Int32)')], ... 'data': [ ... {'x': 100, 'y': [2, 4, 6, 8]}, ... {'x': 500, 'y': [1, 3, 5, 7]}, ... ] ... }] >>> client.execute( ... 'SELECT sum(x) FROM ext', external_tables=tables ... ) [(600,)] Settings -------- There are a lot of ClickHouse server `settings `_. Settings can be specified during Client initialization: .. code-block:: python # Set max number threads for all queries execution. >>> settings = {'max_threads': 2} >>> client = Client('localhost', settings=settings) Each setting can be overridden in an ``execute``, ``execute_with_progress`` and ``execute_iter`` statement: .. code-block:: python # Set lower priority to query and limit max number threads # to execute the request. >>> settings = {'max_threads': 2, 'priority': 10} >>> client.execute('SHOW TABLES', settings=settings) [('first_table',)] Compression ----------- Native protocol supports two types of compression: `LZ4 `_ and `ZSTD `_. When compression is enabled compressed data should be hashed using `CityHash algorithm `_. Additional packages should be installed in order by enable compression support, see :ref:`installation-pypi`. Enabled client-side compression can save network traffic. Client with compression support can be constructed as follows: .. code-block:: python >>> from clickhouse_driver import Client >>> client_with_lz4 = Client('localhost', compression=True) >>> client_with_lz4 = Client('localhost', compression='lz4') >>> client_with_zstd = Client('localhost', compression='zstd') .. _compression-cityhash-notes: CityHash algorithm notes ~~~~~~~~~~~~~~~~~~~~~~~~ Unfortunately ClickHouse server comes with built-in old version of CityHash algorithm (1.0.2). That's why we can't use original `CityHash `_ package. An older version is published separately at `PyPI `_. Secure connection ----------------- If package ``certifi`` is installed it will be loaded by default (*new in version 0.2.10*). There is no need in `ca_certs=certifi.where()`. .. code-block:: python >>> from clickhouse_driver import Client >>> >>> client = Client('localhost', secure=True) >>> # Using self-signed certificate. ... self_signed_client = Client( ... 'localhost', secure=True, ... ca_certs='/etc/clickhouse-server/server.crt' ... ) >>> # Using a client certificate with optional password >>> self_signed_client = Client( ... 'localhost', secure=True, ... ca_certs='/etc/clickhouse-client/ca.crt', ... certfile='/etc/clickhouse-client/client.crt', ... keyfile='/etc/clickhouse-client/client.key', ... keypass='supersecret' ... ) >>> # Disable verification. ... no_verifyed_client = Client( ... 'localhost', secure=True, verify=False ... ) Specifying query id ------------------- You can manually set query identificator for each query. UUID for example: .. code-block:: python >>> from uuid import uuid4 >>> >>> query_id = str(uuid4()) >>> print(query_id) bbd7dea3-eb63-4a21-b727-f55b420a7223 >>> client.execute( ... 'SELECT * FROM system.processes', query_id=query_id ... ) [(1, 'default', 'bbd7dea3-eb63-4a21-b727-f55b420a7223', '127.0.0.1', 57664, 'default', 'bbd7dea3-eb63-4a21-b727-f55b420a7223', '127.0.0.1', 57664, 1, 'klebedev', 'klebedev-ThinkPad-T460', 'ClickHouse python-driver', 18, 10, 3, 54406, 0, '', '', 0.004916541, 0, 0, 0, 0, 0, 0, 0, 0, 'SELECT * FROM system.processes', (25,), ('Query', 'SelectQuery', 'NetworkReceiveElapsedMicroseconds', 'ContextLock', 'RWLockAcquiredReadLocks'), (1, 1, 54, 9, 1), ('use_uncompressed_cache', 'load_balancing', 'max_memory_usage'), ('0', 'random', '10000000000'))] You can cancel query with specific id by sending another query with the same query id if option `replace_running_query `_ is set to 1. Query results are fetched by the same instance of Client that emitted query. Retrieving results in columnar form ----------------------------------- Columnar form sometimes can be more useful. .. code-block:: python >>> client.execute('SELECT arrayJoin(range(3))', columnar=True) [(0, 1, 2)] Data types checking on INSERT ----------------------------- Data types check is disabled for performance on ``INSERT`` queries. You can turn it on by `types_check` option: .. code-block:: python >>> client.execute( ... 'INSERT INTO test (x) VALUES', [('abc', )], ... types_check=True ... ) 1 Query execution statistics -------------------------- Client stores statistics about last query execution. It can be obtained by accessing `last_query` attribute. Statistics is sent from ClickHouse server and calculated on client side. `last_query` contains info about: * profile: rows before limit .. code-block:: python >>> client.execute('SELECT arrayJoin(range(100)) LIMIT 3') [(0,), (1,), (2,)] >>> client.last_query.profile_info.rows_before_limit 100 * progress: - processed rows; - processed bytes; - total rows; - written rows (*new in version 0.1.3*); - written bytes (*new in version 0.1.3*); - elapsed nanoseconds on server side (*new in version 0.2.7*); .. code-block:: python >>> client.execute('SELECT max(number) FROM numbers(10)') [(9,)] >>> client.last_query.progress.rows 10 >>> client.last_query.progress.bytes 80 >>> client.last_query.progress.total_rows 10 >>> client.last_query.progress.total_bytes 0 >>> client.last_query.progress.elapsed_ns 5328901 * elapsed time calculated on client (driver) side: .. code-block:: python >>> client.execute('SELECT sleep(1)') [(0,)] >>> client.last_query.elapsed 1.0060372352600098 Receiving server logs --------------------- Query logs can be received from server by using `send_logs_level` setting: .. code-block:: python >>> from logging.config import dictConfig >>> # Simple logging configuration. ... dictConfig({ ... 'version': 1, ... 'disable_existing_loggers': False, ... 'formatters': { ... 'standard': { ... 'format': '%(asctime)s %(levelname)-8s %(name)s: %(message)s' ... }, ... }, ... 'handlers': { ... 'default': { ... 'level': 'INFO', ... 'formatter': 'standard', ... 'class': 'logging.StreamHandler', ... }, ... }, ... 'loggers': { ... '': { ... 'handlers': ['default'], ... 'level': 'INFO', ... 'propagate': True ... }, ... } ... }) >>> >>> settings = {'send_logs_level': 'debug'} >>> client.execute('SELECT 1', settings=settings) 2018-12-14 10:24:53,873 INFO clickhouse_driver.log: [ klebedev-ThinkPad-T460 ] [ 25 ] {b328ad33-60e8-4012-b4cc-97f44a7b28f2} executeQuery: (from 127.0.0.1:57762) SELECT 1 2018-12-14 10:24:53,874 INFO clickhouse_driver.log: [ klebedev-ThinkPad-T460 ] [ 25 ] {b328ad33-60e8-4012-b4cc-97f44a7b28f2} executeQuery: Query pipeline: Expression Expression One 2018-12-14 10:24:53,875 INFO clickhouse_driver.log: [ klebedev-ThinkPad-T460 ] [ 25 ] {b328ad33-60e8-4012-b4cc-97f44a7b28f2} executeQuery: Read 1 rows, 1.00 B in 0.004 sec., 262 rows/sec., 262.32 B/sec. 2018-12-14 10:24:53,875 INFO clickhouse_driver.log: [ klebedev-ThinkPad-T460 ] [ 25 ] {b328ad33-60e8-4012-b4cc-97f44a7b28f2} MemoryTracker: Peak memory usage (for query): 40.23 KiB. [(1,)] Multiple hosts -------------- *New in version 0.1.3.* Additional connection points can be defined by using `alt_hosts`. If main connection point is unavailable driver will use next one from `alt_hosts`. This option is good for ClickHouse cluster with multiple replicas. .. code-block:: python >>> from clickhouse_driver import Client >>> client = Client('host1', alt_hosts='host2:1234,host3,host4:5678') In example above on every *new* connection driver will use following sequence of hosts if previous host is unavailable: * host1:9000; * host2:1234; * host3:9000; * host4:5678. All queries within established connection will be sent to the same host. *New in version 0.2.5.* You can specify `round_robin` parameter alongside with `alt_hosts`. The host for query execution will be picked with round-robin algorithm. .. code-block:: python >>> from clickhouse_driver import Client >>> client = Client( ... 'host1', alt_hosts='host2:1234,host3', round_robin=True ... ) >>> client.execute('SELECT 1') [(1,)] >>> client.execute('SELECT 2') [(2,)] >>> client.execute('SELECT 3') [(3,)] >>> client.execute('SELECT 4') [(4,)] In this example queries will be executed on following hosts: * `SELECT 1` will be executed on host1; * `SELECT 2` will be executed on host2; * `SELECT 3` will be executed on host3; * `SELECT 4` will be executed on host1. Connection to each host will be established on the first query to the host. All established connections will be kept until client disconnection or disposal. Python DB API 2.0 ----------------- *New in version 0.1.3.* This driver is also implements `DB API 2.0 specification `_. It can be useful for various integrations. Threads may share the module and connections. Parameters are expected in Python extended format codes, e.g. `...WHERE name=%(name)s`. .. code-block:: python >>> from clickhouse_driver import connect >>> conn = connect('clickhouse://localhost') >>> cursor = conn.cursor() >>> >>> cursor.execute('SHOW TABLES') >>> cursor.fetchall() [('test',)] >>> cursor.execute('DROP TABLE IF EXISTS test') >>> cursor.fetchall() [] >>> cursor.execute('CREATE TABLE test (x Int32) ENGINE = Memory') >>> cursor.fetchall() [] >>> cursor.executemany( ... 'INSERT INTO test (x) VALUES', ... [{'x': 100}] ... ) >>> cursor.rowcount 1 >>> cursor.executemany('INSERT INTO test (x) VALUES', [[200]]) >>> cursor.rowcount 1 >>> cursor.execute( ... 'INSERT INTO test (x) ' ... 'SELECT * FROM system.numbers LIMIT %(limit)s', ... {'limit': 3} ... ) >>> cursor.rowcount 0 >>> cursor.execute('SELECT sum(x) FROM test') >>> cursor.fetchall() [(303,)] ClickHouse native protocol is synchronous: when you emit query in connection you must read whole server response before sending next query through this connection. To make DB API thread-safe each cursor should use it's own connection to the server. In Under the hood :ref:`dbapi-cursor` is wrapper around pure :ref:`api-client`. :ref:`dbapi-connection` class is just wrapper for handling multiple cursors (clients) and do not initiate actual connections to the ClickHouse server. There are some non-standard ClickHouse-related :ref:`Cursor methods ` for: external data, settings, etc. For automatic disposal Connection and Cursor instances can be used as context managers: .. code-block:: python >>> with connect('clickhouse://localhost') as conn: >>> with conn.cursor() as cursor: >>> cursor.execute('SHOW TABLES') >>> print(cursor.fetchall()) You can use ``cursor_factory`` argument to get results as dicts or named tuples (since version 0.2.4): .. code-block:: python >>> from clickhouse_driver.dbapi.extras import DictCursor >>> with connect('clickhouse://localhost') as conn: >>> with conn.cursor(cursor_factory=DictCursor) as cursor: >>> cursor.execute('SELECT * FROM system.tables') >>> print(cursor.fetchall()) .. code-block:: python >>> from clickhouse_driver.dbapi.extras import NamedTupleCursor >>> with connect('clickhouse://localhost') as conn: >>> with conn.cursor(cursor_factory=NamedTupleCursor) as cursor: >>> cursor.execute('SELECT * FROM system.tables') >>> print(cursor.fetchall()) NumPy/Pandas support -------------------- *New in version 0.1.6.* Starting from version 0.1.6 package can SELECT and INSERT columns as NumPy arrays. Additional packages are required for :ref:`installation-numpy-support`. .. code-block:: python >>> client = Client('localhost', settings={'use_numpy': True}): >>> client.execute( ... 'SELECT * FROM system.numbers LIMIT 10000', ... columnar=True ... ) [array([ 0, 1, 2, ..., 9997, 9998, 9999], dtype=uint64)] Supported types: * Float32/64 * [U]Int8/16/32/64 * Date/DateTime('timezone')/DateTime64('timezone') * String/FixedString(N) * LowCardinality(T) * Nullable(T) Direct loading into NumPy arrays increases performance and lowers memory requirements on large amounts of rows. Direct loading into pandas DataFrame is also supported by using `query_dataframe`: .. code-block:: python >>> client = Client('localhost', settings={'use_numpy': True}) >>> client.query_dataframe(' ... 'SELECT number AS x, (number + 100) AS y ' ... 'FROM system.numbers LIMIT 10000' ... ) x y 0 0 100 1 1 101 2 2 102 3 3 103 4 4 104 ... ... ... 9995 9995 10095 9996 9996 10096 9997 9997 10097 9998 9998 10098 9999 9999 10099 [10000 rows x 2 columns] Writing pandas DataFrame is also supported with `insert_dataframe`: .. code-block:: python >>> client = Client('localhost', settings={'use_numpy': True}) >>> client.execute( ... 'CREATE TABLE test (x Int64, y Int64) Engine = Memory' ... ) >>> [] >>> df = client.query_dataframe( ... 'SELECT number AS x, (number + 100) AS y ' ... 'FROM system.numbers LIMIT 10000' ... ) >>> client.insert_dataframe('INSERT INTO test VALUES', df) >>> 10000 Starting from version 0.2.2 nullable columns are also supported. Keep in mind that nullable columns have ``object`` dtype. For convenience ``np.nan`` and ``None`` is supported as ``NULL`` values for inserting. But only ``None`` is returned after selecting for ``NULL`` values. .. code-block:: python >>> client = Client('localhost', settings={'use_numpy': True}) >>> client.execute( ... 'CREATE TABLE test (' ... 'a Nullable(Int64), ... 'b Nullable(Float64), ... 'c Nullable(String)' ... ') Engine = Memory' ... ) >>> [] >>> df = pd.DataFrame({ ... 'a': [1, None, None], ... 'b': [1.0, None, np.nan], ... 'c': ['a', None, np.nan], ... }, dtype=object) >>> client.insert_dataframe('INSERT INTO test VALUES', df) 3 >>> client.query_dataframe('SELECT * FROM test') a b c 0 1 1 a 1 None None None 2 None NaN None It's important to specify `dtype` during dataframe creation: .. code-block:: python >>> bad_df = pd.DataFrame({ ... 'a': [1, None, None], ... 'b': [1.0, None, np.nan], ... 'c': ['a', None, np.nan], ... }) >>> bad_df a b c 0 1.0 1.0 a 1 NaN NaN None 2 NaN NaN NaN >>> good_df = pd.DataFrame({ ... 'a': [1, None, None], ... 'b': [1.0, None, np.nan], ... 'c': ['a', None, np.nan], ... }, dtype=object) >>> good_df a b c 0 1 1 a 1 None None None 2 None NaN NaN As you can see float column ``b`` in ``bad_df`` has two ``NaN`` values. But ``NaN`` and ``None`` is not the same for float point numbers. ``NaN`` is ``float('nan')`` where ``None`` is representing ``NULL``. PyArrow support --------------- *New in version 0.2.11.* Package can SELECT data as PyArrow objects. Additional packages are required for :ref:`installation-pyarrow-support`. `query_arrow` returns the whole result as a ``pyarrow.Table``: .. code-block:: python >>> client = Client('localhost') >>> table = client.query_arrow( ... 'SELECT number AS x, toString(number) AS y ' ... 'FROM system.numbers LIMIT 10000' ... ) >>> table pyarrow.Table x: uint64 y: string ... `query_arrow_stream` returns a ``pyarrow.RecordBatchReader`` that yields one ``pyarrow.RecordBatch`` per ClickHouse block, so arbitrarily large results can be processed with constant memory usage: .. code-block:: python >>> client = Client('localhost') >>> reader = client.query_arrow_stream( ... 'SELECT number FROM system.numbers LIMIT 1000000' ... ) >>> for batch in reader: ... process(batch) Block size can be controlled with the ``max_block_size`` setting: .. code-block:: python >>> reader = client.query_arrow_stream( ... 'SELECT number FROM system.numbers LIMIT 1000000', ... settings={'max_block_size': 100000} ... ) The reader doesn't have to be consumed to the end: the streamed query is cancelled when the next query starts. ``NULL`` values in ``Nullable(T)`` columns are returned as proper Arrow nulls (validity bitmap) and the column keeps its original type. For example ``Nullable(Int64)`` is returned as a nullable ``int64`` Arrow column, unlike pandas where such column is converted to ``object`` or ``float64`` dtype. ClickHouse types are mapped to Arrow types as follows: +--------------------------------+------------------------------------+ | ClickHouse type | Arrow type | +================================+====================================+ | [U]Int8/16/32/64 | [u]int8/16/32/64 | +--------------------------------+------------------------------------+ | Float32/64 | float32/64 | +--------------------------------+------------------------------------+ | Bool | bool | +--------------------------------+------------------------------------+ | String/FixedString(N) | string (binary with | | | ``strings_as_bytes``) | +--------------------------------+------------------------------------+ | Date/Date32 | date32 | +--------------------------------+------------------------------------+ | DateTime([tz]) | timestamp('s'[, tz]) | +--------------------------------+------------------------------------+ | DateTime64(P[, tz]) | timestamp(unit[, tz]) | +--------------------------------+------------------------------------+ | Decimal(P, S) | decimal128(P, S) | +--------------------------------+------------------------------------+ | Enum8/16 | string | +--------------------------------+------------------------------------+ | UUID | string | +--------------------------------+------------------------------------+ | IPv4/IPv6 | string | +--------------------------------+------------------------------------+ | LowCardinality(T) | same as T | +--------------------------------+------------------------------------+ | Nullable(T) | same as T with validity bitmap | +--------------------------------+------------------------------------+ | Array(T) | list | +--------------------------------+------------------------------------+ | Map(K, V) | map | +--------------------------------+------------------------------------+ Values of other types are converted with Arrow's type inference on a best-effort basis: their Arrow representation may change in future versions. The default mapping can be overridden per column with ``arrow_types``. For most types the declared Arrow type is used as the conversion target: .. code-block:: python >>> client.query_arrow( ... 'SELECT number FROM system.numbers LIMIT 10', ... arrow_types={'number': pa.int32()} ... ) ``JSON`` columns have no default Arrow representation. Declare ``pyarrow.string()`` to get JSON text. Text output requires server-side JSON serialization with the ``output_format_native_write_json_as_string`` setting (ClickHouse 24.10 and newer): the text is passed through to Arrow without parsing. .. code-block:: python >>> client.query_arrow( ... 'SELECT j FROM test', arrow_types={'j': pa.string()}, ... settings={'output_format_native_write_json_as_string': 1} ... ) Without the setting the query raises ``ValueError``: there is deliberately no client-side serialization fallback, as it is an order of magnitude slower. On servers without the setting transform the column in the query instead: ``SELECT toJSONString(j)`` returns a plain ``String`` column and needs no ``arrow_types`` at all. Alternatively declare a struct type for structured output. With a declared struct, paths missing in a row become nulls, paths not declared in the struct are dropped and paths of varying types raise an error. Struct output works with or without the setting. The declared type is followed into nested containers: e.g. an ``Array(JSON)`` column declared as ``pa.list_(pa.string())`` yields JSON text per array element. The original ClickHouse type of every column is attached to its Arrow field as ``clickhouse_type`` metadata. Pass ``field_metadata=False`` to skip metadata generation. When the client is created with ``use_numpy=True`` (see :ref:`installation-numpy-support`), columns are converted to Arrow without copying where possible: numeric and datetime columns are passed as NumPy arrays, ``String`` columns are read from the wire directly into Arrow offset/data buffers without creating intermediate Python strings. This is significantly faster than the plain client for most column types. Automatic disposal ------------------ *New in version 0.2.2.* Each Client instance can be used as a context manager: .. code-block:: python >>> with Client('localhost') as client: >>> client.execute('SELECT 1') Upon exit, any established connection to the ClickHouse server will be closed automatically. TCP keepalive ------------- *New in version 0.2.6.* You can enable `TCP keepalive `_ on connection with ClickHouse server. This setting is disabled by default. When parameter ``tcp_keepalive`` is set to ``True`` system TCP keepalive settings are used. .. code-block:: python >>> client = Client('localhost', tcp_keepalive=True) For Linux default TCP keepalive settings can be found in: .. code-block:: bash idle_time_sec - /proc/sys/net/ipv4/tcp_keepalive_time interval_sec - /proc/sys/net/ipv4/tcp_keepalive_intvl probes - /proc/sys/net/ipv4/tcp_keepalive_probes You can also specify custom keepalive settings with tuple ``(idle_time_sec, interval_sec, probes)``: .. code-block:: python >>> client = Client('localhost', tcp_keepalive=(60, 5, 2)) .. note:: For Linux and Windows all parameters: idle time, interval and probes can be changed for socket. For Mac OS only the second parameter ``interval_sec`` can be changed for socket. ``idle_time_sec``, ``probes`` are not used, but should be specified for uniformity. clickhouse-driver-0.2.11/docs/index.rst000066400000000000000000000004321522645447600200240ustar00rootroot00000000000000Welcome to clickhouse-driver ============================ Release |release|. Welcome to clickhouse-driver's documentation. Get started with :ref:`installation` and then get an overview with the :ref:`quickstart` where common queries are described. .. include:: contents.rst.inc clickhouse-driver-0.2.11/docs/installation.rst000066400000000000000000000054401522645447600214220ustar00rootroot00000000000000.. _installation: Installation ============ Python Version -------------- Clickhouse-driver supports Python 3.9 and newer and PyPy. Build Dependencies ------------------ Starting from version *0.1.0* for building from source `gcc`, python and linux headers are required. Example for `python:alpine` docker image: .. code-block:: bash apk add gcc musl-dev By default there are wheels for Linux, Mac OS X and Windows. Packages for Linux and Mac OS X are available for python: 3.9 -- 3.14. Packages for Windows are available for python: 3.9 -- 3.14. Starting from version *0.2.3* there are wheels for musl-based Linux distributions. Dependencies ------------ These distributions will be installed automatically when installing clickhouse-driver. * `pytz`_ library for timezone calculations. * `enum34`_ backported Python 3.4 Enum. .. _pytz: http://pytz.sourceforge.net/ .. _enum34: https://pypi.org/project/enum34/ Optional dependencies ~~~~~~~~~~~~~~~~~~~~~ These distributions will not be installed automatically. Clickhouse-driver will detect and use them if you install them. * `clickhouse-cityhash`_ provides CityHash algorithm of specific version, see :ref:`compression-cityhash-notes`. * `lz4`_ enables `LZ4/LZ4HC compression `_ support. * `zstd`_ enables `ZSTD compression `_ support. .. _clickhouse-cityhash: https://pythonhosted.org/blinker/ .. _lz4: https://python-lz4.readthedocs.io/ .. _zstd: https://pypi.org/project/zstd/ .. _installation-pypi: Installation from PyPI ---------------------- The package can be installed using ``pip``: .. code-block:: bash pip install clickhouse-driver You can install extras packages if you need compression support. Example of LZ4 compression requirements installation: .. code-block:: bash pip install clickhouse-driver[lz4] You also can specify multiple extras by using comma. Install LZ4 and ZSTD requirements: .. code-block:: bash pip install clickhouse-driver[lz4,zstd] .. _installation-numpy-support: NumPy support ------------- You can install additional packages (NumPy and Pandas) if you need NumPy support: .. code-block:: bash pip install clickhouse-driver[numpy] NumPy supported versions are limited by ``numpy`` package python support. .. _installation-pyarrow-support: PyArrow support --------------- You can install additional PyArrow package if you need to query data as ``pyarrow.Table`` or ``pyarrow.RecordBatchReader``: .. code-block:: bash pip install clickhouse-driver[arrow] Installation from github ------------------------ Development version can be installed directly from github: .. code-block:: bash pip install git+https://github.com/mymarilyn/clickhouse-driver@master#egg=clickhouse-driver clickhouse-driver-0.2.11/docs/license.rst000066400000000000000000000002111522645447600203320ustar00rootroot00000000000000License ======= ClickHouse Python Driver is distributed under the `MIT license `_. clickhouse-driver-0.2.11/docs/misc.rst000066400000000000000000000112271522645447600176540ustar00rootroot00000000000000 Miscellaneous ============= Client configuring from URL --------------------------- *New in version 0.1.1.* Client can be configured from the given URL: .. code-block:: python >>> from clickhouse_driver import Client >>> client = Client.from_url( ... 'clickhouse://login:password@host:port/database' ... ) Port 9000 is default for schema ``clickhouse``, port 9440 is default for schema ``clickhouses``. Connection to default database: .. code-block:: python >>> client = Client.from_url('clickhouse://localhost') Querystring arguments will be passed along to the :meth:`~clickhouse_driver.connection.Connection` class’s initializer: .. code-block:: python >>> client = Client.from_url( ... 'clickhouse://localhost/database?send_logs_level=trace&' ... 'client_name=myclient&' ... 'compression=lz4' ... ) If parameter doesn't match Connection's init signature will be treated as settings parameter. .. _insert-from-csv-file: Inserting data from CSV file ---------------------------- Let's assume you have following data in CSV file. .. code-block:: shell $ cat /tmp/data.csv time,order,qty 2019-08-01 15:23:14,New order1,5 2019-08-05 09:14:45,New order2,3 2019-08-13 12:20:32,New order3,7 Data can be inserted into ClickHouse in the following way: .. code-block:: python >>> from csv import DictReader >>> from datetime import datetime >>> >>> from clickhouse_driver import Client >>> >>> >>> def iter_csv(filename): ... converters = { ... 'qty': int, ... 'time': lambda x: datetime.strptime(x, '%Y-%m-%d %H:%M:%S') ... } ... ... with open(filename, 'r') as f: ... reader = DictReader(f) ... for line in reader: ... yield {k: (converters[k](v) if k in converters else v) for k, v in line.items()} ... >>> client = Client('localhost') >>> >>> client.execute( ... 'CREATE TABLE IF NOT EXISTS data_csv ' ... '(' ... 'time DateTime, ' ... 'order String, ' ... 'qty Int32' ... ') Engine = Memory' ... ) >>> [] >>> client.execute('INSERT INTO data_csv VALUES', iter_csv('/tmp/data.csv')) 3 Table can be populated with json file in the similar way. Adding missed settings ---------------------- It's hard to keep package settings in consistent state with ClickHouse server's. Some settings can be missed if your server is old. But, if setting is *supported by your server* and missed in the package it can be added by simple monkey pathing. Just look into ClickHouse server source and pick corresponding setting type from package or write your own type. .. code-block:: python >>> from clickhouse_driver.settings.available import settings as available_settings, SettingBool >>> from clickhouse_driver import Client >>> >>> available_settings['allow_suspicious_low_cardinality_types'] = SettingBool >>> >>> client = Client('localhost', settings={'allow_suspicious_low_cardinality_types': True}) >>> client.execute('CREATE TABLE test (x LowCardinality(Int32)) Engine = Null') [] *New in version 0.1.5.* Modern ClickHouse servers (20.*+) use text serialization for settings instead of binary serialization. You don't have to add missed settings manually into available. Just specify new settings and it will work. .. code-block:: python >>> client = Client('localhost', settings={'brand_new_setting': 42}) >>> client.execute('SELECT 1') Inserting NULL into NOT NULL columns ------------------------------------ *New in version 0.2.4.* Client option ``input_format_null_as_default`` does the same thing as in ``clickhouse-client``. But in this package it's disabled by default. You should enable it if you want cast ``None`` value into default value for current type: .. code-block:: python >>> settings = {'input_format_null_as_default': True} >>> client = Client('localhost', settings=settings) Client revision downgrading --------------------------- *New in version 0.2.6.* For various purposes client can be downgraded with ``client_revision`` parameter. .. code-block:: python >>> from clickhouse_driver import Client, defines >>> >>> client = Client('localhost', client_revision=defines.DBMS_MIN_PROTOCOL_VERSION_WITH_INITIAL_QUERY_START_TIME) >>> client.execute('SELECT version()') clickhouse-driver-0.2.11/docs/performance.rst000066400000000000000000000604731522645447600212310ustar00rootroot00000000000000 Performance =========== This section compares clickhouse-driver performance over Native interface with TSV and JSONEachRow formats available over HTTP interface. clickhouse-driver returns already parsed row items in Python data types. Driver performs all transformation for you. When you read data over HTTP you may need to cast strings into Python types. Test data --------- Sample data for testing is taken from `ClickHouse docs `_. Create database and table: .. code-block:: sql DROP DATABASE IF EXISTS perftest; CREATE DATABASE perftest; CREATE TABLE perftest.ontime ( Year UInt16, Quarter UInt8, Month UInt8, DayofMonth UInt8, DayOfWeek UInt8, FlightDate Date, UniqueCarrier FixedString(7), AirlineID Int32, Carrier FixedString(2), TailNum String, FlightNum String, OriginAirportID Int32, OriginAirportSeqID Int32, OriginCityMarketID Int32, Origin FixedString(5), OriginCityName String, OriginState FixedString(2), OriginStateFips String, OriginStateName String, OriginWac Int32, DestAirportID Int32, DestAirportSeqID Int32, DestCityMarketID Int32, Dest FixedString(5), DestCityName String, DestState FixedString(2), DestStateFips String, DestStateName String, DestWac Int32, CRSDepTime Int32, DepTime Int32, DepDelay Int32, DepDelayMinutes Int32, DepDel15 Int32, DepartureDelayGroups String, DepTimeBlk String, TaxiOut Int32, WheelsOff Int32, WheelsOn Int32, TaxiIn Int32, CRSArrTime Int32, ArrTime Int32, ArrDelay Int32, ArrDelayMinutes Int32, ArrDel15 Int32, ArrivalDelayGroups Int32, ArrTimeBlk String, Cancelled UInt8, CancellationCode FixedString(1), Diverted UInt8, CRSElapsedTime Int32, ActualElapsedTime Int32, AirTime Int32, Flights Int32, Distance Int32, DistanceGroup UInt8, CarrierDelay Int32, WeatherDelay Int32, NASDelay Int32, SecurityDelay Int32, LateAircraftDelay Int32, FirstDepTime String, TotalAddGTime String, LongestAddGTime String, DivAirportLandings String, DivReachedDest String, DivActualElapsedTime String, DivArrDelay String, DivDistance String, Div1Airport String, Div1AirportID Int32, Div1AirportSeqID Int32, Div1WheelsOn String, Div1TotalGTime String, Div1LongestGTime String, Div1WheelsOff String, Div1TailNum String, Div2Airport String, Div2AirportID Int32, Div2AirportSeqID Int32, Div2WheelsOn String, Div2TotalGTime String, Div2LongestGTime String, Div2WheelsOff String, Div2TailNum String, Div3Airport String, Div3AirportID Int32, Div3AirportSeqID Int32, Div3WheelsOn String, Div3TotalGTime String, Div3LongestGTime String, Div3WheelsOff String, Div3TailNum String, Div4Airport String, Div4AirportID Int32, Div4AirportSeqID Int32, Div4WheelsOn String, Div4TotalGTime String, Div4LongestGTime String, Div4WheelsOff String, Div4TailNum String, Div5Airport String, Div5AirportID Int32, Div5AirportSeqID Int32, Div5WheelsOn String, Div5TotalGTime String, Div5LongestGTime String, Div5WheelsOff String, Div5TailNum String ) ENGINE = MergeTree PARTITION BY Year ORDER BY (Carrier, FlightDate) SETTINGS index_granularity = 8192; Download some data for 2017 year: .. code-block:: bash for s in `seq 2017 2017` do for m in `seq 1 12` do wget https://transtats.bts.gov/PREZIP/On_Time_Reporting_Carrier_On_Time_Performance_1987_present_${s}_${m}.zip done done Insert data into ClickHouse: .. code-block:: bash for i in *.zip; do echo $i; unzip -cq $i '*.csv' | sed 's/\.00//g' | clickhouse-client --query="INSERT INTO perftest.ontime FORMAT CSVWithNames"; done Required packages ----------------- .. code-block:: bash pip install clickhouse-driver requests clickhouse-connect For fast json parsing we'll use ``ujson`` package: .. code-block:: bash pip install ujson Installed packages: :: $ pip freeze certifi==2026.5.20 clickhouse-cityhash==1.0.2.5 clickhouse-connect==1.4.2 clickhouse-driver==0.2.11 lz4==4.4.5 numpy==2.4.6 pandas==3.0.3 pyarrow==25.0.0 pytz==2026.2 requests==2.34.2 tzlocal==5.3.1 ujson==5.13.0 urllib3==2.7.0 zstd==1.5.7.3 For ``clickhouse-connect`` we need to turn off compression with ``compress=False`` for elimination decompression overhead. This package also adds ``LIMIT`` clause to the query by default. Let's disable it off with ``query_limit=None``. Versions -------- Machine: Apple M2 Pro, 32 GiB RAM, macOS 15.1.1 ClickHouse server: 25.12.11.4 Docker image, ran locally Python: Python 3.11.11 (CPython, arm64) Benchmarking ------------ Let's pick number of rows for testing with ``clickhouse-client``. .. code-block:: sql SELECT count() FROM ontime WHERE FlightDate < '2017-01-04' 45202 .. code-block:: sql SELECT count() FROM ontime WHERE FlightDate < '2017-01-10' 131848 .. code-block:: sql SELECT count() FROM ontime WHERE FlightDate < '2017-01-16' 217015 .. code-block:: sql SELECT count() FROM ontime WHERE FlightDate < '2017-02-01' 450017 .. code-block:: sql SELECT count() FROM ontime WHERE FlightDate < '2017-02-18' 697813 Scripts below can be benchmarked with following one-liner: .. code-block:: bash for d in 2017-01-04 2017-01-10 2017-01-16 2017-02-01 2017-02-18; do python perf/script.py $d; done Each script ends its imports with ``import timing``: the clock starts there and the result is printed on process exit. Measured are: * elapsed real (wall clock) time, in seconds — interpreter startup and imports are excluded; * maximum resident set size of the process during its lifetime — includes the imported packages. .. literalinclude:: ../perf/timing.py :language: python Plain text without parsing ^^^^^^^^^^^^^^^^^^^^^^^^^^ Let's take get plain text response from ClickHouse server as baseline. Fetching not parsed data with pure requests (1) .. literalinclude:: ../perf/script_01.py :language: python Parsed rows ^^^^^^^^^^^ Line split into elements will be consider as "parsed" for TSV format (2) .. literalinclude:: ../perf/script_02.py :language: python Now we cast each element to it's data type (2.5) .. literalinclude:: ../perf/script_02_5.py :language: python JSONEachRow format can be loaded with json loads (3) .. literalinclude:: ../perf/script_03.py :language: python Get fully parsed rows with ``clickhouse-driver`` in Native format (4) .. literalinclude:: ../perf/script_04.py :language: python Get fully parsed rows with ``clickhouse-connect`` (14) .. literalinclude:: ../perf/script_14.py :language: python Iteration over rows ^^^^^^^^^^^^^^^^^^^ Iteration over TSV (5) .. literalinclude:: ../perf/script_05.py :language: python Now we cast each element to it's data type (5.5) .. literalinclude:: ../perf/script_05_5.py :language: python Iteration over JSONEachRow (6) .. literalinclude:: ../perf/script_06.py :language: python Iteration over rows with ``clickhouse-driver`` in Native format (7) .. literalinclude:: ../perf/script_07.py :language: python Iteration over rows with ``clickhouse-connect`` (17) .. literalinclude:: ../perf/script_17.py :language: python Iteration over string rows ^^^^^^^^^^^^^^^^^^^^^^^^^^ OK, but what if we need only string columns? Iteration over TSV (8) .. literalinclude:: ../perf/script_08.py :language: python Iteration over JSONEachRow (9) .. literalinclude:: ../perf/script_09.py :language: python Iteration over string rows with ``clickhouse-driver`` in Native format (10) .. literalinclude:: ../perf/script_10.py :language: python Iteration over string rows with ``clickhouse-connect`` (15) .. literalinclude:: ../perf/script_15.py :language: python Iteration over int rows ^^^^^^^^^^^^^^^^^^^^^^^ Iteration over TSV (11) .. literalinclude:: ../perf/script_11.py :language: python Iteration over JSONEachRow (12) .. literalinclude:: ../perf/script_12.py :language: python Iteration over int rows with ``clickhouse-driver`` in Native format (13) .. literalinclude:: ../perf/script_13.py :language: python Iteration over int rows with ``clickhouse-connect`` (16) .. literalinclude:: ../perf/script_16.py :language: python PyArrow tables ^^^^^^^^^^^^^^ *New in version 0.2.11.* Get query result as PyArrow Table with ``clickhouse-driver`` in Native format (18) .. literalinclude:: ../perf/script_18.py :language: python The same with NumPy fast paths enabled (19) .. literalinclude:: ../perf/script_19.py :language: python Get query result as PyArrow Table with ``clickhouse-connect`` (20) .. literalinclude:: ../perf/script_20.py :language: python PyArrow tables over typed columns ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Analytic extracts usually select a typed subset of columns instead of ``SELECT *``. The same int and string column projections as in the iteration sections above, as PyArrow tables. Int columns with ``clickhouse-driver``, ``use_numpy`` (21) .. literalinclude:: ../perf/script_21.py :language: python Int columns with ``clickhouse-connect`` (22) .. literalinclude:: ../perf/script_22.py :language: python String columns with ``clickhouse-driver``, ``use_numpy`` (23) .. literalinclude:: ../perf/script_23.py :language: python String columns with ``clickhouse-connect`` (24) .. literalinclude:: ../perf/script_24.py :language: python Results ------- This table contains memory and timing benchmark results of snippets above. JSON in table is shorthand for JSONEachRow. .. rst-class:: table-small-text table-center-header table-right-text-align-results +----------------------------------+-----------+-----------+-----------+-----------+-----------+ | | Rows | | +-----------+-----------+-----------+-----------+-----------+ | | 50k | 131k | 217k | 450k | 697k | +==================================+===========+===========+===========+===========+===========+ |**Plain text without parsing: timing** | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |Naive requests.get TSV (1) | 0.13 s | 0.28 s | 0.45 s | 0.80 s | 1.26 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |Naive requests.get JSON (1) | 0.38 s | 1.07 s | 1.81 s | 3.95 s | 7.48 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |**Plain text without parsing: memory** | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |Naive requests.get TSV (1) | 61 MB | 118 MB | 175 MB | 331 MB | 497 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |Naive requests.get JSON (1) | 221 MB | 587 MB | 935 MB | 1.48 GB | 2.84 GB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |**Parsed rows: timing** | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get TSV (2) | 0.25 s | 0.64 s | 1.31 s | 3.81 s | 6.95 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get TSV with cast (2.5) | 0.67 s | 1.69 s | 3.07 s | 7.29 s | 12.35 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get JSON (3) | 0.82 s | 2.53 s | 3.67 s | 8.05 s | 15.04 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-driver Native (4) | 0.18 s | 0.44 s | 0.67 s | 1.46 s | 2.28 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-connect (14) | 0.20 s | 0.50 s | 0.83 s | 1.70 s | 2.71 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |**Parsed rows: memory** | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get TSV (2) | 183 MB | 473 MB | 765 MB | 1.52 GB | 2.33 GB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get TSV with cast (2.5) | 142 MB | 358 MB | 536 MB | 1.12 GB | 1.73 GB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get JSON (3) | 136 MB | 303 MB | 532 MB | 1.05 GB | 1.61 GB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-driver Native (4) | 167 MB | 372 MB | 548 MB | 1.03 GB | 1.47 GB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-connect (14) | 172 MB | 384 MB | 577 MB | 1.01 GB | 1.21 GB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |**Iteration over rows: timing** | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get TSV (5) | 0.22 s | 0.54 s | 0.80 s | 1.42 s | 2.12 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get TSV with cast (5.5) | 0.52 s | 1.42 s | 2.26 s | 4.59 s | 7.34 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get JSON (6) | 0.72 s | 1.97 s | 3.13 s | 9.36 s | 10.45 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-driver Native (7) | 0.23 s | 0.56 s | 0.94 s | 1.98 s | 2.70 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-connect (17) | 0.23 s | 0.50 s | 0.78 s | 1.61 s | 2.50 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |**Iteration over rows: memory** | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get TSV (5) | 31 MB | 31 MB | 31 MB | 31 MB | 31 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get TSV with cast (5.5) | 30 MB | 31 MB | 31 MB | 31 MB | 31 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get JSON (6) | 30 MB | 32 MB | 31 MB | 30 MB | 32 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-driver Native (7) | 111 MB | 136 MB | 135 MB | 148 MB | 156 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-connect (17) | 117 MB | 136 MB | 146 MB | 162 MB | 164 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |**Iteration over string rows: timing** | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get TSV (8) | 0.11 s | 0.25 s | 0.36 s | 0.68 s | 1.17 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get JSON (9) | 0.44 s | 1.19 s | 1.95 s | 3.35 s | 5.08 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-driver Native (10) | 0.11 s | 0.26 s | 0.41 s | 0.82 s | 1.33 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-connect (15) | 0.14 s | 0.34 s | 0.55 s | 1.23 s | 1.67 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |**Iteration over string rows: memory** | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get TSV (8) | 31 MB | 30 MB | 30 MB | 31 MB | 31 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get JSON (9) | 31 MB | 31 MB | 32 MB | 31 MB | 31 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-driver Native (10) | 78 MB | 85 MB | 84 MB | 94 MB | 98 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-connect (15) | 79 MB | 104 MB | 112 MB | 125 MB | 127 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |**Iteration over int rows: timing** | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get TSV (11) | 0.27 s | 0.69 s | 1.08 s | 2.20 s | 3.40 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get JSON (12) | 0.37 s | 1.00 s | 1.49 s | 2.86 s | 4.51 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-driver Native (13) | 0.13 s | 0.20 s | 0.31 s | 0.62 s | 1.00 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-connect (16) | 0.08 s | 0.15 s | 0.23 s | 0.47 s | 0.67 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |**Iteration over int rows: memory** | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get TSV (11) | 30 MB | 31 MB | 30 MB | 31 MB | 31 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |requests.get JSON (12) | 31 MB | 31 MB | 31 MB | 32 MB | 31 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-driver Native (13) | 79 MB | 80 MB | 85 MB | 89 MB | 103 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-connect (16) | 62 MB | 81 MB | 93 MB | 105 MB | 99 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |**PyArrow tables: timing** | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-driver Native (18) | 0.51 s | 0.72 s | 0.93 s | 2.08 s | 2.96 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-driver use_numpy (19) | 0.13 s | 0.34 s | 0.48 s | 0.93 s | 1.41 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-connect (20) | 0.13 s | 0.25 s | 0.40 s | 0.87 s | 1.28 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |**PyArrow tables: memory** | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-driver Native (18) | 181 MB | 272 MB | 303 MB | 446 MB | 600 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-driver use_numpy (19) | 167 MB | 224 MB | 291 MB | 464 MB | 645 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-connect (20) | 97 MB | 170 MB | 240 MB | 435 MB | 639 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |**PyArrow tables, int columns: timing** | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-driver use_numpy (21) | 0.04 s | 0.08 s | 0.12 s | 0.21 s | 0.32 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-connect (22) | 0.05 s | 0.09 s | 0.14 s | 0.27 s | 0.39 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |**PyArrow tables, int columns: memory** | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-driver use_numpy (21) | 130 MB | 153 MB | 176 MB | 243 MB | 310 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-connect (22) | 74 MB | 106 MB | 136 MB | 218 MB | 306 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |**PyArrow tables, string columns: timing** | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-driver use_numpy (23) | 0.09 s | 0.22 s | 0.33 s | 0.83 s | 1.06 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-connect (24) | 0.09 s | 0.20 s | 0.29 s | 0.59 s | 0.92 s | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |**PyArrow tables, string columns: memory** | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-driver use_numpy (23) | 152 MB | 191 MB | 226 MB | 266 MB | 434 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ |clickhouse-connect (24) | 81 MB | 121 MB | 162 MB | 272 MB | 390 MB | +----------------------------------+-----------+-----------+-----------+-----------+-----------+ Conclusion ---------- If you need to get significant number of rows from ClickHouse server **as text** then TSV format is your choice. See **Iteration over string rows** results. But if you need to manipulate over python data types then you should take a look on drivers with Native format. For most data types driver uses binary :func:`~struct.pack` / :func:`~struct.unpack` for serialization / deserialization. Which is obviously faster than ``cls() for x in lst``. See (2.5) and (5.5). It doesn't matter which interface to use if you manipulate small amount of rows.clickhouse-driver-0.2.11/docs/quickstart.rst000066400000000000000000000174031522645447600211150ustar00rootroot00000000000000.. _quickstart: Quickstart ========== This page gives a good introduction to clickhouse-driver. It assumes you already have clickhouse-driver installed. If you do not, head over to the :ref:`installation` section. A minimal working example looks like this: .. code-block:: python >>> from clickhouse_driver import Client >>> >>> client = Client(host='localhost') >>> >>> client.execute('SHOW DATABASES') [('default',)] This code will show all tables from ``'default'`` database. There are two conceptual types of queries: - Read only queries: SELECT, SHOW, etc. - Read and write queries: INSERT. Every query should be executed by calling one of the client's execute methods: `execute`, `execute_with_progress`, `execute_iter method`. - SELECT queries can use `execute`, `execute_with_progress`, `execute_iter` methods. - INSERT queries can use only `execute` method. Selecting data -------------- Simple select query looks like: .. code-block:: python >>> client.execute('SELECT * FROM system.numbers LIMIT 5') [(0,), (1,), (2,), (3,), (4,)] Of course queries can and should be parameterized to avoid SQL injections: .. code-block:: python >>> from datetime import date >>> client.execute( ... 'SELECT %(date)s, %(a)s + %(b)s', ... {'date': date.today(), 'a': 1, 'b': 2} ... ) [('2018-10-21', 3)] Percent symbols in inlined constants should be doubled if you mix constants with ``%`` symbol and ``%(myvar)s`` parameters. .. code-block:: python >>> client.execute( ... "SELECT 'test' like '%%es%%', %(myvar)s", ... {'myvar': 1} ... ) NOTE: formatting queries using Python's f-strings or concatenation can lead to SQL injections. Use ``%(myvar)s`` parameters instead. Server-side parameters supported since 0.2.6 version. Since 0.2.7 it's disabled by default to avoid "limit" and "offset" names collision. See, `issue `_. You can decide which side parameters should be rendered into placeholders with ``server_side_params``. If it's set to: * ``True`` - parameters are rendered on server side; * ``False``- default, parameters are rendered in driver side. ``myvar`` will be rendered on server side and the actual query sent to server will be ``SELECT 'test' like '%%es%%', {myvar:Int32}``: .. code-block:: python >>> client.execute( ... "SELECT 'test' like '%%es%%', {myvar:Int32}", ... {'myvar': 1}, settings={'server_side_params': True} ... ) ``myvar`` will be rendered on driver side and the actual query sent to server will be ``SELECT 'test' like '%%es%%', 1``: .. code-block:: python >>> client.execute( ... "SELECT 'test' like '%%es%%', %(myvar)s, ... {'myvar': 1} ... ) You can't mix client-side and server-side formatting in one query. Customisation ``SELECT`` output with ``FORMAT`` clause is not supported. .. _execute-with-progress: Selecting data with progress statistics --------------------------------------- You can get query progress statistics by using `execute_with_progress`. It can be useful for cancelling long queries. .. code-block:: python >>> from datetime import datetime >>> >>> progress = client.execute_with_progress( ... 'LONG AND COMPLICATED QUERY' ... ) >>> >>> timeout = 20 >>> started_at = datetime.now() >>> >>> for num_rows, total_rows in progress: ... if total_rows: ... done = float(num_rows) / total_rows ... else: ... done = total_rows ... ... now = datetime.now() ... elapsed = (now - started_at).total_seconds() ... # Cancel query if it takes more than 20 seconds ... # to process 50% of rows. ... if elapsed > timeout and done < 0.5: ... client.cancel() ... break ... else: ... rv = progress.get_result() ... print(rv) ... .. _execute-iter: Streaming results ----------------- When you are dealing with large datasets block by block results streaming may be useful: .. code-block:: python >>> settings = {'max_block_size': 100000} >>> rows_gen = client.execute_iter( ... 'QUERY WITH MANY ROWS', settings=settings ... ) >>> >>> for row in rows_gen: ... print(row) ... Inserting data -------------- Insert queries in `Native protocol `_ are a little bit tricky because of ClickHouse's columnar nature. And because we're using Python. INSERT query consists of two parts: query statement and query values. Query values are split into chunks called blocks. Each block is sent in binary columnar form. As data in each block is sent in binary we should not serialize into string by using substitution ``%(a)s`` and then deserialize it back into Python types. This INSERT would be extremely slow if executed with thousands rows of data: .. code-block:: python >>> client.execute( ... 'INSERT INTO test (x) VALUES (%(a)s), (%(b)s), ...', ... {'a': 1, 'b': 2, ...} ... ) To insert data efficiently, provide data separately, and end your statement with a ``VALUES`` clause: .. code-block:: python >>> client.execute( ... 'INSERT INTO test (x) VALUES', ... [{'x': 1}, {'x': 2}, {'x': 3}, {'x': 100}] ... ) 4 >>> client.execute( ... 'INSERT INTO test (x) VALUES', ... [[200]] ... ) 1 >>> client.execute( ... 'INSERT INTO test (x) VALUES', ... ((x, ) for x in range(5)) ... ) 5 You can use any iterable yielding lists, tuples or dicts. If data is not passed, connection will be terminated after a timeout. .. code-block:: python >>> client.execute('INSERT INTO test (x) VALUES') # will hang The following WILL NOT work: .. code-block:: python >>> client.execute( ... 'INSERT INTO test (x) VALUES (%(a)s), (%(b)s)', ... {'a': 1, 'b': 2} ... ) Of course for ``INSERT ... SELECT`` queries data is not needed: .. code-block:: python >>> client.execute( ... 'INSERT INTO test (x) ' ... 'SELECT * FROM system.numbers LIMIT %(limit)s', ... {'limit': 5} ... ) [] ClickHouse will execute this query like a usual ``SELECT`` query. Inserting data in different formats with ``FORMAT`` clause is not supported. See :ref:`insert-from-csv-file` if you need to data in custom format. DDL --- DDL queries can be executed in the same way SELECT queries are executed: .. code-block:: python >>> client.execute('DROP TABLE IF EXISTS test') [] >>> client.execute('CREATE TABLE test (x Int32) ENGINE = Memory') [] Async and multithreading ------------------------ Every ClickHouse query is assigned an identifier to enable request execution tracking. However, ClickHouse native protocol is synchronous: all incoming queries are executed consecutively. Clickhouse-driver does not yet implement a connection pool. To utilize ClickHouse's asynchronous capability you should either use multiple Client instances or implement a queue. The same thing is applied to multithreading. Queries from different threads can't use one Client instance with single connection. You should use different clients for different threads. However, if you are using DB API for communication with the server each cursor create its own Client instance. This makes communication thread-safe. clickhouse-driver-0.2.11/docs/types.rst000066400000000000000000000316211522645447600200650ustar00rootroot00000000000000 Supported types =============== Each ClickHouse type is deserialized to a corresponding Python type when SELECT queries are prepared. When serializing INSERT queries, clickhouse-driver accepts a broader range of Python types. The following ClickHouse types are supported by clickhouse-driver: [U]Int8/16/32/64/128/256 ------------------------ INSERT types: :class:`int`, :class:`long`. SELECT type: :class:`int`. Float32/64 ---------- INSERT types: :class:`float`, :class:`int`, :class:`long`. SELECT type: :class:`float`. Date/Date32 ----------- *Date32 support is new in version 0.2.2.* INSERT types: :class:`~datetime.date`, :class:`~datetime.datetime`. SELECT type: :class:`~datetime.date`. Since version 0.2.8 you can save memory in your application. During package initialization special date lookup table (LUT) was always build for whole supported date range. It takes some time and ~40MB of memory. This table is used for fast Date columns (de)serialization. Now you can control LUT initialization process. There are 3 options: * Static initialization with whole date range like it was before 0.2.8. Default. * Lazy initialization. LUT will filled during Date columns processing. To enable this option set ``CLICKHOUSE_DRIVER_LASY_DATE_LUT`` environment variable with non-empty value. Example ``CLICKHOUSE_DRIVER_LASY_DATE_LUT=1``. * Lazy with static partial date range initialization. To enable this option set ``CLICKHOUSE_DRIVER_LASY_DATE_LUT`` environment variable with desired date range. LUT will partially filled with specified date range. If some date is not in this interval LUT will be lazy updated. Example ``CLICKHOUSE_DRIVER_LASY_DATE_LUT=2000-01-01:2030-01-01``. DateTime('timezone')/DateTime64('timezone') ------------------------------------------- *Timezone support is new in version 0.0.11.* *DateTime64 support is new in version 0.1.3.* INSERT types: :class:`~datetime.datetime`, :class:`int`, :class:`long`. Integers are interpreted as seconds without timezone (UNIX timestamps). Integers can be used when insertion of datetime column is a bottleneck. SELECT type: :class:`~datetime.datetime`. Setting `use_client_time_zone `_ is taken into consideration. You can cast DateTime column to integers if you are facing performance issues when selecting large amount of rows. Due to Python's current limitations minimal DateTime64 resolution is one microsecond. String/FixedString(N) --------------------- INSERT types: :class:`str`, :class:`bytes`. See note below. SELECT type: :class:`str`, :class:`bytes`. See note below. String column is encoded/decoded with encoding specified by ``strings_encoding`` setting. Default encoding is UTF-8. You can specify custom encoding: .. code-block:: python >>> settings = {'strings_encoding': 'cp1251'} >>> rows = client.execute( ... 'SELECT * FROM table_with_strings', ... settings=settings ... ) Encoding is applied to all string fields in query. String columns can be returned without any decoding. In this case return values are `bytes`: .. code-block:: python >>> settings = {'strings_as_bytes': True} >>> rows = client.execute( ... 'SELECT * FROM table_with_strings', ... settings=settings ... ) If a column has FixedString type, upon returning from SELECT it may contain trailing zeroes in accordance with ClickHouse's storage format. Trailing zeroes are stripped by driver for convenience. During SELECT, if a string cannot be decoded with specified encoding, it will return as :class:`bytes`. During INSERT, if ``strings_as_bytes`` setting is not specified and string cannot be encoded with encoding, a ``UnicodeEncodeError`` will be raised. Enum8/16 -------- INSERT types: :class:`~enum.Enum`, :class:`int`, :class:`long`, :class:`str`. SELECT type: :class:`str`. .. code-block:: python >>> from enum import IntEnum >>> >>> class MyEnum(IntEnum): ... foo = 1 ... bar = 2 ... >>> client.execute('DROP TABLE IF EXISTS test') [] >>> client.execute(''' ... CREATE TABLE test ... ( ... x Enum8('foo' = 1, 'bar' = 2) ... ) ENGINE = Memory ... ''') [] >>> client.execute( ... 'INSERT INTO test (x) VALUES', ... [{'x': MyEnum.foo}, {'x': 'bar'}, {'x': 1}] ... ) 3 >>> client.execute('SELECT * FROM test') [('foo',), ('bar',), ('foo',)] *Starting from version 0.2.9* clickhouse-driver can handle special enum values: ``'mro'`` and ``''``. Array(T) -------- INSERT types: :class:`list`, :class:`tuple`. SELECT type: :class:`list`. *Versions before 0.1.4:* SELECT type: :class:`tuple`. .. code-block:: python >>> client.execute('DROP TABLE IF EXISTS test') [] >>> client.execute( ... 'CREATE TABLE test (x Array(Int32)) ' ... 'ENGINE = Memory' ... ) [] >>> client.execute( ... 'INSERT INTO test (x) VALUES', ... [{'x': [10, 20, 30]}, {'x': [11, 21, 31]}] ... ) 2 >>> client.execute('SELECT * FROM test') [((10, 20, 30),), ((11, 21, 31),)] Nullable(T) ----------- INSERT types: :data:`~types.NoneType`, ``T``. SELECT type: :data:`~types.NoneType`, ``T``. Bool ---- INSERT types: :class:`bool`, SELECT type: :class:`bool`. UUID ---- INSERT types: :class:`str`, :class:`~uuid.UUID`. SELECT type: :class:`~uuid.UUID`. Decimal ------- *New in version 0.0.16.* INSERT types: :class:`~decimal.Decimal`, :class:`float`, :class:`int`, :class:`long`. SELECT type: :class:`~decimal.Decimal`. Supported subtypes: * Decimal(P, S). * Decimal32(S). * Decimal64(S). * Decimal128(S). * Decimal256(S). *New in version 0.2.1.* IPv4/IPv6 --------- *New in version 0.0.19.* INSERT types: :class:`~ipaddress.IPv4Address`/:class:`~ipaddress.IPv6Address`, :class:`int`, :class:`long`, :class:`str`. SELECT type: :class:`~ipaddress.IPv4Address`/:class:`~ipaddress.IPv6Address`. .. code-block:: python >>> from ipaddress import IPv4Address, IPv6Address >>> >>> client.execute('DROP TABLE IF EXISTS test') [] >>> client.execute( ... 'CREATE TABLE test (x IPv4) ' ... 'ENGINE = Memory' ... ) [] >>> client.execute( ... 'INSERT INTO test (x) VALUES', [ ... {'x': '192.168.253.42'}, ... {'x': 167772161}, ... {'x': IPv4Address('192.168.253.42')} ... ]) 3 >>> client.execute('SELECT * FROM test') [(IPv4Address('192.168.253.42'),), (IPv4Address('10.0.0.1'),), (IPv4Address('192.168.253.42'),)] >>> >>> client.execute('DROP TABLE IF EXISTS test') [] >>> client.execute( ... 'CREATE TABLE test (x IPv6) ' ... 'ENGINE = Memory' ... ) [] >>> client.execute( ... 'INSERT INTO test (x) VALUES', [ ... {'x': '79f4:e698:45de:a59b:2765:28e3:8d3a:35ae'}, ... {'x': IPv6Address('12ff:0000:0000:0000:0000:0000:0000:0001')}, ... {'x': b"y\xf4\xe6\x98E\xde\xa5\x9b'e(\xe3\x8d:5\xae"} ... ]) 3 >>> client.execute('SELECT * FROM test') [(IPv6Address('79f4:e698:45de:a59b:2765:28e3:8d3a:35ae'),), (IPv6Address('12ff::1'),), (IPv6Address('79f4:e698:45de:a59b:2765:28e3:8d3a:35ae'),)] >>> LowCardinality(T) ----------------- *New in version 0.0.20.* INSERT types: ``T``. SELECT type: ``T``. SimpleAggregateFunction(F, T) ----------------------------- *New in version 0.0.21.* INSERT types: ``T``. SELECT type: ``T``. AggregateFunctions for `AggregatingMergeTree` Engine are not supported. Tuple(T1, T2, ...) ------------------ *New in version 0.1.4.* INSERT types: :class:`list`, :class:`tuple`. SELECT type: :class:`tuple`. .. note:: Currently, for ClickHouse server 23.3.1, JSON column ``Object('json')`` and **namedtuple** column ``Tuple(b Int8)`` have the same binary representation. There is no way to distinct one column from another without additional inspection like ``DESCRIBE TABLE`` `query `_. But this will not work for complicated queries with joins. To interpret ClickHouse namedtuple column alongside with ``allow_experimental_object_type=1`` as Python tuple set ``namedtuple_as_json`` setting to ``False``. .. code-block:: python client.execute(..., settings={'namedtuple_as_json': False}) .. code-block:: sql CREATE TABLE test ( a Tuple(b Int8), c Object('json') ) ENGINE = Memory INSERT INTO test VALUES ((1), '{"x": 2}'); .. code-block:: python >>> client.execute('SELECT * FROM test') [((1,), (2,))] >>> client.execute( ... 'SELECT * FROM test', ... settings={'allow_experimental_object_type': 1} ... ) [({'b': 1}, {'x': 2})] >>> client.execute( ... 'SELECT * FROM test', ... settings={ ... 'allow_experimental_object_type': 1, ... 'namedtuple_as_json': False ... } ... ) [((1,), (2,))] Nested(flatten_nested=1, default) --------------------------------- Nested type is represented by sequence of arrays when flatten_nested=1. In example below actual columns for are ``col.name`` and ``col.version``. .. code-block:: sql :) CREATE TABLE test_nested (col Nested(name String, version UInt32)) Engine = Memory; CREATE TABLE test_nested ( `col` Nested(name String, version UInt32) ) ENGINE = Memory Ok. 0 rows in set. Elapsed: 0.005 sec. :) DESCRIBE TABLE test_nested FORMAT TSV; DESCRIBE TABLE test_nested FORMAT TSV col.name Array(String) col.version Array(UInt32) 2 rows in set. Elapsed: 0.004 sec. Inserting data into nested column in ``clickhouse-client``: .. code-block:: sql :) INSERT INTO test_nested VALUES (['a', 'b', 'c'], [100, 200, 300]); INSERT INTO test_nested VALUES Ok. 1 rows in set. Elapsed: 0.003 sec. Inserting data into nested column with ``clickhouse-driver``: .. code-block:: python client.execute('INSERT INTO test_nested VALUES', [ (['a', 'b', 'c'], [100, 200, 300]), ]) Nested(flatten_nested=0) ------------------------ Nested type is represented by array of named tuples when flatten_nested=0. .. code-block:: sql :) SET flatten_nested = 0; SET flatten_nested = 0 Ok. 0 rows in set. Elapsed: 0.006 sec. :) CREATE TABLE test_nested (col Nested(name String, version UInt32)) Engine = Memory; CREATE TABLE test_nested ( `col` Nested(name String, version UInt32) ) ENGINE = Memory Ok. 0 rows in set. Elapsed: 0.005 sec. :) DESCRIBE TABLE test_nested FORMAT TSV; DESCRIBE TABLE test_nested FORMAT TSV col Nested(name String, version UInt32) 1 rows in set. Elapsed: 0.004 sec. Inserting data into nested column in ``clickhouse-client``: .. code-block:: sql :) INSERT INTO test_nested VALUES ([('a', 100), ('b', 200), ('c', 300)]); INSERT INTO test_nested VALUES Ok. 1 rows in set. Elapsed: 0.003 sec. Inserting data into nested column with ``clickhouse-driver``: .. code-block:: python client.execute( 'INSERT INTO test_nested VALUES', [ ([('a', 100), ('b', 200), ('c', 300)], ) ]) # or client.execute( 'INSERT INTO test_nested VALUES', [ {'col': [ {'name': 'a', 'version': 100}, {'name': 'b', 'version': 200}, {'name': 'c', 'version': 300} ]} ]) Map(key, value) ------------------ *New in version 0.2.1.* INSERT types: :class:`dict`. SELECT type: :class:`dict`. Geo --- *New in version 0.2.4.* Point, Ring, Polygon, MultiPolygon. These types are just aliases: * Point: Tuple(Float64, Float64) * Ring: Array(Point) * Polygon: Array(Ring) * MultiPolygon: Array(Polygon) Object('json') -------------- *New in version 0.2.6.* INSERT types: :class:`dict`. SELECT type: :class:`dict`, :class:`str`. ``orjson`` and ``ujson`` implementations are supported for dumping data into json during ``INSERT``. Set ``allow_experimental_object_type=1`` for to enable json support. JSON -------------- *New in version 0.2.11.* INSERT types: :class:`dict`, :class:`str` (JSON text). SELECT type: :class:`dict`, :class:`str`. Set ``enable_json_type=1`` for to enable json support. ``JSON`` columns nested in container columns, e.g. ``Array(JSON)``, ``Tuple(String, JSON)``, ``Map(String, JSON)`` and their compositions, can be written and read as well. clickhouse-driver-0.2.11/docs/unsupportedserverversions.rst000066400000000000000000000003361522645447600243300ustar00rootroot00000000000000 Unsupported server versions =========================== Following versions are not supported by this package: - 20.1.*. Due to keeping alias type name to metadata. However you can use these versions for your own risk. clickhouse-driver-0.2.11/perf/000077500000000000000000000000001522645447600161705ustar00rootroot00000000000000clickhouse-driver-0.2.11/perf/script_01.py000066400000000000000000000004411522645447600203450ustar00rootroot00000000000000# /// script # dependencies = [ # "requests==2.34.2", # ] # /// import sys import requests import timing query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}' FORMAT {}".format(sys.argv[1], sys.argv[2]) data = requests.get('http://localhost:8123/', params={'query': query}) clickhouse-driver-0.2.11/perf/script_02.py000066400000000000000000000005731522645447600203540ustar00rootroot00000000000000# /// script # dependencies = [ # "requests==2.34.2", # ] # /// import sys import requests import timing query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}' FORMAT TSV".format(sys.argv[1]) resp = requests.get('http://localhost:8123/', stream=True, params={'query': query}) data = [line.decode('utf-8').split('\t') for line in resp.iter_lines(chunk_size=10000)] clickhouse-driver-0.2.11/perf/script_02_5.py000066400000000000000000000020571522645447600205770ustar00rootroot00000000000000# /// script # dependencies = [ # "requests==2.34.2", # ] # /// from datetime import date import sys import requests import timing def get_python_type(ch_type): if ch_type.startswith('Int') or ch_type.startswith('UInt'): return int elif ch_type == 'String' or ch_type.startswith('FixedString'): return None elif ch_type == 'Date': return lambda value: date(*[int(x) for x in value.split('-')]) raise ValueError(f'Unsupported type: "{ch_type}"') resp = requests.get('http://localhost:8123', params={'query': 'describe table perftest.ontime FORMAT TSV'}) ch_types = [x.split('\t')[1] for x in resp.text.split('\n') if x] python_types = [get_python_type(x) for x in ch_types] query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}' FORMAT TSV".format(sys.argv[1]) resp = requests.get('http://localhost:8123/', stream=True, params={'query': query}) data = [] for line in resp.iter_lines(chunk_size=10000): data.append([cls(x) if cls else x for x, cls in zip(line.decode('utf-8').split('\t'), python_types)]) clickhouse-driver-0.2.11/perf/script_03.py000066400000000000000000000006541522645447600203550ustar00rootroot00000000000000# /// script # dependencies = [ # "requests==2.34.2", # "ujson==5.13.0", # ] # /// import sys import requests from ujson import loads import timing query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}' FORMAT JSONEachRow".format(sys.argv[1]) resp = requests.get('http://localhost:8123/', stream=True, params={'query': query}) data = [list(loads(line).values()) for line in resp.iter_lines(chunk_size=10000)] clickhouse-driver-0.2.11/perf/script_04.py000066400000000000000000000004621522645447600203530ustar00rootroot00000000000000# /// script # dependencies = [ # "clickhouse-driver==0.2.11", # ] # /// import sys from clickhouse_driver import Client import timing query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}'".format(sys.argv[1]) client = Client.from_url('clickhouse://localhost') data = client.execute(query) clickhouse-driver-0.2.11/perf/script_05.py000066400000000000000000000005761522645447600203620ustar00rootroot00000000000000# /// script # dependencies = [ # "requests==2.34.2", # ] # /// import sys import requests import timing query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}' FORMAT TSV".format(sys.argv[1]) resp = requests.get('http://localhost:8123/', stream=True, params={'query': query}) for line in resp.iter_lines(chunk_size=10000): line = line.decode('utf-8').split('\t') clickhouse-driver-0.2.11/perf/script_05_5.py000066400000000000000000000020361522645447600205770ustar00rootroot00000000000000# /// script # dependencies = [ # "requests==2.34.2", # ] # /// from datetime import date import sys import requests import timing def get_python_type(ch_type): if ch_type.startswith('Int') or ch_type.startswith('UInt'): return int elif ch_type == 'String' or ch_type.startswith('FixedString'): return None elif ch_type == 'Date': return lambda value: date(*[int(x) for x in value.split('-')]) raise ValueError(f'Unsupported type: "{ch_type}"') resp = requests.get('http://localhost:8123', params={'query': 'describe table perftest.ontime FORMAT TSV'}) ch_types = [x.split('\t')[1] for x in resp.text.split('\n') if x] python_types = [get_python_type(x) for x in ch_types] query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}' FORMAT TSV".format(sys.argv[1]) resp = requests.get('http://localhost:8123/', stream=True, params={'query': query}) for line in resp.iter_lines(chunk_size=10000): line = [cls(x) if cls else x for x, cls in zip(line.decode('utf-8').split('\t'), python_types)] clickhouse-driver-0.2.11/perf/script_06.py000066400000000000000000000006551522645447600203610ustar00rootroot00000000000000# /// script # dependencies = [ # "requests==2.34.2", # "ujson==5.13.0", # ] # /// import sys import requests from ujson import loads import timing query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}' FORMAT JSONEachRow".format(sys.argv[1]) resp = requests.get('http://localhost:8123/', stream=True, params={'query': query}) for line in resp.iter_lines(chunk_size=10000): line = list(loads(line).values()) clickhouse-driver-0.2.11/perf/script_07.py000066400000000000000000000005031522645447600203520ustar00rootroot00000000000000# /// script # dependencies = [ # "clickhouse-driver==0.2.11", # ] # /// import sys from clickhouse_driver import Client import timing query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}'".format(sys.argv[1]) client = Client.from_url('clickhouse://localhost') for row in client.execute_iter(query): pass clickhouse-driver-0.2.11/perf/script_08.py000066400000000000000000000025421522645447600203600ustar00rootroot00000000000000# /// script # dependencies = [ # "requests==2.34.2", # ] # /// import sys import requests import timing cols = [ 'UniqueCarrier', 'Carrier', 'TailNum', 'FlightNum', 'Origin', 'OriginCityName', 'OriginState', 'OriginStateFips', 'OriginStateName', 'Dest', 'DestCityName', 'DestState', 'DestStateFips', 'DestStateName', 'DepartureDelayGroups', 'DepTimeBlk', 'ArrTimeBlk', 'CancellationCode', 'FirstDepTime', 'TotalAddGTime', 'LongestAddGTime', 'DivAirportLandings', 'DivReachedDest', 'DivActualElapsedTime', 'DivArrDelay', 'DivDistance', 'Div1Airport', 'Div1WheelsOn', 'Div1TotalGTime', 'Div1LongestGTime', 'Div1WheelsOff', 'Div1TailNum', 'Div2Airport', 'Div2WheelsOn', 'Div2TotalGTime', 'Div2LongestGTime', 'Div2WheelsOff', 'Div2TailNum', 'Div3Airport', 'Div3WheelsOn', 'Div3TotalGTime', 'Div3LongestGTime', 'Div3WheelsOff', 'Div3TailNum', 'Div4Airport', 'Div4WheelsOn', 'Div4TotalGTime', 'Div4LongestGTime', 'Div4WheelsOff', 'Div4TailNum', 'Div5Airport', 'Div5WheelsOn', 'Div5TotalGTime', 'Div5LongestGTime', 'Div5WheelsOff', 'Div5TailNum' ] query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}' FORMAT TSV".format(', '.join(cols), sys.argv[1]) resp = requests.get('http://localhost:8123/', stream=True, params={'query': query}) for line in resp.iter_lines(chunk_size=10000): line = line.decode('utf-8').split('\t') clickhouse-driver-0.2.11/perf/script_09.py000066400000000000000000000026231522645447600203610ustar00rootroot00000000000000# /// script # dependencies = [ # "requests==2.34.2", # "ujson==5.13.0", # ] # /// import sys import requests from ujson import loads import timing cols = [ 'UniqueCarrier', 'Carrier', 'TailNum', 'FlightNum', 'Origin', 'OriginCityName', 'OriginState', 'OriginStateFips', 'OriginStateName', 'Dest', 'DestCityName', 'DestState', 'DestStateFips', 'DestStateName', 'DepartureDelayGroups', 'DepTimeBlk', 'ArrTimeBlk', 'CancellationCode', 'FirstDepTime', 'TotalAddGTime', 'LongestAddGTime', 'DivAirportLandings', 'DivReachedDest', 'DivActualElapsedTime', 'DivArrDelay', 'DivDistance', 'Div1Airport', 'Div1WheelsOn', 'Div1TotalGTime', 'Div1LongestGTime', 'Div1WheelsOff', 'Div1TailNum', 'Div2Airport', 'Div2WheelsOn', 'Div2TotalGTime', 'Div2LongestGTime', 'Div2WheelsOff', 'Div2TailNum', 'Div3Airport', 'Div3WheelsOn', 'Div3TotalGTime', 'Div3LongestGTime', 'Div3WheelsOff', 'Div3TailNum', 'Div4Airport', 'Div4WheelsOn', 'Div4TotalGTime', 'Div4LongestGTime', 'Div4WheelsOff', 'Div4TailNum', 'Div5Airport', 'Div5WheelsOn', 'Div5TotalGTime', 'Div5LongestGTime', 'Div5WheelsOff', 'Div5TailNum' ] query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}' FORMAT JSONEachRow".format(', '.join(cols), sys.argv[1]) resp = requests.get('http://localhost:8123/', stream=True, params={'query': query}) for line in resp.iter_lines(chunk_size=10000): line = list(loads(line).values()) clickhouse-driver-0.2.11/perf/script_10.py000066400000000000000000000024471522645447600203550ustar00rootroot00000000000000# /// script # dependencies = [ # "clickhouse-driver==0.2.11", # ] # /// import sys from clickhouse_driver import Client import timing cols = [ 'UniqueCarrier', 'Carrier', 'TailNum', 'FlightNum', 'Origin', 'OriginCityName', 'OriginState', 'OriginStateFips', 'OriginStateName', 'Dest', 'DestCityName', 'DestState', 'DestStateFips', 'DestStateName', 'DepartureDelayGroups', 'DepTimeBlk', 'ArrTimeBlk', 'CancellationCode', 'FirstDepTime', 'TotalAddGTime', 'LongestAddGTime', 'DivAirportLandings', 'DivReachedDest', 'DivActualElapsedTime', 'DivArrDelay', 'DivDistance', 'Div1Airport', 'Div1WheelsOn', 'Div1TotalGTime', 'Div1LongestGTime', 'Div1WheelsOff', 'Div1TailNum', 'Div2Airport', 'Div2WheelsOn', 'Div2TotalGTime', 'Div2LongestGTime', 'Div2WheelsOff', 'Div2TailNum', 'Div3Airport', 'Div3WheelsOn', 'Div3TotalGTime', 'Div3LongestGTime', 'Div3WheelsOff', 'Div3TailNum', 'Div4Airport', 'Div4WheelsOn', 'Div4TotalGTime', 'Div4LongestGTime', 'Div4WheelsOff', 'Div4TailNum', 'Div5Airport', 'Div5WheelsOn', 'Div5TotalGTime', 'Div5LongestGTime', 'Div5WheelsOff', 'Div5TailNum' ] query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}'".format(', '.join(cols), sys.argv[1]) client = Client.from_url('clickhouse://localhost') for row in client.execute_iter(query): pass clickhouse-driver-0.2.11/perf/script_11.py000066400000000000000000000023341522645447600203510ustar00rootroot00000000000000# /// script # dependencies = [ # "requests==2.34.2", # ] # /// import sys import requests import timing cols = [ 'Year', 'Quarter', 'Month', 'DayofMonth', 'DayOfWeek', 'AirlineID', 'OriginAirportID', 'OriginAirportSeqID', 'OriginCityMarketID', 'OriginWac', 'DestAirportID', 'DestAirportSeqID', 'DestCityMarketID', 'DestWac', 'CRSDepTime', 'DepTime', 'DepDelay', 'DepDelayMinutes', 'DepDel15', 'TaxiOut', 'WheelsOff', 'WheelsOn', 'TaxiIn', 'CRSArrTime', 'ArrTime', 'ArrDelay', 'ArrDelayMinutes', 'ArrDel15', 'ArrivalDelayGroups', 'Cancelled', 'Diverted', 'CRSElapsedTime', 'ActualElapsedTime', 'AirTime', 'Flights', 'Distance', 'DistanceGroup', 'CarrierDelay', 'WeatherDelay', 'NASDelay', 'SecurityDelay', 'LateAircraftDelay', 'Div1AirportID', 'Div1AirportSeqID', 'Div2AirportID', 'Div2AirportSeqID', 'Div3AirportID', 'Div3AirportSeqID', 'Div4AirportID', 'Div4AirportSeqID', 'Div5AirportID', 'Div5AirportSeqID' ] query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}' FORMAT TSV".format(', '.join(cols), sys.argv[1]) resp = requests.get('http://localhost:8123/', stream=True, params={'query': query}) for line in resp.iter_lines(chunk_size=10000): line = [int(x) for x in line.split(b'\t')] clickhouse-driver-0.2.11/perf/script_12.py000066400000000000000000000024121522645447600203470ustar00rootroot00000000000000# /// script # dependencies = [ # "requests==2.34.2", # "ujson==5.13.0", # ] # /// import sys import requests from ujson import loads import timing cols = [ 'Year', 'Quarter', 'Month', 'DayofMonth', 'DayOfWeek', 'AirlineID', 'OriginAirportID', 'OriginAirportSeqID', 'OriginCityMarketID', 'OriginWac', 'DestAirportID', 'DestAirportSeqID', 'DestCityMarketID', 'DestWac', 'CRSDepTime', 'DepTime', 'DepDelay', 'DepDelayMinutes', 'DepDel15', 'TaxiOut', 'WheelsOff', 'WheelsOn', 'TaxiIn', 'CRSArrTime', 'ArrTime', 'ArrDelay', 'ArrDelayMinutes', 'ArrDel15', 'ArrivalDelayGroups', 'Cancelled', 'Diverted', 'CRSElapsedTime', 'ActualElapsedTime', 'AirTime', 'Flights', 'Distance', 'DistanceGroup', 'CarrierDelay', 'WeatherDelay', 'NASDelay', 'SecurityDelay', 'LateAircraftDelay', 'Div1AirportID', 'Div1AirportSeqID', 'Div2AirportID', 'Div2AirportSeqID', 'Div3AirportID', 'Div3AirportSeqID', 'Div4AirportID', 'Div4AirportSeqID', 'Div5AirportID', 'Div5AirportSeqID' ] query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}' FORMAT JSONEachRow".format(', '.join(cols), sys.argv[1]) resp = requests.get('http://localhost:8123/', stream=True, params={'query': query}) for line in resp.iter_lines(chunk_size=10000): line = list(loads(line).values()) clickhouse-driver-0.2.11/perf/script_13.py000066400000000000000000000022401522645447600203470ustar00rootroot00000000000000# /// script # dependencies = [ # "clickhouse-driver==0.2.11", # ] # /// import sys from clickhouse_driver import Client import timing cols = [ 'Year', 'Quarter', 'Month', 'DayofMonth', 'DayOfWeek', 'AirlineID', 'OriginAirportID', 'OriginAirportSeqID', 'OriginCityMarketID', 'OriginWac', 'DestAirportID', 'DestAirportSeqID', 'DestCityMarketID', 'DestWac', 'CRSDepTime', 'DepTime', 'DepDelay', 'DepDelayMinutes', 'DepDel15', 'TaxiOut', 'WheelsOff', 'WheelsOn', 'TaxiIn', 'CRSArrTime', 'ArrTime', 'ArrDelay', 'ArrDelayMinutes', 'ArrDel15', 'ArrivalDelayGroups', 'Cancelled', 'Diverted', 'CRSElapsedTime', 'ActualElapsedTime', 'AirTime', 'Flights', 'Distance', 'DistanceGroup', 'CarrierDelay', 'WeatherDelay', 'NASDelay', 'SecurityDelay', 'LateAircraftDelay', 'Div1AirportID', 'Div1AirportSeqID', 'Div2AirportID', 'Div2AirportSeqID', 'Div3AirportID', 'Div3AirportSeqID', 'Div4AirportID', 'Div4AirportSeqID', 'Div5AirportID', 'Div5AirportSeqID' ] query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}'".format(', '.join(cols), sys.argv[1]) client = Client.from_url('clickhouse://localhost') for row in client.execute_iter(query): pass clickhouse-driver-0.2.11/perf/script_14.py000066400000000000000000000005311522645447600203510ustar00rootroot00000000000000# /// script # dependencies = [ # "clickhouse-connect==1.4.2", # ] # /// import sys import clickhouse_connect import timing query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}'".format(sys.argv[1]) client = clickhouse_connect.get_client(host='localhost', query_limit=None, compress=False) data = client.query(query).result_rows clickhouse-driver-0.2.11/perf/script_15.py000066400000000000000000000025521522645447600203570ustar00rootroot00000000000000# /// script # dependencies = [ # "clickhouse-connect==1.4.2", # ] # /// import sys import clickhouse_connect import timing cols = [ 'UniqueCarrier', 'Carrier', 'TailNum', 'FlightNum', 'Origin', 'OriginCityName', 'OriginState', 'OriginStateFips', 'OriginStateName', 'Dest', 'DestCityName', 'DestState', 'DestStateFips', 'DestStateName', 'DepartureDelayGroups', 'DepTimeBlk', 'ArrTimeBlk', 'CancellationCode', 'FirstDepTime', 'TotalAddGTime', 'LongestAddGTime', 'DivAirportLandings', 'DivReachedDest', 'DivActualElapsedTime', 'DivArrDelay', 'DivDistance', 'Div1Airport', 'Div1WheelsOn', 'Div1TotalGTime', 'Div1LongestGTime', 'Div1WheelsOff', 'Div1TailNum', 'Div2Airport', 'Div2WheelsOn', 'Div2TotalGTime', 'Div2LongestGTime', 'Div2WheelsOff', 'Div2TailNum', 'Div3Airport', 'Div3WheelsOn', 'Div3TotalGTime', 'Div3LongestGTime', 'Div3WheelsOff', 'Div3TailNum', 'Div4Airport', 'Div4WheelsOn', 'Div4TotalGTime', 'Div4LongestGTime', 'Div4WheelsOff', 'Div4TailNum', 'Div5Airport', 'Div5WheelsOn', 'Div5TotalGTime', 'Div5LongestGTime', 'Div5WheelsOff', 'Div5TailNum' ] query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}'".format(', '.join(cols), sys.argv[1]) client = clickhouse_connect.get_client(host='localhost', query_limit=None, compress=False) with client.query_rows_stream(query) as stream: for row in stream: pass clickhouse-driver-0.2.11/perf/script_16.py000066400000000000000000000023411522645447600203540ustar00rootroot00000000000000# /// script # dependencies = [ # "clickhouse-connect==1.4.2", # ] # /// import sys import clickhouse_connect import timing cols = [ 'Year', 'Quarter', 'Month', 'DayofMonth', 'DayOfWeek', 'AirlineID', 'OriginAirportID', 'OriginAirportSeqID', 'OriginCityMarketID', 'OriginWac', 'DestAirportID', 'DestAirportSeqID', 'DestCityMarketID', 'DestWac', 'CRSDepTime', 'DepTime', 'DepDelay', 'DepDelayMinutes', 'DepDel15', 'TaxiOut', 'WheelsOff', 'WheelsOn', 'TaxiIn', 'CRSArrTime', 'ArrTime', 'ArrDelay', 'ArrDelayMinutes', 'ArrDel15', 'ArrivalDelayGroups', 'Cancelled', 'Diverted', 'CRSElapsedTime', 'ActualElapsedTime', 'AirTime', 'Flights', 'Distance', 'DistanceGroup', 'CarrierDelay', 'WeatherDelay', 'NASDelay', 'SecurityDelay', 'LateAircraftDelay', 'Div1AirportID', 'Div1AirportSeqID', 'Div2AirportID', 'Div2AirportSeqID', 'Div3AirportID', 'Div3AirportSeqID', 'Div4AirportID', 'Div4AirportSeqID', 'Div5AirportID', 'Div5AirportSeqID' ] query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}'".format(', '.join(cols), sys.argv[1]) client = clickhouse_connect.get_client(host='localhost', query_limit=None, compress=False) with client.query_rows_stream(query) as stream: for row in stream: pass clickhouse-driver-0.2.11/perf/script_17.py000066400000000000000000000006061522645447600203570ustar00rootroot00000000000000# /// script # dependencies = [ # "clickhouse-connect==1.4.2", # ] # /// import sys import clickhouse_connect import timing query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}'".format(sys.argv[1]) client = clickhouse_connect.get_client(host='localhost', query_limit=None, compress=False) with client.query_rows_stream(query) as stream: for row in stream: pass clickhouse-driver-0.2.11/perf/script_18.py000066400000000000000000000005721522645447600203620ustar00rootroot00000000000000# /// script # dependencies = [ # "clickhouse-driver[arrow]==0.2.11", # ] # /// import sys from clickhouse_driver import Client # Imported lazily at query time: preload before the clock starts. import pyarrow import timing query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}'".format(sys.argv[1]) client = Client('localhost') table = client.query_arrow(query) clickhouse-driver-0.2.11/perf/script_19.py000066400000000000000000000006711522645447600203630ustar00rootroot00000000000000# /// script # dependencies = [ # "clickhouse-driver[arrow,numpy]==0.2.11", # ] # /// import sys from clickhouse_driver import Client # Imported lazily at query time: preload before the clock starts. import numpy import pandas import pyarrow import timing query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}'".format(sys.argv[1]) client = Client('localhost', settings={'use_numpy': True}) table = client.query_arrow(query) clickhouse-driver-0.2.11/perf/script_20.py000066400000000000000000000007651522645447600203570ustar00rootroot00000000000000# /// script # dependencies = [ # "clickhouse-connect==1.4.2", # "pyarrow==25.0.0", # ] # /// import sys import clickhouse_connect # Imported lazily at query time: preload before the clock starts. import pyarrow import timing query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}'".format(sys.argv[1]) client = clickhouse_connect.get_client(host='localhost', query_limit=None, compress=False) table = client.query_arrow(query, settings={'output_format_arrow_string_as_string': 1}) clickhouse-driver-0.2.11/perf/script_21.py000066400000000000000000000024241522645447600203520ustar00rootroot00000000000000# /// script # dependencies = [ # "clickhouse-driver[arrow,numpy]==0.2.11", # ] # /// import sys from clickhouse_driver import Client # Imported lazily at query time: preload before the clock starts. import numpy import pandas import pyarrow import timing cols = [ 'Year', 'Quarter', 'Month', 'DayofMonth', 'DayOfWeek', 'AirlineID', 'OriginAirportID', 'OriginAirportSeqID', 'OriginCityMarketID', 'OriginWac', 'DestAirportID', 'DestAirportSeqID', 'DestCityMarketID', 'DestWac', 'CRSDepTime', 'DepTime', 'DepDelay', 'DepDelayMinutes', 'DepDel15', 'TaxiOut', 'WheelsOff', 'WheelsOn', 'TaxiIn', 'CRSArrTime', 'ArrTime', 'ArrDelay', 'ArrDelayMinutes', 'ArrDel15', 'ArrivalDelayGroups', 'Cancelled', 'Diverted', 'CRSElapsedTime', 'ActualElapsedTime', 'AirTime', 'Flights', 'Distance', 'DistanceGroup', 'CarrierDelay', 'WeatherDelay', 'NASDelay', 'SecurityDelay', 'LateAircraftDelay', 'Div1AirportID', 'Div1AirportSeqID', 'Div2AirportID', 'Div2AirportSeqID', 'Div3AirportID', 'Div3AirportSeqID', 'Div4AirportID', 'Div4AirportSeqID', 'Div5AirportID', 'Div5AirportSeqID' ] query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}'".format(', '.join(cols), sys.argv[1]) client = Client('localhost', settings={'use_numpy': True}) table = client.query_arrow(query) clickhouse-driver-0.2.11/perf/script_22.py000066400000000000000000000025201522645447600203500ustar00rootroot00000000000000# /// script # dependencies = [ # "clickhouse-connect==1.4.2", # "pyarrow==25.0.0", # ] # /// import sys import clickhouse_connect # Imported lazily at query time: preload before the clock starts. import pyarrow import timing cols = [ 'Year', 'Quarter', 'Month', 'DayofMonth', 'DayOfWeek', 'AirlineID', 'OriginAirportID', 'OriginAirportSeqID', 'OriginCityMarketID', 'OriginWac', 'DestAirportID', 'DestAirportSeqID', 'DestCityMarketID', 'DestWac', 'CRSDepTime', 'DepTime', 'DepDelay', 'DepDelayMinutes', 'DepDel15', 'TaxiOut', 'WheelsOff', 'WheelsOn', 'TaxiIn', 'CRSArrTime', 'ArrTime', 'ArrDelay', 'ArrDelayMinutes', 'ArrDel15', 'ArrivalDelayGroups', 'Cancelled', 'Diverted', 'CRSElapsedTime', 'ActualElapsedTime', 'AirTime', 'Flights', 'Distance', 'DistanceGroup', 'CarrierDelay', 'WeatherDelay', 'NASDelay', 'SecurityDelay', 'LateAircraftDelay', 'Div1AirportID', 'Div1AirportSeqID', 'Div2AirportID', 'Div2AirportSeqID', 'Div3AirportID', 'Div3AirportSeqID', 'Div4AirportID', 'Div4AirportSeqID', 'Div5AirportID', 'Div5AirportSeqID' ] query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}'".format(', '.join(cols), sys.argv[1]) client = clickhouse_connect.get_client(host='localhost', query_limit=None, compress=False) table = client.query_arrow(query, settings={'output_format_arrow_string_as_string': 1}) clickhouse-driver-0.2.11/perf/script_23.py000066400000000000000000000026351522645447600203600ustar00rootroot00000000000000# /// script # dependencies = [ # "clickhouse-driver[arrow,numpy]==0.2.11", # ] # /// import sys from clickhouse_driver import Client # Imported lazily at query time: preload before the clock starts. import numpy import pandas import pyarrow import timing cols = [ 'UniqueCarrier', 'Carrier', 'TailNum', 'FlightNum', 'Origin', 'OriginCityName', 'OriginState', 'OriginStateFips', 'OriginStateName', 'Dest', 'DestCityName', 'DestState', 'DestStateFips', 'DestStateName', 'DepartureDelayGroups', 'DepTimeBlk', 'ArrTimeBlk', 'CancellationCode', 'FirstDepTime', 'TotalAddGTime', 'LongestAddGTime', 'DivAirportLandings', 'DivReachedDest', 'DivActualElapsedTime', 'DivArrDelay', 'DivDistance', 'Div1Airport', 'Div1WheelsOn', 'Div1TotalGTime', 'Div1LongestGTime', 'Div1WheelsOff', 'Div1TailNum', 'Div2Airport', 'Div2WheelsOn', 'Div2TotalGTime', 'Div2LongestGTime', 'Div2WheelsOff', 'Div2TailNum', 'Div3Airport', 'Div3WheelsOn', 'Div3TotalGTime', 'Div3LongestGTime', 'Div3WheelsOff', 'Div3TailNum', 'Div4Airport', 'Div4WheelsOn', 'Div4TotalGTime', 'Div4LongestGTime', 'Div4WheelsOff', 'Div4TailNum', 'Div5Airport', 'Div5WheelsOn', 'Div5TotalGTime', 'Div5LongestGTime', 'Div5WheelsOff', 'Div5TailNum' ] query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}'".format(', '.join(cols), sys.argv[1]) client = Client('localhost', settings={'use_numpy': True}) table = client.query_arrow(query) clickhouse-driver-0.2.11/perf/script_24.py000066400000000000000000000027311522645447600203560ustar00rootroot00000000000000# /// script # dependencies = [ # "clickhouse-connect==1.4.2", # "pyarrow==25.0.0", # ] # /// import sys import clickhouse_connect # Imported lazily at query time: preload before the clock starts. import pyarrow import timing cols = [ 'UniqueCarrier', 'Carrier', 'TailNum', 'FlightNum', 'Origin', 'OriginCityName', 'OriginState', 'OriginStateFips', 'OriginStateName', 'Dest', 'DestCityName', 'DestState', 'DestStateFips', 'DestStateName', 'DepartureDelayGroups', 'DepTimeBlk', 'ArrTimeBlk', 'CancellationCode', 'FirstDepTime', 'TotalAddGTime', 'LongestAddGTime', 'DivAirportLandings', 'DivReachedDest', 'DivActualElapsedTime', 'DivArrDelay', 'DivDistance', 'Div1Airport', 'Div1WheelsOn', 'Div1TotalGTime', 'Div1LongestGTime', 'Div1WheelsOff', 'Div1TailNum', 'Div2Airport', 'Div2WheelsOn', 'Div2TotalGTime', 'Div2LongestGTime', 'Div2WheelsOff', 'Div2TailNum', 'Div3Airport', 'Div3WheelsOn', 'Div3TotalGTime', 'Div3LongestGTime', 'Div3WheelsOff', 'Div3TailNum', 'Div4Airport', 'Div4WheelsOn', 'Div4TotalGTime', 'Div4LongestGTime', 'Div4WheelsOff', 'Div4TailNum', 'Div5Airport', 'Div5WheelsOn', 'Div5TotalGTime', 'Div5LongestGTime', 'Div5WheelsOff', 'Div5TailNum' ] query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}'".format(', '.join(cols), sys.argv[1]) client = clickhouse_connect.get_client(host='localhost', query_limit=None, compress=False) table = client.query_arrow(query, settings={'output_format_arrow_string_as_string': 1}) clickhouse-driver-0.2.11/perf/timing.py000066400000000000000000000006141522645447600200320ustar00rootroot00000000000000import atexit import resource import sys import time _start = time.monotonic() @atexit.register def _report(): elapsed = time.monotonic() - _start rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss if sys.platform != "darwin": rss *= 1024 # Linux reports kilobytes, macOS reports bytes. print("{:.2f} s / {} bytes max RSS".format(elapsed, rss), file=sys.stderr) clickhouse-driver-0.2.11/setup.cfg000066400000000000000000000003331522645447600170540ustar00rootroot00000000000000[db] host=localhost port=9000 secure_port=9440 database=test user=default password= compression=lz4,lz4hc,zstd client=clickhouse-client [log] level=ERROR [bdist_wheel] universal = 0 [metadata] license_file = LICENSE clickhouse-driver-0.2.11/setup.py000066400000000000000000000075071522645447600167570ustar00rootroot00000000000000import os import re from codecs import open from setuptools import setup, find_packages from distutils.extension import Extension try: from Cython.Build import cythonize except ImportError: USE_CYTHON = False else: USE_CYTHON = True CYTHON_TRACE = bool(os.getenv('CYTHON_TRACE', False)) here = os.path.abspath(os.path.dirname(__file__)) def read_version(): regexp = re.compile(r'^VERSION\W*=\W*\(([^\(\)]*)\)') init_py = os.path.join(here, 'clickhouse_driver', '__init__.py') with open(init_py, encoding='utf-8') as f: for line in f: match = regexp.match(line) if match is not None: return match.group(1).replace(', ', '.') else: raise RuntimeError( 'Cannot find version in clickhouse_driver/__init__.py' ) with open(os.path.join(here, 'README.rst'), encoding='utf-8') as f: long_description = f.read() # Prepare extensions. ext = '.pyx' if USE_CYTHON else '.c' extensions = [ Extension( 'clickhouse_driver.bufferedreader', ['clickhouse_driver/bufferedreader' + ext] ), Extension( 'clickhouse_driver.bufferedwriter', ['clickhouse_driver/bufferedwriter' + ext] ), Extension( 'clickhouse_driver.columns.largeint', ['clickhouse_driver/columns/largeint' + ext] ), Extension( 'clickhouse_driver.varint', ['clickhouse_driver/varint' + ext] ) ] if USE_CYTHON: compiler_directives = {'language_level': '3'} if CYTHON_TRACE: compiler_directives['linetrace'] = True extensions = cythonize(extensions, compiler_directives=compiler_directives) github_url = 'https://github.com/mymarilyn/clickhouse-driver' setup( name='clickhouse-driver', version=read_version(), description='Python driver with native interface for ClickHouse', long_description=long_description, url=github_url, author='Konstantin Lebedev', author_email='kostyan.lebedev@gmail.com', license='MIT', classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Console', 'Intended Audience :: Developers', 'Intended Audience :: Information Technology', 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Programming Language :: SQL', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', 'Programming Language :: Python :: 3.13', 'Programming Language :: Python :: 3.14', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Database', 'Topic :: Software Development', 'Topic :: Software Development :: Libraries', 'Topic :: Software Development :: Libraries :: Application Frameworks', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Scientific/Engineering :: Information Analysis' ], keywords='ClickHouse db database cloud analytics', project_urls={ 'Documentation': 'https://clickhouse-driver.readthedocs.io', 'Changes': github_url + '/blob/master/CHANGELOG.md' }, packages=find_packages('.', exclude=['tests*']), python_requires='>=3.9, <4', install_requires=[ 'pytz', 'tzlocal' ], ext_modules=extensions, extras_require={ 'lz4': [ 'lz4<=3.0.1; implementation_name=="pypy"', 'lz4; implementation_name!="pypy"', 'clickhouse-cityhash>=1.0.2.6' ], 'zstd': ['zstd', 'clickhouse-cityhash>=1.0.2.6'], 'numpy': ['numpy>=1.12.0', 'pandas>=0.24.0'], 'arrow': ['pyarrow>=8.0.0'] }, test_suite='pytest' ) clickhouse-driver-0.2.11/tests/000077500000000000000000000000001522645447600163765ustar00rootroot00000000000000clickhouse-driver-0.2.11/tests/__init__.py000066400000000000000000000000001522645447600204750ustar00rootroot00000000000000clickhouse-driver-0.2.11/tests/arrow/000077500000000000000000000000001522645447600175305ustar00rootroot00000000000000clickhouse-driver-0.2.11/tests/arrow/__init__.py000066400000000000000000000000001522645447600216270ustar00rootroot00000000000000clickhouse-driver-0.2.11/tests/arrow/test_generic.py000066400000000000000000000255401522645447600225630ustar00rootroot00000000000000try: import pyarrow as pa except ImportError: pa = None from clickhouse_driver import errors from tests.testcase import BaseTestCase from tests.arrow.testcase import ArrowBaseTestCase class QueryArrowTestCase(ArrowBaseTestCase): def test_simple(self): table = self.client.query_arrow( 'SELECT number FROM system.numbers LIMIT 100' ) self.assertIsInstance(table, pa.Table) self.assertEqual(table.num_rows, 100) self.assertEqual(table.column_names, ['number']) self.assertEqual(table.schema.field('number').type, pa.uint64()) self.assertEqual(table.column('number').to_pylist(), list(range(100))) def test_column_names_preserved(self): table = self.client.query_arrow('SELECT 1 AS "my col"') self.assertEqual(table.column_names, ['my col']) def test_multiple_columns(self): table = self.client.query_arrow( 'SELECT ' 'CAST(number AS Int32) AS x, ' 'toString(number) AS y ' 'FROM system.numbers LIMIT 3' ) self.assertEqual(table.column_names, ['x', 'y']) self.assertEqual(table.column('x').to_pylist(), [0, 1, 2]) self.assertEqual(table.column('y').to_pylist(), ['0', '1', '2']) def test_empty_result_keeps_schema(self): table = self.client.query_arrow( 'SELECT CAST(number AS Int32) AS x, toString(number) AS y ' 'FROM system.numbers LIMIT 0' ) self.assertEqual(table.num_rows, 0) self.assertEqual(table.schema.field('x').type, pa.int32()) self.assertEqual(table.schema.field('y').type, pa.string()) def test_params_substitution(self): table = self.client.query_arrow( 'SELECT CAST(%(x)s AS Int64) AS x', params={'x': 42} ) self.assertEqual(table.column('x').to_pylist(), [42]) def test_settings(self): table = self.client.query_arrow( 'SELECT number FROM system.numbers LIMIT 1000', settings={'max_block_size': 100} ) self.assertEqual(table.num_rows, 1000) def test_external_tables(self): table = self.client.query_arrow( 'SELECT * FROM ext ORDER BY x', external_tables=[{ 'name': 'ext', 'structure': [('x', 'Int32')], 'data': [{'x': 1}, {'x': 2}] }] ) self.assertEqual(table.column('x').to_pylist(), [1, 2]) def test_field_metadata(self): table = self.client.query_arrow( 'SELECT CAST(1 AS Nullable(Int32)) AS x, ' 'toLowCardinality(toString(1)) AS lc' ) self.assertEqual( table.schema.field('x').metadata, {b'clickhouse_type': b'Nullable(Int32)'} ) self.assertEqual( table.schema.field('lc').metadata, {b'clickhouse_type': b'LowCardinality(String)'} ) def test_field_metadata_opt_out(self): table = self.client.query_arrow( 'SELECT 1 AS x', field_metadata=False ) self.assertIsNone(table.schema.field('x').metadata) def test_several_blocks_concatenated(self): table = self.client.query_arrow( 'SELECT number FROM system.numbers LIMIT 1000', settings={'max_block_size': 100} ) self.assertEqual(table.column('number').to_pylist(), list(range(1000))) class QueryArrowStreamTestCase(ArrowBaseTestCase): def test_returns_record_batch_reader(self): reader = self.client.query_arrow_stream( 'SELECT number FROM system.numbers LIMIT 10' ) self.assertIsInstance(reader, pa.RecordBatchReader) reader.close() def test_schema_available_before_consumption(self): reader = self.client.query_arrow_stream( 'SELECT CAST(number AS Int32) AS x ' 'FROM system.numbers LIMIT 10' ) self.assertEqual(reader.schema.field('x').type, pa.int32()) reader.close() def test_stream_field_metadata(self): reader = self.client.query_arrow_stream( 'SELECT number FROM system.numbers LIMIT 10' ) self.assertEqual( reader.schema.field('number').metadata, {b'clickhouse_type': b'UInt64'} ) reader.read_all() def test_multiple_batches(self): reader = self.client.query_arrow_stream( 'SELECT number FROM system.numbers LIMIT 1000', settings={'max_block_size': 100} ) batches = list(reader) self.assertGreater(len(batches), 1) for batch in batches: self.assertIsInstance(batch, pa.RecordBatch) total_rows = sum(batch.num_rows for batch in batches) self.assertEqual(total_rows, 1000) def test_read_all_equals_query_arrow(self): query = ('SELECT number, toString(number) AS s ' 'FROM system.numbers LIMIT 1000') settings = {'max_block_size': 100} reader = self.client.query_arrow_stream(query, settings=settings) streamed = reader.read_all() table = self.client.query_arrow(query, settings=settings) self.assertTrue(streamed.equals(table)) def test_empty_result(self): reader = self.client.query_arrow_stream( 'SELECT CAST(number AS Int32) AS x FROM system.numbers LIMIT 0' ) table = reader.read_all() self.assertEqual(table.num_rows, 0) self.assertEqual(table.schema.field('x').type, pa.int32()) def test_client_usable_after_stream_consumed(self): reader = self.client.query_arrow_stream( 'SELECT number FROM system.numbers LIMIT 10' ) reader.read_all() rv = self.client.execute('SELECT 1') self.assertEqual(rv, [(1, )]) def test_client_usable_after_close_before_consuming(self): reader = self.client.query_arrow_stream( 'SELECT number FROM system.numbers LIMIT 100000', settings={'max_block_size': 100} ) reader.close() rv = self.client.execute('SELECT 1') self.assertEqual(rv, [(1, )]) def test_client_usable_after_close_after_one_batch(self): reader = self.client.query_arrow_stream( 'SELECT number FROM system.numbers LIMIT 100000', settings={'max_block_size': 100} ) batch = reader.read_next_batch() self.assertEqual(batch.num_rows, 100) reader.close() rv = self.client.execute('SELECT 1') self.assertEqual(rv, [(1, )]) def test_arrow_query_after_close_after_one_batch(self): reader = self.client.query_arrow_stream( 'SELECT number FROM system.numbers LIMIT 100000', settings={'max_block_size': 100} ) reader.read_next_batch() reader.close() table = self.client.query_arrow( 'SELECT number FROM system.numbers LIMIT 10' ) self.assertEqual(table.column('number').to_pylist(), list(range(10))) def test_abandoned_reader_raises_after_next_query(self): reader = self.client.query_arrow_stream( 'SELECT number FROM system.numbers LIMIT 100000', settings={'max_block_size': 100} ) reader.read_next_batch() self.client.execute('SELECT 1') # The streamed query was cancelled by the query above: reading # further must fail loudly instead of consuming its packets. with self.assertRaises(errors.PartiallyConsumedQueryError): reader.read_all() class ArrowNumpyPathTestCase(ArrowBaseTestCase): """ query_arrow must return identical results with and without use_numpy fast path. """ def setUp(self): super(ArrowNumpyPathTestCase, self).setUp() try: import numpy # noqa: F401 import pandas # noqa: F401 except ImportError: self.skipTest('NumPy package is not installed') def test_results_equal_with_use_numpy(self): query = ( 'SELECT ' 'CAST(number AS Int64) AS x, ' 'toString(number) AS y, ' 'CAST(number AS Float64) / 3 AS z, ' "toDateTime(number, 'UTC') AS dt, " "toDateTime64(number + 0.123, 3, 'UTC') AS dt64, " 'toLowCardinality(toString(number % 3)) AS lc ' 'FROM system.numbers LIMIT 1000' ) table = self.client.query_arrow(query) with self.created_client(settings={'use_numpy': True}) as client: numpy_table = client.query_arrow(query) self.assertTrue(table.equals(numpy_table)) def test_long_strings_equal_with_use_numpy(self): # Strings longer than the reader buffer exercise the # buffer-spanning path of the Arrow string reader. query = ( "SELECT concat('привет', repeat('x', 1000000), " "repeat('y', 1000000), toString(number)) AS s " 'FROM system.numbers LIMIT 3' ) table = self.client.query_arrow(query) with self.created_client(settings={'use_numpy': True}) as client: numpy_table = client.query_arrow(query) self.assertTrue(table.equals(numpy_table)) def test_nullable_results_equal_with_use_numpy(self): query = ( 'SELECT ' 'CAST(if(number % 2 = 0, NULL, number) AS Nullable(Int64)) ' 'AS x, ' 'CAST(if(number % 3 = 0, NULL, number / 7) ' 'AS Nullable(Float64)) AS f, ' 'CAST(if(number % 4 = 0, NULL, toString(number)) ' 'AS Nullable(String)) AS s, ' 'CAST(if(number % 6 = 0, NULL, toString(number % 10)) ' 'AS Nullable(FixedString(2))) AS fs, ' "CAST(if(number % 5 = 0, NULL, toDateTime(number, 'UTC')) " "AS Nullable(DateTime('UTC'))) AS dt " 'FROM system.numbers LIMIT 10' ) table = self.client.query_arrow(query) with self.created_client(settings={'use_numpy': True}) as client: numpy_table = client.query_arrow(query) self.assertTrue(table.equals(numpy_table)) self.assertEqual(table.column('x').null_count, 5) class NoPyArrowTestCase(BaseTestCase): def setUp(self): super(NoPyArrowTestCase, self).setUp() try: import pyarrow # noqa: F401 except ImportError: pass else: self.skipTest('PyArrow extras are installed') def test_query_arrow(self): with self.assertRaises(RuntimeError) as e: self.client.query_arrow('SELECT 1 AS x') self.assertEqual( 'Extras for PyArrow must be installed', str(e.exception) ) def test_query_arrow_stream(self): with self.assertRaises(RuntimeError) as e: self.client.query_arrow_stream('SELECT 1 AS x') self.assertEqual( 'Extras for PyArrow must be installed', str(e.exception) ) clickhouse-driver-0.2.11/tests/arrow/test_mapping.py000066400000000000000000000076571522645447600226130ustar00rootroot00000000000000from unittest import TestCase from uuid import UUID from clickhouse_driver.context import Context try: import pyarrow as pa from clickhouse_driver.arrow import mapping from clickhouse_driver.arrow.convert import ( ArrowStreamState, _json_declared_converter, create_record_batch_reader ) except ImportError: pa = None mapping = None class MappingTestCase(TestCase): """ Unit tests for the spec -> Arrow type mapping. No server needed. """ def setUp(self): if pa is None: self.skipTest('PyArrow package is not installed') def get(self, spec, **kwargs): return mapping.get_type_and_converter(spec, **kwargs) def test_object_json_unsupported(self): # Legacy JSON type: only served by pre-25 servers. type_, _ = self.get("Object('json')") self.assertIs(type_, mapping.UNSUPPORTED) def test_decimal_prefixed_specs(self): self.assertEqual(self.get('Decimal32(2)')[0], pa.decimal128(9, 2)) self.assertEqual(self.get('Decimal64(4)')[0], pa.decimal128(18, 4)) self.assertEqual(self.get('Decimal128(6)')[0], pa.decimal128(38, 6)) self.assertEqual(self.get('Decimal256(8)')[0], pa.decimal256(76, 8)) def test_unknown_decimal_prefix_falls_back_to_inference(self): self.assertEqual(self.get('Decimal512(2)'), (None, None)) def test_decimal_high_precision_is_decimal256(self): self.assertEqual(self.get('Decimal(76, 10)')[0], pa.decimal256(76, 10)) def test_datetime64_units(self): self.assertEqual(self.get('DateTime64(0)')[0], pa.timestamp('s')) self.assertEqual(self.get('DateTime64(9)')[0], pa.timestamp('ns')) def test_tuple_without_json_falls_back_to_inference(self): self.assertEqual(self.get('Tuple(UInt8, String)'), (None, None)) def test_unknown_spec_falls_back_to_inference(self): self.assertEqual(self.get('Int128'), (None, None)) def test_simple_aggregate_function_unwraps(self): type_, converter = self.get('SimpleAggregateFunction(anyLast, Int64)') self.assertEqual(type_, pa.int64()) self.assertIsNone(converter) def test_array_of_uuid_converter(self): type_, converter = self.get('Array(UUID)') self.assertEqual(type_, pa.list_(pa.string())) uid = UUID('c0fcbba9-0752-44ed-a5d6-4dfb4342b89d') self.assertEqual(converter([uid, None]), [str(uid), None]) def test_map_with_value_converter(self): type_, converter = self.get('Map(String, UUID)') self.assertEqual(type_, pa.map_(pa.string(), pa.string())) uid = UUID('c0fcbba9-0752-44ed-a5d6-4dfb4342b89d') self.assertEqual(converter({'k': uid}), [('k', str(uid))]) def test_json_as_object_parses_wire_strings(self): self.assertEqual(mapping.json_as_object('{"a": 1}'), {'a': 1}) self.assertEqual(mapping.json_as_object(''), {}) self.assertEqual(mapping.json_as_object({'a': 1}), {'a': 1}) class ConvertTestCase(TestCase): """ Unit tests for reader creation edge cases. No server needed. """ def setUp(self): if pa is None: self.skipTest('PyArrow package is not installed') def make_context(self): context = Context() context.client_settings = {'strings_as_bytes': False} return context def test_empty_packet_stream(self): state = ArrowStreamState(connection=None) reader = create_record_batch_reader( iter([]), self.make_context(), state=state ) self.assertEqual(reader.read_all().num_rows, 0) self.assertTrue(state.finished) def test_declared_converter_none_for_json_free_containers(self): self.assertIsNone(_json_declared_converter( 'Array(Int32)', pa.list_(pa.int32()), 'x' )) self.assertIsNone(_json_declared_converter( 'Map(String, Int32)', pa.map_(pa.string(), pa.int32()), 'x' )) clickhouse-driver-0.2.11/tests/arrow/test_types.py000066400000000000000000000503121522645447600223060ustar00rootroot00000000000000import json from datetime import date, datetime, timezone from decimal import Decimal from uuid import UUID try: import pyarrow as pa except ImportError: pa = None from tests.arrow.testcase import ArrowBaseTestCase from tests.util import require_server_version class IntTestCase(ArrowBaseTestCase): def test_int8(self): self.assert_arrow_column('Int8', pa.int8(), [-128, 0, 127]) def test_int16(self): self.assert_arrow_column('Int16', pa.int16(), [-32768, 0, 32767]) def test_int32(self): self.assert_arrow_column( 'Int32', pa.int32(), [-2147483648, 0, 2147483647] ) def test_int64(self): self.assert_arrow_column( 'Int64', pa.int64(), [-9223372036854775808, 0, 9223372036854775807] ) def test_uint8(self): self.assert_arrow_column('UInt8', pa.uint8(), [0, 255]) def test_uint16(self): self.assert_arrow_column('UInt16', pa.uint16(), [0, 65535]) def test_uint32(self): self.assert_arrow_column('UInt32', pa.uint32(), [0, 4294967295]) def test_uint64(self): self.assert_arrow_column( 'UInt64', pa.uint64(), [0, 18446744073709551615] ) class FloatTestCase(ArrowBaseTestCase): def test_float32(self): self.assert_arrow_column('Float32', pa.float32(), [-0.5, 0.0, 0.5]) def test_float64(self): self.assert_arrow_column('Float64', pa.float64(), [-1.5, 0.0, 1.5]) class BoolTestCase(ArrowBaseTestCase): required_server_version = (21, 12) def test_bool(self): self.assert_arrow_column('Bool', pa.bool_(), [True, False]) class StringTestCase(ArrowBaseTestCase): def test_string(self): self.assert_arrow_column('String', pa.string(), ['a', 'b', 'привет']) def test_fixed_string(self): self.assert_arrow_column('FixedString(3)', pa.string(), ['abc', 'def']) def test_strings_as_bytes(self): with self.create_table('a String'): self.client.execute( 'INSERT INTO test (a) VALUES', [(b'ab', ), (b'cd', )] ) with self.created_client( settings={'strings_as_bytes': True}) as client: table = client.query_arrow('SELECT a FROM test') self.assertEqual(table.schema.field('a').type, pa.binary()) self.assertEqual(table.column('a').to_pylist(), [b'ab', b'cd']) def test_strings_as_bytes_with_numpy(self): try: import numpy # noqa: F401 import pandas # noqa: F401 except ImportError: self.skipTest('NumPy package is not installed') with self.create_table('a String'): self.client.execute( 'INSERT INTO test (a) VALUES', [(b'ab', ), (b'cd', )] ) with self.created_client( settings={'strings_as_bytes': True, 'use_numpy': True}) as client: table = client.query_arrow('SELECT a FROM test') self.assertEqual(table.schema.field('a').type, pa.binary()) self.assertEqual(table.column('a').to_pylist(), [b'ab', b'cd']) class NullableTestCase(ArrowBaseTestCase): def test_nullable_int(self): self.assert_arrow_column( 'Nullable(Int32)', pa.int32(), [1, None, 3] ) def test_nullable_float(self): self.assert_arrow_column( 'Nullable(Float64)', pa.float64(), [1.5, None, 3.5] ) def test_nullable_string(self): self.assert_arrow_column( 'Nullable(String)', pa.string(), ['a', None, 'c'] ) def test_null_count(self): with self.create_table('a Nullable(Int64)'): self.client.execute( 'INSERT INTO test (a) VALUES', [(1, ), (None, ), (None, ), (4, )] ) table = self.client.query_arrow('SELECT a FROM test') self.assertEqual(table.column('a').null_count, 2) def test_all_null(self): self.assert_arrow_column( 'Nullable(Int32)', pa.int32(), [None, None] ) class DateTestCase(ArrowBaseTestCase): def test_date(self): self.assert_arrow_column( 'Date', pa.date32(), [date(1970, 1, 2), date(2024, 2, 29)] ) class Date32TestCase(ArrowBaseTestCase): required_server_version = (21, 9) def test_date32(self): self.assert_arrow_column( 'Date32', pa.date32(), [date(1925, 1, 2), date(2024, 2, 29)] ) class DateTimeTestCase(ArrowBaseTestCase): def test_datetime_with_timezone(self): self.assert_arrow_column( "DateTime('UTC')", pa.timestamp('s', tz='UTC'), [ datetime(2024, 1, 1, 12, 30, 45, tzinfo=timezone.utc), datetime(1970, 1, 2, 0, 0, 1, tzinfo=timezone.utc) ] ) def test_datetime_naive(self): # Expected values are taken from plain execute to stay # independent of local/server timezone conversions. with self.create_table('a DateTime'): self.client.execute( 'INSERT INTO test (a) VALUES', [(datetime(2024, 1, 1, 12, 30, 45), )] ) table = self.client.query_arrow('SELECT a FROM test') expected = [x[0] for x in self.client.execute( 'SELECT a FROM test' )] self.assertEqual(table.schema.field('a').type, pa.timestamp('s')) self.assertEqual(table.column('a').to_pylist(), expected) class DateTime64TestCase(ArrowBaseTestCase): required_server_version = (20, 1, 2) def test_datetime64_millisecond(self): self.assert_arrow_column( "DateTime64(3, 'UTC')", pa.timestamp('ms', tz='UTC'), [datetime(2024, 1, 1, 12, 30, 45, 123000, tzinfo=timezone.utc)] ) def test_datetime64_microsecond(self): self.assert_arrow_column( "DateTime64(6, 'UTC')", pa.timestamp('us', tz='UTC'), [datetime(2024, 1, 1, 12, 30, 45, 123456, tzinfo=timezone.utc)] ) class DecimalTestCase(ArrowBaseTestCase): required_server_version = (18, 12, 13) def test_decimal(self): self.assert_arrow_column( 'Decimal(9, 5)', pa.decimal128(9, 5), [Decimal('123.45678'), Decimal('-123.45678')] ) def test_decimal_high_precision(self): self.assert_arrow_column( 'Decimal(38, 10)', pa.decimal128(38, 10), [Decimal('1234567890.1234567890')] ) class EnumTestCase(ArrowBaseTestCase): def test_enum8(self): self.assert_arrow_column( "Enum8('hello' = 1, 'world' = 2)", pa.string(), ['hello', 'world'] ) def test_enum16(self): self.assert_arrow_column( "Enum16('hello' = 1000, 'world' = 2000)", pa.string(), ['hello', 'world'] ) class UUIDTestCase(ArrowBaseTestCase): def test_uuid(self): self.assert_arrow_column( 'UUID', pa.string(), [UUID('c0fcbba9-0752-44ed-a5d6-4dfb4342b89d')], expected=['c0fcbba9-0752-44ed-a5d6-4dfb4342b89d'] ) class IPTestCase(ArrowBaseTestCase): required_server_version = (19, 3, 3) def test_ipv4(self): self.assert_arrow_column( 'IPv4', pa.string(), ['10.0.0.1', '192.168.1.1'] ) def test_ipv6(self): self.assert_arrow_column( 'IPv6', pa.string(), ['2001:db8::1', '::1'] ) class LowCardinalityTestCase(ArrowBaseTestCase): required_server_version = (19, 3, 3) def test_low_cardinality_string(self): self.assert_arrow_column( 'LowCardinality(String)', pa.string(), ['yes', 'no', 'yes'] ) def test_low_cardinality_nullable_string(self): self.assert_arrow_column( 'LowCardinality(Nullable(String))', pa.string(), ['yes', None, 'yes'] ) class ArrayTestCase(ArrowBaseTestCase): def test_array_of_ints(self): self.assert_arrow_column( 'Array(UInt64)', pa.list_(pa.uint64()), [[1, 2, 3], [], [4]] ) def test_array_of_strings(self): self.assert_arrow_column( 'Array(String)', pa.list_(pa.string()), [['a', 'b'], []] ) def test_array_of_nullable(self): self.assert_arrow_column( 'Array(Nullable(Int32))', pa.list_(pa.int32()), [[1, None], [3]] ) def test_nested_arrays(self): self.assert_arrow_column( 'Array(Array(Int32))', pa.list_(pa.list_(pa.int32())), [[[1, 2], [3]], [[]]] ) class JSONTestCase(ArrowBaseTestCase): required_server_version = (24, 8, 0) def client_kwargs(self, version): return {'settings': {'enable_json_type': True}} def cli_client_kwargs(self): return {'enable_json_type': 1} def test_json_requires_arrow_types(self): with self.create_table('a JSON'): self.client.execute( 'INSERT INTO test (a) VALUES', [({'k': 1}, )] ) with self.assertRaises(ValueError) as e: self.client.query_arrow('SELECT a FROM test') self.assertIn('arrow_types', str(e.exception)) # client is not broken by the rejected query self.assertEqual(self.client.execute('SELECT 1'), [(1, )]) @require_server_version(24, 10) def test_json_as_text(self): # Memory engine returns blocks in nondeterministic order: # an explicit ordering key is required. with self.create_table('i UInt8, a JSON'): self.client.execute( 'INSERT INTO test (i, a) VALUES', [(1, {'k': 1, 's': 'x'}), (2, {})] ) self.client.execute( 'INSERT INTO test (i, a) VALUES', [(3, {'b': 'y'})] ) table = self.client.query_arrow( 'SELECT a FROM test ORDER BY i', arrow_types={'a': pa.string()}, settings={ 'output_format_native_write_json_as_string': 1, # default differs across server versions 'output_format_json_quote_64bit_integers': 0 } ) self.assertEqual(table.schema.field('a').type, pa.string()) values = [json.loads(x) for x in table.column('a').to_pylist()] self.assertEqual(values, [{'k': 1, 's': 'x'}, {}, {'b': 'y'}]) def test_json_as_text_without_server_serialization_raises(self): # Client-side JSON serialization is deliberately not provided: # it would be an order of magnitude slower than the server-side one. with self.create_table('a JSON'): self.client.execute( 'INSERT INTO test (a) VALUES', [({'k': 1}, )] ) with self.assertRaises(ValueError) as e: self.client.query_arrow( 'SELECT a FROM test', arrow_types={'a': pa.string()} ) self.assertIn( 'output_format_native_write_json_as_string', str(e.exception) ) # raised mid-stream, after the reader was created: # client must survive self.assertEqual(self.client.execute('SELECT 1'), [(1, )]) def test_json_as_text_without_server_serialization_raises_stream(self): with self.create_table('a JSON'): self.client.execute( 'INSERT INTO test (a) VALUES', [({'k': 1}, )] ) reader = self.client.query_arrow_stream( 'SELECT a FROM test', arrow_types={'a': pa.string()} ) with self.assertRaises(ValueError): reader.read_all() self.assertEqual(self.client.execute('SELECT 1'), [(1, )]) @require_server_version(24, 10) def test_json_as_struct_string_wire_format(self): # Struct declaration must work whichever wire format arrives: # with string serialization values are parsed on the client. struct = pa.struct([('k', pa.int64())]) with self.create_table('a JSON'): self.client.execute( 'INSERT INTO test (a) VALUES', [({'k': 1}, )] ) table = self.client.query_arrow( 'SELECT a FROM test', arrow_types={'a': struct}, settings={ 'output_format_native_write_json_as_string': 1, # default differs across server versions 'output_format_json_quote_64bit_integers': 0 } ) self.assertEqual(table.column('a').to_pylist(), [{'k': 1}]) def test_json_as_struct(self): struct = pa.struct([('k', pa.int64()), ('s', pa.string())]) with self.create_table('i UInt8, a JSON'): self.client.execute( 'INSERT INTO test (i, a) VALUES', [(1, {'k': 1, 's': 'x'})] ) # declared schema contract: missing paths are null-filled self.client.execute( 'INSERT INTO test (i, a) VALUES', [(2, {'k': 2})] ) table = self.client.query_arrow( 'SELECT a FROM test ORDER BY i', arrow_types={'a': struct} ) self.assertEqual(table.schema.field('a').type, struct) self.assertEqual(table.column('a').to_pylist(), [ {'k': 1, 's': 'x'}, {'k': 2, 's': None}, ]) class NestedJSONTestCase(ArrowBaseTestCase): required_server_version = (24, 8, 0) def client_kwargs(self, version): return {'settings': {'enable_json_type': True, 'flatten_nested': 0}} def cli_client_kwargs(self): return {'enable_json_type': 1, 'flatten_nested': 0} def test_array_json_requires_arrow_types(self): with self.create_table('a Array(JSON)'): with self.assertRaises(ValueError) as e: self.client.query_arrow('SELECT a FROM test') self.assertIn('arrow_types', str(e.exception)) @require_server_version(24, 10) def test_array_json_as_text_elements(self): with self.create_table('a Array(JSON)'): # nested JSON inserts are not supported by the driver: # insert via CLI self.emit_cli( 'INSERT INTO test VALUES ' '([CAST(\'{"k":1}\' AS JSON), ' 'CAST(\'{"b":"x"}\' AS JSON)])', enable_json_type=1 ) table = self.client.query_arrow( 'SELECT a FROM test', arrow_types={'a': pa.list_(pa.string())}, settings={ 'output_format_native_write_json_as_string': 1, # default differs across server versions 'output_format_json_quote_64bit_integers': 0 } ) values = [ [json.loads(x) for x in row] for row in table.column('a').to_pylist() ] self.assertEqual(values, [[{'k': 1}, {'b': 'x'}]]) @require_server_version(24, 10) def test_nullable_json_as_text(self): with self.create_table('i UInt8, a Nullable(JSON)'): self.client.execute( 'INSERT INTO test (i, a) VALUES', [(1, {'k': 1}), (2, None)] ) table = self.client.query_arrow( 'SELECT a FROM test ORDER BY i', arrow_types={'a': pa.string()}, settings={ 'output_format_native_write_json_as_string': 1, # default differs across server versions 'output_format_json_quote_64bit_integers': 0 } ) values = [ json.loads(x) if x is not None else None for x in table.column('a').to_pylist() ] self.assertEqual(values, [{'k': 1}, None]) @require_server_version(24, 10) def test_map_json_as_text_values(self): with self.create_table('a Map(String, JSON)'): self.emit_cli( 'INSERT INTO test VALUES ' '(map(\'k\', CAST(\'{"n":1}\' AS JSON)))', enable_json_type=1 ) table = self.client.query_arrow( 'SELECT a FROM test', arrow_types={'a': pa.map_(pa.string(), pa.string())}, settings={ 'output_format_native_write_json_as_string': 1, # default differs across server versions 'output_format_json_quote_64bit_integers': 0 } ) values = [ [(k, json.loads(v)) for k, v in row] for row in table.column('a').to_pylist() ] self.assertEqual(values, [[('k', {'n': 1})]]) def test_nested_json_requires_arrow_types(self): with self.create_table('a Nested(j JSON, n UInt8)'): self.emit_cli( 'INSERT INTO test VALUES ' '([(CAST(\'{"k":1}\' AS JSON), 7)])', enable_json_type=1, flatten_nested=0 ) with self.assertRaises(ValueError) as e: self.client.query_arrow('SELECT a FROM test') self.assertIn('arrow_types', str(e.exception)) def test_tuple_json_requires_arrow_types(self): # Tuple has no explicit mapping, but JSON inside it must not # leak into type inference. with self.create_table('a Tuple(JSON, UInt8)'): self.client.execute( 'INSERT INTO test (a) VALUES', [(({'k': 1}, 7), )] ) with self.assertRaises(ValueError) as e: self.client.query_arrow('SELECT a FROM test') self.assertIn('arrow_types', str(e.exception)) class InferenceTestCase(ArrowBaseTestCase): # Int128 has no explicit mapping: Arrow type is inferred from the # first non-empty block. required_server_version = (21, 6) def test_unmapped_type_inferred_from_data(self): table = self.client.query_arrow( 'SELECT CAST(number AS Int128) AS x ' 'FROM system.numbers LIMIT 3' ) self.assertEqual(table.schema.field('x').type, pa.int64()) self.assertEqual(table.column('x').to_pylist(), [0, 1, 2]) def test_unmapped_type_empty_result(self): table = self.client.query_arrow( 'SELECT CAST(number AS Int128) AS x ' 'FROM system.numbers LIMIT 0' ) self.assertEqual(table.num_rows, 0) self.assertEqual(table.schema.field('x').type, pa.null()) class ArrowTypesOverrideTestCase(ArrowBaseTestCase): def test_general_type_override(self): table = self.client.query_arrow( 'SELECT CAST(number AS Int64) AS x ' 'FROM system.numbers LIMIT 3', arrow_types={'x': pa.int32()} ) self.assertEqual(table.schema.field('x').type, pa.int32()) self.assertEqual(table.column('x').to_pylist(), [0, 1, 2]) def test_stream_schema_uses_declared_type(self): reader = self.client.query_arrow_stream( 'SELECT CAST(number AS Int64) AS x ' 'FROM system.numbers LIMIT 3', arrow_types={'x': pa.float64()} ) self.assertEqual(reader.schema.field('x').type, pa.float64()) reader.read_all() class MapTestCase(ArrowBaseTestCase): required_server_version = (21, 1, 2) def client_kwargs(self, version): if version < (21, 4): return {'settings': {'allow_experimental_map_type': True}} def cli_client_kwargs(self): if self.server_version < (21, 4): return {'allow_experimental_map_type': 1} def test_map(self): with self.create_table('a Map(String, UInt64)'): self.client.execute( 'INSERT INTO test (a) VALUES', [({'a': 1, 'b': 2}, ), ({}, )] ) table = self.client.query_arrow('SELECT a FROM test') self.assertEqual( table.schema.field('a').type, pa.map_(pa.string(), pa.uint64()) ) self.assertEqual( table.column('a').to_pylist(), [[('a', 1), ('b', 2)], []] ) clickhouse-driver-0.2.11/tests/arrow/testcase.py000066400000000000000000000021571522645447600217220ustar00rootroot00000000000000try: import pyarrow as pa except ImportError: pa = None from tests.testcase import BaseTestCase class ArrowBaseTestCase(BaseTestCase): def setUp(self): if pa is None: self.skipTest('PyArrow package is not installed') super(ArrowBaseTestCase, self).setUp() def assert_arrow_column(self, ch_type, expected_pa_type, data, expected=None): """ Creates a table with a single column of ``ch_type``, inserts ``data`` into it and checks that ``query_arrow`` returns a table with expected Arrow type and values. """ with self.create_table('a {}'.format(ch_type)): self.client.execute( 'INSERT INTO test (a) VALUES', [(x, ) for x in data] ) table = self.client.query_arrow('SELECT a FROM test') self.assertIsInstance(table, pa.Table) self.assertEqual(table.schema.field('a').type, expected_pa_type) self.assertEqual( table.column('a').to_pylist(), data if expected is None else expected ) clickhouse-driver-0.2.11/tests/clickhouse_server_config/000077500000000000000000000000001522645447600234425ustar00rootroot00000000000000clickhouse-driver-0.2.11/tests/clickhouse_server_config/certs/000077500000000000000000000000001522645447600245625ustar00rootroot00000000000000clickhouse-driver-0.2.11/tests/clickhouse_server_config/certs/dhparam.pem000066400000000000000000000014051522645447600267010ustar00rootroot00000000000000-----BEGIN DH PARAMETERS----- MIICDAKCAgEA66P8i6eWye0lVlAeAxDdF2fqHh93OjEVaiSRwqojyq0L4UeXDPkx xWtQujZG4xvxyBH9udpqBmtoyNLgMShiMeCEZKQ4YTYOZIEsJU6GxADevDjAArwg BB3Qri3YL/u3zKxvFd36NIHj5/gOrCoC7c8R2NA8wDIOP+SPD1Tdk7i5yYk1u7SB m7O2tyK+ZrU4lF6k4lpLryDPjYPavAXia3DXUqCJdAwtqTz/jR3QmuaT1iPENnR7 /Xgm3JiKQLkOMBJLdLJqL/43KtnRboMhsqjDO4go039GLVSp6yFQ4V/NbuEFKLhH d4DJJYc3zmS94Oq9UNWDEsokTMAT/4mPpLNVCXOLR4yoaOW5qikq08PytFNV7dKa Pbbgy6yC/NSt5CB9MfdfY0IU1ddMgE+sBbCBxFCZdXUXx3eNCtziqQLGmg++RjBV qJgeMqc+dFKkOb6alJNUkO0svuelcjAWVJ0kZ9FIDPb36I8VmEVpxaHB2dRKrQPO z3Yj4fx7VIMILFg/8Wfm5Vu19BvQRTIpjPdVl3uHs/UyEQSs1g37LnGWCiBN9OhV uQe4yDVlUficWYmWRF/rwkPL/3cUQrWyQfbzSapGWMLDown7+jcAuXZyZNvskmYB cgF4BYbEM8cJrlmMbJNYkT522T5mxiiVEMxD6yUIymU586rYWjBOu6cCAQICAgFF -----END DH PARAMETERS----- clickhouse-driver-0.2.11/tests/clickhouse_server_config/certs/server.crt000066400000000000000000000021231522645447600266000ustar00rootroot00000000000000-----BEGIN CERTIFICATE----- MIIDBTCCAe2gAwIBAgIUbWRGuPelwmGh762nyTO5l+IzrVowDQYJKoZIhvcNAQEL BQAwGTEXMBUGA1UEAwwOdGVzdHMubG9jYWwgQ0EwHhcNMjQwMzAzMTk0MzU2WhcN MjUwMzAzMTk0MzU2WjAcMRowGAYDVQQDDBFjbGlja2hvdXNlLXNlcnZlcjCCASIw DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANSLt5AVi1uHiU/eg8XsXmWmDnAk fbRC1jzgfP53jTVJdCBU4dMNdi6lNnnCcuIySx+oOiQZ6OwR2tqs1trwnKxgyqnH WDexZL04sPlvS8EqD/JiTqQW297YI6ev+1SiChfoF88gH62zInfj4wiLmxw+kJgL F/zCuIz4oFNs+Eu5XDcB35/Ec1d/1deIQkP6jtyLs+scytME2Oy8kgy8aXU1vf5R zqgek8sYF4LPwOd3uXnhRAdMs+9kgFUKwN12rin5BviQmuylN3CS0BWflYu4Jnzv +Fwb5ofCfUvmM6W1WgkSkfwFjCvWeUxZVJZm+BbX6C0tOPjy1oTYtRLhLqkCAwEA AaNCMEAwHQYDVR0OBBYEFPxxrwgl2071sxoU6HEKgT5pkXr3MB8GA1UdIwQYMBaA FFgOIk+h1x8iFcZ2wIsf9PMYSdJpMA0GCSqGSIb3DQEBCwUAA4IBAQAggmdsCr/G ZWe5KMSYK3KSiQHnvAb05uKLL1tP4vb9TGO/ailWBL/b+mH09s8OwEMx68Yo91SR GtYvF4ri/f4y4sqesmbNoqRD9EdXZhItF/K4WbMIlu0+URP7AIytA2UDk32vhf86 sHpLV7sbfgFbEWfV5xuWsZeSVJXpiq4HQoJuXoQahHclDOHNPC2NyWLWLKHLLPTJ LVqtb52/dajVmvX5HiwqSpLt/7XBsYex1IqsI16oouo2oe2FcjIBNK6A5weEGhoZ n7XgItP7uLqvhUmEcmFB24ts/6FXSc5bxHk0GkQVKT48CvM0UemRgVVRkaywqNNv Oh9OMh6TqP4h -----END CERTIFICATE----- clickhouse-driver-0.2.11/tests/clickhouse_server_config/certs/server.csr000066400000000000000000000017141522645447600266040ustar00rootroot00000000000000-----BEGIN CERTIFICATE REQUEST----- MIICljCCAX4CAQAwHDEaMBgGA1UEAwwRY2xpY2tob3VzZS1zZXJ2ZXIwggEiMA0G CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDUi7eQFYtbh4lP3oPF7F5lpg5wJH20 QtY84Hz+d401SXQgVOHTDXYupTZ5wnLiMksfqDokGejsEdrarNba8JysYMqpx1g3 sWS9OLD5b0vBKg/yYk6kFtve2COnr/tUogoX6BfPIB+tsyJ34+MIi5scPpCYCxf8 wriM+KBTbPhLuVw3Ad+fxHNXf9XXiEJD+o7ci7PrHMrTBNjsvJIMvGl1Nb3+Uc6o HpPLGBeCz8Dnd7l54UQHTLPvZIBVCsDddq4p+Qb4kJrspTdwktAVn5WLuCZ87/hc G+aHwn1L5jOltVoJEpH8BYwr1nlMWVSWZvgW1+gtLTj48taE2LUS4S6pAgMBAAGg NTAzBgkqhkiG9w0BCQ4xJjAkMCIGA1UdEQQbMBmCEWNsaWNraG91c2Utc2VydmVy hwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQCsVsVB7VAofJUtr3L/hcj/PExccdKf RYBcZQP3ekdY07V69B/FeLFxDHrWkoWV5vcI8g+87FpEUNR8tn7GrbEtiQe7elxY kAzddwIlz8YqjeyVyd7FUpUtPts7I9YvglGg/y7yIlGxwvcg8lP+rkC6A6H5Q/tj zsUMbRZvC84BZIwxswj9yvoQhH79HRUsN8rv3T9as6PwbKKGcRRfPvBBk0T0uecZ PYFSbpZD9Zt5VLtUy/A/Q5skS8mLUV9/BZk2P/8nTLsZvg+rxSEyDa7d7QP5uNF9 7jOFh2tF9JOl0yxAWPtAnesiAfA82Y2xeV5GqgwJnPcV2Xhj6VwDBC8F -----END CERTIFICATE REQUEST----- clickhouse-driver-0.2.11/tests/clickhouse_server_config/certs/server.key000066400000000000000000000032501522645447600266020ustar00rootroot00000000000000-----BEGIN PRIVATE KEY----- MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDUi7eQFYtbh4lP 3oPF7F5lpg5wJH20QtY84Hz+d401SXQgVOHTDXYupTZ5wnLiMksfqDokGejsEdra rNba8JysYMqpx1g3sWS9OLD5b0vBKg/yYk6kFtve2COnr/tUogoX6BfPIB+tsyJ3 4+MIi5scPpCYCxf8wriM+KBTbPhLuVw3Ad+fxHNXf9XXiEJD+o7ci7PrHMrTBNjs vJIMvGl1Nb3+Uc6oHpPLGBeCz8Dnd7l54UQHTLPvZIBVCsDddq4p+Qb4kJrspTdw ktAVn5WLuCZ87/hcG+aHwn1L5jOltVoJEpH8BYwr1nlMWVSWZvgW1+gtLTj48taE 2LUS4S6pAgMBAAECggEAFAz8K6EErQVLvFei+bxzKUaxjP28SBGYEVUiJYVUsma0 CErJpPXbpMncKj9gRBt3f8yIc5hoI0EJ8uAkQrI5LX/SDpMqLNLUzI75DwbjUB0u NPD2Nz+azVp5fpu464J/zkKMYHNI2cOQ6Ft8svUslE0Iqfc984/RBid8RHJ+t/Hf +ycFra5rdYEEn5fe/B9XWqrimYONO2f6fY0qJ3hV2HG/dRu5S8D7J63HnEJxoKtG gcxNBF46mnVTDZspD7V2fYKeRTp2SP6xkZdbAK5mrW7IwZuZstorbZ/H+jY6YlSw XkQ5OrvOITaaC5xBRR1psR8709UZffIDfMdnOQwJqQKBgQD4MrL5nTl76hPwQXb/ 1B2QoKaInGUwOINFWVK9OgwUHjCEW5bZ1TEb0iXZC8DCh/X3JLhVykp/CJZNjZ1U q+SSkcE0UXMIP6+MKEvIJVBCAuwgd9ZKIYuGM1dN90wxlYvJnH6SYjqLLag5Tapa lBoAbGYqg8WqRAcC8LEOCUmsjQKBgQDbOh3hHY6Vdg5KYy2exnk+f2EHGeAXCK6X Iregf9qovj6j6ccNHDT2Qf3DkR9Fdu05ZWD2U5C7PU7e6V9botwdauoB0mr2Yszc EaTQfjIT9eLE2XaLUw/Q5105+PAxc4QScc/0y5VtujjMUKhGCbnF2fubtIEyHk1i dn287Fj5jQKBgEZecXnuBr9INZD3rpqH9D3uHmk7FkFetHE0Cw5VZ9lIWe8c3J80 H7FImqx39ZXx4F3KzmycZxSvRZYFYacA+VRI+OMxeJDNJaNyRVIgqimdFH98Goh4 DEvnQIh9Zd/lC3YE5anxKbIOJtTgXT1DIkAee7TwGVnV4bsGrNxS6819AoGBALdX Rk/TYUB8B/2MLkYAJLvw2ZuPt0psN18saLew1ZST7l01EQRU17IvhGO/BZEZodGD iHDZeEwvPLvOHrLLZByyIlw9trix7jQKCXVYZNcup2ULnUltwOdr5xqpp28j9Ytb ZZiLfj/TItc0iVZxoczmvbb9YaMhloRHJmcOnmatAoGACljWbDkPeQNF+EH6OoC6 Eresu12MeQChia7jaXuLm68h4M6CxboZnhqAJRV1x63joZK15eVGxBjg+30Hw2mq 7jKwsDrQLAjgxdMO/vZ+U/lPpqvObKdPZw4Ld6fJ8OcXKxGg/wENu770vVAzxpUr j64QFrbN/9tlhDGD+xCcuYE= -----END PRIVATE KEY----- clickhouse-driver-0.2.11/tests/clickhouse_server_config/certs/tests_ca.crt000066400000000000000000000021471522645447600271050ustar00rootroot00000000000000-----BEGIN CERTIFICATE----- MIIDEzCCAfugAwIBAgIUTwSVyR94CL34RTPkujqVP17HOEYwDQYJKoZIhvcNAQEL BQAwGTEXMBUGA1UEAwwOdGVzdHMubG9jYWwgQ0EwHhcNMjQwMzAzMTk0MTMxWhcN MjcwMzAzMTk0MTMxWjAZMRcwFQYDVQQDDA50ZXN0cy5sb2NhbCBDQTCCASIwDQYJ KoZIhvcNAQEBBQADggEPADCCAQoCggEBALzOQgfgDZY+sjPamQp7omKwkKlxEzAq EdFGXPM2nqbfsCnDxjNmXeEukX9Ml0md4swscKjoqDRamCOwWPGB6IrRTI5SaTOW wVJLuloN6iworNUECHlKJhE6Fi15r+vXx1wRplucgyGUYY3msz1OQmbegGZyUGV7 DE4J93RIxeVz8nmmSXydxCiawrp7pb4z1d47uXu9dcgQvjkOQcsl7to0tLjoyFSI IHYgiFri/X12r16nzVJZCxO6DHFRMOUTrpXbR4qxMMqQsfu1YvXZjSuCdP16Kt4v gsFkNtw7pIgvtIROq0f+c6rpYRM3wHRH/u9iRxDaiJLUlpM34ntK0h8CAwEAAaNT MFEwHQYDVR0OBBYEFFgOIk+h1x8iFcZ2wIsf9PMYSdJpMB8GA1UdIwQYMBaAFFgO Ik+h1x8iFcZ2wIsf9PMYSdJpMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEL BQADggEBAFqIeReZefr9KJRuiDXr7+2unLAKBDTWBmnKsVnP80EgffsV4CE+qMSF v9Ep3JYDDQXfq0Vm6NJUidTCg7p4JNzr/jy1gPv4lWCYRN4cZkZT1JZ1dXfvm7Ra ebGQgBrOZ2Q1qBWy4vf9CbAV9T/TrMDC9u7pxX+tpKuS63nLob8tOGxT4iMZqziV WpvO4haTboz1MiZczwAXXDtyNKL0sTEhmaLe7pURhWSjqngpln3GAvjoyGabCDsU 800IhYps+Y809caZwUz8rLKtTZG3bSg9cvq7qVI2SKeh1BWDbcMejpBuO4/6BHAC LZU5ylW64KMrv14/4DOcZD/jYEN7DNQ= -----END CERTIFICATE----- clickhouse-driver-0.2.11/tests/clickhouse_server_config/certs/tests_ca.key000066400000000000000000000032501522645447600271010ustar00rootroot00000000000000-----BEGIN PRIVATE KEY----- MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC8zkIH4A2WPrIz 2pkKe6JisJCpcRMwKhHRRlzzNp6m37Apw8YzZl3hLpF/TJdJneLMLHCo6Kg0Wpgj sFjxgeiK0UyOUmkzlsFSS7paDeosKKzVBAh5SiYROhYtea/r18dcEaZbnIMhlGGN 5rM9TkJm3oBmclBlewxOCfd0SMXlc/J5pkl8ncQomsK6e6W+M9XeO7l7vXXIEL45 DkHLJe7aNLS46MhUiCB2IIha4v19dq9ep81SWQsTugxxUTDlE66V20eKsTDKkLH7 tWL12Y0rgnT9eireL4LBZDbcO6SIL7SETqtH/nOq6WETN8B0R/7vYkcQ2oiS1JaT N+J7StIfAgMBAAECggEAHABca1M/u0cEd4ugY51JzGiH++lI7D1rs7ruHCVp9YZ6 rPxbunx1yJN3LAcNmkhv6NIKdLKUsmG2lfcYfzDsw8ceGy7TwBKdYfmDOMnphK+/ pOlajF/X3M7dl9RSp/Vc8XsDTiuciHAQ4Se+8NpYyhg5DiM+vd44SUv8cY2SyWBd eqFYbcHkxsFLPllCWFN92KEfHBoT4EkNPhiXgWOdZn6CcSMw8wsgFsoZ559mTo+O fPG0Nz+yHTNWDO/fvVIdR970Pd8STE2UYM6Bo3lWzs8XmUGxiinkSMYZ9yul5Gf/ 18ZY+115Z7zB5N5XOZntz1a4PjBLNJxe6PnCNTRhGQKBgQD4T1D9JX9mSRW6RZ9x GlS3Kjb6PN33zUXNIAvgMk3gGQBd/KDljaTP70KugJFDK7WKNyE+0K3+pd5GlKeC 6ph/ZDsrnOZfKferFeYyY4i68TOnMLZ0ucT+HZ4wGyKcS4PqLitgRMdCWkpBN9OU T0kYVO85Aq/QS4ZHysbqclgUuwKBgQDCpyw+ctFtVY65v9UMtpx4eEr0VDy9Plx9 vZfe45tKtOpkJGfttb1dxLr6cMy/UN8QcHOSP3A1OKAnYHz978GtIG3YAcHb/qn9 C7aYdZTGh5ZRwS08sOt5+QVHyQkqgrLlKeSodbbF24+V81Fhx5rJYxS/j4kWqz6o ZzwzFiVT7QKBgQC2UM5fQEP9XxYD8ZCy46ll3yoEq+IyStbAWJI/p8/EBbdeStn8 Efb78WmdZKrDjfk6JWZUj7XhLfo5Cna/ye30QyyqxgXjw5WkWWzufGRtFiJd1Idy xt9b0XVPTu0nos6ViBazFWzUTCUPI6VG1LwPkHUg/9cE8h8C4WERzKjddwKBgQCL ZlljJ6sf18Ps9prHDggkplFXhPQyuvRWAG9A6lOOPt4VdZUQQbUp7/fP3vRilrII /d9mfxQGqVTYnlslKIzVRYIkza1dtZVbaQYNTTeMrhFS3ztcWX9pzJKhhDGSRiOD xmrA0fxg2gqMYsKHegE59EEppsuQdnba94O/Oj7lSQKBgC7JiZtWS3gfZNtDM+fz zE4+u2TBQuJYAi4qcJdqXOUkxoPvKO32f4S5dTvsFDQu/6hC+1bjNGN6AlnocyjR cwNcEuG5U+VN5bRwfBUk50J7++S+OhSJo8LaArk/pm+8l5mwE5Lth9Q0Ieo5YsMX BEtzCOrLBd5Yv4lqHx0tqbri -----END PRIVATE KEY----- clickhouse-driver-0.2.11/tests/clickhouse_server_config/certs/tests_ca.srl000066400000000000000000000000511522645447600271050ustar00rootroot000000000000006D6446B8F7A5C261A1EFADA7C933B997E233AD5A clickhouse-driver-0.2.11/tests/clickhouse_server_config/clickhouse.xml000066400000000000000000000016661522645447600263260ustar00rootroot00000000000000 9440 /etc/clickhouse-server/certs/server.crt /etc/clickhouse-server/certs/server.key /etc/clickhouse-server/certs/dhparam.pem none /etc/clickhouse-server/certs/tests_ca.crt true sslv2,sslv3 true clickhouse-driver-0.2.11/tests/clickhouse_server_config/clickhouse_users.xml000066400000000000000000000007221522645447600275370ustar00rootroot00000000000000 ::/0 default default 1 clickhouse-driver-0.2.11/tests/clickhouse_server_config/yandex.xml000066400000000000000000000016561522645447600254640ustar00rootroot00000000000000 9440 /etc/clickhouse-server/certs/server.crt /etc/clickhouse-server/certs/server.key /etc/clickhouse-server/certs/dhparam.pem none /etc/clickhouse-server/certs/tests_ca.crt true sslv2,sslv3 true clickhouse-driver-0.2.11/tests/clickhouse_server_config/yandex_users.xml000066400000000000000000000007121522645447600266750ustar00rootroot00000000000000 ::/0 default default 1 clickhouse-driver-0.2.11/tests/columns/000077500000000000000000000000001522645447600200565ustar00rootroot00000000000000clickhouse-driver-0.2.11/tests/columns/__init__.py000066400000000000000000000000001522645447600221550ustar00rootroot00000000000000clickhouse-driver-0.2.11/tests/columns/test_array.py000066400000000000000000000205151522645447600226100ustar00rootroot00000000000000from uuid import UUID from tests.testcase import BaseTestCase from clickhouse_driver import errors from tests.util import require_server_version class ArrayTestCase(BaseTestCase): def test_empty(self): columns = 'a Array(Int32)' data = [([], )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '[]\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_simple(self): columns = 'a Array(Int32)' data = [([100, 500], )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '[100,500]\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_write_column_as_nested_array(self): columns = 'a Array(Int32)' data = [([100, 500], ), ([100, 500], )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '[100,500]\n[100,500]\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_nested_with_enum(self): columns = "a Array(Array(Enum8('hello' = -1, 'world' = 2)))" data = [([['hello', 'world'], ['hello']], )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "[['hello','world'],['hello']]\n" ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_nested_of_nested(self): columns = 'a Array(Array(Array(Int32))), b Array(Array(Array(Int32)))' data = [([ [[255, 170], [127, 127, 127, 127, 127], [170, 170, 170], [170]], [[255, 255, 255], [255]], [[255], [255], [255]] ], [ [[255, 170], [127, 127, 127, 127, 127], [170, 170, 170], [170]], [[255, 255, 255], [255]], [[255], [255], [255]] ])] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a, b) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '[[[255,170],[127,127,127,127,127],[170,170,170],[170]],' '[[255,255,255],[255]],[[255],[255],[255]]]\t' '[[[255,170],[127,127,127,127,127],[170,170,170],[170]],' '[[255,255,255],[255]],[[255],[255],[255]]]\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_multidimensional(self): columns = "a Array(Array(Array(Nullable(String))))" data = [([[['str1_1', 'str1_2', None], [None]], [['str1_3', 'str1_4', None], [None]]], ), ([[['str2_1', 'str2_2', None], [None]]], ), ([[['str3_1', 'str3_2', None], [None]]],)] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '[[[\'str1_1\',\'str1_2\',NULL],[NULL]],' '[[\'str1_3\',\'str1_4\',NULL],[NULL]]]\n' '[[[\'str2_1\',\'str2_2\',NULL],[NULL]]]\n' '[[[\'str3_1\',\'str3_2\',NULL],[NULL]]]\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_empty_nested(self): columns = "a Array(Array(Array(Int32))), b Array(Array(Array(Int32)))" data = [ ([], [[]],), ] with self.create_table(columns): self.client.execute("INSERT INTO test (a, b) VALUES", data) query = "SELECT * FROM test" inserted = self.emit_cli(query) self.assertEqual( inserted, "[]\t[[]]\n", ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_type_mismatch_error(self): columns = 'a Array(Int32)' data = [('test', )] with self.create_table(columns): with self.assertRaises(errors.TypeMismatchError): self.client.execute('INSERT INTO test (a) VALUES', data) data = [(['test'], )] with self.create_table(columns): with self.assertRaises(errors.TypeMismatchError): self.client.execute('INSERT INTO test (a) VALUES', data) def test_string_array(self): columns = 'a Array(String)' data = [(['aaa', 'bbb'], )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "['aaa','bbb']\n" ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_string_nullable_array(self): columns = 'a Array(Nullable(String))' data = [(['aaa', None, 'bbb'], )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "['aaa',NULL,'bbb']\n" ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_uuid_array(self): columns = 'a Array(UUID)' data = [([ UUID('c0fcbba9-0752-44ed-a5d6-4dfb4342b89d'), UUID('2efcead4-ff55-4db5-bdb4-6b36a308d8e0') ], )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "['c0fcbba9-0752-44ed-a5d6-4dfb4342b89d'," "'2efcead4-ff55-4db5-bdb4-6b36a308d8e0']\n" ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_uuid_nullable_array(self): columns = 'a Array(Nullable(UUID))' data = [([ UUID('c0fcbba9-0752-44ed-a5d6-4dfb4342b89d'), None, UUID('2efcead4-ff55-4db5-bdb4-6b36a308d8e0') ], )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "['c0fcbba9-0752-44ed-a5d6-4dfb4342b89d'," "NULL," "'2efcead4-ff55-4db5-bdb4-6b36a308d8e0']\n" ) inserted = self.client.execute(query) self.assertEqual(inserted, data) @require_server_version(19, 16, 13) def test_tuple_array(self): columns = 'a Array(Tuple(Int32))' data = [([], )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "[]\n" ) inserted = self.client.execute(query) self.assertEqual(inserted, data) clickhouse-driver-0.2.11/tests/columns/test_bool.py000066400000000000000000000040351522645447600224240ustar00rootroot00000000000000from tests.testcase import BaseTestCase from clickhouse_driver import errors class BoolTestCase(BaseTestCase): required_server_version = (21, 12) def test_simple(self): columns = ("a Bool") data = [(1,), (0,), (True,), (False,), (None,), ("False",), ("",)] with self.create_table(columns): self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, ( 'true\n' 'false\n' 'true\n' 'false\n' 'false\n' 'true\n' 'false\n' ) ) inserted = self.client.execute(query) self.assertEqual( inserted, [ (True, ), (False, ), (True, ), (False, ), (False, ), (True, ), (False, ), ] ) def test_errors(self): columns = "a Bool" with self.create_table(columns): with self.assertRaises(errors.TypeMismatchError): self.client.execute( 'INSERT INTO test (a) VALUES', [(1, )], types_check=True ) def test_nullable(self): columns = "a Nullable(Bool)" data = [(None, ), (True, ), (False, )] with self.create_table(columns): self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, ( '\\N\ntrue\nfalse\n' ) ) inserted = self.client.execute(query) self.assertEqual( inserted, [ (None, ), (True, ), (False, ), ] ) clickhouse-driver-0.2.11/tests/columns/test_common.py000066400000000000000000000033501522645447600227600ustar00rootroot00000000000000from tests.testcase import BaseTestCase class CommonTestCase(BaseTestCase): client_kwargs = {'settings': {'insert_block_size': 1}} def setUp(self): super(CommonTestCase, self).setUp() self.send_data_count = 0 old_send_data = self.client.connection.send_data def send_data(*args, **kwargs): self.send_data_count += 1 return old_send_data(*args, **kwargs) self.client.connection.send_data = send_data def test_insert_block_size(self): with self.create_table('a UInt8'): data = [(x, ) for x in range(4)] self.client.execute( 'INSERT INTO test (a) VALUES', data ) # Two empty blocks: for end of sending external tables # and data. self.assertEqual(self.send_data_count, 4 + 2) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '0\n1\n2\n3\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_columnar_insert_block_size(self): with self.create_table('a UInt8'): data = [(0, 1, 2, 3)] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) # Two empty blocks: for end of sending external tables # and data. self.assertEqual(self.send_data_count, 4 + 2) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '0\n1\n2\n3\n') inserted = self.client.execute(query) expected = [(0, ), (1, ), (2, ), (3, )] self.assertEqual(inserted, expected) clickhouse-driver-0.2.11/tests/columns/test_date.py000066400000000000000000000102211522645447600224000ustar00rootroot00000000000000import os from datetime import date, datetime from unittest.mock import patch from freezegun import freeze_time from tests.testcase import BaseTestCase from tests.util import require_server_version class DateTestCase(BaseTestCase): @freeze_time('2017-03-05 03:00:00') def test_do_not_use_timezone(self): with self.create_table('a Date'): data = [(date(1970, 1, 2), )] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '1970-01-02\n') with patch.dict(os.environ, {'TZ': 'US/Hawaii'}): inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_insert_datetime_to_date(self): with self.create_table('a Date'): testTime = datetime(2015, 6, 6, 12, 30, 54) self.client.execute( 'INSERT INTO test (a) VALUES', [(testTime, )] ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '2015-06-06\n') def test_wrong_date_insert(self): with self.create_table('a Date'): data = [ (date(5555, 1, 1), ), (date(1, 1, 1), ), (date(2149, 6, 7), ) ] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) expected = ( 3*'1970-01-01\n' if self.server_version > (20, 7, 2) else 3*'0000-00-00\n' ) self.assertEqual(inserted, expected) def test_boundaries(self): extended_date = self.server_version > (21, 4) with self.create_table('a Date'): data = [ (date(1970, 1, 1), ), ((date(2149, 6, 6) if extended_date else date(2106, 2, 7)), ) ] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) if extended_date: expected = '1970-01-01\n2149-06-06\n' else: if self.server_version > (20, 7, 2): expected = '1970-01-01\n2106-02-07\n' else: expected = '0000-00-00\n2106-02-07\n' self.assertEqual(inserted, expected) inserted = self.client.execute(query) self.assertEqual(inserted, data) class Date32TestCase(BaseTestCase): required_server_version = (21, 9) def test_wrong_date_insert(self): with self.create_table('a Date32'): data = [ (date(5555, 1, 1), ), (date(1, 1, 1), ), (date(2300, 1, 1), ), (date(1899, 12, 31), ) ] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '1970-01-01\n1970-01-01\n1970-01-01\n1970-01-01\n', ) @require_server_version(22, 8) def test_boundaries_1900(self): with self.create_table('a Date32'): data = [(date(1900, 1, 1),), (date(2299, 12, 31), )] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '1900-01-01\n2299-12-31\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_boundaries(self): with self.create_table('a Date32'): data = [(date(1925, 1, 1), ), (date(2283, 11, 11), )] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '1925-01-01\n2283-11-11\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) clickhouse-driver-0.2.11/tests/columns/test_datetime.py000066400000000000000000000446531522645447600232770ustar00rootroot00000000000000from datetime import date, datetime from unittest.mock import patch from pytz import timezone, utc, UnknownTimeZoneError import tzlocal from tests.testcase import BaseTestCase from tests.util import require_server_version, patch_env_tz class DateTimeTestCase(BaseTestCase): def test_simple(self): with self.create_table('a Date, b DateTime'): data = [(date(2012, 10, 25), datetime(2012, 10, 25, 14, 7, 19))] self.client.execute( 'INSERT INTO test (a, b) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '2012-10-25\t2012-10-25 14:07:19\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_nullable_date(self): with self.create_table('a Nullable(Date)'): data = [ (None, ), (date(2012, 10, 25), ), (None, ), (date(2017, 6, 23), ) ] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '\\N\n2012-10-25\n\\N\n2017-06-23\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_nullable_datetime(self): with self.create_table('a Nullable(DateTime)'): data = [ (None, ), (datetime(2012, 10, 25, 14, 7, 19), ), (None, ), (datetime(2017, 6, 23, 19, 10, 15), ) ] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '\\N\n2012-10-25 14:07:19\n\\N\n2017-06-23 19:10:15\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_handle_errors_from_tzlocal(self): with patch('tzlocal.get_localzone') as mocked: mocked.side_effect = UnknownTimeZoneError() self.client.execute('SELECT now()') if hasattr(tzlocal, 'get_localzone_name'): with patch('tzlocal.get_localzone_name') as mocked: mocked.side_effect = None self.client.execute('SELECT now()') @require_server_version(20, 1, 2) def test_datetime64_frac_trunc(self): with self.create_table('a DateTime64'): data = [(datetime(2012, 10, 25, 14, 7, 19, 125600), )] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '2012-10-25 14:07:19.125\n') inserted = self.client.execute(query) self.assertEqual( inserted, [(datetime(2012, 10, 25, 14, 7, 19, 125000), )] ) def test_insert_integers(self): with self.create_table('a DateTime'): self.client.execute( 'INSERT INTO test (a) VALUES', [(1530211034, )] ) query = 'SELECT toUInt32(a), a FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '1530211034\t2018-06-28 21:37:14\n') @require_server_version(20, 1, 2) def test_insert_integers_datetime64(self): with self.create_table('a DateTime64'): self.client.execute( 'INSERT INTO test (a) VALUES', [(1530211034123, )] ) query = 'SELECT toUInt32(a), a FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '1530211034\t2018-06-28 21:37:14.123\n') def test_insert_integer_bounds(self): with self.create_table('a DateTime'): self.client.execute( 'INSERT INTO test (a) VALUES', [(0, ), (1, ), (1500000000, ), (2**32-1, )] ) query = 'SELECT toUInt32(a) FROM test ORDER BY a' inserted = self.emit_cli(query) self.assertEqual(inserted, '0\n1\n1500000000\n4294967295\n') @require_server_version(21, 4) def test_insert_datetime64_extended_range(self): with self.create_table('a DateTime64(0)'): self.client.execute( 'INSERT INTO test (a) VALUES', [(-1420077600, ), (-1420077599, ), (0, ), (1, ), (9877248000, )] ) query = 'SELECT toInt64(a), a FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '-1420077600\t1925-01-01 00:00:00\n' '-1420077599\t1925-01-01 00:00:01\n' '0\t1970-01-01 03:00:00\n' '1\t1970-01-01 03:00:01\n' '9877248000\t2282-12-31 03:00:00\n' ) query = 'SELECT a FROM test ORDER BY a' inserted = self.client.execute(query) self.assertEqual( inserted, [ (datetime(1925, 1, 1, 0, 0, 0), ), (datetime(1925, 1, 1, 0, 0, 1), ), (datetime(1970, 1, 1, 3, 0, 0), ), (datetime(1970, 1, 1, 3, 0, 1), ), (datetime(2282, 12, 31, 3, 0, 0), ) ] ) @require_server_version(21, 4) def test_insert_datetime64_extended_range_pure_ints_out_of_range(self): with self.create_table('a DateTime64(0)'): self.client.execute( 'INSERT INTO test (a) VALUES', [(0, ), (1, ), (-2**63, ), (2**63-1, )] ) query = 'SELECT toInt64(a) FROM test ORDER BY a' inserted = self.emit_cli(query) self.assertEqual( inserted, '-9223372036854775808\n0\n1\n9223372036854775807\n' ) class DateTimeTimezonesTestCase(BaseTestCase): dt_type = 'DateTime' # Asia/Kamchatka = UTC+12 # Asia/Novosibirsk = UTC+7 # Europe/Moscow = UTC+3 # 1500010800 second since epoch in Europe/Moscow. # 1500000000 second since epoch in UTC. dt = datetime(2017, 7, 14, 5, 40) dt_tz = timezone('Asia/Kamchatka').localize(dt) col_tz_name = 'Asia/Novosibirsk' col_tz = timezone(col_tz_name) # INSERTs and SELECTs must be the same as clickhouse-client's # if column has no timezone. def table_columns(self, with_tz=False): if not with_tz: return 'a {}'.format(self.dt_type) return "a {}('{}')".format(self.dt_type, self.col_tz_name) def test_use_server_timezone(self): # Insert datetime with timezone UTC # into column with no timezone # using server's timezone (Europe/Moscow) # Determine server timezone and calculate expected timestamp. server_tz_name = self.client.execute('SELECT timezone()')[0][0] offset = timezone(server_tz_name).utcoffset(self.dt).total_seconds() timestamp = 1500010800 - int(offset) with patch_env_tz('Asia/Novosibirsk'): with self.create_table(self.table_columns()): self.client.execute( 'INSERT INTO test (a) VALUES', [(self.dt, )] ) self.emit_cli( "INSERT INTO test (a) VALUES ('2017-07-14 05:40:00')" ) query = 'SELECT toInt32(a) FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '{ts}\n{ts}\n'.format(ts=timestamp)) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '2017-07-14 05:40:00\n2017-07-14 05:40:00\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, [(self.dt, ), (self.dt, )]) def test_use_client_timezone(self): # Insert datetime with timezone UTC # into column with no timezone # using client's timezone Asia/Novosibirsk settings = {'use_client_time_zone': True} with patch_env_tz('Asia/Novosibirsk'): with self.create_table(self.table_columns()): self.client.execute( 'INSERT INTO test (a) VALUES', [(self.dt, )], settings=settings ) self.emit_cli( "INSERT INTO test (a) VALUES ('2017-07-14 05:40:00')", use_client_time_zone=1 ) query = 'SELECT toInt32(a) FROM test' inserted = self.emit_cli(query, use_client_time_zone=1) # 1499985600 = 1500000000 - 4 * 3600 self.assertEqual(inserted, '1499985600\n1499985600\n') query = 'SELECT * FROM test' inserted = self.emit_cli(query, use_client_time_zone=1) self.assertEqual( inserted, '2017-07-14 05:40:00\n2017-07-14 05:40:00\n' ) inserted = self.client.execute(query, settings=settings) self.assertEqual(inserted, [(self.dt, ), (self.dt, )]) @require_server_version(1, 1, 54337) def test_datetime_with_timezone_use_server_timezone(self): # Insert datetime with timezone Asia/Kamchatka # into column with no timezone # using server's timezone (Europe/Moscow) server_tz_name = self.client.execute('SELECT timezone()')[0][0] offset = timezone(server_tz_name).utcoffset(self.dt) with patch_env_tz('Asia/Novosibirsk'): with self.create_table(self.table_columns()): self.client.execute( 'INSERT INTO test (a) VALUES', [(self.dt_tz, )] ) self.emit_cli( "INSERT INTO test (a) VALUES " "(toDateTime('2017-07-14 05:40:00', 'Asia/Kamchatka'))", ) query = 'SELECT toInt32(a) FROM test' inserted = self.emit_cli(query) # 1499967600 = 1500000000 - 12 * 3600 self.assertEqual(inserted, '1499967600\n1499967600\n') query = 'SELECT * FROM test' inserted = self.emit_cli(query) dt = (self.dt_tz.astimezone(utc) + offset).replace(tzinfo=None) self.assertEqual(inserted, '{dt}\n{dt}\n'.format(dt=dt)) inserted = self.client.execute(query) self.assertEqual(inserted, [(dt, ), (dt, )]) @require_server_version(1, 1, 54337) def test_datetime_with_timezone_use_client_timezone(self): # Insert datetime with timezone Asia/Kamchatka # into column with no timezone # using client's timezone Asia/Novosibirsk settings = {'use_client_time_zone': True} with patch_env_tz('Asia/Novosibirsk'): with self.create_table(self.table_columns()): self.client.execute( 'INSERT INTO test (a) VALUES', [(self.dt_tz, )], settings=settings ) self.emit_cli( "INSERT INTO test (a) VALUES " "(toDateTime('2017-07-14 05:40:00', 'Asia/Kamchatka'))", use_client_time_zone=1 ) query = 'SELECT toInt32(a) FROM test' inserted = self.emit_cli(query, use_client_time_zone=1) # 1499967600 = 1500000000 - 12 * 3600 self.assertEqual(inserted, '1499967600\n1499967600\n') query = 'SELECT * FROM test' inserted = self.emit_cli(query, use_client_time_zone=1) # 2017-07-14 00:40:00 = 2017-07-14 05:40:00 - 05:00:00 # (Kamchatka - Novosibirsk) self.assertEqual( inserted, '2017-07-14 00:40:00\n2017-07-14 00:40:00\n' ) inserted = self.client.execute(query, settings=settings) dt = datetime(2017, 7, 14, 0, 40) self.assertEqual(inserted, [(dt, ), (dt, )]) @require_server_version(1, 1, 54337) def test_column_use_server_timezone(self): # Insert datetime with no timezone # into column with timezone Asia/Novosibirsk # using server's timezone (Europe/Moscow) with patch_env_tz('Europe/Moscow'): with self.create_table(self.table_columns(with_tz=True)): self.client.execute( 'INSERT INTO test (a) VALUES', [(self.dt, )] ) self.emit_cli( "INSERT INTO test (a) VALUES ('2017-07-14 05:40:00')" ) query = 'SELECT toInt32(a) FROM test' inserted = self.emit_cli(query) # 1499985600 = 1500000000 - 4 * 3600 self.assertEqual(inserted, '1499985600\n1499985600\n') query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '2017-07-14 05:40:00\n2017-07-14 05:40:00\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, [ (self.col_tz.localize(self.dt), ), (self.col_tz.localize(self.dt), ) ]) @require_server_version(1, 1, 54337) def test_column_use_client_timezone(self): # Insert datetime with no timezone # into column with timezone Asia/Novosibirsk # using client's timezone Europe/Moscow settings = {'use_client_time_zone': True} with patch_env_tz('Europe/Moscow'): with self.create_table(self.table_columns(with_tz=True)): self.client.execute( 'INSERT INTO test (a) VALUES', [(self.dt, )], settings=settings ) self.emit_cli( "INSERT INTO test (a) VALUES ('2017-07-14 05:40:00')", use_client_time_zone=1 ) query = 'SELECT toInt32(a) FROM test' inserted = self.emit_cli(query, use_client_time_zone=1) # 1499985600 = 1500000000 - 4 * 3600 self.assertEqual(inserted, '1499985600\n1499985600\n') query = 'SELECT * FROM test' inserted = self.emit_cli(query, use_client_time_zone=1) self.assertEqual( inserted, '2017-07-14 05:40:00\n2017-07-14 05:40:00\n' ) inserted = self.client.execute(query, settings=settings) self.assertEqual(inserted, [ (self.col_tz.localize(self.dt), ), (self.col_tz.localize(self.dt), ) ]) @require_server_version(1, 1, 54337) def test_datetime_with_timezone_column_use_server_timezone(self): # Insert datetime with timezone Asia/Kamchatka # into column with timezone Asia/Novosibirsk # using server's timezone (Europe/Moscow) with patch_env_tz('Europe/Moscow'): with self.create_table(self.table_columns(with_tz=True)): self.client.execute( 'INSERT INTO test (a) VALUES', [(self.dt_tz, )] ) self.emit_cli( "INSERT INTO test (a) VALUES " "(toDateTime('2017-07-14 05:40:00', 'Asia/Kamchatka'))", ) query = 'SELECT toInt32(a) FROM test' inserted = self.emit_cli(query) # 1499967600 = 1500000000 - 12 * 3600 self.assertEqual(inserted, '1499967600\n1499967600\n') query = 'SELECT * FROM test' inserted = self.emit_cli(query) # 2017-07-14 00:40:00 = 2017-07-14 05:40:00 - 05:00:00 # (Kamchatka - Novosibirsk) self.assertEqual( inserted, '2017-07-14 00:40:00\n2017-07-14 00:40:00\n' ) inserted = self.client.execute(query) dt = datetime(2017, 7, 14, 0, 40) self.assertEqual(inserted, [ (self.col_tz.localize(dt), ), (self.col_tz.localize(dt), ) ]) @require_server_version(1, 1, 54337) def test_datetime_with_timezone_column_use_client_timezone(self): # Insert datetime with timezone Asia/Kamchatka # into column with timezone Asia/Novosibirsk # using client's timezone (Europe/Moscow) settings = {'use_client_time_zone': True} with patch_env_tz('Europe/Moscow'): with self.create_table(self.table_columns(with_tz=True)): self.client.execute( 'INSERT INTO test (a) VALUES', [(self.dt_tz, )], settings=settings ) self.emit_cli( "INSERT INTO test (a) VALUES " "(toDateTime('2017-07-14 05:40:00', 'Asia/Kamchatka'))", use_client_time_zone=1 ) query = 'SELECT toInt32(a) FROM test' inserted = self.emit_cli(query, use_client_time_zone=1) # 1499967600 = 1500000000 - 12 * 3600 self.assertEqual(inserted, '1499967600\n1499967600\n') query = 'SELECT * FROM test' inserted = self.emit_cli(query, use_client_time_zone=1) # 2017-07-14 00:40:00 = 2017-07-14 05:40:00 - 05:00:00 # (Kamchatka - Novosibirsk) self.assertEqual( inserted, '2017-07-14 00:40:00\n2017-07-14 00:40:00\n' ) inserted = self.client.execute(query, settings=settings) dt = datetime(2017, 7, 14, 0, 40) self.assertEqual(inserted, [ (self.col_tz.localize(dt), ), (self.col_tz.localize(dt), ) ]) class DateTime64TimezonesTestCase(DateTimeTimezonesTestCase): dt_type = 'DateTime64' required_server_version = (20, 1, 2) def table_columns(self, with_tz=False): if not with_tz: return 'a {}(0)'.format(self.dt_type) return "a {}(0, '{}')".format(self.dt_type, self.col_tz_name) clickhouse-driver-0.2.11/tests/columns/test_decimal.py000066400000000000000000000232271522645447600230730ustar00rootroot00000000000000from decimal import Decimal from clickhouse_driver import errors from tests.testcase import BaseTestCase from tests.util import require_server_version class DecimalTestCase(BaseTestCase): required_server_version = (18, 12, 13) stable_support_version = (18, 14, 9) trailing_zeros_version = (21, 9) def client_kwargs(self, version): if version < self.stable_support_version: return {'settings': {'allow_experimental_decimal_type': True}} def cli_client_kwargs(self): if self.stable_support_version > self.server_version: return {'allow_experimental_decimal_type': 1} def test_simple(self): with self.create_table('a Decimal(9, 5)'): data = [(Decimal('300.42'), ), (300.42, ), (-300, )] self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) if self.server_version < self.trailing_zeros_version: expected = '300.42000\n300.42000\n-300.00000\n' else: expected = '300.42\n300.42\n-300\n' self.assertEqual(inserted, expected) inserted = self.client.execute(query) self.assertEqual(inserted, [ (Decimal('300.42'), ), (Decimal('300.42'), ), (Decimal('-300'), ) ]) @require_server_version(18, 12, 17) def test_different_precisions(self): columns = 'a Decimal32(2), b Decimal64(2), c Decimal128(2)' with self.create_table(columns): data = [( Decimal('300.42'), # 300.42 + (1 << 34) Decimal('17179869484.42'), # 300.42 + (1 << 100) Decimal('1267650600228229401496703205676.42') )] self.client.execute( 'INSERT INTO test (a, b, c) VALUES', data ) # Casting to string saves precision. query = ( 'SELECT ' 'CAST(a AS String), CAST(b AS String), CAST(c AS String)' 'FROM test' ) inserted = self.emit_cli(query) self.assertEqual( inserted, '300.42\t' '17179869484.42\t' '1267650600228229401496703205676.42\n' ) inserted = self.client.execute('SELECT * FROM test') self.assertEqual(inserted, data) @require_server_version(18, 12, 17) def test_different_precisions_negative(self): columns = 'a Decimal32(2), b Decimal64(2), c Decimal128(2)' with self.create_table(columns): data = [( Decimal('-300.42'), # 300.42 + (1 << 34) Decimal('-17179869484.42'), # 300.42 + (1 << 100) Decimal('-1267650600228229401496703205676.42') )] self.client.execute( 'INSERT INTO test (a, b, c) VALUES', data ) # Casting to string saves precision. query = ( 'SELECT ' 'CAST(a AS String), CAST(b AS String), CAST(c AS String)' 'FROM test' ) inserted = self.emit_cli(query) self.assertEqual( inserted, '-300.42\t' '-17179869484.42\t' '-1267650600228229401496703205676.42\n' ) inserted = self.client.execute('SELECT * FROM test') self.assertEqual(inserted, data) @require_server_version(18, 12, 17) def test_max_precisions(self): columns = 'a Decimal32(0), b Decimal64(0), c Decimal128(0)' with self.create_table(columns): data = [( Decimal(10**9 - 1), Decimal(10**18 - 1), Decimal(10**38 - 1) ), ( Decimal(-10**9 + 1), Decimal(-10**18 + 1), Decimal(-10**38 + 1) )] self.client.execute( 'INSERT INTO test (a, b, c) VALUES', data ) # Casting to string saves precision. query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '999999999\t' '999999999999999999\t' '99999999999999999999999999999999999999\n' '-999999999\t' '-999999999999999999\t' '-99999999999999999999999999999999999999\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_nullable(self): with self.create_table('a Nullable(Decimal32(3))'): data = [(300.42, ), (None, )] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) if self.server_version < self.trailing_zeros_version: expected = '300.420\n\\N\n' else: expected = '300.42\n\\N\n' self.assertEqual(inserted, expected) inserted = self.client.execute(query) self.assertEqual(inserted, [(Decimal('300.42'), ), (None, ), ]) def test_no_scale(self): with self.create_table('a Decimal32(0)'): data = [(2147483647, )] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '2147483647\n') inserted = self.client.execute(query) self.assertEqual(inserted, [(Decimal('2147483647'), )]) def test_type_mismatch(self): data = [(2147483649, )] with self.create_table('a Decimal32(0)'): with self.assertRaises(errors.TypeMismatchError) as e: self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) self.assertIn('2147483649 for column "a"', str(e.exception)) with self.assertRaises(errors.TypeMismatchError) as e: self.client.execute( 'INSERT INTO test (a) VALUES', data ) self.assertIn('Column a', str(e.exception)) def test_preserve_precision(self): data = [(1.66, ), (1.15, )] with self.create_table('a Decimal(18, 2)'): self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '1.66\n1.15\n') inserted = self.client.execute(query) self.assertEqual(inserted, [ (Decimal('1.66'), ), (Decimal('1.15'), ) ]) def test_precision_one_sign_after_point(self): data = [(1.6, ), (1.0, ), (12312.0, ), (999999.6, )] with self.create_table('a Decimal(8, 1)'): self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) if self.server_version < self.trailing_zeros_version: expected = '1.6\n1.0\n12312.0\n999999.6\n' else: expected = '1.6\n1\n12312\n999999.6\n' self.assertEqual(inserted, expected) inserted = self.client.execute(query) self.assertEqual(inserted, [ (Decimal('1.6'),), (Decimal('1.0'),), (Decimal('12312.0'),), (Decimal('999999.6'),) ]) def test_truncates_scale(self): with self.create_table('a Decimal(9, 4)'): data = [(3.14159265358,), (2.7182,)] expected = [(Decimal('3.1415'),), (Decimal('2.7182'),)] self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True, ) query = 'SELECT * FROM test' inserted = self.client.execute(query) self.assertEqual(inserted, expected) class Decimal256TestCase(BaseTestCase): required_server_version = (18, 12, 13) def cli_client_kwargs(self): return {'allow_experimental_bigint_types': 1} @require_server_version(20, 9, 2) def test_decimal256(self): data = [ (1.66, ), (1.15, ), # 300.42 + (1 << 200) (Decimal('1606938044258990275541962092341162602522202993782792835301676.42'), ), # noqa: E501 (Decimal('-1606938044258990275541962092341162602522202993782792835301676.42'), ) # noqa: E501 ] with self.create_table('a Decimal256(2)'): self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '1.66\n' '1.15\n' '1606938044258990275541962092341162602522202993782792835301676.42\n' # noqa: E501 '-1606938044258990275541962092341162602522202993782792835301676.42\n' # noqa: E501 ) inserted = self.client.execute(query) self.assertEqual(inserted, [ (Decimal('1.66'), ), (Decimal('1.15'), ), (Decimal('1606938044258990275541962092341162602522202993782792835301676.42'), ), # noqa: E501 (Decimal('-1606938044258990275541962092341162602522202993782792835301676.42'), ) # noqa: E501 ]) clickhouse-driver-0.2.11/tests/columns/test_dynamic_shared_value.py000066400000000000000000000377171522645447600256540ustar00rootroot00000000000000from unittest import TestCase from clickhouse_driver.context import Context from clickhouse_driver.columns.service import get_column_by_spec from clickhouse_driver.columns.dynamiccolumn import ( DynamicColumn, SharedValueDecoder, _decode_type_spec, _split_tuple_elements, _SharedValueReader, ) from clickhouse_driver.columns.newjsoncolumn import ( NewJsonColumn, OBJECT_STRING, _tuples_to_lists, ) def _varint(value): out = bytearray() while True: byte = value & 0x7F value >>= 7 if value: out.append(byte | 0x80) else: out.append(byte) return bytes(out) def _binary_string(text): raw = text.encode('utf-8') return _varint(len(raw)) + raw def _make_context(): context = Context() context.client_settings = { 'use_numpy': False, 'input_format_null_as_default': False, 'strings_as_bytes': False, 'strings_encoding': 'utf-8', } return context def _make_getter(context=None): """A column-by-spec getter matching the one the driver wires into the JSON reader, but standing alone so SharedVariant decoding can be tested without a live server.""" context = context or _make_context() options = {'context': context, 'has_custom_serialization': False} def getter(spec): return get_column_by_spec(spec, options, use_numpy=False) return getter class DecodeTypeSpecTestCase(TestCase): """``_decode_type_spec`` turns an ``encodeDataType`` byte stream into a ClickHouse type string. These tags are not reachable from JSON input on the supported server versions, so they are exercised directly.""" def decode(self, blob): return _decode_type_spec(_SharedValueReader_for(blob)) def test_primitives(self): self.assertEqual(self.decode(bytes([0x0A])), "Int64") self.assertEqual(self.decode(bytes([0x15])), "String") self.assertEqual(self.decode(bytes([0x2D])), "Bool") self.assertEqual(self.decode(bytes([0x00])), "Nothing") def test_fixed_string(self): self.assertEqual( self.decode(bytes([0x16]) + _varint(7)), "FixedString(7)") def test_datetime_with_timezone(self): self.assertEqual( self.decode(bytes([0x12]) + _binary_string("UTC")), "DateTime('UTC')") def test_datetime64_utc(self): self.assertEqual( self.decode(bytes([0x13]) + _varint(3)), "DateTime64(3)") def test_datetime64_with_timezone(self): self.assertEqual( self.decode( bytes([0x14]) + _varint(6) + _binary_string("Europe/Moscow")), "DateTime64(6, 'Europe/Moscow')") def test_nullable_and_array(self): self.assertEqual( self.decode(bytes([0x23, 0x0A])), "Nullable(Int64)") self.assertEqual( self.decode(bytes([0x1E, 0x15])), "Array(String)") def test_unnamed_tuple(self): self.assertEqual( self.decode(bytes([0x1F]) + _varint(2) + bytes([0x0A, 0x15])), "Tuple(Int64, String)") def test_named_tuple(self): blob = ( bytes([0x20]) + _varint(2) + _binary_string("a") + bytes([0x0A]) + _binary_string("b") + bytes([0x15]) ) self.assertEqual(self.decode(blob), "Tuple(a Int64, b String)") def test_json(self): # JSON tag (0x30) followed by its encoded parameters: version, # max_dynamic_paths, max_dynamic_types, and three empty path # lists. The value layout does not depend on them, so the spec # collapses to "JSON". blob = bytes([0x30, 0x00]) + _varint(0) + bytes([0x00]) \ + _varint(0) + _varint(0) + _varint(0) self.assertEqual(self.decode(blob), "JSON") def test_json_with_typed_skip_and_regexp_paths(self): # Non-empty typed paths (name + nested type), skip paths and skip # regexps must all be consumed, and the spec still collapses to # "JSON". blob = ( bytes([0x30, 0x00]) + _varint(8) + bytes([0x10]) + _varint(1) + _binary_string("ts") + bytes([0x0A]) # ts Int64 + _varint(1) + _binary_string("secret") # skip path + _varint(1) + _binary_string("^tmp") # skip regexp ) self.assertEqual(self.decode(blob), "JSON") def test_unknown_tag_raises(self): with self.assertRaises(NotImplementedError): self.decode(bytes([0xFF])) def test_truncated_stream_raises(self): with self.assertRaises(EOFError): self.decode(b"") class SplitTupleElementsTestCase(TestCase): def test_flat(self): self.assertEqual( _split_tuple_elements("Int64, String"), ["Int64", "String"]) def test_nested_parens_are_kept_together(self): self.assertEqual( _split_tuple_elements("Array(Int64), Tuple(Int64, String)"), ["Array(Int64)", "Tuple(Int64, String)"]) def test_empty(self): self.assertEqual(_split_tuple_elements(""), []) class SharedValueDecoderTestCase(TestCase): def setUp(self): self.decoder = SharedValueDecoder(_make_getter()) def test_empty_blob_is_none(self): self.assertIsNone(self.decoder.decode(b"")) def test_scalar(self): blob = bytes([0x0A]) + (42).to_bytes(8, 'little') self.assertEqual(self.decoder.decode(blob), 42) def test_nothing(self): self.assertIsNone(self.decoder.decode(bytes([0x00]))) def test_nullable_null_and_value(self): self.assertIsNone(self.decoder.decode(bytes([0x23, 0x0A, 0x01]))) value = bytes([0x23, 0x0A, 0x00]) + (7).to_bytes(8, 'little') self.assertEqual(self.decoder.decode(value), 7) def test_array(self): blob = ( bytes([0x1E, 0x0A]) + _varint(2) + (1).to_bytes(8, 'little') + (2).to_bytes(8, 'little') ) self.assertEqual(self.decoder.decode(blob), [1, 2]) def test_tuple(self): blob = ( bytes([0x1F]) + _varint(2) + bytes([0x0A, 0x15]) + (5).to_bytes(8, 'little') + _binary_string("x") ) self.assertEqual(self.decoder.decode(blob), (5, "x")) def test_json_value(self): # A nested JSON value: header + paths. "p" is Int64(1), "a.b" is # String("x") (a dotted path that denormalises into a nested # dict), and "gone" carries a Nothing value that must be dropped. header = ( bytes([0x30, 0x00]) + _varint(0) + bytes([0x00]) + _varint(0) + _varint(0) + _varint(0) ) value = ( _varint(3) + _binary_string("p") + bytes([0x0A]) + (1).to_bytes(8, 'little') + _binary_string("a.b") + bytes([0x15]) + _binary_string("x") + _binary_string("gone") + bytes([0x00]) ) self.assertEqual( self.decoder.decode(header + value), {"p": 1, "a": {"b": "x"}}) def test_array_of_json(self): # Array(JSON) — the shape that previously raised on tag 0x30. json_header = ( bytes([0x30, 0x00]) + _varint(0) + bytes([0x00]) + _varint(0) + _varint(0) + _varint(0) ) def json_value(name, ivalue): return ( _varint(1) + _binary_string(name) + bytes([0x0A]) + (ivalue).to_bytes(8, 'little') ) blob = ( bytes([0x1E]) + json_header + _varint(2) + json_value("p", 1) + json_value("q", 2) ) self.assertEqual( self.decoder.decode(blob), [{"p": 1}, {"q": 2}]) def test_handler_cache_reuse(self): # Decoding the same spec twice must reuse the cached handler. first = bytes([0x0A]) + (1).to_bytes(8, 'little') second = bytes([0x0A]) + (2).to_bytes(8, 'little') self.assertEqual(self.decoder.decode(first), 1) self.assertEqual(self.decoder.decode(second), 2) class DynamicColumnStatePrefixTestCase(TestCase): """Defensive guards in ``DynamicColumn`` that the JSON happy path never triggers.""" def setUp(self): self.ctx = _make_context() def test_builds_default_shared_value_decoder(self): # Constructed without an explicit decoder, the column makes its own. column = DynamicColumn(_make_getter(self.ctx), context=self.ctx) self.assertIsInstance( column.shared_value_decoder, SharedValueDecoder) def test_unsupported_structure_version_raises(self): column = DynamicColumn(_make_getter(self.ctx), context=self.ctx) buf = _ListReader([(99).to_bytes(8, 'little')]) with self.assertRaises(NotImplementedError): column.read_state_prefix(buf) def test_unsupported_discriminators_mode_raises(self): column = DynamicColumn(_make_getter(self.ctx), context=self.ctx) buf = _ListReader([ (2).to_bytes(8, 'little'), # structure version V2 _varint(0), # zero declared variants (5).to_bytes(8, 'little'), # bogus discriminators mode ]) with self.assertRaises(NotImplementedError): column.read_state_prefix(buf) def test_compact_discriminators_mode_not_supported(self): column = DynamicColumn(_make_getter(self.ctx), context=self.ctx) column.discriminators_mode = 1 # VARIANT_MODE_COMPACT with self.assertRaises(NotImplementedError): column.read_items(1, _ListReader([])) def test_truncated_discriminators_raise(self): column = DynamicColumn(_make_getter(self.ctx), context=self.ctx) column._shared_variant_index = None with self.assertRaises(EOFError): # 3 rows promised, only 2 discriminator bytes available. column.read_items(3, _ListReader([bytes([0, 0])])) def test_out_of_range_discriminator_raises(self): column = DynamicColumn(_make_getter(self.ctx), context=self.ctx) column._shared_variant_index = None with self.assertRaises(ValueError): # No variants declared, so any non-NULL discriminator is bogus. column.read_items(1, _ListReader([bytes([5])])) def test_read_state_prefix_v1_then_all_null_items(self): # End-to-end read of a Dynamic(Int64) column header in the legacy # V1 framing, followed by a body with only NULL discriminators. # Exercises the V1 legacy-slot read, the non-SharedVariant column # construction and its state-prefix call, and the # "no rows for this variant, skip" branch in read_items. buf = _ListReader([ (1).to_bytes(8, 'little'), # structure_version = DYNAMIC_V1 _varint(0), # legacy max_dynamic_types slot _varint(1), # one declared variant _binary_string("Int64"), # variant type spec (0).to_bytes(8, 'little'), # discriminators_mode = BASIC ]) column = DynamicColumn(_make_getter(self.ctx), context=self.ctx) column.read_state_prefix(buf) self.assertEqual(column.variant_specs, ["Int64"]) # "Int64" sorts before "SharedVariant", so the latter takes # global discriminator 1 and the SharedVariant slot is the last. self.assertEqual(column._shared_variant_index, 1) result = column.read_items(2, _ListReader([bytes([0xFF, 0xFF])])) self.assertEqual(result, [None, None]) def test_read_items_routes_rows_to_variants(self): # Row 0 hits a variant exposing only read_items (the fallback # branch); row 1 hits the SharedVariant slot, whose bytes go # through the shared-value decoder; row 2 is NULL. column = DynamicColumn(_make_getter(self.ctx), context=self.ctx) column.discriminators_mode = 0 # VARIANT_MODE_BASIC column.variant_columns = [_ReadItemsOnlyColumn(), _ReadDataColumn()] column._shared_variant_index = 1 column.shared_value_decoder = _FakeSharedDecoder() result = column.read_items(3, _ListReader([bytes([0, 1, 0xFF])])) self.assertEqual(result, ["from_read_items", "decoded:blob", None]) class NewJsonColumnUnitTestCase(TestCase): """Branches of the JSON column reader/writer that the live-server tests on CH 25.5 do not reach: the string serialization version, and a few write-path / normalisation helpers.""" def setUp(self): self.ctx = _make_context() self.column = NewJsonColumn(_make_getter(self.ctx), context=self.ctx) def test_unsupported_serialization_version_raises(self): buf = _SharedValueReader() buf.reset((99).to_bytes(8, 'little')) with self.assertRaises(NotImplementedError): self.column.read_state_prefix(buf) def test_string_serialization_round_trip(self): # OBJECT_STRING framing: a version header, then one String per row # carrying the JSON text. An empty string decodes to ``{}``. buf = _SharedValueReader() buf.reset( (OBJECT_STRING).to_bytes(8, 'little') + _binary_string('{"a": 1}') + _binary_string("") ) self.column.read_state_prefix(buf) self.assertEqual(self.column.serialization_version, OBJECT_STRING) self.assertEqual(self.column.read_items(2, buf), [{"a": 1}, {}]) def test_value_spec_for_mixed_float_and_bool_array(self): # A float+bool array has no common numeric type, so it widens to # Array(Nullable(String)). self.assertEqual( self.column._get_json_value_spec([1.5, True], 0), "Array(Nullable(String))") def test_value_spec_for_pure_bool_array(self): self.assertEqual( self.column._get_json_value_spec([True, False], 0), "Array(Nullable(Bool))") def test_preprocess_array_passthrough_for_unknown_type(self): # A spec matching none of the scalar branches is passed through # unchanged. values = [[1, 2]] self.assertEqual( self.column._preprocess_array(values, "Nothing"), values) def test_unfold_json_item_defaults_result(self): # Called without an accumulator, it allocates its own. result = self.column._unfold_json_item({"a": 1}, depth=0) # Leaves are keyed by their dotted path with a trailing separator # that ``_unfold_json`` strips later. self.assertIn("a.", result) def test_denormalize_dotted_paths_conflict_raises(self): with self.assertRaises(ValueError): self.column._denormalize_dotted_paths({"a": 1, "a.b": 2}) def test_tuples_to_lists_scalar_and_nested(self): self.assertEqual(_tuples_to_lists(5), 5) self.assertEqual(_tuples_to_lists((1, "x")), (1, "x")) self.assertEqual(_tuples_to_lists([1, 2]), [1, 2]) # ---------------------------------------------------------------------- # Minimal buffer stand-ins # ---------------------------------------------------------------------- def _SharedValueReader_for(blob): reader = _SharedValueReader() reader.reset(blob) return reader class _ReadItemsOnlyColumn(object): """A variant column that only exposes ``read_items`` — forces ``DynamicColumn.read_items`` down its low-level fallback branch.""" def read_items(self, n_items, buf): return ["from_read_items"] * n_items class _ReadDataColumn(object): """The implicit SharedVariant String column: returns raw blobs.""" def read_data(self, n_items, buf): return [b"blob"] * n_items class _FakeSharedDecoder(object): def decode(self, blob): return "decoded:" + blob.decode() class _ListReader(object): """A buffer that yields pre-chunked byte strings for the driver's ``read_binary_*`` / ``read_varint`` helpers, which only call ``read(n)``.""" def __init__(self, chunks): self._buf = b"".join(chunks) self._pos = 0 def read(self, n): start = self._pos self._pos += n return self._buf[start:start + n] def read_one(self): byte = self._buf[self._pos] self._pos += 1 return byte clickhouse-driver-0.2.11/tests/columns/test_enum.py000066400000000000000000000122351522645447600224360ustar00rootroot00000000000000from enum import IntEnum from tests.testcase import BaseTestCase from clickhouse_driver import errors class A(IntEnum): hello = -1 world = 2 class B(IntEnum): foo = -300 bar = 300 class EnumTestCase(BaseTestCase): def test_simple(self): columns = ( "a Enum8('hello' = -1, 'world' = 2), " "b Enum16('foo' = -300, 'bar' = 300)" ) data = [(A.hello, B.bar), (A.world, B.foo), (-1, 300), (2, -300)] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a, b) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, ( 'hello\tbar\n' 'world\tfoo\n' 'hello\tbar\n' 'world\tfoo\n' ) ) inserted = self.client.execute(query) self.assertEqual( inserted, [ ('hello', 'bar'), ('world', 'foo'), ('hello', 'bar'), ('world', 'foo') ] ) def test_enum_by_string(self): columns = "a Enum8('hello' = 1, 'world' = 2)" data = [('hello', ), ('world', )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, ( 'hello\n' 'world\n' ) ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_errors(self): columns = "a Enum8('test' = 1, 'me' = 2)" data = [(A.world, )] with self.create_table(columns): with self.assertRaises(errors.LogicalError): self.client.execute( 'INSERT INTO test (a) VALUES', data ) columns = "a Enum8('test' = 1, 'me' = 2)" data = [(3, )] with self.create_table(columns): with self.assertRaises(errors.LogicalError): self.client.execute( 'INSERT INTO test (a) VALUES', data ) def test_quote_in_name(self): columns = "a Enum8(' \\' t = ' = -1, 'test' = 2)" data = [(-1, ), (" ' t = ", )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, ( " \\' t = \n" " \\' t = \n" ) ) inserted = self.client.execute(query) self.assertEqual(inserted, [(" ' t = ", ), (" ' t = ", )]) def test_comma_and_space_in_name(self): columns = "a Enum8('one' = 1, 'two_with_comma, ' = 2, 'three' = 3)" data = [(2, ), ('two_with_comma, ', )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, ( 'two_with_comma, \n' 'two_with_comma, \n' ) ) inserted = self.client.execute(query) self.assertEqual( inserted, [('two_with_comma, ',), ('two_with_comma, ',)] ) def test_nullable(self): columns = "a Nullable(Enum8('hello' = -1, 'world' = 2))" data = [(None, ), (A.hello, ), (None, ), (A.world, )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, ( '\\N\nhello\n\\N\nworld\n' ) ) inserted = self.client.execute(query) self.assertEqual( inserted, [ (None, ), ('hello', ), (None, ), ('world', ), ] ) def test_invalid_python_names(self): data = [(1, ), (2, ), (3, ), ('', ), ('mro', )] with self.create_table("a Enum8('mro' = 1, '' = 2, 'test' = 3)"): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, ( 'mro\n' '\n' 'test\n' '\n' 'mro\n' ) ) inserted = self.client.execute(query) self.assertEqual( inserted, [ ('mro', ), ('', ), ('test', ), ('', ), ('mro', ) ] ) clickhouse-driver-0.2.11/tests/columns/test_fixedstring.py000066400000000000000000000172361522645447600240260ustar00rootroot00000000000000# coding=utf-8 from __future__ import unicode_literals from tests.testcase import BaseTestCase from clickhouse_driver import errors class FixedStringTestCase(BaseTestCase): def test_simple(self): data = [('a', ), ('bb', ), ('ccc', ), ('dddd', ), ('Ñ�', )] with self.create_table('a FixedString(4)'): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, ( 'a\\0\\0\\0\n' 'bb\\0\\0\n' 'ccc\\0\n' 'dddd\n' 'Ñ�\\0\\0\n' ) ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_non_utf(self): data = [('Ñ�ндекÑ�'.encode('koi8-r'), )] with self.create_table('a FixedString(6)'): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query, encoding='koi8-r') self.assertEqual(inserted, 'Ñ�ндекÑ�\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_oversized(self): columns = 'a FixedString(4)' data = [('aaaaa', )] with self.create_table(columns): with self.assertRaises(errors.TooLargeStringSize): self.client.execute( 'INSERT INTO test (a) VALUES', data ) data = [('теÑ�Ñ‚', )] with self.create_table(columns): with self.assertRaises(errors.TooLargeStringSize): self.client.execute( 'INSERT INTO test (a) VALUES', data ) def test_nullable(self): with self.create_table('a Nullable(FixedString(10))'): data = [(None, ), ('test', ), (None, ), ('nullable', )] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '\\N\ntest\\0\\0\\0\\0\\0\\0\n\\N\nnullable\\0\\0\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_null_byte_in_the_middle(self): data = [('test\0test', )] with self.create_table('a FixedString(9)'): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_empty(self): data = [('',)] with self.create_table('a FixedString(5)'): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_custom_encoding(self): settings = {'strings_encoding': 'cp1251'} data = [(('Ñ�ндекÑ�'), ), (('test'), )] with self.create_table('a FixedString(10)'): self.client.execute( 'INSERT INTO test (a) VALUES', data, settings=settings ) query = 'SELECT * FROM test' inserted = self.emit_cli(query, encoding='cp1251') self.assertEqual( inserted, 'Ñ�ндекÑ�\\0\\0\\0\\0\n' 'test\\0\\0\\0\\0\\0\\0\n' ) inserted = self.client.execute(query, settings=settings) self.assertEqual(inserted, data) self.assertIsInstance(inserted[0][0], str) self.assertIsInstance(inserted[1][0], str) def test_not_supported_types(self): datas = [ [(bytearray(b'asd'), )], [(123, )] ] with self.create_table('a String'): for data in datas: with self.assertRaises(errors.TypeMismatchError) as e: self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) self.assertIn('for column "a"', str(e.exception)) with self.assertRaises(AttributeError): self.client.execute( 'INSERT INTO test (a) VALUES', data ) class ByteFixedStringTestCase(BaseTestCase): client_kwargs = {'settings': {'strings_as_bytes': True}} def test_oversized(self): columns = 'a FixedString(4)' data = [(bytes('aaaaa'.encode('utf-8')), )] with self.create_table(columns): with self.assertRaises(errors.TooLargeStringSize): self.client.execute( 'INSERT INTO test (a) VALUES', data ) data = [(bytes('теÑ�Ñ‚'.encode('utf-8')), )] with self.create_table(columns): with self.assertRaises(errors.TooLargeStringSize): self.client.execute( 'INSERT INTO test (a) VALUES', data ) def test_not_decoded(self): data = [ (bytes('Ñ�ндекÑ�'.encode('cp1251')), ), (bytes('test'.encode('cp1251')), ), ] with self.create_table('a FixedString(8)'): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query, encoding='cp1251') self.assertEqual( inserted, 'Ñ�ндекÑ�\\0\\0\ntest\\0\\0\\0\\0\n' ) inserted = self.client.execute(query) # Assert items with trailing zeros self.assertEqual( inserted, [ ('Ñ�ндекÑ�'.encode('cp1251') + b'\x00' * 2, ), ('test'.encode('cp1251') + b'\x00' * 4, ) ] ) self.assertIsInstance(inserted[0][0], bytes) self.assertIsInstance(inserted[1][0], bytes) def test_nullable(self): with self.create_table('a Nullable(FixedString(10))'): data = [ (None, ), (b'test\x00\x00\x00\x00\x00\x00', ), (None, ), (b'nullable\x00\x00', ) ] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '\\N\ntest\\0\\0\\0\\0\\0\\0\n\\N\nnullable\\0\\0\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_not_supported_types(self): datas = [ [('asd', )], [(bytearray(b'asd'), )], [(123, )] ] with self.create_table('a String'): for data in datas: with self.assertRaises(errors.TypeMismatchError) as e: self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) self.assertIn('for column "a"', str(e.exception)) with self.assertRaises(ValueError) as e: self.client.execute( 'INSERT INTO test (a) VALUES', data ) self.assertIn('bytes object expected', str(e.exception)) clickhouse-driver-0.2.11/tests/columns/test_float.py000066400000000000000000000052371522645447600226030ustar00rootroot00000000000000import math from tests.testcase import BaseTestCase from clickhouse_driver import errors class FloatTestCase(BaseTestCase): def test_chop_to_type(self): with self.create_table('a Float32, b Float64'): data = [ (3.4028235e38, 3.4028235e38), (3.4028235e39, 3.4028235e39), (-3.4028235e39, 3.4028235e39), (1, 2) ] with self.assertRaises(errors.TypeMismatchError) as e: self.client.execute( 'INSERT INTO test (a, b) VALUES', data ) self.assertIn('Column a', str(e.exception)) def test_simple(self): with self.create_table('a Float32, b Float64'): data = [ (3.4028235e38, 3.4028235e38), (3.4028235e39, 3.4028235e39), (-3.4028235e39, 3.4028235e39), (1, 2) ] self.client.execute( 'INSERT INTO test (a, b) VALUES', data, types_check=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, ( '3.4028235e38\t3.4028235e38\n' 'inf\t3.4028235e39\n' '-inf\t3.4028235e39\n' '1\t2\n' ) ) inserted = self.client.execute(query) self.assertEqual(inserted, [ (3.4028234663852886e+38, 3.4028235e38), (float('inf'), 3.4028235e39), (-float('inf'), 3.4028235e39), (1, 2) ]) def test_nullable(self): with self.create_table('a Nullable(Float32)'): data = [(None, ), (0.5, ), (None, ), (1.5, )] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '\\N\n0.5\n\\N\n1.5\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_nan(self): with self.create_table('a Float32'): data = [(float('nan'), ), (0.5, )] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, 'nan\n0.5\n') inserted = self.client.execute(query) self.assertEqual(len(inserted), 2) self.assertTrue(math.isnan(inserted[0][0])) self.assertEqual(inserted[1][0], 0.5) clickhouse-driver-0.2.11/tests/columns/test_geo.py000066400000000000000000000054161522645447600222470ustar00rootroot00000000000000from tests.testcase import BaseTestCase class GeoTypesTestCase(BaseTestCase): required_server_version = (20, 5, 1) def client_kwargs(self, version): return {'settings': {'allow_experimental_geo_types': True}} def cli_client_kwargs(self): return {'allow_experimental_geo_types': 1} def entuple(self, lst): return tuple( self.entuple(x) if isinstance(x, list) else x for x in lst ) def test_point(self): columns = 'a Point' data = [ ((1.5, 2), ), ((3, 4), ) ] with self.create_table(columns): self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '(1.5,2)\n(3,4)\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_ring(self): columns = 'a Ring' data = [ ([(1.5, 2), (3, 4)], ) ] with self.create_table(columns): self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '[(1.5,2),(3,4)]\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_polygon(self): columns = 'a Polygon' data = [ ([ [(1.5, 2), (3, 4)], [(5.5, 6), (7, 8)], ], ) ] with self.create_table(columns): self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '[[(1.5,2),(3,4)],[(5.5,6),(7,8)]]\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_multipolygon(self): columns = 'a MultiPolygon' data = [ ([ [ [(1.5, 2), (3, 4)], [(5.5, 6), (7, 8)], ], [ [(2.5, 3), (4, 5)], [(6.5, 7), (8, 9)], ] ], ) ] with self.create_table(columns): self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '[' '[[(1.5,2),(3,4)],[(5.5,6),(7,8)]],' '[[(2.5,3),(4,5)],[(6.5,7),(8,9)]]' ']\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) clickhouse-driver-0.2.11/tests/columns/test_int.py000066400000000000000000000206571522645447600222730ustar00rootroot00000000000000from tests.testcase import BaseTestCase from clickhouse_driver import errors from tests.util import require_server_version class IntTestCase(BaseTestCase): def test_chop_to_type(self): with self.create_table('a UInt8'): data = [(300, )] self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '44\n') inserted = self.client.execute(query) self.assertEqual(inserted, [(44, )]) with self.create_table('a Int8'): data = [(-300,)] self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '-44\n') inserted = self.client.execute(query) self.assertEqual(inserted, [(-44, )]) def test_raise_struct_error(self): with self.create_table('a UInt8'): with self.assertRaises(errors.TypeMismatchError) as e: data = [(300, )] self.client.execute( 'INSERT INTO test (a) VALUES', data ) exc = str(e.exception) self.assertIn('Column a', exc) self.assertIn('types_check=True', exc) def test_uint_type_mismatch(self): data = [(-1, )] with self.create_table('a UInt8'): with self.assertRaises(errors.TypeMismatchError) as e: self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) self.assertIn('-1 for column "a"', str(e.exception)) with self.assertRaises(errors.TypeMismatchError) as e: self.client.execute( 'INSERT INTO test (a) VALUES', data ) self.assertIn('Column a', str(e.exception)) def test_all_sizes(self): columns = ( 'a Int8, b Int16, c Int32, d Int64, ' 'e UInt8, f UInt16, g UInt32, h UInt64' ) data = [ (-10, -300, -123581321, -123581321345589144, 10, 300, 123581321, 123581321345589144) ] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a, b, c, d, e, f, g, h) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, ( '-10\t-300\t-123581321\t-123581321345589144\t' '10\t300\t123581321\t123581321345589144\n' ) ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_corner_cases(self): columns = ( 'a Int8, b Int16, c Int32, d Int64, ' 'e UInt8, f UInt16, g UInt32, h UInt64' ) data = [ (-128, -32768, -2147483648, -9223372036854775808, 255, 65535, 4294967295, 18446744073709551615), (127, 32767, 2147483647, 9223372036854775807, 0, 0, 0, 0), ] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a, b, c, d, e, f, g, h) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, ( '-128\t-32768\t-2147483648\t-9223372036854775808\t' '255\t65535\t4294967295\t18446744073709551615\n' '127\t32767\t2147483647\t9223372036854775807\t0\t0\t0\t0\n' ) ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_nullable(self): with self.create_table('a Nullable(Int32)'): data = [(2, ), (None, ), (4, ), (None, ), (8, )] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '2\n\\N\n4\n\\N\n8\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) class BigIntTestCase(BaseTestCase): required_server_version = (20, 8, 2) def cli_client_kwargs(self): return {'allow_experimental_bigint_types': 1} def test_int128(self): with self.create_table('a Int128'): data = [ (-170141183460469231731687303715884105728, ), (-111111111111111111111111111111111111111, ), (123, ), (111111111111111111111111111111111111111, ), (170141183460469231731687303715884105727, ) ] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '-170141183460469231731687303715884105728\n' '-111111111111111111111111111111111111111\n' '123\n' '111111111111111111111111111111111111111\n' '170141183460469231731687303715884105727\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) @require_server_version(21, 6) def test_uint128(self): with self.create_table('a UInt128'): data = [ (0, ), (123, ), (340282366920938463463374607431768211455, ) ] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '0\n' '123\n' '340282366920938463463374607431768211455\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_int256(self): with self.create_table('a Int256'): data = [ (-57896044618658097711785492504343953926634992332820282019728792003956564819968, ), # noqa: E501 (-11111111111111111111111111111111111111111111111111111111111111111111111111111, ), # noqa: E501 (123, ), (11111111111111111111111111111111111111111111111111111111111111111111111111111, ), # noqa: E501 (57896044618658097711785492504343953926634992332820282019728792003956564819967, ) # noqa: E501 ] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '-57896044618658097711785492504343953926634992332820282019728792003956564819968\n' # noqa: E501 '-11111111111111111111111111111111111111111111111111111111111111111111111111111\n' # noqa: E501 '123\n' '11111111111111111111111111111111111111111111111111111111111111111111111111111\n' # noqa: E501 '57896044618658097711785492504343953926634992332820282019728792003956564819967\n' # noqa: E501 ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_uint256(self): with self.create_table('a UInt256'): data = [ (0, ), (123, ), (111111111111111111111111111111111111111111111111111111111111111111111111111111, ), # noqa: E501 (115792089237316195423570985008687907853269984665640564039457584007913129639935, ) # noqa: E501 ] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '0\n' '123\n' '111111111111111111111111111111111111111111111111111111111111111111111111111111\n' # noqa: E501 '115792089237316195423570985008687907853269984665640564039457584007913129639935\n' # noqa: E501 ) inserted = self.client.execute(query) self.assertEqual(inserted, data) clickhouse-driver-0.2.11/tests/columns/test_interval.py000066400000000000000000000013371522645447600233170ustar00rootroot00000000000000from tests.testcase import BaseTestCase class IntervalTestCase(BaseTestCase): required_server_version = (1, 1, 54310) def test_all(self): interval = [ ('YEAR', 1), ('MONTH', 2), ('WEEK', 3), ('DAY', 4), ('HOUR', 5), ('MINUTE', 6), ('SECOND', 7) ] columns = ', '.join(['INTERVAL {} {}'.format(v, k) for k, v in interval]) query = 'SELECT {}'.format(columns) cli_result = self.emit_cli(query) self.assertEqual(cli_result, '1\t2\t3\t4\t5\t6\t7\n') client_result = self.client.execute(query) self.assertEqual(client_result, [(1, 2, 3, 4, 5, 6, 7)]) clickhouse-driver-0.2.11/tests/columns/test_ip.py000066400000000000000000000165061522645447600221070ustar00rootroot00000000000000from __future__ import unicode_literals from clickhouse_driver import errors from ipaddress import IPv6Address, IPv4Address from tests.testcase import BaseTestCase class IPv4TestCase(BaseTestCase): required_server_version = (19, 3, 3) def test_simple(self): with self.create_table('a IPv4'): data = [ (IPv4Address("10.0.0.1"),), (IPv4Address("192.168.253.42"),) ] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, ( '10.0.0.1\n' '192.168.253.42\n' )) inserted = self.client.execute(query) self.assertEqual(inserted, [ (IPv4Address("10.0.0.1"),), (IPv4Address("192.168.253.42"),) ]) def test_from_int(self): with self.create_table('a IPv4'): data = [ (167772161,), ] self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, ( '10.0.0.1\n' )) inserted = self.client.execute(query) self.assertEqual(inserted, [ (IPv4Address("10.0.0.1"),), ]) def test_from_str(self): with self.create_table('a IPv4'): data = [ ("10.0.0.1",), ] self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, ( '10.0.0.1\n' )) inserted = self.client.execute(query) self.assertEqual(inserted, [ (IPv4Address("10.0.0.1"),), ]) def test_type_mismatch(self): data = [(1025.2147,)] with self.create_table('a IPv4'): with self.assertRaises(errors.TypeMismatchError): self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) def test_bad_ipv4(self): data = [('985.512.12.0',)] with self.create_table('a IPv4'): with self.assertRaises(errors.CannotParseDomainError): self.client.execute( 'INSERT INTO test (a) VALUES', data ) def test_bad_ipv4_with_type_check(self): data = [('985.512.12.0',)] with self.create_table('a IPv4'): with self.assertRaises(errors.TypeMismatchError): self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) def test_nullable(self): with self.create_table('a Nullable(IPv4)'): data = [(IPv4Address('10.10.10.10'),), (None,)] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '10.10.10.10\n\\N\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) class IPv6TestCase(BaseTestCase): required_server_version = (19, 3, 3) def test_simple(self): with self.create_table('a IPv6'): data = [ (IPv6Address('79f4:e698:45de:a59b:2765:28e3:8d3a:35ae'),), (IPv6Address('a22:cc64:cf47:1653:4976:3c0c:ff8d:417c'),), (IPv6Address('12ff:0000:0000:0000:0000:0000:0000:0001'),) ] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, ( '79f4:e698:45de:a59b:2765:28e3:8d3a:35ae\n' 'a22:cc64:cf47:1653:4976:3c0c:ff8d:417c\n' '12ff::1\n' )) inserted = self.client.execute(query) self.assertEqual(inserted, [ (IPv6Address('79f4:e698:45de:a59b:2765:28e3:8d3a:35ae'),), (IPv6Address('a22:cc64:cf47:1653:4976:3c0c:ff8d:417c'),), (IPv6Address('12ff::1'),) ]) def test_from_str(self): with self.create_table('a IPv6'): data = [ ('79f4:e698:45de:a59b:2765:28e3:8d3a:35ae',), ] self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, ( '79f4:e698:45de:a59b:2765:28e3:8d3a:35ae\n' )) inserted = self.client.execute(query) self.assertEqual(inserted, [ (IPv6Address('79f4:e698:45de:a59b:2765:28e3:8d3a:35ae'),), ]) def test_from_bytes(self): with self.create_table('a IPv6'): data = [ (b"y\xf4\xe6\x98E\xde\xa5\x9b'e(\xe3\x8d:5\xae",), ] self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, ( '79f4:e698:45de:a59b:2765:28e3:8d3a:35ae\n' )) inserted = self.client.execute(query) self.assertEqual(inserted, [ (IPv6Address('79f4:e698:45de:a59b:2765:28e3:8d3a:35ae'),), ]) def test_type_mismatch(self): data = [(1025.2147,)] with self.create_table('a IPv6'): with self.assertRaises(errors.TypeMismatchError): self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) def test_bad_ipv6(self): data = [("ghjk:e698:45de:a59b:2765:28e3:8d3a:zzzz",)] with self.create_table('a IPv6'): with self.assertRaises(errors.CannotParseDomainError): self.client.execute( 'INSERT INTO test (a) VALUES', data ) def test_bad_ipv6_with_type_check(self): data = [("ghjk:e698:45de:a59b:2765:28e3:8d3a:zzzz",)] with self.create_table('a IPv6'): with self.assertRaises(errors.TypeMismatchError): self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) def test_nullable(self): with self.create_table('a Nullable(IPv6)'): data = [ (IPv6Address('79f4:e698:45de:a59b:2765:28e3:8d3a:35ae'),), (None,)] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '79f4:e698:45de:a59b:2765:28e3:8d3a:35ae\n\\N\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) clickhouse-driver-0.2.11/tests/columns/test_json.py000066400000000000000000000057051522645447600224470ustar00rootroot00000000000000import json from tests.testcase import BaseTestCase class JSONTestCase(BaseTestCase): required_server_version = (22, 3, 2) def client_kwargs(self, version): return {'settings': {'allow_experimental_object_type': True}} def cli_client_kwargs(self): return {'allow_experimental_object_type': 1} def test_simple(self): rv = self.client.execute( """ SELECT '{\"bb\": {\"cc\": [255, 1]}}'::Object('json') """, ) self.assertEqual(rv, [({'bb': {'cc': [255, 1]}},)]) def test_from_table(self): with self.create_table("a Object('json')"): data = [ ({},), ({'key1': 1}, ), ({'key1': 2.1, 'key2': {'nested': 'key'}}, ), ({'key1': 3, 'key3': ['test'], 'key4': [10, 20]}, ) ] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "(0,(''),[],[])\n" "(1,(''),[],[])\n" "(2.1,('key'),[],[])\n" "(3,(''),['test'],[10,20])\n" ) inserted = self.client.execute(query) data_with_all_keys = [ ({'key1': 0, 'key2': {'nested': ''}, 'key3': [], 'key4': []},), ({'key1': 1, 'key2': {'nested': ''}, 'key3': [], 'key4': []},), ({'key1': 2.1, 'key2': {'nested': 'key'}, 'key3': [], 'key4': []},), ({'key1': 3, 'key2': {'nested': ''}, 'key3': ['test'], 'key4': [10, 20]},) ] self.assertEqual(inserted, data_with_all_keys) def test_insert_json_strings(self): with self.create_table("a Object('json')"): data = [ (json.dumps({'i-am': 'dumped json'}),), ] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "('dumped json')\n" ) inserted = self.client.execute(query) data_with_all_keys = [ ({'`i-am`': 'dumped json'},) ] self.assertEqual(inserted, data_with_all_keys) def test_json_as_named_tuple(self): settings = {'namedtuple_as_json': False} query = 'SELECT * FROM test' with self.create_table("a Object('json')"): data = [ ({'key': 'value'}, ), ] self.client.execute('INSERT INTO test (a) VALUES', data) inserted = self.client.execute(query) self.assertEqual(inserted, data) with self.created_client(settings=settings) as client: inserted = client.execute(query) self.assertEqual(inserted, [(('value',),)]) clickhouse-driver-0.2.11/tests/columns/test_low_cardinality.py000066400000000000000000000151041522645447600246540ustar00rootroot00000000000000from datetime import date, timedelta from decimal import Decimal from uuid import UUID from tests.testcase import BaseTestCase from tests.util import require_server_version class LowCardinalityTestCase(BaseTestCase): required_server_version = (19, 3, 3) stable_support_version = (19, 9, 2) def cli_client_kwargs(self): if self.server_version >= self.stable_support_version: return {'allow_suspicious_low_cardinality_types': 1} def test_uint8(self): with self.create_table('a LowCardinality(UInt8)'): data = [(x, ) for x in range(255)] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '\n'.join(str(x[0]) for x in data) + '\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_int8(self): with self.create_table('a LowCardinality(Int8)'): data = [(x - 127, ) for x in range(255)] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '\n'.join(str(x[0]) for x in data) + '\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_nullable_int8(self): with self.create_table('a LowCardinality(Nullable(Int8))'): data = [(None, ), (-1, ), (0, ), (1, ), (None, )] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '\\N\n-1\n0\n1\n\\N\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_date(self): with self.create_table('a LowCardinality(Date)'): start = date(1970, 1, 1) data = [(start + timedelta(x), ) for x in range(300)] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_nullable_date(self): with self.create_table('a LowCardinality(Nullable(Date))'): data = [(date(2023, 4, 1), ), (None, ), (date(1970, 1, 1), )] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.client.execute(query) self.assertEqual(inserted, data) @require_server_version(21, 6) def test_nullable_uuid(self): with self.create_table('a LowCardinality(Nullable(UUID))'): data = [(UUID('2efcead4-ff55-4db5-bdb4-6b36a308d8e0'), ), (None, )] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_float(self): with self.create_table('a LowCardinality(Float)'): data = [(float(x),) for x in range(300)] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_decimal(self): with self.create_table('a LowCardinality(Float)'): data = [(Decimal(x),) for x in range(300)] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_array(self): with self.create_table('a Array(LowCardinality(Int16))'): data = [([100, 500], )] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '[100,500]\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_empty_array(self): with self.create_table('a Array(LowCardinality(Int16))'): data = [([], )] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '[]\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_string(self): with self.create_table('a LowCardinality(String)'): data = [ ('test', ), ('low', ), ('cardinality', ), ('test', ), ('test', ), ('', ) ] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, 'test\nlow\ncardinality\ntest\ntest\n\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_fixed_string(self): with self.create_table('a LowCardinality(FixedString(12))'): data = [ ('test', ), ('low', ), ('cardinality', ), ('test', ), ('test', ), ('', ) ] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, 'test\\0\\0\\0\\0\\0\\0\\0\\0\n' 'low\\0\\0\\0\\0\\0\\0\\0\\0\\0\n' 'cardinality\\0\n' 'test\\0\\0\\0\\0\\0\\0\\0\\0\n' 'test\\0\\0\\0\\0\\0\\0\\0\\0\n' '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_nullable_string(self): with self.create_table('a LowCardinality(Nullable(String))'): data = [ ('test', ), ('', ), (None, ) ] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, 'test\n\n\\N\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) clickhouse-driver-0.2.11/tests/columns/test_map.py000066400000000000000000000113011522645447600222400ustar00rootroot00000000000000from tests.testcase import BaseTestCase from decimal import Decimal class MapTestCase(BaseTestCase): required_server_version = (21, 1, 2) stable_support_version = (21, 8, 1) def client_kwargs(self, version): if version < self.stable_support_version: return {'settings': {'allow_experimental_map_type': True}} def cli_client_kwargs(self): if self.stable_support_version > self.server_version: return {'allow_experimental_map_type': 1} def _sorted_dicts(self, text): items = [ ('{' + ','.join(sorted(x.strip('{}\n').split(','))) + '}') for x in text.strip('\n').split('\n') ] return '\n'.join(items) + '\n' def test_simple(self): with self.create_table('a Map(String, UInt64)'): data = [ ({},), ({'key1': 1}, ), ({'key1': 2, 'key2': 20}, ), ({'key1': 3, 'key2': 30, 'key3': 50}, ) ] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( self._sorted_dicts(inserted), "{}\n" "{'key1':1}\n" "{'key1':2,'key2':20}\n" "{'key1':3,'key2':30,'key3':50}\n" ) inserted = self.client.execute(query) self.assertEqual(inserted, data) # def test_nullable(self): # with self.create_table('a Map(Nullable(String), Nullable(UInt64))'): # data = [ # ({},), # ({None: None},), # ({'key1': 1}, ) # ] # self.client.execute('INSERT INTO test (a) VALUES', data) # query = 'SELECT * FROM test' # inserted = self.emit_cli(query) # self.assertEqual( # inserted, # "{}\n" # "{NULL:NULL}\n" # "{'key1':1}\n" # ) # inserted = self.client.execute(query) # self.assertEqual(inserted, data) # # def test_low_cardinality(self): # columns = 'a Map(LowCardinality(String), LowCardinality(UInt64))' # with self.create_table(columns): # data = [ # ({'key1': 1}, ), # ({'key1': 1}, ), # ({'key1': 1}, ) # ] # self.client.execute('INSERT INTO test (a) VALUES', data) # query = 'SELECT * FROM test' # inserted = self.emit_cli(query) # self.assertEqual( # inserted, # "{'key1':1}\n" # "{'key1':1}\n" # "{'key1':1}\n" # ) # inserted = self.client.execute(query) # self.assertEqual(inserted, data) def test_array(self): columns = 'a Map(String, Array(UInt64))' with self.create_table(columns): data = [ ({'key1': []}, ), ({'key2': [1, 2, 3]}, ), ({'key3': [1, 1, 1, 1]}, ) ] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "{'key1':[]}\n" "{'key2':[1,2,3]}\n" "{'key3':[1,1,1,1]}\n" ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_decimal(self): columns = 'a Map(String, Decimal(9, 2))' with self.create_table(columns): data = [ ({'key1': Decimal('123.45')}, ), ({'key2': Decimal('234.56')}, ), ({'key3': Decimal('345.67')}, ) ] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "{'key1':123.45}\n" "{'key2':234.56}\n" "{'key3':345.67}\n" ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_only_empty_map(self): columns = 'a Map(String, Map(String, Int32))' with self.create_table(columns): data = [ ({}, ), ] self.client.execute('INSERT INTO test (a) VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '{}\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) clickhouse-driver-0.2.11/tests/columns/test_nested.py000066400000000000000000000062601522645447600227550ustar00rootroot00000000000000from tests.testcase import BaseTestCase class NestedTestCase(BaseTestCase): required_server_version = (21, 3, 13) def entuple(self, lst): return tuple( self.entuple(x) if isinstance(x, list) else x for x in lst ) def test_simple(self): columns = 'n Nested(i Int32, s String)' # INSERT INTO test_nested VALUES ([(0, 'a'), (1, 'b')]); data = [([(0, 'a'), (1, 'b')],)] with self.create_table(columns, flatten_nested=0): self.client.execute( 'INSERT INTO test (n) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, "[(0,'a'),(1,'b')]\n") inserted = self.client.execute(query) self.assertEqual(inserted, data) projected_i = self.client.execute('SELECT n.i FROM test') self.assertEqual( projected_i, [([0, 1],)] ) projected_s = self.client.execute('SELECT n.s FROM test') self.assertEqual( projected_s, [(['a', 'b'],)] ) def test_multiple_rows(self): columns = 'n Nested(i Int32, s String)' data = [([(0, 'a'), (1, 'b')],), ([(3, 'd'), (4, 'e')],)] with self.create_table(columns, flatten_nested=0): self.client.execute( 'INSERT INTO test (n) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "[(0,'a'),(1,'b')]\n[(3,'d'),(4,'e')]\n" ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_dict(self): columns = 'n Nested(i Int32, s String)' data = [ {'n': [{'i': 0, 's': 'a'}, {'i': 1, 's': 'b'}]}, {'n': [{'i': 3, 's': 'd'}, {'i': 4, 's': 'e'}]}, ] with self.create_table(columns, flatten_nested=0): self.client.execute( 'INSERT INTO test (n) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "[(0,'a'),(1,'b')]\n[(3,'d'),(4,'e')]\n" ) inserted = self.client.execute(query) self.assertEqual( inserted, [([(0, 'a'), (1, 'b')],), ([(3, 'd'), (4, 'e')],)] ) def test_nested_side_effect_as_json(self): client_settings = { 'allow_experimental_object_type': True } columns = 'n Nested(i Int32, s String)' data = [([(0, 'a'), (1, 'b')],)] with self.create_table(columns, flatten_nested=0): with self.created_client(settings=client_settings) as client: client.execute( 'INSERT INTO test (n) VALUES', data ) inserted = client.execute('SELECT * FROM test') self.assertEqual( inserted, [([{'i': 0, 's': 'a'}, {'i': 1, 's': 'b'}],)] ) clickhouse-driver-0.2.11/tests/columns/test_newjson.py000066400000000000000000001446421522645447600231650ustar00rootroot00000000000000from io import BytesIO from unittest import TestCase from tests.testcase import BaseTestCase from clickhouse_driver.bufferedreader import CompressedBufferedReader from clickhouse_driver.bufferedwriter import CompressedBufferedWriter from clickhouse_driver.columns.service import read_column, write_column from clickhouse_driver.context import Context class NewJSONTestCase(BaseTestCase): required_server_version = (24, 8, 0) def client_kwargs(self, version): return {"settings": {"enable_json_type": True}} def cli_client_kwargs(self): return {"enable_json_type": 1} def test_simple(self): rv = self.client.execute('SELECT \'{"bb": {"cc": [255, 1]}}\'::JSON') self.assertEqual(rv, [({"bb": {"cc": [255, 1]}},)]) def test_json_0(self): with self.create_table("a JSON"): data = [({"key": 1},), ({"key": "val"},), ({"key": 2.0},)] self.client.execute("INSERT INTO test (a) VALUES", data) query = "SELECT * FROM test" expected_result = [ ({"key": 1},), ({"key": "val"},), ({"key": 2.0},)] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_0_fromcli(self): with self.create_table("a JSON"): self.emit_cli( 'INSERT INTO test (a) VALUES (\'{"key": 1}\'),\ (\'{"key": "val"}\'),\ (\'{"key": 2.0}\')' ) query = "SELECT * FROM test" expected_result = [ ({"key": 1},), ({"key": "val"},), ({"key": 2.0},)] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_1(self): with self.create_table("a JSON"): data = [ ( { "user_id": 101, "username": "john_doe", "email": "john.doe@example.com", "profile": { "first_name": "John", "last_name": "Doe", "age": 30, "gender": "male", }, "preferences": {"theme": "dark", "notifications": True}, "roles": ["admin", "user"], }, ) ] self.client.execute("INSERT INTO test (a) VALUES", data) query = "SELECT * FROM test" expected_result = [ ( { "email": "john.doe@example.com", "roles": ["admin", "user"], "user_id": 101, "username": "john_doe", "preferences": {"notifications": True, "theme": "dark"}, "profile": { "age": 30, "first_name": "John", "gender": "male", "last_name": "Doe", }, }, ) ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_1_fromcli(self): with self.create_table("a JSON"): self.emit_cli( 'INSERT INTO test (a) VALUES (\'{"user_id": 101, "username": "john_doe", "email": "john.doe@example.com", "profile": {"first_name": "John", "last_name": "Doe", "age": 30, "gender": "male"}, "preferences": {"theme": "dark", "notifications": true}, "roles": ["admin", "user"]}\')' ) query = "SELECT * FROM test" expected_result = [ ( { "email": "john.doe@example.com", "roles": ["admin", "user"], "user_id": 101, "username": "john_doe", "preferences": {"notifications": True, "theme": "dark"}, "profile": { "age": 30, "first_name": "John", "gender": "male", "last_name": "Doe", }, }, ) ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_2(self): with self.create_table("a JSON"): data = [ ({},), ({"foo": "bar", "bar": "baz"},), ({"baz": "qux", "foo": 4919},), ({"qux": "quux"},), ({"foo": "AAAA"},), ({"qux": 14099},), ({"foo": [1, 0.2, "bar", "baz", False]},), ({"foo": 0.1337},), ({"foo": False},), ({"bar": 1337},), ({"bar": 0.999},), ({"quux": 1000},), ({"quux": 2000},), ({"quux": 20.25},), ({"alice": 0.432},), ({"bob": 0.991},), ({"boolean": True},), ({"null": None},), ({"string": "A quick brown fox jumps over the lazy dog."},), ( { "nested": { "number": 4141, "string": "Hello, World!", "double-nested": { "foo": "bar", "no.escaping": "1337", "triple-nested": {"foo": "bar"}, "numbers": [1, 2, 3], "floats": [0.1, 0.2, 4], "tuple-list": [ 1, 3, "asdf", [1, 4, 6], {"foo": "bar", "list": [ 1, 2, {"hello": "world"}]}, ], }, } }, ), ( { "list": [ 123, "2", True, {"foo": "bar", "list": [0.123, {"baz": "bar"}]}, ] }, ), ] self.client.execute("INSERT INTO test (a) VALUES", data) query = "SELECT * FROM test" expected_result = [ ({},), ({"bar": "baz", "foo": "bar"},), ({"baz": "qux", "foo": 4919},), ({"qux": "quux"},), ({"foo": "AAAA"},), ({"qux": 14099},), ({"foo": ["1", "0.2", "bar", "baz", "false"]},), ({"foo": 0.1337},), ({"foo": False},), ({"bar": 1337},), ({"bar": 0.999},), ({"quux": 1000},), ({"quux": 2000},), ({"quux": 20.25},), ({"alice": 0.432},), ({"bob": 0.991},), ({"boolean": True},), ({},), ({"string": "A quick brown fox jumps over the lazy dog."},), ( { "nested": { "double-nested": { "floats": [0.1, 0.2, 4.0], "foo": "bar", "no": {"escaping": "1337"}, "numbers": [1, 2, 3], "triple-nested": {"foo": "bar"}, "tuple-list": [ 1, 3, "asdf", [1, 4, 6], {"foo": "bar", "list": [ 1, 2, {"hello": "world"}]}, ], }, "number": 4141, "string": "Hello, World!", } }, ), ( { "list": [ 123, "2", True, {"foo": "bar", "list": [0.123, {"baz": "bar"}]}, ] }, ), ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_2_fromcli(self): with self.create_table("a JSON"): self.emit_cli( 'INSERT INTO test (a) VALUES (\'{}\'),\ (\'{"foo": "bar", "bar": "baz"}\'),\ (\'{"baz": "qux", "foo": 4919}\'),\ (\'{"qux": "quux"}\'),\ (\'{"foo": "AAAA"}\'),\ (\'{"qux": 14099}\'),\ (\'{"foo": [1, 0.2, "bar", "baz", false]}\'),\ (\'{"foo": 0.1337}\'),\ (\'{"foo": false}\'),\ (\'{"bar": 1337}\'),\ (\'{"bar": 0.999}\'),\ (\'{"quux": 1000}\'),\ (\'{"quux": 2000}\'),\ (\'{"quux": 20.25}\'),\ (\'{"alice": 0.432}\'),\ (\'{"bob": 0.991}\'),\ (\'{"boolean": true}\'),\ (\'{"null": null}\'),\ (\'{"string": "A quick brown fox jumps over the lazy dog."}\'),\ (\'{"nested": {"number": 4141, "string": "Hello, World!", "double-nested": {"foo": "bar", "no.escaping": "1337", "triple-nested": {"foo": "bar"}, "numbers": [1, 2, 3], "floats": [0.1, 0.2, 4], "tuple-list": [1, 3, "asdf", [1, 4, 6], {"foo": "bar", "list": [1, 2, {"hello": "world"}]}]}}}\'),\ (\'{"list": [123, "2", true, {"foo": "bar", "list": [0.123, {"baz": "bar"}]}]}\')' ) query = "SELECT * FROM test" expected_result = [ ({},), ({"bar": "baz", "foo": "bar"},), ({"baz": "qux", "foo": 4919},), ({"qux": "quux"},), ({"foo": "AAAA"},), ({"qux": 14099},), ({"foo": ["1", "0.2", "bar", "baz", "false"]},), ({"foo": 0.1337},), ({"foo": False},), ({"bar": 1337},), ({"bar": 0.999},), ({"quux": 1000},), ({"quux": 2000},), ({"quux": 20.25},), ({"alice": 0.432},), ({"bob": 0.991},), ({"boolean": True},), ({},), ({"string": "A quick brown fox jumps over the lazy dog."},), ( { "nested": { "double-nested": { "floats": [0.1, 0.2, 4.0], "foo": "bar", "no": {"escaping": "1337"}, "numbers": [1, 2, 3], "triple-nested": {"foo": "bar"}, "tuple-list": [ 1, 3, "asdf", [1, 4, 6], {"foo": "bar", "list": [ 1, 2, {"hello": "world"}]}, ], }, "number": 4141, "string": "Hello, World!", } }, ), ( { "list": [ 123, "2", True, {"foo": "bar", "list": [0.123, {"baz": "bar"}]}, ] }, ), ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_3(self): with self.create_table("a JSON"): data = [ ({"list": [1, "asdf", 0.025, None, ["foo", "bar"], ["foo", "bar"]]},) ] self.client.execute("INSERT INTO test (a) VALUES", data) query = "SELECT * FROM test" expected_result = [ ({"list": (1, "asdf", 0.025, None, ["foo", "bar"], ["foo", "bar"])},) ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_3_fromcli(self): with self.create_table("a JSON"): self.emit_cli( 'INSERT INTO test (a) VALUES (\'{"list": [1, "asdf", 0.025, null, ["foo", "bar"], ["foo", "bar"]]}\')' ) query = "SELECT * FROM test" expected_result = [ ({"list": (1, "asdf", 0.025, None, ["foo", "bar"], ["foo", "bar"])},) ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_4(self): with self.create_table("a JSON"): data = [ ({"list": [1, 2, 3]},), ({"list": [0.1, 2, 3, None]},), ({"list": ["test"]},), ({"list": [None, None, None]},), ({"list": [1, 2, None]},), ({"list": ["asdf", None]},), ] self.client.execute("INSERT INTO test (a) VALUES", data) query = "SELECT * FROM test" expected_result = [ ({"list": [1, 2, 3]},), ({"list": [0.1, 2.0, 3.0, 0.0]},), ({"list": ["test"]},), ({"list": [None, None, None]},), ({"list": [1, 2, 0]},), ({"list": ["asdf", None]},), ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_4_fromcli(self): with self.create_table("a JSON"): self.emit_cli( 'INSERT INTO test (a) VALUES (\'{"list": [1, 2, 3]}\'),\ (\'{"list": [0.1, 2, 3, null]}\'),\ (\'{"list": ["test"]}\'),\ (\'{"list": [null, null, null]}\'),\ (\'{"list": [1, 2, null]}\'),\ (\'{"list": ["asdf", null]}\')' ) query = "SELECT * FROM test" expected_result = [ ({"list": [1, 2, 3]},), ({"list": [0.1, 2.0, 3.0, None]},), ({"list": ["test"]},), ({"list": [None, None, None]},), ({"list": [1, 2, None]},), ({"list": ["asdf", None]},), ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_5(self): with self.create_table("a JSON"): data = [ ( { "list": [ "123", "456", { "nested-list": [ "789", "10", { "double-nested-list": [ 14099, "AAAA", { "triple-nested-list": [ 1, 2, { "quadruple-nested-list": [ 3, 4, { "quintuple-nested-list": [ 5, 6, ] }, ] }, ] }, ] }, ] }, ] }, ) ] self.client.execute("INSERT INTO test (a) VALUES", data) query = "SELECT * FROM test" expected_result = [ ( { "list": [ "123", "456", { "nested-list": [ "789", "10", { "double-nested-list": [ 14099, "AAAA", { "triple-nested-list": [ 1, 2, { "quadruple-nested-list": [ 3, 4, { "quintuple-nested-list": [ 5, 6, ] }, ] }, ] }, ] }, ] }, ] }, ) ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_5_fromcli(self): with self.create_table("a JSON"): self.emit_cli( 'INSERT INTO test (a) VALUES (\'{"list": ["123", "456", {"nested-list": ["789", "10", {"double-nested-list": [14099, "AAAA", {"triple-nested-list": [1, 2, {"quadruple-nested-list": [3, 4, {"quintuple-nested-list": [5, 6]}]}]}]}]}]}\')' ) query = "SELECT * FROM test" expected_result = [ ( { "list": [ "123", "456", { "nested-list": [ "789", "10", { "double-nested-list": [ 14099, "AAAA", { "triple-nested-list": [ 1, 2, { "quadruple-nested-list": [ 3, 4, { "quintuple-nested-list": [ 5, 6, ] }, ] }, ] }, ] }, ] }, ] }, ) ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_6(self): with self.create_table("a JSON"): data = [ ( { "list": [ "123", "456", {"nested-list": ["789", "10", {"double-nested": "test"}]}, ] }, ), ( { "list": [ "1337", "444", {"nested-list": ["123", "654", {"asdf": "fdas"}]}, ] }, ), ({"list": ["123", "456", {"nested-list": "1234"}]},), ] self.client.execute("INSERT INTO test (a) VALUES", data) query = "SELECT * FROM test" expected_result = [ ( { "list": [ "123", "456", {"nested-list": ["789", "10", {"double-nested": "test"}]}, ] }, ), ( { "list": [ "1337", "444", {"nested-list": ["123", "654", {"asdf": "fdas"}]}, ] }, ), ({"list": ["123", "456", {"nested-list": "1234"}]},), ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_6_fromcli(self): with self.create_table("a JSON"): self.emit_cli( 'INSERT INTO test (a) VALUES (\'{"list": ["123", "456", {"nested-list": ["789", "10", {"double-nested": "test"}]}]}\'),\ (\'{"list": ["1337", "444", {"nested-list": ["123", "654", {"asdf": "fdas"}]}]}\'),\ (\'{"list": ["123", "456", {"nested-list": "1234"}]}\')' ) query = "SELECT * FROM test" expected_result = [ ( { "list": [ "123", "456", {"nested-list": ["789", "10", {"double-nested": "test"}]}, ] }, ), ( { "list": [ "1337", "444", {"nested-list": ["123", "654", {"asdf": "fdas"}]}, ] }, ), ({"list": ["123", "456", {"nested-list": "1234"}]},), ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_7(self): with self.create_table("a JSON"): data = [ ({"list": [1, "2", {"foo": "bar"}]},), ({"list": "not a list"},), ({"list": 14009},), ({"list": 0.025},), ({"list": True},), ({"list": [14099, {"bar": "baz"}, {"baz": "quux"}]},), ] self.client.execute("INSERT INTO test (a) VALUES", data) query = "SELECT * FROM test" expected_result = [ ({"list": [1, "2", {"foo": "bar"}]},), ({"list": "not a list"},), ({"list": 14009},), ({"list": 0.025},), ({"list": True},), ({"list": [14099, {"bar": "baz"}, {"baz": "quux"}]},), ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_7_fromcli(self): with self.create_table("a JSON"): self.emit_cli( 'INSERT INTO test (a) VALUES (\'{"list": [1, "2", {"foo": "bar"}]}\'),\ (\'{"list": "not a list"}\'),\ (\'{"list": 14009}\'),\ (\'{"list": 0.025}\'),\ (\'{"list": true}\'),\ (\'{"list": [14099, {"bar": "baz"}, {"baz": "quux"}]}\')' ) query = "SELECT * FROM test" expected_result = [ ({"list": [1, "2", {"foo": "bar"}]},), ({"list": "not a list"},), ({"list": 14009},), ({"list": 0.025},), ({"list": True},), ({"list": [14099, {"bar": "baz"}, {"baz": "quux"}]},), ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_8(self): with self.create_table("a JSON"): data = [ ({"list1": [1, "2", {"foo": "bar"}]},), ({"string": "string"},), ({"int": 14009},), ({"float": 0.025},), ({"bool": True},), ({"list2": [14099, {"bar": "baz"}, {"baz": "quux"}]},), ] self.client.execute("INSERT INTO test (a) VALUES", data) query = "SELECT * FROM test" expected_result = [ ({"list1": [1, "2", {"foo": "bar"}]},), ({"string": "string"},), ({"int": 14009},), ({"float": 0.025},), ({"bool": True},), ({"list2": [14099, {"bar": "baz"}, {"baz": "quux"}]},), ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_8_fromcli(self): with self.create_table("a JSON"): self.emit_cli( 'INSERT INTO test (a) VALUES (\'{"list1": [1, "2", {"foo": "bar"}]}\'),\ (\'{"string": "string"}\'),\ (\'{"int": 14009}\'),\ (\'{"float": 0.025}\'),\ (\'{"bool": true}\'),\ (\'{"list2": [14099, {"bar": "baz"}, {"baz": "quux"}]}\')' ) query = "SELECT * FROM test" expected_result = [ ({"list1": [1, "2", {"foo": "bar"}]},), ({"string": "string"},), ({"int": 14009},), ({"float": 0.025},), ({"bool": True},), ({"list2": [14099, {"bar": "baz"}, {"baz": "quux"}]},), ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_9(self): with self.create_table("a JSON"): data = [ ({"list": [1, "asdf", 0.025, ["foo", "bar", ["baz", "qux"]]]},), ({"list": [10, "fdas", 0.075, ["bar", "foo", ["qux", "baz"]]]},), ] self.client.execute("INSERT INTO test (a) VALUES", data) query = "SELECT * FROM test" expected_result = [ ({"list": (1, "asdf", 0.025, ("foo", "bar", ["baz", "qux"]))},), ({"list": (10, "fdas", 0.075, ("bar", "foo", ["qux", "baz"]))},), ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_9_fromcli(self): with self.create_table("a JSON"): self.emit_cli( 'INSERT INTO test (a) VALUES (\'{"list": [1, "asdf", 0.025, ["foo", "bar", ["baz", "qux"]]]}\'),\ (\'{"list": [10, "fdas", 0.075, ["bar", "foo", ["qux", "baz"]]]}\')' ) query = "SELECT * FROM test" expected_result = [ ({"list": (1, "asdf", 0.025, ("foo", "bar", ["baz", "qux"]))},), ({"list": (10, "fdas", 0.075, ("bar", "foo", ["qux", "baz"]))},), ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_10(self): with self.create_table("a JSON"): data = [({"list": ["a", None, "b", None, "c", None]},)] self.client.execute("INSERT INTO test (a) VALUES", data) query = "SELECT * FROM test" expected_result = [({"list": ["a", None, "b", None, "c", None]},)] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_10_fromcli(self): with self.create_table("a JSON"): self.emit_cli( 'INSERT INTO test (a) VALUES (\'{"list": ["a", null, "b", null, "c", null]}\')' ) query = "SELECT * FROM test" expected_result = [({"list": ["a", None, "b", None, "c", None]},)] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_11(self): with self.create_table("a JSON"): data = [ ({"asdf": [{"foo": "bar"}, {"bar": "baz"}]},), ({"asdf": [{"baz": "qux"}, {"qux": "quux"}]},), ] self.client.execute("INSERT INTO test (a) VALUES", data) query = "SELECT * FROM test" expected_result = [ ({"asdf": [{"foo": "bar"}, {"bar": "baz"}]},), ({"asdf": [{"baz": "qux"}, {"qux": "quux"}]},), ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_11_fromcli(self): with self.create_table("a JSON"): self.emit_cli( 'INSERT INTO test (a) VALUES (\'{"asdf": [{"foo": "bar"}, {"bar": "baz"}]}\'),\ (\'{"asdf": [{"baz": "qux"}, {"qux": "quux"}]}\')' ) query = "SELECT * FROM test" expected_result = [ ({"asdf": [{"foo": "bar"}, {"bar": "baz"}]},), ({"asdf": [{"baz": "qux"}, {"qux": "quux"}]},), ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_12(self): with self.create_table("a JSON"): data = [ ({"fdsa": [["foo", "bar"], ["bar", "baz"]]},), ({"fdsa": [["baz", "qux"], ["qux", "quux"]]},), ] self.client.execute("INSERT INTO test (a) VALUES", data) query = "SELECT * FROM test" expected_result = [ ({"fdsa": [["foo", "bar"], ["bar", "baz"]]},), ({"fdsa": [["baz", "qux"], ["qux", "quux"]]},), ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_12_fromcli(self): with self.create_table("a JSON"): self.emit_cli( 'INSERT INTO test (a) VALUES (\'{"fdsa": [["foo", "bar"], ["bar", "baz"]]}\'),\ (\'{"fdsa": [["baz", "qux"], ["qux", "quux"]]}\')' ) query = "SELECT * FROM test" expected_result = [ ({"fdsa": [["foo", "bar"], ["bar", "baz"]]},), ({"fdsa": [["baz", "qux"], ["qux", "quux"]]},), ] result = self.client.execute(query) self.assertEqual(result, expected_result) def test_json_shared_paths(self): # Paths that overflow max_dynamic_paths land in the JSON column's # shared data sub-column. Force a merge so the shared data # representation is actually persisted. spec = "id UInt32, a JSON(max_dynamic_paths=2, max_dynamic_types=2)" template = "CREATE TABLE test ({}) ENGINE = MergeTree ORDER BY id" with self.create_table(spec, template=template): data = [] for i in range(8): data.append({ "id": i, "a": { "common": "shared", "k{}".format(i): i, "num": i * 2, }, }) self.client.execute( "INSERT INTO test (id, a) VALUES", data) self.client.execute("OPTIMIZE TABLE test FINAL") result = self.client.execute( "SELECT a FROM test ORDER BY id") expected = [ ({ "common": "shared", "k{}".format(i): i, "num": i * 2, },) for i in range(8) ] self.assertEqual(result, expected) def test_json_shared_paths_mixed_types(self): # All paths go to shared data because both limits are zero; the # values exercise the binary-encoded type tags for Int, Float, # String and Bool. spec = "id UInt32, a JSON(max_dynamic_paths=0, max_dynamic_types=0)" template = "CREATE TABLE test ({}) ENGINE = MergeTree ORDER BY id" with self.create_table(spec, template=template): data = [ {"id": 0, "a": {"x": 1, "y": "two", "z": True}}, {"id": 1, "a": {"x": 2, "y": "three", "z": False}}, {"id": 2, "a": {"f": 3.5}}, {"id": 3, "a": {}}, ] self.client.execute( "INSERT INTO test (id, a) VALUES", data) self.client.execute("OPTIMIZE TABLE test FINAL") result = self.client.execute( "SELECT a FROM test ORDER BY id") self.assertEqual(result, [ ({"x": 1, "y": "two", "z": True},), ({"x": 2, "y": "three", "z": False},), ({"f": 3.5},), ({},), ]) def test_nullable_json_round_trip(self): with self.create_table("a Nullable(JSON)"): data = [(None,), ({"x": 1},), (None,), ({"y": "two"},)] self.client.execute("INSERT INTO test (a) VALUES", data) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, data) def test_non_nullable_json_coerces_none_to_empty_dict(self): with self.create_table("a JSON"): self.client.execute( "INSERT INTO test (a) VALUES", [(None,), ({"x": 1},)]) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, [({},), ({"x": 1},)]) def test_json_array_value_types(self): # Each homogeneous array maps to a distinct Array spec on the # write path (Int64 / Float64 / Bool / String), and round-trips # back through the per-path Dynamic reader. with self.create_table("a JSON"): data = [ ({"ints": [1, 2, 3]},), ({"floats": [1.5, 2.5]},), ({"bools": [True, False]},), ({"strings": ["a", "b"]},), ] self.client.execute("INSERT INTO test (a) VALUES", data) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, data) def test_json_array_mixed_numeric_coerced_to_string(self): # A heterogeneous array has no common numeric type, so the # server widens every element to String. with self.create_table("a JSON"): self.client.execute( "INSERT INTO test (a) VALUES", [({"v": [1, "x", 2.5]},)]) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, [({"v": ["1", "x", "2.5"]},)]) def test_json_nested_arrays(self): # Arrays whose elements are themselves arrays exercise the # recursive Array spec inference / decoder. with self.create_table("a JSON"): data = [({"grid": [[1, 2], [3]]},)] self.client.execute("INSERT INTO test (a) VALUES", data) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, data) def test_json_array_of_objects(self): # An array of objects becomes a Tuple spec on the write path and # a dynamic path on read. with self.create_table("a JSON"): data = [({"items": [{"p": 1}, {"p": 2}]},)] self.client.execute("INSERT INTO test (a) VALUES", data) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, data) def test_json_deeply_nested_object(self): with self.create_table("a JSON"): data = [({"a": {"b": {"c": {"d": 1}}}},)] self.client.execute("INSERT INTO test (a) VALUES", data) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, data) def test_json_string_value_input(self): # A row given as a JSON string is parsed by the write path # before serialization. with self.create_table("a JSON"): self.client.execute( "INSERT INTO test (a) VALUES", [('{"x": 1, "y": "two"}',)]) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, [({"x": 1, "y": "two"},)]) def test_json_shared_arrays(self): # Arrays forced into the shared-data sub-column exercise the # SharedVariant Array / nested-Array decoders, which the typed # dynamic-path reader never reaches. spec = "id UInt32, a JSON(max_dynamic_paths=0, max_dynamic_types=0)" template = "CREATE TABLE test ({}) ENGINE = MergeTree ORDER BY id" with self.create_table(spec, template=template): data = [ {"id": 0, "a": {"ints": [1, 2, 3]}}, {"id": 1, "a": {"nested": [[1, 2], [3]]}}, {"id": 2, "a": {"strings": ["a", "b"]}}, {"id": 3, "a": {"floats": [1.5, 2.5]}}, ] self.client.execute("INSERT INTO test (id, a) VALUES", data) self.client.execute("OPTIMIZE TABLE test FINAL") result = self.client.execute("SELECT a FROM test ORDER BY id") self.assertEqual(result, [ ({"ints": [1, 2, 3]},), ({"nested": [[1, 2], [3]]},), ({"strings": ["a", "b"]},), ({"floats": [1.5, 2.5]},), ]) def test_json_array_with_nested_tuple_and_object(self): # Heterogeneous arrays infer a Tuple spec on the write path. When # an element is itself such an array, the spec nests # (Tuple(Tuple(...), JSON)); the write path has to split the spec # paren-aware and recurse rather than mishandle the inner commas. with self.create_table("a JSON"): data = [ ({"v": [[[1], {"p": 1}], {"q": 2}]},), ({"v": [[2, 3], {"p": 5}]},), ] self.client.execute("INSERT INTO test (a) VALUES", data) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, data) def test_json_nested_container_shapes(self): # Each of these infers a different nested spec on the write path, # exercising the paren-aware recursion through Tuple/Array # elements that carry a JSON sub-column. with self.create_table("a JSON"): data = [ # Tuple(Array(JSON), Nullable(Int64)) ({"v": [[{"p": 1}], 5]},), # Array(Tuple(Nullable(Int64), JSON)) ({"w": [[1, {"p": 1}], [2, {"q": 2}]]},), # Array(Array(Array(JSON))) ({"x": [[[{"p": 1}]]]},), ] self.client.execute("INSERT INTO test (a) VALUES", data) result = self.client.execute("SELECT * FROM test ORDER BY a") self.assertCountEqual(result, data) def test_json_tuple_with_plain_tuple_element(self): # A complex tuple whose first element is a Tuple that has no JSON # is written via the non-JSON Tuple branch. On read, a tuple # without a dict stays a Python tuple (the long-standing # _tuples_to_lists surface), so the inner element comes back as a # tuple rather than a list. with self.create_table("a JSON"): self.client.execute( "INSERT INTO test (a) VALUES", [({"v": [[[1], "x"], {"p": 1}]},)]) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, [({"v": [([1], "x"), {"p": 1}]},)]) def test_json_shared_arrays_of_objects(self): # An array of objects forced into shared data serialises as # Array(JSON); the SharedVariant decoder has to recurse into the # nested JSON value (including dotted paths) to reconstruct it. spec = "id UInt32, a JSON(max_dynamic_paths=0, max_dynamic_types=0)" template = "CREATE TABLE test ({}) ENGINE = MergeTree ORDER BY id" with self.create_table(spec, template=template): data = [ {"id": 0, "a": {"items": [{"p": 1}, {"q": "x"}]}}, {"id": 1, "a": {"items": [{"nested": {"deep": 5}}]}}, ] self.client.execute("INSERT INTO test (id, a) VALUES", data) self.client.execute("OPTIMIZE TABLE test FINAL") result = self.client.execute("SELECT a FROM test ORDER BY id") self.assertEqual(result, [ ({"items": [{"p": 1}, {"q": "x"}]},), ({"items": [{"nested": {"deep": 5}}]},), ]) class JSONInContainerColumnsTestCase(BaseTestCase): """ JSON columns nested inside container column types. The object prefix is data-dependent, so the write path threads the block's items into ``write_state_prefix`` to emit it in the prefix stream position the server expects for nested columns; inserts into ``Map(String, JSON)`` used to deadlock and ``Array(JSON)`` raised ``NotImplementedError`` (issue #511). """ required_server_version = (24, 8, 0) def client_kwargs(self, version): return {"settings": {"enable_json_type": True}} def cli_client_kwargs(self): return {"enable_json_type": 1} def test_map_of_json(self): with self.create_table("a Map(String, JSON)"): data = [ ({"k": {"a": 1}},), ({"k": {"b": "x"}, "j": {"c": 2.5, "d": {"e": True}}},), ({},), ({"empty": {}},), ] self.client.execute("INSERT INTO test (a) VALUES", data) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, data) def test_map_of_json_server_side_view(self): # The CLI view proves the bytes landed correctly on the server, # not just that the client can read back its own encoding. with self.create_table("a Map(String, JSON)"): self.client.execute( "INSERT INTO test (a) VALUES", [({"k": {"a": 1, "n": {"d": "deep"}}},)]) # Integer quoting in JSON output defaults differently across # server versions; pin it so the assertion is stable. cli = self.emit_cli( "SELECT toJSONString(a) FROM test", output_format_json_quote_64bit_integers=0, ) self.assertEqual(cli, '{"k":{"a":1,"n":{"d":"deep"}}}\n') def test_map_of_json_string_value_input(self): # JSON given as text is parsed by the write path, same as for # top-level JSON columns. with self.create_table("a Map(String, JSON)"): self.client.execute( "INSERT INTO test (a) VALUES", [({"k": '{"s": 1}'},)]) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, [({"k": {"s": 1}},)]) def test_array_of_json(self): with self.create_table("a Array(JSON)"): data = [ ([{"a": 1}, {"b": "x"}],), ([],), ([{"c": [1, 2, 3]}],), ] self.client.execute("INSERT INTO test (a) VALUES", data) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, data) def test_tuple_with_json(self): with self.create_table("a Tuple(String, JSON)"): data = [ (("s1", {"a": 1}),), (("s2", {"b": {"c": "deep"}}),), ] self.client.execute("INSERT INTO test (a) VALUES", data) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, data) def test_map_of_array_of_json(self): with self.create_table("a Map(String, Array(JSON))"): data = [ ({"k": [{"a": 1}], "l": [{"b": 2}, {"c": 3}]},), ({},), ] self.client.execute("INSERT INTO test (a) VALUES", data) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, data) def test_array_of_array_of_json(self): with self.create_table("a Array(Array(JSON))"): data = [ ([[{"a": 1}], [{"b": 2}, {"c": 3}]],), ([[]],), ] self.client.execute("INSERT INTO test (a) VALUES", data) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, data) def test_map_of_nullable_json(self): with self.create_table("a Map(String, Nullable(JSON))"): data = [({"k": {"a": 1}, "n": None},)] self.client.execute("INSERT INTO test (a) VALUES", data) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, data) def test_array_of_nullable_json(self): with self.create_table("a Array(Nullable(JSON))"): data = [([{"a": 1}, None, {"b": 2}],)] self.client.execute("INSERT INTO test (a) VALUES", data) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, data) def test_map_of_map_of_json(self): with self.create_table("a Map(String, Map(String, JSON))"): data = [({"outer": {"inner": {"a": 1}}},)] self.client.execute("INSERT INTO test (a) VALUES", data) result = self.client.execute("SELECT * FROM test") self.assertEqual(result, data) class JSONWireRoundTripTestCase(TestCase): # Which server versions run the integration tests above is a matrix # choice, so the JSON write path would go uncovered on jobs against # servers without JSON support. Serialize and deserialize a block # locally so every line is exercised deterministically on every # job. Wire compatibility itself is covered by the server-backed # tests. def make_context(self): context = Context() context.client_settings = { 'use_numpy': False, 'strings_as_bytes': False, } context.settings = {} return context def round_trip(self, spec, items): context = self.make_context() sink = BytesIO() write_buf = CompressedBufferedWriter(sink, 1024) # prepare_items mutates the list it is given (e.g. None -> # null_value); write a copy so `items` stays comparable. write_column(context, 'a', spec, list(items), write_buf) write_buf.flush() chunks = [sink.getvalue()] read_buf = CompressedBufferedReader( lambda: chunks.pop() if chunks else b'', 1024) return list(read_column(context, spec, len(items), read_buf)) def test_json(self): items = [ {'i': 1, 'f': 2.5, 's': 'x', 'b': True, 'n': {'d': 'deep'}}, {'list': [1, 2], 'strings': ['a', 'b']}, {}, ] self.assertEqual(self.round_trip('JSON', items), items) def test_nullable_json(self): items = [None, {'x': 1}, None] self.assertEqual(self.round_trip('Nullable(JSON)', items), items) def test_map_of_json(self): items = [ {'k': {'a': 1}, 'j': {'b': 'x'}}, {}, {'empty': {}}, ] self.assertEqual(self.round_trip('Map(String, JSON)', items), items) def test_array_of_json(self): items = [ [{'a': 1}, {'b': 'x'}], [], ] self.assertEqual(self.round_trip('Array(JSON)', items), items) def test_array_of_nullable_json(self): items = [[{'a': 1}, None]] self.assertEqual( self.round_trip('Array(Nullable(JSON))', items), items) def test_tuple_with_json(self): items = [('s1', {'a': 1}), ('s2', {'b': 2})] self.assertEqual( self.round_trip('Tuple(String, JSON)', items), items) def test_map_of_array_of_json(self): items = [{'k': [{'a': 1}], 'l': [{'b': 2}, {'c': 3}]}] self.assertEqual( self.round_trip('Map(String, Array(JSON))', items), items) def test_write_state_prefix_requires_items(self): from clickhouse_driver.columns.service import get_column_by_spec column = get_column_by_spec( 'JSON', {'context': self.make_context()}, use_numpy=False) with self.assertRaises(NotImplementedError): column.write_state_prefix(BytesIO(), None) clickhouse-driver-0.2.11/tests/columns/test_null.py000066400000000000000000000003051522645447600224370ustar00rootroot00000000000000from tests.testcase import BaseTestCase class NullTestCase(BaseTestCase): def test_select_null(self): rv = self.client.execute('SELECT NULL') self.assertEqual(rv, [(None, )]) clickhouse-driver-0.2.11/tests/columns/test_nullable.py000066400000000000000000000025611522645447600232710ustar00rootroot00000000000000from tests.testcase import BaseTestCase from clickhouse_driver import errors ErrorCodes = errors.ErrorCodes class NullableTestCase(BaseTestCase): def test_simple(self): columns = 'a Nullable(Int32)' data = [(3, ), (None, ), (2, )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '3\n\\N\n2\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_nullable_inside_nullable(self): columns = 'a Nullable(Nullable(Int32))' with self.assertRaises(errors.ServerException) as e: self.client.execute( 'CREATE TABLE test ({}) ''ENGINE = Memory'.format(columns) ) self.assertEqual(e.exception.code, ErrorCodes.ILLEGAL_TYPE_OF_ARGUMENT) def test_nullable_array(self): columns = 'a Nullable(Array(Nullable(Array(Nullable(Int32)))))' with self.assertRaises(errors.ServerException) as e: self.client.execute( 'CREATE TABLE test ({}) ''ENGINE = Memory'.format(columns) ) self.assertEqual(e.exception.code, ErrorCodes.ILLEGAL_TYPE_OF_ARGUMENT) clickhouse-driver-0.2.11/tests/columns/test_simpleaggregatefunction.py000066400000000000000000000061751522645447600264060ustar00rootroot00000000000000from enum import IntEnum from tests.testcase import BaseTestCase class SimpleAggregateFunctionTestCase(BaseTestCase): required_server_version = (19, 8, 3) def test_simple(self): columns = 'a SimpleAggregateFunction(any, Int32)' data = [(3, ), (2, )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '3\n2\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_nullable(self): columns = 'a SimpleAggregateFunction(any, Nullable(Int32))' data = [(3, ), (None, ), (2, )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '3\n\\N\n2\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_simple_agg_function(self): class A(IntEnum): hello = -1 world = 2 columns = "a SimpleAggregateFunction(anyLast, " \ "Enum8('hello' = -1, 'world' = 2))" data = [(A.hello,), (A.world,), (-1,), (2,)] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, ( 'hello\n' 'world\n' 'hello\n' 'world\n' ) ) inserted = self.client.execute(query) self.assertEqual( inserted, [ ('hello',), ('world',), ('hello',), ('world',) ] ) def test_simple_agg_function_nullable(self): class A(IntEnum): hello = -1 world = 2 columns = "a SimpleAggregateFunction(anyLast, " \ "Nullable(Enum8('hello' = -1, 'world' = 2)))" data = [(A.hello,), (A.world,), (None,), (-1,), (2,)] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, ( 'hello\n' 'world\n' '\\N\n' 'hello\n' 'world\n' ) ) inserted = self.client.execute(query) self.assertEqual( inserted, [ ('hello',), ('world',), (None, ), ('hello',), ('world',) ] ) clickhouse-driver-0.2.11/tests/columns/test_sparse.py000066400000000000000000000134621522645447600227720ustar00rootroot00000000000000from datetime import date from io import BytesIO from ipaddress import IPv6Address from unittest import TestCase from tests.testcase import BaseTestCase from clickhouse_driver import errors from clickhouse_driver.columns.base import SparseSerialization from clickhouse_driver.varint import write_varint ErrorCodes = errors.ErrorCodes class SparseTestCase(BaseTestCase): required_server_version = (22, 1) create_table_template = ( 'CREATE TABLE test ({}) ' 'ENGINE = MergeTree ' 'ORDER BY tuple() ' 'SETTINGS ratio_of_defaults_for_sparse_serialization = 0.5' ) def test_int_all_defaults(self): columns = 'a Int32' data = [(0, ), (0, ), (0, )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '0\n0\n0\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) data = [(0,)] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '0\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_int_borders_cases(self): columns = 'a Int32' data = [(1, ), (0, ), (0, ), (1, ), (0, ), (0, ), (1, )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '1\n0\n0\n1\n0\n0\n1\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_int_default_last(self): columns = 'a Int32' data = [(1, ), (0, ), (0, )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '1\n0\n0\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_sparse_tuples(self): columns = 'a Int32, b Tuple(Int32, Tuple(Int32, Int32))' data = [ (1, (1, (1, 0))), (0, (0, (0, 0))), (0, (0, (0, 0))) ] with self.create_table(columns): self.client.execute( 'INSERT INTO test VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '1\t(1,(1,0))\n' '0\t(0,(0,0))\n' '0\t(0,(0,0))\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_sparse_ipv6(self): columns = 'a IPv6' data = [ (IPv6Address('::'), ), (IPv6Address('::'), ), (IPv6Address('2001:db8::1'), ), ] with self.create_table(columns): self.client.execute( 'INSERT INTO test VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '::\n' '::\n' '2001:db8::1\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_sparse_dates(self): columns = 'a Date32' data = [ (date(1970, 1, 1), ), (date(1970, 1, 1), ), ] with self.create_table(columns): self.client.execute( 'INSERT INTO test VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '1970-01-01\n' '1970-01-01\n' ) inserted = self.client.execute(query) self.assertEqual(inserted, data) class FakeColumn(object): null_value = 0 after_read_items = None class SparseSerializationTestCase(TestCase): # Sending sparse blocks is the server's choice; test directly. END_OF_GRANULE_FLAG = 1 << 62 def make_buf(self, group_sizes): buf = BytesIO() for size in group_sizes: write_varint(size, buf) buf.seek(0) buf.read_one = lambda: ord(buf.read(1)) return buf def test_read_and_apply_sparse(self): serialization = SparseSerialization(FakeColumn()) # Non-default items at positions 3 and 7 of [0,0,5,0,0,0,7,0]. buf = self.make_buf([2, 3, self.END_OF_GRANULE_FLAG | 1]) n_items = serialization.read_sparse(8, buf) self.assertEqual(n_items, 2) self.assertEqual(serialization.sparse_indexes, [3, 7]) self.assertEqual(serialization.items_total, 9) self.assertEqual( serialization.apply_sparse([5, 7]), [0, 0, 5, 0, 0, 0, 7, 0] ) def test_apply_sparse_with_after_read_items(self): column = FakeColumn() column.after_read_items = lambda items, nulls_map=None: \ tuple(x + 100 for x in items) serialization = SparseSerialization(column) buf = self.make_buf([0, self.END_OF_GRANULE_FLAG | 1]) n_items = serialization.read_sparse(3, buf) self.assertEqual(n_items, 1) self.assertEqual(serialization.apply_sparse([105]), [105, 100]) clickhouse-driver-0.2.11/tests/columns/test_string.py000066400000000000000000000142331522645447600230000ustar00rootroot00000000000000# coding=utf-8 from __future__ import unicode_literals from tests.testcase import BaseTestCase from clickhouse_driver import errors class StringTestCase(BaseTestCase): def test_unicode(self): data = [('Ñ�ндекÑ�', )] with self.create_table('a String'): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, 'Ñ�ндекÑ�\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_non_utf(self): data = [('Ñ�ндекÑ�'.encode('koi8-r'), )] with self.create_table('a String'): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query, encoding='koi8-r') self.assertEqual(inserted, 'Ñ�ндекÑ�\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_null_byte_in_the_middle(self): data = [('a\x00b', )] with self.create_table('a String'): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, 'a\\0b\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_nullable(self): with self.create_table('a Nullable(String)'): data = [(None, ), ('test', ), (None, ), ('nullable', )] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '\\N\ntest\n\\N\nnullable\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_buffer_reader(self): data = [('a' * 300, )] * 300 with self.create_table('a String'): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_compressed_client(self): with self.created_client(compression=True) as client: data = [('a' * 300, )] with self.create_table('a String'): client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = client.execute(query) self.assertEqual(inserted, data) def test_custom_encoding(self): settings = {'strings_encoding': 'cp1251'} data = [(('Ñ�ндекÑ�'), ), (('test'), )] with self.create_table('a String'): self.client.execute( 'INSERT INTO test (a) VALUES', data, settings=settings ) query = 'SELECT * FROM test' inserted = self.emit_cli(query, encoding='cp1251') self.assertEqual(inserted, 'Ñ�ндекÑ�\ntest\n') inserted = self.client.execute(query, settings=settings) self.assertEqual(inserted, data) self.assertIsInstance(inserted[0][0], str) self.assertIsInstance(inserted[1][0], str) def test_not_supported_types(self): datas = [ [(bytearray(b'asd'), )], [(123, )] ] with self.create_table('a String'): for data in datas: with self.assertRaises(errors.TypeMismatchError) as e: self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) self.assertIn('for column "a"', str(e.exception)) with self.assertRaises(AttributeError): self.client.execute( 'INSERT INTO test (a) VALUES', data ) class ByteStringTestCase(BaseTestCase): client_kwargs = {'settings': {'strings_as_bytes': True}} def test_not_decoded(self): data = [ (bytes('Ñ�ндекÑ�'.encode('cp1251')), ), (bytes('test'.encode('cp1251')), ), ] with self.create_table('a String'): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query, encoding='cp1251') self.assertEqual(inserted, 'Ñ�ндекÑ�\ntest\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) self.assertIsInstance(inserted[0][0], bytes) self.assertIsInstance(inserted[1][0], bytes) def test_nullable(self): with self.create_table('a Nullable(String)'): data = [(None, ), (b'test', ), (None, ), (b'nullable', )] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '\\N\ntest\n\\N\nnullable\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_not_supported_types(self): datas = [ [('asd', )], [(bytearray(b'asd'), )], [(123, )] ] with self.create_table('a String'): for data in datas: with self.assertRaises(errors.TypeMismatchError) as e: self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) self.assertIn('for column "a"', str(e.exception)) with self.assertRaises(ValueError) as e: self.client.execute( 'INSERT INTO test (a) VALUES', data ) self.assertIn('bytes object expected', str(e.exception)) clickhouse-driver-0.2.11/tests/columns/test_tuple.py000066400000000000000000000135771522645447600226350ustar00rootroot00000000000000from datetime import date from clickhouse_driver import errors from tests.testcase import BaseTestCase from tests.util import require_server_version class TupleTestCase(BaseTestCase): def entuple(self, lst): return tuple( self.entuple(x) if isinstance(x, list) else x for x in lst ) def test_simple(self): columns = 'a Tuple(Int32, String)' data = [((1, 'a'), ), ((2, 'b'), )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, "(1,'a')\n(2,'b')\n") inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_tuple_single_element(self): columns = 'a Tuple(Int32)' data = [((1, ), ), ((2, ), )] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, "(1)\n(2)\n") inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_nullable(self): data = [ ((1, 'a'),), ((2, None),), ((None, None),), ((None, 'd'),), ((5, 'e'),) ] with self.create_table('a Tuple(Nullable(Int32), Nullable(String))'): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "(1,'a')\n" "(2,NULL)\n(NULL,NULL)\n(NULL,'d')\n" "(5,'e')\n" ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_nested_tuple_with_common_types(self): columns = 'a Tuple(String, Tuple(Int32, String), String)' data = [ (('one', (1, 'a'), 'two'),), (('three', (2, 'b'), 'four'),) ] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "('one',(1,'a'),'two')\n" "('three',(2,'b'),'four')\n" ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_tuple_of_tuples(self): columns = ( "a Tuple(" "Tuple(Int32, String)," "Tuple(Enum8('hello' = 1, 'world' = 2), Date)" ")" ) data = [ (((1, 'a'), (1, date(2020, 3, 11))),), (((2, 'b'), (2, date(2020, 3, 12))),) ] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "((1,'a'),('hello','2020-03-11'))\n" "((2,'b'),('world','2020-03-12'))\n" ) inserted = self.client.execute(query) self.assertEqual( inserted, [ (((1, 'a'), ('hello', date(2020, 3, 11))), ), (((2, 'b'), ('world', date(2020, 3, 12))), ) ] ) def test_tuple_of_arrays(self): data = [(([1, 2, 3],),), (([4, 5, 6],),)] with self.create_table('a Tuple(Array(Int32))'): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "([1,2,3])\n([4,5,6])\n" ) inserted = self.client.execute(query) self.assertEqual(inserted, data) # Bug in Array of Tuple handing before 19.16.13: # DESCRIBE TABLE test # # | a.1 | Array(UInt8) | # | a.2 | Array(UInt8) | # | a.3 | Array(UInt8) | # https://github.com/ClickHouse/ClickHouse/pull/8866 @require_server_version(19, 16, 13) def test_array_of_tuples(self): data = [ ([(1, 2, 3), (4, 5, 6)],), ([(7, 8, 9)],), ] with self.create_table('a Array(Tuple(UInt8, UInt8, UInt8))'): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "[(1,2,3),(4,5,6)]\n" "[(7,8,9)]\n" ) inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_type_mismatch_error(self): columns = 'a Tuple(Int32)' data = [('test', )] with self.create_table(columns): with self.assertRaises(errors.TypeMismatchError): self.client.execute('INSERT INTO test (a) VALUES', data) def test_tuple_of_low_cardinality(self): data = [(('1', '2'), )] columns = 'a Tuple(LowCardinality(String), LowCardinality(String))' with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, "('1','2')\n" ) inserted = self.client.execute(query) self.assertEqual(inserted, data) clickhouse-driver-0.2.11/tests/columns/test_unknown.py000066400000000000000000000006031522645447600231650ustar00rootroot00000000000000 from unittest import TestCase from clickhouse_driver import errors from clickhouse_driver.columns.service import get_column_by_spec class UnknownColumnTestCase(TestCase): def test_get_unknown_column(self): with self.assertRaises(errors.UnknownTypeError) as e: get_column_by_spec('Unicorn', {'context': {}}) self.assertIn('Unicorn', str(e.exception)) clickhouse-driver-0.2.11/tests/columns/test_util.py000066400000000000000000000005451522645447600224500ustar00rootroot00000000000000from clickhouse_driver.columns.util import get_inner_spec from tests.testcase import BaseTestCase class UtilTestCase(BaseTestCase): def test_get_inner_spec(self): inner = 'a Tuple(Array(Int8), Array(Int64)), b Nullable(String)' self.assertEqual( get_inner_spec('Nested', 'Nested({}) dummy '.format(inner)), inner ) clickhouse-driver-0.2.11/tests/columns/test_uuid.py000066400000000000000000000054731522645447600224460ustar00rootroot00000000000000from uuid import UUID from tests.testcase import BaseTestCase from clickhouse_driver import errors class UUIDTestCase(BaseTestCase): def test_simple(self): with self.create_table('a UUID'): data = [ (UUID('c0fcbba9-0752-44ed-a5d6-4dfb4342b89d'), ), ('2efcead4-ff55-4db5-bdb4-6b36a308d8e0', ) ] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, ( 'c0fcbba9-0752-44ed-a5d6-4dfb4342b89d\n' '2efcead4-ff55-4db5-bdb4-6b36a308d8e0\n' )) inserted = self.client.execute(query) self.assertEqual(inserted, [ (UUID('c0fcbba9-0752-44ed-a5d6-4dfb4342b89d'), ), (UUID('2efcead4-ff55-4db5-bdb4-6b36a308d8e0'), ) ]) def test_type_mismatch(self): data = [(62457709573696417404743346296141175008, )] with self.create_table('a UUID'): with self.assertRaises(errors.TypeMismatchError): self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) with self.assertRaises(AttributeError): self.client.execute( 'INSERT INTO test (a) VALUES', data ) def test_bad_uuid(self): data = [('a', )] with self.create_table('a UUID'): with self.assertRaises(errors.CannotParseUuidError): self.client.execute( 'INSERT INTO test (a) VALUES', data ) def test_nullable(self): with self.create_table('a Nullable(UUID)'): data = [(UUID('2efcead4-ff55-4db5-bdb4-6b36a308d8e0'), ), (None, )] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '2efcead4-ff55-4db5-bdb4-6b36a308d8e0\n\\N\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test_input_format_null_as_default(self): with self.create_table('a UUID'): self.client.execute( 'INSERT INTO test (a) VALUES', [(None, )], settings={'input_format_null_as_default': True} ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '00000000-0000-0000-0000-000000000000\n') inserted = self.client.execute(query) self.assertEqual(inserted, [ (UUID(int=0), ) ]) clickhouse-driver-0.2.11/tests/conftest.py000066400000000000000000000002701522645447600205740ustar00rootroot00000000000000import pytest @pytest.fixture(autouse=True) def assert_empty_output(capfd): yield captured = capfd.readouterr() assert captured.out == '' assert captured.err == '' clickhouse-driver-0.2.11/tests/docker-compose.yml000066400000000000000000000013441522645447600220350ustar00rootroot00000000000000version: '3' services: clickhouse-server: image: "$ORG/clickhouse-server:$CLICKHOUSE_VERSION" container_name: test-clickhouse-server environment: - TZ=Europe/Moscow ports: - "127.0.0.1:9000:9000" - "127.0.0.1:9440:9440" volumes: - "./clickhouse_server_config/$TOP_LEVEL.xml:/etc/clickhouse-server/config.d/test_config.xml" - "./clickhouse_server_config/${TOP_LEVEL}_users.xml:/etc/clickhouse-server/users.d/test_users.xml" - "./clickhouse_server_config/certs:/etc/clickhouse-server/certs" clickhouse-client: image: "$ORG/clickhouse-server:$CLICKHOUSE_VERSION" container_name: test-clickhouse-client entrypoint: /bin/sh command: [-c, 'while :; do sleep 1; done'] clickhouse-driver-0.2.11/tests/log.py000066400000000000000000000012401522645447600175260ustar00rootroot00000000000000from logging.config import dictConfig def configure(level): dictConfig({ 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'standard': { 'format': '%(asctime)s %(levelname)-8s %(name)s: %(message)s' }, }, 'handlers': { 'default': { 'level': level, 'formatter': 'standard', 'class': 'logging.StreamHandler', }, }, 'loggers': { '': { 'handlers': ['default'], 'level': level, 'propagate': True }, } }) clickhouse-driver-0.2.11/tests/numpy/000077500000000000000000000000001522645447600175465ustar00rootroot00000000000000clickhouse-driver-0.2.11/tests/numpy/__init__.py000066400000000000000000000000001522645447600216450ustar00rootroot00000000000000clickhouse-driver-0.2.11/tests/numpy/columns/000077500000000000000000000000001522645447600212265ustar00rootroot00000000000000clickhouse-driver-0.2.11/tests/numpy/columns/__init__.py000066400000000000000000000000001522645447600233250ustar00rootroot00000000000000clickhouse-driver-0.2.11/tests/numpy/columns/test_bool.py000066400000000000000000000045101522645447600235720ustar00rootroot00000000000000try: import numpy as np except ImportError: np = None from tests.numpy.testcase import NumpyBaseTestCase class BoolTestCase(NumpyBaseTestCase): n = 10 # https://clickhouse.com/docs/en/whats-new/changelog/2021 required_server_version = (21, 12, 0) def check_result(self, rv, col_type): data = (np.array(range(self.n)) % 2).astype(bool) self.assertArraysEqual(rv[0], data) self.assertEqual(rv[0].dtype, col_type) def get_query(self, ch_type): with self.create_table('a {}'.format(ch_type)): data = [(np.array(range(self.n)) % 2).astype(bool)] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '\n'.join(str(x).lower() for x in data[0]) + '\n' ) return self.client.execute(query, columnar=True) def test_bool(self): rv = self.get_query('Bool') self.check_result(rv, np.bool_) def test_insert_nan_into_non_nullable(self): with self.create_table('a Bool'): data = [ np.array([True, np.nan], dtype=object) ] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, 'true\nfalse\n' ) inserted = self.client.execute(query, columnar=True) self.assertArraysEqual(inserted[0], np.array([True, 0])) self.assertEqual(inserted[0].dtype, np.bool_) def test_nullable(self): with self.create_table('a Nullable(Bool)'): data = [np.array([False, None, True, None, False])] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, 'false\n\\N\ntrue\n\\N\nfalse\n') inserted = self.client.execute(query, columnar=True) self.assertArraysEqual(inserted[0], data[0]) self.assertEqual(inserted[0].dtype, object) clickhouse-driver-0.2.11/tests/numpy/columns/test_datetime.py000066400000000000000000000630231522645447600244370ustar00rootroot00000000000000from datetime import datetime, date from unittest.mock import patch try: import numpy as np except ImportError: np = None try: import pandas as pd except ImportError: pd = None from pytz import timezone, utc, UnknownTimeZoneError import tzlocal from tests.numpy.testcase import NumpyBaseTestCase from tests.util import require_server_version, patch_env_tz class BaseDateTimeTestCase(NumpyBaseTestCase): def make_numpy_d64ns(self, items): return np.array(items, dtype='datetime64[ns]') class DateTimeTestCase(BaseDateTimeTestCase): def test_datetime_type(self): query = 'SELECT now()' rv = self.client.execute(query, columnar=True) self.assertIsInstance(rv[0][0], np.datetime64) @require_server_version(20, 1, 2) def test_datetime64_type(self): query = 'SELECT now64()' rv = self.client.execute(query, columnar=True) self.assertIsInstance(rv[0][0], np.datetime64) def test_simple(self): with self.create_table('a Date, b DateTime'): data = [ np.array(['2012-10-25'], dtype='datetime64[D]'), np.array(['2012-10-25T14:07:19'], dtype='datetime64[ns]') ] self.client.execute( 'INSERT INTO test (a, b) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '2012-10-25\t2012-10-25 14:07:19\n') inserted = self.client.execute(query, columnar=True) self.assertArraysEqual( inserted[0], np.array(['2012-10-25'], dtype='datetime64[D]') ) self.assertArraysEqual( inserted[1], self.make_numpy_d64ns(['2012-10-25T14:07:19']) ) def test_nullable_date(self): with self.create_table('a Nullable(Date)'): data = [ np.array([None, date(2012, 10, 25), None, date(2017, 6, 23)], dtype=object) ] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '\\N\n2012-10-25\n\\N\n2017-06-23\n' ) inserted = self.client.execute(query, columnar=True) self.assertArraysEqual(inserted[0], data[0]) self.assertEqual(inserted[0].dtype, object) def test_nullable_datetime(self): with self.create_table('a Nullable(DateTime)'): data = [ np.array([ None, datetime(2012, 10, 25, 14, 7, 19), None, datetime(2017, 6, 23, 19, 10, 15) ], dtype=object) ] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '\\N\n2012-10-25 14:07:19\n\\N\n2017-06-23 19:10:15\n' ) inserted = self.client.execute(query, columnar=True) self.assertArraysEqual(inserted[0], data[0]) self.assertEqual(inserted[0].dtype, object) def test_handle_errors_from_tzlocal(self): with patch('tzlocal.get_localzone') as mocked: mocked.side_effect = UnknownTimeZoneError() self.client.execute('SELECT now()') if hasattr(tzlocal, 'get_localzone_name'): with patch('tzlocal.get_localzone_name') as mocked: mocked.side_effect = None self.client.execute('SELECT now()') @require_server_version(20, 1, 2) def test_datetime64_frac_trunc(self): with self.create_table('a DateTime64'): data = [self.make_numpy_d64ns(['2012-10-25T14:07:19.125600'])] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '2012-10-25 14:07:19.125\n') inserted = self.client.execute(query, columnar=True) self.assertArraysEqual( inserted[0], self.make_numpy_d64ns(['2012-10-25T14:07:19.125']) ) @require_server_version(20, 1, 2) def test_datetime64_explicit_frac(self): with self.create_table('a DateTime64(1)'): data = [self.make_numpy_d64ns(['2012-10-25T14:07:19.125600'])] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '2012-10-25 14:07:19.1\n') inserted = self.client.execute(query, columnar=True) self.assertArraysEqual( inserted[0], self.make_numpy_d64ns(['2012-10-25T14:07:19.1']) ) @require_server_version(20, 1, 2) def test_datetime64_nanosecond_precision(self): with self.create_table('a DateTime64(8)'): data = [self.make_numpy_d64ns([ '2012-10-25T14:07:19.12345678', '2012-10-25T14:07:19.99999999', ])] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '2012-10-25 14:07:19.12345678\n' '2012-10-25 14:07:19.99999999\n' ) inserted = self.client.execute(query, columnar=True) self.assertArraysEqual(inserted[0], data[0]) @require_server_version(20, 1, 2) def test_datetime64_max_precision(self): with self.create_table('a DateTime64(9)'): data = [self.make_numpy_d64ns([ '2012-10-25T14:07:19.123456789', '2012-10-25T14:07:19.999999999', ])] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '2012-10-25 14:07:19.123456789\n' '2012-10-25 14:07:19.999999999\n' ) inserted = self.client.execute(query, columnar=True) self.assertArraysEqual(inserted[0], data[0]) def test_insert_integers_datetime(self): with self.create_table('a DateTime'): self.client.execute( 'INSERT INTO test (a) VALUES', [np.array([1530211034], dtype=np.uint32)], columnar=True ) query = 'SELECT toUInt32(a), a FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '1530211034\t2018-06-28 21:37:14\n') @require_server_version(20, 1, 2) def test_insert_integers_datetime64(self): with self.create_table('a DateTime64'): self.client.execute( 'INSERT INTO test (a) VALUES', [np.array([1530211034123], dtype=np.uint64)], columnar=True ) query = 'SELECT toUInt32(a), a FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '1530211034\t2018-06-28 21:37:14.123\n') def test_insert_integer_bounds(self): with self.create_table('a DateTime'): self.client.execute( 'INSERT INTO test (a) VALUES', [np.array([0, 1, 1500000000, 2**32-1], dtype=np.uint32)], columnar=True ) query = 'SELECT toUInt32(a) FROM test ORDER BY a' inserted = self.emit_cli(query) self.assertEqual(inserted, '0\n1\n1500000000\n4294967295\n') @require_server_version(20, 1, 2) def test_negative_timestamps(self): with self.create_table("a DateTime64(3, 'UTC')"): times = np.array(['1900-01-01 00:00'], dtype='datetime64[ns]') self.client.execute( 'INSERT INTO test(a) VALUES', [times], columnar=True, ) inserted = self.client.execute('SELECT * FROM test', columnar=True) self.assertArraysEqual(inserted[0], times) class DateTimeTimezonesTestCase(BaseDateTimeTestCase): dt_type = 'DateTime' def make_tz_numpy_array(self, dt, tz_name): dtype = 'datetime64[ns]' return pd.to_datetime(np.array([dt] * 2, dtype=dtype)) \ .tz_localize(tz_name).to_numpy(dtype) # Asia/Kamchatka = UTC+12 # Asia/Novosibirsk = UTC+7 # Europe/Moscow = UTC+3 # 1500010800 second since epoch in Europe/Moscow. # 1500000000 second since epoch in UTC. dt = datetime(2017, 7, 14, 5, 40) dt_str = dt.isoformat() # properties for lazy evaluation for dealing with AttributeError when no # numpy/pandas installed @property def dt_arr(self): return np.array([self.dt_str], dtype='datetime64[s]') @property def dt_tz(self): return pd.to_datetime(self.dt_arr).tz_localize('Asia/Kamchatka') col_tz_name = 'Asia/Novosibirsk' col_tz = timezone(col_tz_name) # INSERTs and SELECTs must be the same as clickhouse-client's # if column has no timezone. def table_columns(self, with_tz=False): if not with_tz: return 'a {}'.format(self.dt_type) return "a {}('{}')".format(self.dt_type, self.col_tz_name) def test_use_server_timezone(self): # Insert datetime with timezone UTC # into column with no timezone # using server's timezone (Europe/Moscow) # Determine server timezone and calculate expected timestamp. server_tz_name = self.client.execute('SELECT timezone()')[0][0] offset = timezone(server_tz_name).utcoffset(self.dt).total_seconds() timestamp = 1500010800 - int(offset) with patch_env_tz('Asia/Novosibirsk'): with self.create_table(self.table_columns()): self.client.execute( 'INSERT INTO test (a) VALUES', [self.dt_arr], columnar=True ) self.emit_cli( "INSERT INTO test (a) VALUES ('2017-07-14 05:40:00')" ) query = 'SELECT toInt32(a) FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '{ts}\n{ts}\n'.format(ts=timestamp)) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '2017-07-14 05:40:00\n2017-07-14 05:40:00\n' ) inserted = self.client.execute(query, columnar=True) self.assertArraysEqual( inserted[0], self.make_numpy_d64ns([self.dt_str] * 2) ) def test_use_client_timezone(self): # Insert datetime with timezone UTC # into column with no timezone # using client's timezone Asia/Novosibirsk settings = {'use_client_time_zone': True} with patch_env_tz('Asia/Novosibirsk'): with self.create_table(self.table_columns()): self.client.execute( 'INSERT INTO test (a) VALUES', [self.dt_arr], settings=settings, columnar=True ) self.emit_cli( "INSERT INTO test (a) VALUES ('2017-07-14 05:40:00')", use_client_time_zone=1 ) query = 'SELECT toInt32(a) FROM test' inserted = self.emit_cli(query, use_client_time_zone=1) # 1499985600 = 1500000000 - 4 * 3600 self.assertEqual(inserted, '1499985600\n1499985600\n') query = 'SELECT * FROM test' inserted = self.emit_cli(query, use_client_time_zone=1) self.assertEqual( inserted, '2017-07-14 05:40:00\n2017-07-14 05:40:00\n' ) inserted = self.client.execute(query, columnar=True, settings=settings) self.assertArraysEqual( inserted[0], self.make_numpy_d64ns([self.dt_str] * 2) ) @require_server_version(1, 1, 54337) def test_datetime_with_timezone_use_server_timezone(self): # Insert datetime with timezone Asia/Kamchatka # into column with no timezone # using server's timezone (Europe/Moscow) server_tz_name = self.client.execute('SELECT timezone()')[0][0] offset = timezone(server_tz_name).utcoffset(self.dt) with patch_env_tz('Asia/Novosibirsk'): with self.create_table(self.table_columns()): self.client.execute( 'INSERT INTO test (a) VALUES', [self.dt_tz], columnar=True ) self.emit_cli( "INSERT INTO test (a) VALUES " "(toDateTime('2017-07-14 05:40:00', 'Asia/Kamchatka'))", ) query = 'SELECT toInt32(a) FROM test' inserted = self.emit_cli(query) # 1499967600 = 1500000000 - 12 * 3600 self.assertEqual(inserted, '1499967600\n1499967600\n') query = 'SELECT * FROM test' inserted = self.emit_cli(query) dt = (self.dt_tz.to_pydatetime()[0].astimezone(utc) + offset) \ .replace(tzinfo=None) self.assertEqual(inserted, '{dt}\n{dt}\n'.format(dt=dt)) inserted = self.client.execute(query, columnar=True) self.assertArraysEqual( inserted[0], self.make_numpy_d64ns([dt.isoformat()] * 2) ) @require_server_version(1, 1, 54337) def test_datetime_with_timezone_use_client_timezone(self): # Insert datetime with timezone Asia/Kamchatka # into column with no timezone # using client's timezone Asia/Novosibirsk settings = {'use_client_time_zone': True} with patch_env_tz('Asia/Novosibirsk'): with self.create_table(self.table_columns()): self.client.execute( 'INSERT INTO test (a) VALUES', [self.dt_tz], settings=settings, columnar=True ) self.emit_cli( "INSERT INTO test (a) VALUES " "(toDateTime('2017-07-14 05:40:00', 'Asia/Kamchatka'))", use_client_time_zone=1 ) query = 'SELECT toInt32(a) FROM test' inserted = self.emit_cli(query, use_client_time_zone=1) # 1499967600 = 1500000000 - 12 * 3600 self.assertEqual(inserted, '1499967600\n1499967600\n') query = 'SELECT * FROM test' inserted = self.emit_cli(query, use_client_time_zone=1) # 2017-07-14 00:40:00 = 2017-07-14 05:40:00 - 05:00:00 # (Kamchatka - Novosibirsk) self.assertEqual( inserted, '2017-07-14 00:40:00\n2017-07-14 00:40:00\n' ) inserted = self.client.execute(query, columnar=True, settings=settings) dt = datetime(2017, 7, 14, 0, 40) self.assertArraysEqual( inserted[0], self.make_numpy_d64ns([dt.isoformat()] * 2) ) @require_server_version(1, 1, 54337) def test_column_use_server_timezone(self): # Insert datetime with no timezone # into column with timezone Asia/Novosibirsk # using server's timezone (Europe/Moscow) with patch_env_tz('Europe/Moscow'): with self.create_table(self.table_columns(with_tz=True)): self.client.execute( 'INSERT INTO test (a) VALUES', [self.dt_arr], columnar=True ) self.emit_cli( "INSERT INTO test (a) VALUES ('2017-07-14 05:40:00')" ) query = 'SELECT toInt32(a) FROM test' inserted = self.emit_cli(query) # 1499985600 = 1500000000 - 4 * 3600 self.assertEqual(inserted, '1499985600\n1499985600\n') query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '2017-07-14 05:40:00\n2017-07-14 05:40:00\n' ) inserted = self.client.execute(query, columnar=True) self.assertArraysEqual( inserted[0], self.make_tz_numpy_array(self.dt, self.col_tz_name) ) @require_server_version(1, 1, 54337) def test_column_use_client_timezone(self): # Insert datetime with no timezone # into column with timezone Asia/Novosibirsk # using client's timezone Europe/Moscow settings = {'use_client_time_zone': True} with patch_env_tz('Europe/Moscow'): with self.create_table(self.table_columns(with_tz=True)): self.client.execute( 'INSERT INTO test (a) VALUES', [self.dt_arr], settings=settings, columnar=True ) self.emit_cli( "INSERT INTO test (a) VALUES ('2017-07-14 05:40:00')", use_client_time_zone=1 ) query = 'SELECT toInt32(a) FROM test' inserted = self.emit_cli(query, use_client_time_zone=1) # 1499985600 = 1500000000 - 4 * 3600 self.assertEqual(inserted, '1499985600\n1499985600\n') query = 'SELECT * FROM test' inserted = self.emit_cli(query, use_client_time_zone=1) self.assertEqual( inserted, '2017-07-14 05:40:00\n2017-07-14 05:40:00\n' ) inserted = self.client.execute(query, columnar=True, settings=settings) self.assertArraysEqual( inserted[0], self.make_tz_numpy_array(self.dt, self.col_tz_name) ) @require_server_version(1, 1, 54337) def test_datetime_with_timezone_column_use_server_timezone(self): # Insert datetime with timezone Asia/Kamchatka # into column with timezone Asia/Novosibirsk # using server's timezone (Europe/Moscow) with patch_env_tz('Europe/Moscow'): with self.create_table(self.table_columns(with_tz=True)): self.client.execute( 'INSERT INTO test (a) VALUES', [self.dt_tz], columnar=True ) self.emit_cli( "INSERT INTO test (a) VALUES " "(toDateTime('2017-07-14 05:40:00', 'Asia/Kamchatka'))", ) query = 'SELECT toInt32(a) FROM test' inserted = self.emit_cli(query) # 1499967600 = 1500000000 - 12 * 3600 self.assertEqual(inserted, '1499967600\n1499967600\n') query = 'SELECT * FROM test' inserted = self.emit_cli(query) # 2017-07-14 00:40:00 = 2017-07-14 05:40:00 - 05:00:00 # (Kamchatka - Novosibirsk) self.assertEqual( inserted, '2017-07-14 00:40:00\n2017-07-14 00:40:00\n' ) inserted = self.client.execute(query, columnar=True) dt = datetime(2017, 7, 14, 0, 40) self.assertArraysEqual( inserted[0], self.make_tz_numpy_array(dt, self.col_tz_name) ) @require_server_version(1, 1, 54337) def test_datetime_with_timezone_column_use_client_timezone(self): # Insert datetime with timezone Asia/Kamchatka # into column with timezone Asia/Novosibirsk # using client's timezone (Europe/Moscow) settings = {'use_client_time_zone': True} with patch_env_tz('Europe/Moscow'): with self.create_table(self.table_columns(with_tz=True)): self.client.execute( 'INSERT INTO test (a) VALUES', [self.dt_tz], settings=settings, columnar=True ) self.emit_cli( "INSERT INTO test (a) VALUES " "(toDateTime('2017-07-14 05:40:00', 'Asia/Kamchatka'))", use_client_time_zone=1 ) query = 'SELECT toInt32(a) FROM test' inserted = self.emit_cli(query, use_client_time_zone=1) # 1499967600 = 1500000000 - 12 * 3600 self.assertEqual(inserted, '1499967600\n1499967600\n') query = 'SELECT * FROM test' inserted = self.emit_cli(query, use_client_time_zone=1) # 2017-07-14 00:40:00 = 2017-07-14 05:40:00 - 05:00:00 # (Kamchatka - Novosibirsk) self.assertEqual( inserted, '2017-07-14 00:40:00\n2017-07-14 00:40:00\n' ) inserted = self.client.execute(query, columnar=True, settings=settings) dt = datetime(2017, 7, 14, 0, 40) self.assertArraysEqual( inserted[0], self.make_tz_numpy_array(dt, self.col_tz_name) ) @require_server_version(1, 1, 54337) def test_read_tz_aware_column(self): # read data from tz aware column Asia/Novosibirsk # offset_naive is False -> tz convert not needed with self.create_table(self.table_columns(with_tz=True)): with patch.object( pd, 'to_datetime', wraps=pd.to_datetime ) as to_datetime_spy: self.client.execute( 'INSERT INTO test (a) VALUES', [self.dt_arr], columnar=True ) self.emit_cli( "INSERT INTO test (a) VALUES ('2017-07-14 05:40:00')", ) to_datetime_calls_before_read = to_datetime_spy.call_count query = 'SELECT * FROM test' inserted = self.client.execute(query, columnar=True) self.assertEqual( to_datetime_calls_before_read, to_datetime_spy.call_count ) self.assertArraysEqual( inserted[0], self.make_tz_numpy_array(self.dt, self.col_tz_name) ) @require_server_version(1, 1, 54337) def test_read_tz_naive_column_with_client_timezone(self): # read data from column without timezone # client timezone = Asia/Novosibirsk # offset_naive is True and timezone is not UTC -> tz convert needed settings = {'use_client_time_zone': True} with patch_env_tz('Asia/Novosibirsk'): with self.create_table(self.table_columns()): with patch.object( pd, 'to_datetime', wraps=pd.to_datetime ) as to_datetime_spy: self.client.execute( 'INSERT INTO test (a) VALUES', [self.dt_arr], settings=settings, columnar=True ) self.emit_cli( "INSERT INTO test (a) VALUES ('2017-07-14 05:40:00')", use_client_time_zone=1 ) to_datetime_calls_before_read = to_datetime_spy.call_count query = 'SELECT * FROM test' inserted = self.client.execute( query, settings=settings, columnar=True ) self.assertEqual( to_datetime_calls_before_read + 2, to_datetime_spy.call_count ) self.assertArraysEqual( inserted[0], self.make_numpy_d64ns([self.dt_str] * 2) ) @require_server_version(1, 1, 54337) def test_do_not_localize_already_localized(self): # Insert datetime with timezone Asia/Kamchatka # into column with no timezone # using server's timezone (Europe/Moscow) with patch_env_tz('Asia/Novosibirsk'): with self.create_table(self.table_columns()): self.client.execute( 'INSERT INTO test (a) VALUES', [np.array([pd.Timestamp('2017-07-14 05:40:00+1200')])], columnar=True ) self.emit_cli( "INSERT INTO test (a) VALUES " "(toDateTime('2017-07-14 05:40:00', 'Asia/Kamchatka'))", ) query = 'SELECT toInt32(a) FROM test' inserted = self.emit_cli(query) # 1499967600 = 1500000000 - 12 * 3600 self.assertEqual(inserted, '1499967600\n1499967600\n') class DateTime64TimezonesTestCase(DateTimeTimezonesTestCase): dt_type = 'DateTime64' required_server_version = (20, 1, 2) def table_columns(self, with_tz=False): if not with_tz: return 'a {}(0)'.format(self.dt_type) return "a {}(0, '{}')".format(self.dt_type, self.col_tz_name) clickhouse-driver-0.2.11/tests/numpy/columns/test_float.py000066400000000000000000000056331522645447600237530ustar00rootroot00000000000000from parameterized import parameterized try: import numpy as np except ImportError: np = None from tests.numpy.testcase import NumpyBaseTestCase class FloatTestCase(NumpyBaseTestCase): n = 10 def check_result(self, rv, col_type): self.assertArraysEqual(rv[0], np.array(range(self.n))) self.assertEqual(rv[0].dtype, col_type) def get_query(self, ch_type): with self.create_table('a {}'.format(ch_type)): data = [np.array(range(self.n))] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '\n'.join(str(x) for x in data[0]) + '\n' ) return self.client.execute(query, columnar=True) def test_float32(self): rv = self.get_query('Float32') self.check_result(rv, np.float32) def test_float64(self): rv = self.get_query('Float64') self.check_result(rv, np.float64) def test_fractional_round_trip(self): with self.create_table('a Float32'): data = [np.array([0.5, 1.5], dtype=np.float32)] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '0.5\n1.5\n') inserted = self.client.execute(query, columnar=True) self.assertArraysEqual(inserted[0], data[0]) @parameterized.expand(['Float32', 'Float64']) def test_nullable(self, float_type): with self.create_table('a Nullable({})'.format(float_type)): data = [np.array([np.nan, 0.5, None, 1.5], dtype=object)] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, 'nan\n0.5\n\\N\n1.5\n') inserted = self.client.execute(query, columnar=True) self.assertArraysEqual( inserted[0].astype(str), data[0].astype(str) ) self.assertEqual(inserted[0].dtype, object) def test_nan(self): with self.create_table('a Float32'): data = [np.array([float('nan'), 0.5], dtype=np.float32)] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, 'nan\n0.5\n') inserted = self.client.execute(query, columnar=True) self.assertArraysEqual( inserted[0].astype(str), data[0].astype(str) ) self.assertEqual(inserted[0].dtype, np.float32) clickhouse-driver-0.2.11/tests/numpy/columns/test_int.py000066400000000000000000000055421522645447600234370ustar00rootroot00000000000000try: import numpy as np except ImportError: np = None from tests.numpy.testcase import NumpyBaseTestCase class IntTestCase(NumpyBaseTestCase): n = 10 def check_result(self, rv, col_type): self.assertArraysEqual(rv[0], np.array(range(self.n))) self.assertEqual(rv[0].dtype, col_type) def get_query(self, ch_type): with self.create_table('a {}'.format(ch_type)): data = [np.array(range(self.n))] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '\n'.join(str(x) for x in data[0]) + '\n' ) return self.client.execute(query, columnar=True) def test_int8(self): rv = self.get_query('Int8') self.check_result(rv, np.int8) def test_int16(self): rv = self.get_query('Int16') self.check_result(rv, np.int16) def test_int32(self): rv = self.get_query('Int32') self.check_result(rv, np.int32) def test_int64(self): rv = self.get_query('Int64') self.check_result(rv, np.int64) def test_uint8(self): rv = self.get_query('UInt8') self.check_result(rv, np.uint8) def test_uint16(self): rv = self.get_query('UInt16') self.check_result(rv, np.uint16) def test_uint32(self): rv = self.get_query('UInt32') self.check_result(rv, np.uint32) def test_uint64(self): rv = self.get_query('UInt64') self.check_result(rv, np.uint64) def test_insert_nan_into_non_nullable(self): with self.create_table('a Int32'): data = [ np.array([123, np.nan], dtype=object) ] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '123\n0\n' ) inserted = self.client.execute(query, columnar=True) self.assertArraysEqual(inserted[0], np.array([123, 0])) self.assertEqual(inserted[0].dtype, np.int32) def test_nullable(self): with self.create_table('a Nullable(Int32)'): data = [np.array([2, None, 4, None, 8])] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '2\n\\N\n4\n\\N\n8\n') inserted = self.client.execute(query, columnar=True) self.assertArraysEqual(inserted[0], data[0]) self.assertEqual(inserted[0].dtype, object) clickhouse-driver-0.2.11/tests/numpy/columns/test_low_cardinality.py000066400000000000000000000176451522645447600260400ustar00rootroot00000000000000try: import numpy as np except ImportError: np = None try: import pandas as pd except ImportError: pd = None from tests.numpy.testcase import NumpyBaseTestCase # from decimal import Decimal class LowCardinalityTestCase(NumpyBaseTestCase): required_server_version = (19, 3, 3) stable_support_version = (19, 9, 2) def cli_client_kwargs(self): if self.server_version >= self.stable_support_version: return {'allow_suspicious_low_cardinality_types': 1} def check_result(self, inserted, data): self.assertArraysEqual(inserted[0], data[0]) self.assertIsInstance(inserted[0], pd.Categorical) def test_uint8(self): with self.create_table('a LowCardinality(UInt8)'): data = [np.array(range(255))] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '\n'.join(str(x) for x in data[0]) + '\n' ) inserted = self.client.execute(query, columnar=True) self.check_result(inserted, data) def test_int8(self): with self.create_table('a LowCardinality(Int8)'): data = [np.array([x - 127 for x in range(255)])] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '\n'.join(str(x) for x in data[0]) + '\n' ) inserted = self.client.execute(query, columnar=True) self.check_result(inserted, data) def test_nullable_int8(self): with self.create_table('a LowCardinality(Nullable(Int8))'): data = [np.array([None, -1, 0, 1, None], dtype=object)] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '\\N\n-1\n0\n1\n\\N\n') inserted = self.client.execute(query, columnar=True) # pandas 3.x: Categorical.astype(str) preserves missing as NaN, and # NaN != NaN. Substitute a sentinel so equality holds. self.assertArraysEqual( pd.Series(inserted[0]).astype(object).fillna('\\N').to_numpy(), pd.Series(pd.Categorical(data[0])) .astype(object).fillna('\\N').to_numpy(), ) self.assertIsInstance(inserted[0], pd.Categorical) def test_date(self): with self.create_table('a LowCardinality(Date)'): data = [np.array(list(range(300)), dtype='datetime64[D]')] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.client.execute(query, columnar=True) self.check_result(inserted, data) def test_float(self): with self.create_table('a LowCardinality(Float)'): data = [np.array([float(x) for x in range(300)])] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.client.execute(query, columnar=True) self.check_result(inserted, data) # def test_decimal(self): # with self.create_table('a LowCardinality(Float)'): # data = [(Decimal(x),) for x in range(300)] # self.client.execute('INSERT INTO test (a) VALUES', data[0]) # # query = 'SELECT * FROM test' # inserted = self.client.execute(query) # self.assertEqual(inserted, data[0]) # # def test_array(self): # with self.create_table('a Array(LowCardinality(Int16))'): # data = [([100, 500], )] # self.client.execute('INSERT INTO test (a) VALUES', data[0]) # # query = 'SELECT * FROM test' # inserted = self.emit_cli(query) # self.assertEqual(inserted, '[100,500]\n') # # inserted = self.client.execute(query) # self.assertEqual(inserted, data[0]) # # def test_empty_array(self): # with self.create_table('a Array(LowCardinality(Int16))'): # data = [([], )] # self.client.execute('INSERT INTO test (a) VALUES', data[0]) # # query = 'SELECT * FROM test' # inserted = self.emit_cli(query) # self.assertEqual(inserted, '[]\n') # # inserted = self.client.execute(query) # self.assertEqual(inserted, data[0]) # def test_string(self): with self.create_table('a LowCardinality(String)'): data = [ np.array(['test', 'low', 'cardinality', 'test', 'test', '']) ] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, 'test\nlow\ncardinality\ntest\ntest\n\n' ) inserted = self.client.execute(query, columnar=True) self.check_result(inserted, data) def test_insert_nan_string_into_non_nullable(self): with self.create_table('a LowCardinality(String)'): data = [ np.array(['test', None], dtype=object) ] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, 'test\n\n' ) inserted = self.client.execute(query, columnar=True) self.check_result(inserted, [np.array(['test', ''])]) def test_fixed_string(self): with self.create_table('a LowCardinality(FixedString(12))'): data = [ np.array(['test', 'low', 'cardinality', 'test', 'test', '']) ] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, 'test\\0\\0\\0\\0\\0\\0\\0\\0\n' 'low\\0\\0\\0\\0\\0\\0\\0\\0\\0\n' 'cardinality\\0\n' 'test\\0\\0\\0\\0\\0\\0\\0\\0\n' 'test\\0\\0\\0\\0\\0\\0\\0\\0\n' '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\n' ) inserted = self.client.execute(query, columnar=True) self.check_result(inserted, data) def test_nullable_string(self): with self.create_table('a LowCardinality(Nullable(String))'): data = [ np.array(['test', '', None], dtype=object) ] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, 'test\n\n\\N\n' ) inserted = self.client.execute(query, columnar=True) # pandas 3.x: Categorical.astype(str) preserves missing as NaN, and # NaN != NaN. Substitute a sentinel so equality holds. self.assertArraysEqual( pd.Series(inserted[0]).astype(object).fillna('\\N').to_numpy(), pd.Series(pd.Categorical(data[0])) .astype(object).fillna('\\N').to_numpy(), ) self.assertIsInstance(inserted[0], pd.Categorical) clickhouse-driver-0.2.11/tests/numpy/columns/test_nullable.py000066400000000000000000000035121522645447600244360ustar00rootroot00000000000000try: import numpy as np except ImportError: np = None try: import pandas as pd except ImportError: pd = None from tests.numpy.testcase import NumpyBaseTestCase from clickhouse_driver import errors ErrorCodes = errors.ErrorCodes class NullableTestCase(NumpyBaseTestCase): def test_simple(self): columns = 'a Nullable(Int32)' data = [np.array([3, None, 2], dtype=object)] with self.create_table(columns): self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '3\n\\N\n2\n' ) inserted = self.client.execute(query, columnar=True) self.assertArraysEqual(inserted[0], data[0]) self.assertEqual(inserted[0].dtype, object) def test_simple_dataframe(self): columns = ( 'a Int64, ' 'b Nullable(Float64), ' 'c Nullable(String), ' 'd Nullable(Int64)' ) df = pd.DataFrame({ 'a': [1, 2, 3], 'b': [1.0, None, np.nan], 'c': ['a', None, np.nan], 'd': [1, None, None], }, dtype=object) expected = pd.DataFrame({ 'a': np.array([1, 2, 3], dtype=np.int64), 'b': np.array([1.0, None, np.nan], dtype=object), 'c': np.array(['a', None, None], dtype=object), 'd': np.array([1, None, None], dtype=object), }) with self.create_table(columns): rv = self.client.insert_dataframe('INSERT INTO test VALUES', df) self.assertEqual(rv, 3) df2 = self.client.query_dataframe('SELECT * FROM test ORDER BY a') self.assertTrue(expected.equals(df2)) clickhouse-driver-0.2.11/tests/numpy/columns/test_other.py000066400000000000000000000020731522645447600237620ustar00rootroot00000000000000from parameterized import parameterized from clickhouse_driver import errors from clickhouse_driver.columns.service import get_column_by_spec from clickhouse_driver.context import Context from tests.numpy.testcase import NumpyBaseTestCase class OtherColumnsTestCase(NumpyBaseTestCase): def get_column(self, spec): ctx = Context() ctx.client_settings = {'strings_as_bytes': False, 'use_numpy': True} return get_column_by_spec(spec, {'context': ctx}) @parameterized.expand([ ("Enum8('hello' = 1, 'world' = 2)", ), ('Decimal(8, 4)', ), ('Array(String)', ), ('Tuple(String)', ), ('SimpleAggregateFunction(any, Int32)', ), ('Map(String, String)', ), ('Array(LowCardinality(String))', ) ]) def test_generic_type(self, spec): col = self.get_column(spec) self.assertIsNotNone(col) def test_get_unknown_column(self): with self.assertRaises(errors.UnknownTypeError) as e: self.get_column('Unicorn') self.assertIn('Unicorn', str(e.exception)) clickhouse-driver-0.2.11/tests/numpy/columns/test_string.py000066400000000000000000000143451522645447600241540ustar00rootroot00000000000000try: import numpy as np except ImportError: np = None try: import pandas as pd except ImportError: pd = None from tests.numpy.testcase import NumpyBaseTestCase class StringTestCase(NumpyBaseTestCase): def test_string(self): with self.create_table('a String'): data = [np.array(['a', 'b', 'c'])] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, 'a\nb\nc\n') rv = self.client.execute(query, columnar=True) self.assertArraysEqual(rv[0], data) self.assertNotEqual(rv[0].dtype, object) self.assertIsInstance(rv[0][1], (np.str_, )) def test_nullable(self): with self.create_table('a Nullable(String)'): data = [np.array([np.nan, 'test', None, 'nullable'], dtype=object)] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '\\N\ntest\n\\N\nnullable\n') inserted = self.client.execute(query, columnar=True) self.assertArraysEqual( inserted[0], [np.array([None, 'test', None, 'nullable'])] ) self.assertEqual(inserted[0].dtype, object) def test_insert_pandas_string(self): with self.create_table('a String'): df = pd.DataFrame({'a': ['a', 'b', 'c']}, dtype='string') self.client.insert_dataframe( 'INSERT INTO test VALUES', dataframe=df ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, 'a\nb\nc\n') class ByteStringTestCase(NumpyBaseTestCase): client_kwargs = {'settings': {'strings_as_bytes': True, 'use_numpy': True}} def test_string(self): with self.create_table('a String'): data = [np.array([b'a', b'b', b'c'])] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, 'a\nb\nc\n') rv = self.client.execute(query, columnar=True) self.assertArraysEqual(rv[0], data) self.assertNotEqual(rv[0].dtype, object) self.assertIsInstance(rv[0][0], (np.bytes_, )) def test_nullable(self): with self.create_table('a Nullable(String)'): data = [ np.array([np.nan, b'test', None, b'nullable'], dtype=object) ] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '\\N\ntest\n\\N\nnullable\n') inserted = self.client.execute(query, columnar=True) self.assertArraysEqual( inserted[0], [np.array([None, b'test', None, b'nullable'])] ) self.assertEqual(inserted[0].dtype, object) class FixedStringTestCase(NumpyBaseTestCase): def test_string(self): with self.create_table('a FixedString(3)'): data = [np.array(['a', 'b', 'c'])] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, 'a\\0\\0\nb\\0\\0\nc\\0\\0\n') rv = self.client.execute(query, columnar=True) self.assertArraysEqual(rv[0], data) self.assertNotEqual(rv[0].dtype, object) self.assertIsInstance(rv[0][0], (np.str_, )) def test_nullable(self): with self.create_table('a Nullable(FixedString(10))'): data = [np.array([np.nan, 'test', None, 'nullable'], dtype=object)] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '\\N\ntest\\0\\0\\0\\0\\0\\0\n\\N\nnullable\\0\\0\n' ) inserted = self.client.execute(query, columnar=True) self.assertArraysEqual( inserted[0], [np.array([None, 'test', None, 'nullable'])] ) self.assertEqual(inserted[0].dtype, object) class ByteFixedStringTestCase(NumpyBaseTestCase): client_kwargs = {'settings': {'strings_as_bytes': True, 'use_numpy': True}} def test_string(self): with self.create_table('a FixedString(3)'): data = [np.array([b'a', b'b', b'c'])] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, 'a\\0\\0\nb\\0\\0\nc\\0\\0\n') rv = self.client.execute(query, columnar=True) self.assertArraysEqual(rv[0], data) self.assertNotEqual(rv[0].dtype, object) self.assertIsInstance(rv[0][0], (np.bytes_, )) def test_nullable(self): with self.create_table('a Nullable(FixedString(10))'): data = [np.array([ np.nan, b'test\x00\x00\x00\x00\x00\x00', None, b'nullable\x00\x00' ], dtype=object)] self.client.execute( 'INSERT INTO test (a) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual( inserted, '\\N\ntest\\0\\0\\0\\0\\0\\0\n\\N\nnullable\\0\\0\n' ) inserted = self.client.execute(query, columnar=True) self.assertArraysEqual( inserted[0], [np.array([None, b'test', None, b'nullable'])] ) self.assertEqual(inserted[0].dtype, object) clickhouse-driver-0.2.11/tests/numpy/columns/test_tuple.py000066400000000000000000000065561522645447600240040ustar00rootroot00000000000000try: import numpy as np except ImportError: np = None from tests.numpy.testcase import NumpyBaseTestCase class TupleTestCase(NumpyBaseTestCase): def test_simple(self): columns = 'a Tuple(Int32, String)' dtype = [('f0', np.int32), ('f1', ' (20,): # total_rows in progress depends on server version self.assertIn( list(progress), ([(1, 0), (1, 0)], [(1, 1), (1, 1)]) ) else: self.assertEqual(list(progress), [(1, 0)]) self.assertEqual(progress.get_result(), [(2,)]) self.assertTrue(self.client.connection.connected) def test_select_with_progress_no_progress_obtaining(self): progress = self.client.execute_with_progress('SELECT 2') self.assertEqual(progress.get_result(), [(2,)]) class NumpyIteratorTestCase(NumpyBaseTestCase): def test_select_with_iter(self): result = self.client.execute_iter( 'SELECT number FROM system.numbers LIMIT 10' ) self.assertIsInstance(result, types.GeneratorType) self.assertEqual(list(result), list(zip(range(10)))) self.assertEqual(list(result), []) def test_select_with_iter_with_column_types(self): result = self.client.execute_iter( 'SELECT CAST(number AS UInt32) as number ' 'FROM system.numbers LIMIT 10', with_column_types=True ) self.assertIsInstance(result, types.GeneratorType) self.assertEqual( list(result), [[('number', 'UInt32')]] + list(zip(range(10))) ) self.assertEqual(list(result), []) class DataFrameTestCase(NumpyBaseTestCase): def test_query_simple(self): df = self.client.query_dataframe( 'SELECT CAST(number AS Int64) AS x FROM system.numbers LIMIT 100' ) self.assertTrue(df.equals(pd.DataFrame({'x': range(100)}))) def test_query_replace_whitespace_in_column_names(self): df = self.client.query_dataframe( 'SELECT number AS "test me" FROM system.numbers LIMIT 100' ) self.assertIn('test_me', df) def test_insert_simple(self): n = 10 df = pd.DataFrame({ 'a': range(n), 'b': [float(x) for x in range(n)] }) with self.create_table('a Int64, b Float64'): rv = self.client.insert_dataframe('INSERT INTO test VALUES', df) self.assertEqual(rv, n) df2 = self.client.query_dataframe('SELECT * FROM test ORDER BY a') self.assertTrue(df.equals(df2)) def test_insert_chunking(self): with self.create_table('a Int64'): rv = self.client.execute( 'INSERT INTO test VALUES', [np.array(range(3))], columnar=True, settings={'insert_block_size': 1} ) self.assertEqual(rv, 3) def test_insert_not_ordered_columns(self): n = 10 df = pd.DataFrame({ 'b': range(n), 'a': [str(x) for x in range(n)] })[['b', 'a']] with self.create_table('a String, b Float64'): rv = self.client.insert_dataframe( 'INSERT INTO test (a, b) VALUES', df ) self.assertEqual(rv, n) def test_empty_frame_shape(self): df = self.client.query_dataframe( 'SELECT number AS a, number AS a FROM system.numbers LIMIT 0' ) self.assertEqual(df.shape, (0, 2)) def test_data_less_columns_than_expected(self): with self.create_table('a Int8, b Int8'): with self.assertRaises(ValueError) as e: df = pd.DataFrame([1, 2, 3], columns=['a']) self.client.insert_dataframe('INSERT INTO test VALUES', df) expected = "DataFrame missing required columns: ['b']" self.assertEqual(str(e.exception), expected) def test_data_different_columns_than_expected(self): with self.create_table('a Int8, b Int8'): with self.assertRaises(ValueError) as e: df = pd.DataFrame([[1, 2], [3, 4]], columns=['a', 'c']) self.client.insert_dataframe('INSERT INTO test VALUES', df) expected = "DataFrame missing required columns: ['b']" self.assertEqual(str(e.exception), expected) class NoNumPyTestCase(BaseTestCase): def setUp(self): super(NoNumPyTestCase, self).setUp() try: import numpy # noqa: F401 import pandas # noqa: F401 except Exception: pass else: self.skipTest('NumPy extras are installed') def test_runtime_error_without_numpy(self): with self.assertRaises(RuntimeError) as e: with self.created_client(settings={'use_numpy': True}) as client: client.execute('SELECT 1') self.assertEqual( 'Extras for NumPy must be installed', str(e.exception) ) def test_query_dataframe(self): with self.assertRaises(RuntimeError) as e: with self.created_client(settings={'use_numpy': True}) as client: client.query_dataframe('SELECT 1 AS x') self.assertEqual( 'Extras for NumPy must be installed', str(e.exception) ) clickhouse-driver-0.2.11/tests/numpy/testcase.py000066400000000000000000000011511522645447600217310ustar00rootroot00000000000000try: import numpy as np except ImportError: np = None from tests.numpy.util import check_numpy from tests.testcase import BaseTestCase class NumpyBaseTestCase(BaseTestCase): client_kwargs = {'settings': {'use_numpy': True}} @check_numpy def setUp(self): super(NumpyBaseTestCase, self).setUp() def assertArraysEqual(self, first, second): return self.assertTrue((first == second).all()) def assertArraysListEqual(self, first, second): self.assertEqual(len(first), len(second)) for x, y in zip(first, second): self.assertTrue((x == y).all()) clickhouse-driver-0.2.11/tests/numpy/util.py000066400000000000000000000005141522645447600210750ustar00rootroot00000000000000from functools import wraps from unittest import SkipTest def check_numpy(f): @wraps(f) def wrapper(*args, **kwargs): try: return f(*args, **kwargs) except RuntimeError as e: if 'NumPy' in str(e): raise SkipTest('Numpy package is not installed') return wrapper clickhouse-driver-0.2.11/tests/test_blocks.py000066400000000000000000000230761522645447600212740ustar00rootroot00000000000000import types from unittest.mock import patch from clickhouse_driver.errors import ServerException from tests.testcase import BaseTestCase, file_config from tests.util import capture_logging from clickhouse_driver.util.helpers import chunks class BlocksTestCase(BaseTestCase): def test_return_totals_extremes(self): rv = self.client.execute( 'SELECT a, sum(b + a) FROM (' 'SELECT arrayJoin(range(3)) - 1 AS a,' 'arrayJoin(range(4)) AS b' ') AS t ' 'GROUP BY a WITH TOTALS ' 'ORDER BY a', settings={'extremes': 1} ) self.assertEqual(rv, [ (-1, 2), (0, 6), (1, 10), # TOTALS (0, 18), # EXTREMES (-1, 2), (1, 10) ]) def test_columnar_result(self): rv = self.client.execute( 'SELECT a, sum(b + a) FROM (' 'SELECT arrayJoin(range(3)) - 1 AS a,' 'arrayJoin(range(4)) AS b' ') AS t ' 'GROUP BY a ' 'ORDER BY a', columnar=True ) self.assertEqual(rv, [ (-1, 0, 1), (2, 6, 10) ]) def test_columnar_block_extend(self): with self.create_table('a Int32'): self.client.execute('INSERT INTO test (a) VALUES', [(1, )]) self.client.execute('INSERT INTO test (a) VALUES', [(2, )]) query = 'SELECT * FROM test ORDER BY a' # One row per block even if the two parts get merged. inserted = self.client.execute( query, columnar=True, settings={'max_block_size': 1} ) self.assertEqual(inserted, [(1, 2)]) def test_select_with_column_types(self): rv = self.client.execute( 'SELECT CAST(1 AS Int32) AS x', with_column_types=True ) self.assertEqual(rv, ([(1,)], [('x', 'Int32')])) def test_select_with_columnar_with_column_types(self): progress = self.client.execute_with_progress( 'SELECT arrayJoin(A) -1 as j,' 'arrayJoin(A)+1 as k FROM(' 'SELECT range(3) as A)', columnar=True, with_column_types=True) rv = ([(-1, 0, 1), (1, 2, 3)], [('j', 'Int16'), ('k', 'UInt16')]) self.assertEqual(progress.get_result(), rv) def test_close_connection_on_keyboard_interrupt(self): connection = self.client.connection with self.assertRaises(KeyboardInterrupt): with patch.object(connection, 'send_query') as mocked_send_query: mocked_send_query.side_effect = KeyboardInterrupt self.client.execute('SELECT 1') self.assertFalse(self.client.connection.connected) class ProgressTestCase(BaseTestCase): def test_select_with_progress(self): progress = self.client.execute_with_progress('SELECT 2') # CH 25 reports 1 byte per progress chunk for trivial selects; # earlier versions reported 0. if self.server_version >= (25,): expected = [(1, 1), (1, 1)] elif self.server_version > (20,): expected = [(1, 0), (1, 0)] else: expected = [(1, 0)] self.assertEqual(list(progress), expected) self.assertEqual(progress.get_result(), [(2,)]) self.assertTrue(self.client.connection.connected) def test_progress_totals(self): progress = self.client.execute_with_progress('SELECT 2') self.assertEqual(progress.progress_totals.rows, 0) self.assertEqual(progress.progress_totals.bytes, 0) self.assertEqual(progress.progress_totals.total_rows, 0) self.assertEqual(progress.get_result(), [(2,)]) self.assertEqual(progress.progress_totals.rows, 1) self.assertEqual(progress.progress_totals.bytes, 1) # CH 25 sets total_rows for trivial selects to 1; earlier # versions left it at 0. expected_total_rows = 1 if self.server_version >= (25,) else 0 self.assertEqual( progress.progress_totals.total_rows, expected_total_rows) def test_select_with_progress_error(self): with self.assertRaises(ServerException): progress = self.client.execute_with_progress('SELECT error') list(progress) self.assertFalse(self.client.connection.connected) def test_select_with_progress_no_progress_unwind(self): progress = self.client.execute_with_progress('SELECT 2') self.assertEqual(progress.get_result(), [(2,)]) self.assertTrue(self.client.connection.connected) def test_select_with_progress_cancel(self): self.client.execute_with_progress('SELECT 2') rv = self.client.cancel() self.assertEqual(rv, [(2,)]) self.assertTrue(self.client.connection.connected) def test_select_with_progress_cancel_with_column_types(self): self.client.execute_with_progress('SELECT CAST(2 AS Int32) as x') rv = self.client.cancel(with_column_types=True) self.assertEqual(rv, ([(2,)], [('x', 'Int32')])) self.assertTrue(self.client.connection.connected) def test_select_with_progress_with_params(self): progress = self.client.execute_with_progress( 'SELECT %(x)s', params={'x': 2} ) self.assertEqual(progress.get_result(), [(2,)]) self.assertTrue(self.client.connection.connected) def test_close_connection_on_keyboard_interrupt(self): connection = self.client.connection with self.assertRaises(KeyboardInterrupt): with patch.object(connection, 'send_query') as mocked_send_query: mocked_send_query.side_effect = KeyboardInterrupt self.client.execute_with_progress('SELECT 1') self.assertFalse(self.client.connection.connected) class IteratorTestCase(BaseTestCase): def test_select_with_iter(self): result = self.client.execute_iter( 'SELECT number FROM system.numbers LIMIT 10' ) self.assertIsInstance(result, types.GeneratorType) self.assertEqual(list(result), list(zip(range(10)))) self.assertEqual(list(result), []) def test_select_with_chunk_one_iter(self): result = self.client.execute_iter( 'SELECT number FROM system.numbers LIMIT 10', chunk_size=1 ) self.assertIsInstance(result, types.GeneratorType) self.assertEqual(list(result), list(zip(range(10)))) self.assertEqual(list(result), []) def test_select_with_chunk_some_iter(self): result = self.client.execute_iter( 'SELECT number FROM system.numbers LIMIT 10', chunk_size=3 ) self.assertIsInstance(result, types.GeneratorType) self.assertEqual(list(result), list(chunks(zip(range(10)), 3))) self.assertEqual(list(result), []) def test_select_with_iter_with_column_types(self): result = self.client.execute_iter( 'SELECT CAST(number AS UInt32) as number ' 'FROM system.numbers LIMIT 10', with_column_types=True ) self.assertIsInstance(result, types.GeneratorType) self.assertEqual( list(result), [[('number', 'UInt32')]] + list(zip(range(10))) ) self.assertEqual(list(result), []) def test_select_with_iter_error(self): with self.assertRaises(ServerException): result = self.client.execute_iter('SELECT error') self.assertIsInstance(result, types.GeneratorType) list(result) self.assertFalse(self.client.connection.connected) def test_close_connection_on_keyboard_interrupt(self): connection = self.client.connection with self.assertRaises(KeyboardInterrupt): with patch.object(connection, 'send_query') as mocked_send_query: mocked_send_query.side_effect = KeyboardInterrupt self.client.execute_iter('SELECT 1') self.assertFalse(self.client.connection.connected) class LogTestCase(BaseTestCase): required_server_version = (18, 12, 13) def test_logs(self): with capture_logging('clickhouse_driver.log', 'INFO') as buffer: settings = {'send_logs_level': 'debug'} query = 'SELECT 1' self.client.execute(query, settings=settings) self.assertIn(query, buffer.getvalue()) def test_logs_insert(self): with capture_logging('clickhouse_driver.log', 'INFO') as buffer: with self.create_table('a Int32'): settings = {'send_logs_level': 'debug'} query = 'INSERT INTO test (a) VALUES' self.client.execute(query, [(1, )], settings=settings) logs = buffer.getvalue() self.assertIn(query, logs) # Test all packets of INSERT query are consumed. rv = self.client.execute('SELECT 1', settings=settings) self.assertEqual(rv, [(1, )]) def test_logs_with_compression(self): compression = 'lz4' supported_compressions = ( file_config.get('db', 'compression').split(',') ) if compression not in supported_compressions: self.skipTest( 'Compression {} is not supported'.format(compression) ) with self.created_client(compression='lz4') as client: with capture_logging('clickhouse_driver.log', 'INFO') as buffer: settings = {'send_logs_level': 'debug'} query = 'SELECT 1' client.execute(query, settings=settings) self.assertIn(query, buffer.getvalue()) clickhouse-driver-0.2.11/tests/test_buffered_reader.py000066400000000000000000000013641522645447600231170ustar00rootroot00000000000000import socket from unittest import TestCase, mock from clickhouse_driver.bufferedreader import BufferedSocketReader class BufferedReaderTestCase(TestCase): def test_overflow_signed_int_string_size(self): data = b'\xFF\xFE\xFC\xFE\xFE\xFE\xFE\xFE\x29\x80\x40\x00\x00\x01' def recv_into(buf): size = len(data) buf[0:size] = data return size with mock.patch('socket.socket') as mock_socket: mock_socket.return_value.recv_into.side_effect = recv_into reader = BufferedSocketReader(socket.socket(), 1024) # Trying to allocate huge amount of memory. with self.assertRaises(MemoryError): reader.read_strings(5, encoding='utf-8') clickhouse-driver-0.2.11/tests/test_client.py000066400000000000000000000261131522645447600212700ustar00rootroot00000000000000import ssl from clickhouse_driver import Client from clickhouse_driver.compression.lz4 import Compressor as LZ4Compressor from clickhouse_driver.compression.lz4hc import Compressor as LZHC4Compressor from clickhouse_driver.compression.zstd import Compressor as ZSTDCompressor from clickhouse_driver.protocol import Compression from tests.numpy.util import check_numpy from tests.testcase import TestCase class ClientFromUrlTestCase(TestCase): def assertHostsEqual(self, client, another, msg=None): self.assertEqual(list(client.connection.hosts), another, msg=msg) def test_simple(self): c = Client.from_url('clickhouse://host') self.assertHostsEqual(c, [('host', 9000)]) self.assertEqual(c.connection.database, '') c = Client.from_url('clickhouse://host/db') self.assertHostsEqual(c, [('host', 9000)]) self.assertEqual(c.connection.database, 'db') def test_credentials(self): c = Client.from_url('clickhouse://host/db') self.assertEqual(c.connection.user, 'default') self.assertEqual(c.connection.password, '') c = Client.from_url('clickhouse://admin:secure@host/db') self.assertEqual(c.connection.user, 'admin') self.assertEqual(c.connection.password, 'secure') c = Client.from_url('clickhouse://user:@host/db') self.assertEqual(c.connection.user, 'user') self.assertEqual(c.connection.password, '') def test_credentials_unquoting(self): c = Client.from_url('clickhouse://ad%3Amin:se%2Fcure@host/db') self.assertEqual(c.connection.user, 'ad:min') self.assertEqual(c.connection.password, 'se/cure') def test_schema(self): c = Client.from_url('clickhouse://host') self.assertFalse(c.connection.secure_socket) c = Client.from_url('clickhouses://host') self.assertTrue(c.connection.secure_socket) c = Client.from_url('test://host') self.assertFalse(c.connection.secure_socket) def test_port(self): c = Client.from_url('clickhouse://host') self.assertHostsEqual(c, [('host', 9000)]) c = Client.from_url('clickhouses://host') self.assertHostsEqual(c, [('host', 9440)]) c = Client.from_url('clickhouses://host:1234') self.assertHostsEqual(c, [('host', 1234)]) def test_secure(self): c = Client.from_url('clickhouse://host?secure=n') self.assertHostsEqual(c, [('host', 9000)]) self.assertFalse(c.connection.secure_socket) c = Client.from_url('clickhouse://host?secure=y') self.assertHostsEqual(c, [('host', 9440)]) self.assertTrue(c.connection.secure_socket) c = Client.from_url('clickhouse://host:1234?secure=y') self.assertHostsEqual(c, [('host', 1234)]) self.assertTrue(c.connection.secure_socket) with self.assertRaises(ValueError): Client.from_url('clickhouse://host:1234?secure=nonono') def test_compression(self): c = Client.from_url('clickhouse://host?compression=n') self.assertEqual(c.connection.compression, Compression.DISABLED) self.assertIsNone(c.connection.compressor_cls) c = Client.from_url('clickhouse://host?compression=y') self.assertEqual(c.connection.compression, Compression.ENABLED) self.assertIs(c.connection.compressor_cls, LZ4Compressor) c = Client.from_url('clickhouse://host?compression=lz4') self.assertEqual(c.connection.compression, Compression.ENABLED) self.assertIs(c.connection.compressor_cls, LZ4Compressor) c = Client.from_url('clickhouse://host?compression=lz4hc') self.assertEqual(c.connection.compression, Compression.ENABLED) self.assertIs(c.connection.compressor_cls, LZHC4Compressor) c = Client.from_url('clickhouse://host?compression=zstd') self.assertEqual(c.connection.compression, Compression.ENABLED) self.assertIs(c.connection.compressor_cls, ZSTDCompressor) with self.assertRaises(ValueError): Client.from_url('clickhouse://host:1234?compression=custom') def test_client_name(self): c = Client.from_url('clickhouse://host?client_name=native') self.assertEqual(c.connection.client_name, 'ClickHouse native') def test_timeouts(self): with self.assertRaises(ValueError): Client.from_url('clickhouse://host?connect_timeout=test') c = Client.from_url('clickhouse://host?connect_timeout=1.2') self.assertEqual(c.connection.connect_timeout, 1.2) c = Client.from_url('clickhouse://host?send_receive_timeout=1.2') self.assertEqual(c.connection.send_receive_timeout, 1.2) c = Client.from_url('clickhouse://host?sync_request_timeout=1.2') self.assertEqual(c.connection.sync_request_timeout, 1.2) def test_compress_block_size(self): with self.assertRaises(ValueError): Client.from_url('clickhouse://host?compress_block_size=test') c = Client.from_url('clickhouse://host?compress_block_size=100500') # compression is not set self.assertIsNone(c.connection.compress_block_size) c = Client.from_url( 'clickhouse://host?' 'compress_block_size=100500&' 'compression=1' ) self.assertEqual(c.connection.compress_block_size, 100500) def test_settings(self): c = Client.from_url( 'clickhouse://host?' 'send_logs_level=trace&' 'max_block_size=123' ) self.assertEqual(c.settings, { 'send_logs_level': 'trace', 'max_block_size': '123' }) def test_ssl(self): c = Client.from_url( 'clickhouses://host?' 'verify=false&' 'ssl_version=PROTOCOL_SSLv23&' 'ca_certs=/tmp/certs&' 'ciphers=HIGH:-aNULL:-eNULL:-PSK:RC4-SHA:RC4-MD5' ) self.assertEqual(c.connection.ssl_options, { 'ssl_version': ssl.PROTOCOL_SSLv23, 'ca_certs': '/tmp/certs', 'ciphers': 'HIGH:-aNULL:-eNULL:-PSK:RC4-SHA:RC4-MD5' }) def test_ssl_key_cert(self): base_url = ( 'clickhouses://host?' 'verify=true&' 'ssl_version=PROTOCOL_SSLv23&' 'ca_certs=/tmp/certs&' 'ciphers=HIGH:-aNULL:-eNULL:-PSK:RC4-SHA:RC4-MD5&' ) base_expected = { 'ssl_version': ssl.PROTOCOL_SSLv23, 'ca_certs': '/tmp/certs', 'ciphers': 'HIGH:-aNULL:-eNULL:-PSK:RC4-SHA:RC4-MD5' } c = Client.from_url( base_url + 'keyfile=/tmp/client.key&' 'certfile=/tmp/client.cert' ) expected = base_expected.copy() expected.update({ 'keyfile': '/tmp/client.key', 'certfile': '/tmp/client.cert' }) self.assertEqual(c.connection.ssl_options, expected) c = Client.from_url( base_url + 'keyfile=/tmp/client.key&' 'certfile=/tmp/client.cert&' 'keypass=foobar' ) expected = base_expected.copy() expected.update({ 'keyfile': '/tmp/client.key', 'certfile': '/tmp/client.cert', 'keypass': 'foobar', }) self.assertEqual(c.connection.ssl_options, expected) c = Client.from_url( base_url + 'certfile=/tmp/client.cert' ) expected = base_expected.copy() expected.update({ 'certfile': '/tmp/client.cert' }) self.assertEqual(c.connection.ssl_options, expected) def test_check_hostname(self): c = Client.from_url( 'clickhouses://host?verify=true&check_hostname=false' ) self.assertEqual(c.connection.check_hostname, False) def test_alt_hosts(self): c = Client.from_url('clickhouse://host?alt_hosts=host2:1234') self.assertHostsEqual(c, [('host', 9000), ('host2', 1234)]) c = Client.from_url('clickhouse://host?alt_hosts=host2') self.assertHostsEqual(c, [('host', 9000), ('host2', 9000)]) def test_parameters_cast(self): c = Client.from_url('clickhouse://host?insert_block_size=123') self.assertEqual( c.connection.context.client_settings['insert_block_size'], 123 ) def test_settings_is_important(self): c = Client.from_url('clickhouse://host?settings_is_important=1') self.assertEqual(c.connection.settings_is_important, True) with self.assertRaises(ValueError): c = Client.from_url('clickhouse://host?settings_is_important=2') self.assertEqual(c.connection.settings_is_important, True) c = Client.from_url('clickhouse://host?settings_is_important=0') self.assertEqual(c.connection.settings_is_important, False) @check_numpy def test_use_numpy(self): c = Client.from_url('clickhouse://host?use_numpy=true') self.assertTrue(c.connection.context.client_settings['use_numpy']) def test_opentelemetry(self): c = Client.from_url( 'clickhouse://host?opentelemetry_traceparent=' '00-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-00' ) self.assertEqual( c.connection.context.client_settings['opentelemetry_traceparent'], '00-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-00' ) self.assertEqual( c.connection.context.client_settings['opentelemetry_tracestate'], '' ) c = Client.from_url( 'clickhouse://host?opentelemetry_traceparent=' '00-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-00&' 'opentelemetry_tracestate=state' ) self.assertEqual( c.connection.context.client_settings['opentelemetry_traceparent'], '00-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-00' ) self.assertEqual( c.connection.context.client_settings['opentelemetry_tracestate'], 'state' ) def test_quota_key(self): c = Client.from_url('clickhouse://host?quota_key=myquota') self.assertEqual( c.connection.context.client_settings['quota_key'], 'myquota' ) c = Client.from_url('clickhouse://host') self.assertEqual( c.connection.context.client_settings['quota_key'], '' ) def test_round_robin(self): c = Client.from_url('clickhouse://host?alt_hosts=host2') self.assertEqual(len(c.connections), 0) c = Client.from_url( 'clickhouse://host?round_robin=true&alt_hosts=host2' ) self.assertEqual(len(c.connections), 1) def test_tcp_keepalive(self): c = Client.from_url('clickhouse://host?tcp_keepalive=true') self.assertTrue(c.connection.tcp_keepalive) c = Client.from_url('clickhouse://host?tcp_keepalive=10,2,3') self.assertEqual( c.connection.tcp_keepalive, (10, 2, 3) ) def test_client_revision(self): c = Client.from_url('clickhouse://host?client_revision=54032') self.assertEqual(c.connection.client_revision, 54032) clickhouse-driver-0.2.11/tests/test_compression.py000066400000000000000000000061111522645447600223470ustar00rootroot00000000000000from datetime import date, datetime from unittest import TestCase from clickhouse_driver import errors from clickhouse_driver.client import Client from clickhouse_driver.compression import get_compressor_cls from clickhouse_driver.compression.lz4 import Compressor from .testcase import BaseTestCase, file_config class BaseCompressionTestCase(BaseTestCase): compression = False supported_compressions = file_config.get('db', 'compression').split(',') def _create_client(self): settings = None if self.compression: # Set server compression method explicitly # By default server sends blocks compressed by LZ4. method = self.compression if self.server_version > (19, ): method = method.upper() settings = {'network_compression_method': method} return Client( self.host, self.port, self.database, self.user, self.password, compression=self.compression, settings=settings ) def setUp(self): super(BaseCompressionTestCase, self).setUp() supported = ( self.compression is False or self.compression in self.supported_compressions ) if not supported: self.skipTest( 'Compression {} is not supported'.format(self.compression) ) def run_simple(self): with self.create_table('a Date, b DateTime'): data = [(date(2012, 10, 25), datetime(2012, 10, 25, 14, 7, 19))] self.client.execute( 'INSERT INTO test (a, b) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '2012-10-25\t2012-10-25 14:07:19\n') inserted = self.client.execute(query) self.assertEqual(inserted, data) def test(self): if self.compression is False: return self.run_simple() class LZ4ReadWriteTestCase(BaseCompressionTestCase): compression = 'lz4' class LZ4HCReadWriteTestCase(BaseCompressionTestCase): compression = 'lz4hc' class ZSTDReadWriteTestCase(BaseCompressionTestCase): compression = 'zstd' class MiscCompressionTestCase(TestCase): def test_default_compression(self): client = Client('localhost', compression=True) self.assertEqual(client.connection.compressor_cls, Compressor) def test_unknown_compressor(self): with self.assertRaises(errors.UnknownCompressionMethod) as e: get_compressor_cls('hello') self.assertEqual( e.exception.code, errors.ErrorCodes.UNKNOWN_COMPRESSION_METHOD ) class ReadByBlocksTestCase(BaseCompressionTestCase): compression = 'lz4' def test(self): with self.create_table('a Int32'): data = [(x % 200, ) for x in range(1000000)] self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.client.execute(query) self.assertEqual(inserted, data) clickhouse-driver-0.2.11/tests/test_connect.py000066400000000000000000000345161522645447600214510ustar00rootroot00000000000000# coding: utf-8 import socket from io import BytesIO from unittest.mock import patch from clickhouse_driver import errors from clickhouse_driver.client import Client from clickhouse_driver.protocol import ClientPacketTypes, ServerPacketTypes from clickhouse_driver.bufferedreader import BufferedReader from clickhouse_driver.writer import write_binary_str from tests.testcase import BaseTestCase from unittest import TestCase class PacketsTestCase(BaseTestCase): def test_packets_to_str(self): self.assertEqual(ClientPacketTypes.to_str(2), 'Data') self.assertEqual(ClientPacketTypes.to_str(6), 'Unknown packet') self.assertEqual(ClientPacketTypes.to_str(42), 'Unknown packet') self.assertEqual(ServerPacketTypes.to_str(4), 'Pong') self.assertEqual(ServerPacketTypes.to_str(18), 'Unknown packet') self.assertEqual(ServerPacketTypes.to_str(42), 'Unknown packet') class ConnectTestCase(BaseTestCase): def unexpected_packet_message(self, expected, got): return ( 'Code: 102. Unexpected packet from server {}:{} ' '(expected {}, got {})' ).format(self.host, self.port, expected, got) def test_exception_on_hello_packet(self): with self.created_client(user='wrong_user') as client: with self.assertRaises(errors.ServerException) as e: client.execute('SHOW TABLES') # Simple exception formatting checks exc = e.exception self.assertIn('Code:', str(exc)) self.assertIn('Stack trace:', str(exc)) def test_network_error(self): client = Client('bad-address') with patch('socket.getaddrinfo') as mocked_getaddrinfo: mocked_getaddrinfo.side_effect = socket.error( -2, 'Name or service not known' ) with self.assertRaises(errors.NetworkError): client.execute('SHOW TABLES') def test_timeout_error(self): with patch('socket.socket') as ms: ms.return_value.connect.side_effect = socket.timeout with self.assertRaises(errors.SocketTimeoutError) as e: self.client.execute('SHOW TABLES') self.assertEqual( str(e.exception), 'Code: 209. ({}:{})'.format(self.host, self.port) ) ms.return_value.connect.side_effect = socket.timeout(42, 'Test') with self.assertRaises(errors.SocketTimeoutError) as e: self.client.execute('SHOW TABLES') self.assertEqual( str(e.exception), 'Code: 209. Test ({}:{})'.format(self.host, self.port) ) def test_transport_not_connection_on_disconnect(self): # Create connection. self.client.execute('SELECT 1') connection = self.client.connection with patch.object(connection, 'ping') as mocked_ping: mocked_ping.return_value = False with patch.object(connection, 'socket') as mocked_socket: mocked_socket.shutdown.side_effect = socket.error( 107, 'Transport endpoint is not connected' ) # New socket should be created. rv = self.client.execute('SELECT 1') self.assertEqual(rv, [(1, )]) # Close newly created socket. connection.socket.close() def test_transport_disable_reconnect(self): with self.created_client(disable_reconnect=True) as client: # Create connection. client.execute('SELECT 1') connection = client.connection with patch.object(connection, 'ping') as mocked_ping: mocked_ping.return_value = False self.assertTrue(connection.connected) error = errors.NetworkError with self.assertRaises(error) as e: client.execute('SELECT 1') self.assertFalse(connection.connected) self.assertEqual( str(e.exception), 'Code: 210. Connection was closed, reconnect is disabled.' ) def test_socket_error_on_ping(self): self.client.execute('SELECT 1') with patch.object(self.client.connection, 'fout') as mocked_fout: mocked_fout.flush.side_effect = socket.error(32, 'Broken pipe') rv = self.client.execute('SELECT 1') self.assertEqual(rv, [(1, )]) def test_ping_got_unexpected_package(self): self.client.execute('SELECT 1') with patch.object(self.client.connection, 'fin') as mocked_fin: # Emulate Exception packet on ping. mocked_fin.read_one.return_value = 2 error = errors.UnexpectedPacketFromServerError with self.assertRaises(error) as e: self.client.execute('SELECT 1') self.assertEqual( str(e.exception), self.unexpected_packet_message('Pong', 'Exception') ) def test_eof_on_receive_packet(self): self.client.execute('SELECT 1') with patch.object(self.client.connection, 'fin') as mocked_fin: # Emulate Exception packet on ping. mocked_fin.read_one.side_effect = [4, EOFError] with self.assertRaises(EOFError): self.client.execute('SELECT 1') def test_eof_error_on_ping(self): self.client.execute('SELECT 1') self.raised = False read_one = self.client.connection.fin.read_one def side_effect(*args, **kwargs): if not self.raised: self.raised = True raise EOFError('Unexpected EOF while reading bytes') else: return read_one(*args, **kwargs) with patch.object(self.client.connection, 'fin') as mocked_fin: mocked_fin.read_one.side_effect = side_effect rv = self.client.execute('SELECT 1') self.assertEqual(rv, [(1, )]) def test_alt_hosts(self): client = Client( 'wrong_host', 1234, self.database, self.user, self.password, alt_hosts='{}:{}'.format(self.host, self.port) ) self.n_calls = 0 getaddrinfo = socket.getaddrinfo def side_getaddrinfo(host, *args, **kwargs): if host == 'wrong_host': self.n_calls += 1 raise socket.error(-2, 'Name or service not known') return getaddrinfo(host, *args, **kwargs) with patch('socket.getaddrinfo') as mocked_getaddrinfo: mocked_getaddrinfo.side_effect = side_getaddrinfo rv = client.execute('SELECT 1') self.assertEqual(rv, [(1,)]) client.disconnect() rv = client.execute('SELECT 1') self.assertEqual(rv, [(1,)]) # Last host must be remembered and getaddrinfo must call exactly # once with host == 'wrong_host'. self.assertEqual(self.n_calls, 1) client.disconnect() def test_remember_current_database(self): with self.created_client() as client: client.execute(' USE system ; ') client.disconnect() rv = client.execute('SELECT currentDatabase()') self.assertEqual(rv, [('system', )]) def test_context_manager(self): with self.created_client() as c: c.execute('SELECT 1') self.assertTrue(c.connection.connected) self.assertFalse(c.connection.connected) def test_unknown_packet(self): self.client.execute('SELECT 1') with patch('clickhouse_driver.connection.read_varint') as read_mock, \ patch.object(self.client.connection, 'force_connect'): read_mock.return_value = 42 with self.assertRaises(errors.UnknownPacketFromServerError) as e: self.client.execute('SELECT 1') self.assertEqual( str(e.exception), 'Code: 100. Unknown packet 42 from server {}:{}'.format( self.host, self.port ) ) def test_unknown_packet_on_connect(self): with patch('clickhouse_driver.connection.read_varint') as read_mock: read_mock.return_value = 42 error = errors.UnexpectedPacketFromServerError with self.assertRaises(error) as e: self.client.execute('SELECT 1') msg = self.unexpected_packet_message( 'Hello or Exception', 'Unknown packet' ) self.assertEqual(str(e.exception), msg) def test_partially_consumed_query(self): self.client.execute_iter('SELECT 1') error = errors.PartiallyConsumedQueryError with self.assertRaises(error) as e: self.client.execute_iter('SELECT 1') self.assertEqual( str(e.exception), 'Simultaneous queries on single connection detected' ) rv = self.client.execute('SELECT 1') self.assertEqual(rv, [(1, )]) def test_read_all_packets_on_execute_iter(self): list(self.client.execute_iter('SELECT 1')) list(self.client.execute_iter('SELECT 1')) def test_round_robin(self): kwargs = { 'round_robin': True, 'alt_hosts': '{}:{}'.format(self.host, self.port) } with self.created_client(**kwargs) as client: self.assertFalse(client.connection.connected) self.assertFalse(list(client.connections)[0].connected) client.execute('SELECT 1') self.assertTrue(client.connection.connected) self.assertFalse(list(client.connections)[0].connected) client.execute('SELECT 1') self.assertTrue(client.connection.connected) self.assertTrue(list(client.connections)[0].connected) client.disconnect() self.assertFalse(client.connection.connected) self.assertFalse(list(client.connections)[0].connected) def test_round_robin_client_construction(self): # host and port as keyword args Client( host='host', port=9000, round_robin=True, alt_hosts='host2' ) # host as positional and port as keyword arg Client( 'host', 9000, round_robin=True, alt_hosts='host2' ) # host and port as positional args Client( 'host', 9000, round_robin=True, alt_hosts='host2' ) def test_tcp_keepalive(self): self.assertFalse(self.client.connection.tcp_keepalive) with self.created_client(tcp_keepalive=True) as client: self.assertTrue(client.connection.tcp_keepalive) client.execute('SELECT 1') with self.created_client(tcp_keepalive=(100, 20, 2)) as client: self.assertEqual(client.connection.tcp_keepalive, (100, 20, 2)) client.execute('SELECT 1') def test_client_revision(self): with self.created_client(client_revision=54032) as client: client.execute('SELECT 1') def test_client_with_no_cert_validation(self): try: self.client.execute('SELECT showCertificate()') except errors.ServerException as e: # If there is no such function skip this check. if e.code == errors.ErrorCodes.UNKNOWN_FUNCTION: pass # If certificate not found elif e.code == errors.ErrorCodes.POCO_EXCEPTION and \ 'No such file or directory' in e.message: self.skipTest('No certificate found on ClickHouse server') else: raise with self.created_client(port=self.secure_port, secure=True, verify=False) as client: client.execute('SELECT 1') class FakeBufferedReader(BufferedReader): def __init__(self, inputs, bufsize=128): super(FakeBufferedReader, self).__init__(bufsize) self._inputs = inputs self._counter = 0 def read_into_buffer(self): try: value = self._inputs[self._counter] except IndexError: value = b'' else: self._counter += 1 self.current_buffer_size = len(value) self.buffer[:len(value)] = value if self.current_buffer_size == 0: raise EOFError('Unexpected EOF while reading bytes') class TestBufferedReader(TestCase): def test_corner_case_read(self): rdr = FakeBufferedReader([ b'\x00' * 10, b'\xff' * 10, ]) self.assertEqual(rdr.read(5), b'\x00' * 5) self.assertEqual(rdr.read(10), b'\x00' * 5 + b'\xff' * 5) self.assertEqual(rdr.read(5), b'\xff' * 5) self.assertRaises(EOFError, rdr.read, 10) def test_corner_case_read_to_end_of_buffer(self): rdr = FakeBufferedReader([ b'\x00' * 10, b'\xff' * 10, ]) self.assertEqual(rdr.read(5), b'\x00' * 5) self.assertEqual(rdr.read(5), b'\x00' * 5) self.assertEqual(rdr.read(5), b'\xff' * 5) self.assertEqual(rdr.read(5), b'\xff' * 5) self.assertRaises(EOFError, rdr.read, 10) def test_corner_case_exact_buffer(self): rdr = FakeBufferedReader([ b'\x00' * 10, b'\xff' * 10, ], bufsize=10) self.assertEqual(rdr.read(5), b'\x00' * 5) self.assertEqual(rdr.read(10), b'\x00' * 5 + b'\xff' * 5) self.assertEqual(rdr.read(5), b'\xff' * 5) def test_read_strings(self): strings = [ u'Yoyodat' * 10, u'Peter Maffay' * 10, ] buf = BytesIO() for name in strings: write_binary_str(name, buf) buf = buf.getvalue() ref_values = tuple(x.encode('utf-8') for x in strings) for split in range(1, len(buf) - 1): for split_2 in range(split + 1, len(buf) - 2): self.assertEqual( buf[:split] + buf[split:split_2] + buf[split_2:], buf ) bufs = [ buf[:split], buf[split:split_2], buf[split_2:], ] rdr = FakeBufferedReader(bufs, bufsize=4096) read_values = rdr.read_strings(2) self.assertEqual(repr(ref_values), repr(read_values)) clickhouse-driver-0.2.11/tests/test_dbapi.py000066400000000000000000000466351522645447600211040ustar00rootroot00000000000000import types from collections import namedtuple from contextlib import contextmanager import socket from unittest.mock import patch from clickhouse_driver import connect from clickhouse_driver.dbapi import ( ProgrammingError, InterfaceError, OperationalError ) from clickhouse_driver.dbapi.extras import DictCursor, NamedTupleCursor from tests.testcase import BaseTestCase class DBAPITestCaseBase(BaseTestCase): def create_connection(self, **kwargs): kwargs.setdefault('user', self.user) kwargs.setdefault('password', self.password) kwargs.setdefault('host', self.host) kwargs.setdefault('port', self.port) kwargs.setdefault('database', self.database) return connect(**kwargs) @contextmanager def created_connection(self, **kwargs): connection = self.create_connection(**kwargs) try: yield connection finally: connection.close() @contextmanager def created_cursor(self, **kwargs): cursor_kwargs = kwargs.pop('cursor_kwargs', {}) with self.created_connection(**kwargs) as connection: cursor = connection.cursor(**cursor_kwargs) try: yield cursor finally: cursor.close() class DBAPITestCase(DBAPITestCaseBase): def test_no_host_and_dsn(self): with self.assertRaises(ValueError) as e: self.create_connection(host=None) self.assertEqual(str(e.exception), 'host or dsn is required') def test_simple(self): with self.created_connection() as connection: cursor = connection.cursor() rv = cursor.execute('SELECT 1') self.assertIsNone(rv) self.assertEqual(cursor.fetchall(), [(1, )]) def test_from_dsn(self): connection = connect( 'clickhouse://{user}:{password}@{host}:{port}/{database}'.format( user=self.user, password=self.password, host=self.host, port=self.port, database=self.database ) ) cursor = connection.cursor() rv = cursor.execute('SELECT 1') self.assertIsNone(rv) self.assertEqual(cursor.fetchall(), [(1, )]) connection.close() def test_connect_default_params(self): connection = connect(host=self.host) cursor = connection.cursor() rv = cursor.execute('SELECT 1') self.assertIsNone(rv) self.assertEqual(cursor.fetchall(), [(1, )]) connection.close() def test_execute_fetchone(self): with self.created_cursor() as cursor: cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertIsInstance(cursor._rows, list) self.assertEqual(cursor.fetchone(), (0, )) self.assertEqual(cursor.fetchone(), (1, )) self.assertEqual(cursor.fetchone(), (2, )) self.assertEqual(cursor.fetchone(), (3, )) self.assertEqual(cursor.fetchone(), None) def test_execute_fetchmany(self): with self.created_cursor() as cursor: cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertIsInstance(cursor._rows, list) self.assertEqual(cursor.fetchmany(), [(0, )]) self.assertEqual(cursor.fetchmany(None), [(1, )]) self.assertEqual(cursor.fetchmany(0), []) self.assertEqual(cursor.fetchmany(-1), [(2, ), (3, )]) cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertEqual(cursor.fetchmany(1), [(0, )]) self.assertEqual(cursor.fetchmany(2), [(1, ), (2, )]) self.assertEqual(cursor.fetchmany(3), [(3, )]) self.assertEqual(cursor.fetchmany(3), []) cursor.arraysize = 2 cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertEqual(cursor.fetchmany(), [(0,), (1,)]) self.assertEqual(cursor.fetchmany(), [(2,), (3,)]) def test_execute_fetchall(self): with self.created_cursor() as cursor: cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertEqual(cursor.rowcount, 4) self.assertEqual(cursor.fetchall(), [(0,), (1,), (2,), (3,)]) def test_executemany(self): with self.created_cursor() as cursor, self.create_table('a UInt32'): data = [(0, ), (1, ), (2, )] rv = cursor.executemany('INSERT INTO test VALUES', data) self.assertIsNone(rv, None) self.assertEqual(cursor.rowcount, 3) cursor.execute('SELECT * FROM test') self.assertEqual(cursor.fetchall(), data) def test_fake_transactions(self): with self.created_connection() as connection: connection.commit() connection.rollback() def test_exception_execute(self): with self.created_cursor(user='wrong_user') as cursor: with self.assertRaises(OperationalError) as e: cursor.execute('SELECT 1') code = 516 if self.server_version > (20, ) else 192 self.assertIn('Code: {}'.format(code), str(e.exception)) def test_exception_executemany(self): with self.created_cursor(user='wrong_user') as cursor: with self.assertRaises(OperationalError) as e: cursor.executemany('INSERT INTO test VALUES', [(0, )]) code = 516 if self.server_version > (20, ) else 192 self.assertIn('Code: {}'.format(code), str(e.exception)) self.assertEqual(cursor.rowcount, -1) def test_rowcount_insert_from_select(self): with self.created_cursor() as cursor, self.create_table('a UInt8'): cursor.execute( 'INSERT INTO test ' 'SELECT number FROM system.numbers LIMIT 4' ) self.assertEqual(cursor.rowcount, -1) def test_execute_insert(self): with self.created_cursor() as cursor, self.create_table('a UInt8'): cursor.execute('INSERT INTO test VALUES', [[4]]) self.assertEqual(cursor.rowcount, 1) def test_description(self): with self.created_cursor() as cursor: self.assertIsNone(cursor.description) cursor.execute('SELECT CAST(1 AS UInt32) AS test') desc = cursor.description self.assertEqual(len(desc), 1) self.assertEqual(desc[0].name, 'test') self.assertEqual(desc[0].type_code, 'UInt32') def test_pep249_sizes(self): with self.created_cursor() as cursor: cursor.setinputsizes(0) cursor.setoutputsize(0) def test_ddl(self): with self.created_cursor() as cursor: cursor.execute('DROP TABLE IF EXISTS test') self.assertEqual(cursor.fetchall(), []) self.assertEqual(cursor.rowcount, -1) def test_remember_last_host(self): self.n_calls = 0 getaddrinfo = socket.getaddrinfo def side_getaddrinfo(host, *args, **kwargs): if host == 'wrong_host': self.n_calls += 1 raise socket.error(-2, 'Name or service not known') return getaddrinfo(host, *args, **kwargs) with patch('socket.getaddrinfo') as mocked_getaddrinfo: mocked_getaddrinfo.side_effect = side_getaddrinfo conn_kwargs = { 'host': 'wrong_host', 'port': 1234, 'alt_hosts': '{}:{}'.format(self.host, self.port) } with self.created_connection(**conn_kwargs) as connection: cursor = connection.cursor() cursor.execute('SELECT 1') self.assertEqual(cursor.fetchall(), [(1, )]) cursor.close() cursor = connection.cursor() cursor.execute('SELECT 1') self.assertEqual(cursor.fetchall(), [(1, )]) cursor.close() # Last host must be remembered and getaddrinfo must call exactly # once with host == 'wrong_host'. self.assertEqual(self.n_calls, 1) def test_remove_cursor_from_connection_on_closing(self): with self.created_connection() as connection: self.assertEqual(len(connection.cursors), 0) cur = connection.cursor() self.assertEqual(len(connection.cursors), 1) cur.close() self.assertEqual(len(connection.cursors), 0) class StreamingTestCase(DBAPITestCaseBase): def test_fetchone(self): with self.created_cursor() as cursor: cursor.set_stream_results(True, 2) cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertIsInstance(cursor._rows, types.GeneratorType) self.assertEqual(cursor.fetchone(), (0, )) self.assertEqual(cursor.fetchone(), (1, )) self.assertEqual(cursor.fetchone(), (2, )) self.assertEqual(cursor.fetchone(), (3, )) self.assertEqual(cursor.fetchone(), None) def test_fetchmany(self): with self.created_cursor() as cursor: cursor.set_stream_results(True, 2) cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertIsInstance(cursor._rows, types.GeneratorType) self.assertEqual(cursor.fetchmany(), [(0, )]) self.assertEqual(cursor.fetchmany(None), [(1, )]) self.assertEqual(cursor.fetchmany(0), []) self.assertEqual(cursor.fetchmany(-1), [(2, ), (3, )]) cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertEqual(cursor.fetchmany(1), [(0, )]) self.assertEqual(cursor.fetchmany(2), [(1, ), (2, )]) self.assertEqual(cursor.fetchmany(3), [(3, )]) self.assertEqual(cursor.fetchmany(3), []) def test_fetchall(self): with self.created_cursor() as cursor: cursor.set_stream_results(True, 2) cursor.execute('SELECT number FROM system.numbers LIMIT 4') # Check rowcount before and after fetch. self.assertEqual(cursor.rowcount, -1) self.assertEqual(cursor.fetchall(), [(0, ), (1, ), (2, ), (3, )]) self.assertEqual(cursor.rowcount, -1) class ReprTestCase(DBAPITestCaseBase): def test_cursor_repr(self): with self.created_cursor() as cursor: self.assertIn('closed: False', str(cursor)) def test_connection_repr(self): with self.created_connection() as conn: self.assertIn('closed: False', str(conn)) class ExtrasTestCase(DBAPITestCaseBase): def test_columns_with_types_select(self): with self.created_cursor() as cursor: self.assertIsNone(cursor.columns_with_types) cursor.execute( 'SELECT CAST(number AS UInt64) AS x ' 'FROM system.numbers LIMIT 4' ) cursor.fetchall() self.assertEqual(cursor.columns_with_types, [('x', 'UInt64')]) def test_columns_with_types_insert(self): with self.created_cursor() as cursor, self.create_table('a UInt8'): cursor.executemany('INSERT INTO test (a) VALUES', [(123, )]) self.assertIsNone(cursor.columns_with_types) def test_columns_with_types_streaming(self): with self.created_cursor() as cursor: cursor.set_stream_results(True, 2) cursor.execute( 'SELECT CAST(number AS UInt64) AS x ' 'FROM system.numbers LIMIT 4' ) self.assertEqual(cursor.columns_with_types, [('x', 'UInt64')]) list(cursor) self.assertEqual(cursor.columns_with_types, [('x', 'UInt64')]) def test_set_external_tables(self): with self.created_cursor() as cursor: data = [(0, ), (1, ), (2, )] cursor.set_external_table('table1', [('x', 'UInt32')], data) cursor.execute('SELECT * FROM table1') self.assertEqual(cursor.fetchall(), data) def test_settings(self): with self.created_cursor() as cursor: cursor.set_settings({'max_threads': 42}) cursor.execute( "SELECT name, value, changed FROM system.settings " "WHERE name = 'max_threads'", ) self.assertEqual(cursor.fetchall(), [('max_threads', '42', 1)]) def test_set_query_id(self): with self.created_cursor() as cursor: query_id = 'my_query_id' cursor.set_query_id(query_id) cursor.execute( 'SELECT query_id ' 'FROM system.processes ' 'WHERE query_id = %(query_id)s', {'query_id': query_id} ) self.assertEqual(cursor.fetchall(), [(query_id, )]) def test_types_check(self): with self.created_cursor() as cursor, self.create_table('a UInt8'): cursor.set_types_check(True) data = [(300, )] cursor.executemany('INSERT INTO test (a) VALUES', data) cursor.execute('SELECT * FROM test') self.assertEqual(cursor.fetchall(), [(44, )]) def test_cursor_iteration(self): with self.created_cursor() as cursor: cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertEqual(list(cursor), [(0,), (1,), (2,), (3,)]) def test_context_managers(self): with self.create_connection() as connection: with connection.cursor() as cursor: cursor.execute('SELECT 1') self.assertEqual(cursor.fetchall(), [(1, )]) class InterfaceTestCase(DBAPITestCaseBase): def test_execute_after_close(self): with self.created_cursor() as cursor: cursor.close() with self.assertRaises(InterfaceError) as e: cursor.execute('SELECT 1') self.assertEqual(str(e.exception), 'cursor already closed') def test_create_cursor_on_closed_connection(self): connection = self.create_connection() connection.close() with self.assertRaises(InterfaceError) as e: connection.cursor() self.assertEqual(str(e.exception), 'connection already closed') def test_execute_fetch_before_query(self): with self.created_cursor() as cursor: with self.assertRaises(ProgrammingError) as e: cursor.fetchall() self.assertEqual(str(e.exception), 'no results to fetch') class DictCursorFactoryTestCase(DBAPITestCaseBase): def test_execute_fetchone(self): cursor_kwargs = {'cursor_factory': DictCursor} with self.created_cursor(cursor_kwargs=cursor_kwargs) as cursor: cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertIsInstance(cursor._rows, list) self.assertEqual(cursor.fetchone(), {'number': 0}) self.assertEqual(cursor.fetchone(), {'number': 1}) self.assertEqual(cursor.fetchone(), {'number': 2}) self.assertEqual(cursor.fetchone(), {'number': 3}) self.assertEqual(cursor.fetchone(), None) def test_execute_fetchmany(self): cursor_kwargs = {'cursor_factory': DictCursor} with self.created_cursor(cursor_kwargs=cursor_kwargs) as cursor: cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertIsInstance(cursor._rows, list) self.assertEqual(cursor.fetchmany(), [{'number': 0}]) self.assertEqual(cursor.fetchmany(None), [{'number': 1}]) self.assertEqual(cursor.fetchmany(0), []) self.assertEqual( cursor.fetchmany(-1), [{'number': 2}, {'number': 3}] ) cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertEqual(cursor.fetchmany(1), [{'number': 0}]) self.assertEqual( cursor.fetchmany(2), [{'number': 1}, {'number': 2}] ) self.assertEqual(cursor.fetchmany(3), [{'number': 3}]) self.assertEqual(cursor.fetchmany(3), []) cursor.arraysize = 2 cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertEqual( cursor.fetchmany(), [{'number': 0}, {'number': 1}]) self.assertEqual( cursor.fetchmany(), [{'number': 2}, {'number': 3}] ) def test_execute_fetchall(self): cursor_kwargs = {'cursor_factory': DictCursor} with self.created_cursor(cursor_kwargs=cursor_kwargs) as cursor: cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertEqual(cursor.rowcount, 4) self.assertEqual( cursor.fetchall(), [ {'number': 0}, {'number': 1}, {'number': 2}, {'number': 3} ]) class NamedTupleCursorFactoryTestCase(DBAPITestCaseBase): def test_execute_fetchone(self): cursor_kwargs = {'cursor_factory': NamedTupleCursor} with self.created_cursor(cursor_kwargs=cursor_kwargs) as cursor: cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertIsInstance(cursor._rows, list) nt = namedtuple('Record', cursor._columns) self.assertEqual(cursor.fetchone(), nt(0)) self.assertEqual(cursor.fetchone(), nt(1)) self.assertEqual(cursor.fetchone(), nt(2)) self.assertEqual(cursor.fetchone(), nt(3)) self.assertEqual(cursor.fetchone(), None) def test_execute_fetchmany(self): cursor_kwargs = {'cursor_factory': NamedTupleCursor} with self.created_cursor(cursor_kwargs=cursor_kwargs) as cursor: cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertIsInstance(cursor._rows, list) nt = namedtuple('Record', cursor._columns) self.assertEqual(cursor.fetchmany(), [nt(0)]) self.assertEqual(cursor.fetchmany(None), [nt(1)]) self.assertEqual(cursor.fetchmany(0), []) self.assertEqual(cursor.fetchmany(-1), [nt(2), nt(3)]) cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertEqual(cursor.fetchmany(1), [nt(0)]) self.assertEqual(cursor.fetchmany(2), [nt(1), nt(2)]) self.assertEqual(cursor.fetchmany(3), [nt(3)]) self.assertEqual(cursor.fetchmany(3), []) cursor.arraysize = 2 cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertEqual(cursor.fetchmany(), [nt(0), nt(1)]) self.assertEqual(cursor.fetchmany(), [nt(2), nt(3)]) def test_execute_fetchall(self): cursor_kwargs = {'cursor_factory': NamedTupleCursor} with self.created_cursor(cursor_kwargs=cursor_kwargs) as cursor: cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertEqual(cursor.rowcount, 4) nt = namedtuple('Record', cursor._columns) self.assertEqual(cursor.fetchall(), [nt(0), nt(1), nt(2), nt(3)]) def test_make_nt_caching(self): cursor_kwargs = {'cursor_factory': NamedTupleCursor} with self.created_cursor(cursor_kwargs=cursor_kwargs) as cursor: cursor.execute('SELECT number FROM system.numbers LIMIT 4') self.assertIsInstance(cursor._rows, list) nt = namedtuple('Record', cursor._columns) self.assertEqual(cursor.fetchone(), nt(0)) with patch('clickhouse_driver.dbapi.extras.namedtuple') as nt_mock: nt_mock.side_effect = ValueError self.assertEqual(cursor.fetchone(), nt(1)) clickhouse-driver-0.2.11/tests/test_errors.py000066400000000000000000000006541522645447600213300ustar00rootroot00000000000000import pickle import clickhouse_driver.errors as err def picklable(o): picked = pickle.loads(pickle.dumps(o)) assert repr(o) == repr(picked) assert str(o) == str(picked) def test_exception_picklable(): picklable(err.Error('foo')) picklable(err.Error(message='foo')) picklable(err.ServerException('foo', 0, Exception())) picklable(err.ServerException(message='foo', code=0, nested=Exception())) clickhouse-driver-0.2.11/tests/test_external_tables.py000066400000000000000000000022031522645447600231600ustar00rootroot00000000000000 from tests.testcase import BaseTestCase class ExternalTablesTestCase(BaseTestCase): def test_select(self): tables = [{ 'name': 'test', 'structure': [('x', 'Int32'), ('y', 'Array(Int32)')], 'data': [ {'x': 100, 'y': [2, 4, 6, 8]}, {'x': 500, 'y': [1, 3, 5, 7]}, ] }] rv = self.client.execute('SELECT * FROM test', external_tables=tables) self.assertEqual(rv, [(100, [2, 4, 6, 8]), (500, [1, 3, 5, 7])]) def test_send_empty_table(self): tables = [{ 'name': 'test', 'structure': [('x', 'Int32')], 'data': [] }] rv = self.client.execute('SELECT * FROM test', external_tables=tables) self.assertEqual(rv, []) def test_send_empty_table_structure(self): tables = [{ 'name': 'test', 'structure': [], 'data': [] }] with self.assertRaises(ValueError) as e: self.client.execute('SELECT * FROM test', external_tables=tables) self.assertIn('Empty table "test" structure', str(e.exception)) clickhouse-driver-0.2.11/tests/test_insert.py000066400000000000000000000213411522645447600213140ustar00rootroot00000000000000from datetime import date from tests.testcase import BaseTestCase from clickhouse_driver import errors from clickhouse_driver.errors import ServerException from tests.util import require_server_version class InsertTestCase(BaseTestCase): def test_type_mismatch(self): with self.create_table('a Float32'): with self.assertRaises(errors.TypeMismatchError): data = [(date(2012, 10, 25), )] self.client.execute( 'INSERT INTO test (a) VALUES', data ) def test_no_such_column(self): with self.create_table('a Float32'): with self.assertRaises(ServerException): data = [(1, )] self.client.execute( 'INSERT INTO test (b) VALUES', data ) def test_data_malformed_rows(self): with self.create_table('a Int8'), self.assertRaises(TypeError): data = [1] self.client.execute( 'INSERT INTO test (a) VALUES', data ) def test_data_less_columns_then_expected(self): with self.create_table('a Int8, b Int8'): with self.assertRaises(ValueError) as e: data = [(1, )] self.client.execute( 'INSERT INTO test (a, b) VALUES', data ) self.assertEqual(str(e.exception), 'Expected 2 columns, got 1') def test_data_more_columns_then_expected(self): with self.create_table('a Int8, b Int8'): with self.assertRaises(ValueError) as e: data = [(1, 2, 3)] self.client.execute( 'INSERT INTO test (a, b) VALUES', data ) self.assertEqual(str(e.exception), 'Expected 2 columns, got 3') def test_data_different_rows_length(self): with self.create_table('a Int8, b Int8'): with self.assertRaises(ValueError) as e: data = [(1, 2), (3, )] self.client.execute( 'INSERT INTO test (a, b) VALUES', data ) self.assertEqual(str(e.exception), 'Different rows length') def test_data_different_rows_length_from_dicts(self): with self.create_table('a Int8, b Int8'): with self.assertRaises(KeyError): data = [{'a': 1, 'b': 2}, {'a': 3}] self.client.execute( 'INSERT INTO test (a, b) VALUES', data ) def test_data_unsupported_row_type(self): with self.create_table('a Int8'): with self.assertRaises(TypeError) as e: data = [1] self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) self.assertIn('dict, list or tuple is expected', str(e.exception)) def test_data_dicts_ok(self): with self.create_table('a Int8, b Int8'): data = [{'a': 1, 'b': 2}, {'a': 3, 'b': 4}] self.client.execute( 'INSERT INTO test (a, b) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '1\t2\n3\t4\n') inserted = self.client.execute(query) self.assertEqual(inserted, [(1, 2), (3, 4)]) def test_data_generator_type(self): with self.create_table('a Int8'): data = ((x, ) for x in range(3)) self.client.execute( 'INSERT INTO test (a) VALUES', data ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '0\n1\n2\n') inserted = self.client.execute(query) self.assertEqual(inserted, [(0,), (1, ), (2, )]) def test_data_dicts_mixed_with_lists(self): with self.create_table('a Int8'): with self.assertRaises(TypeError) as e: data = [{'a': 1}, (2, )] self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) self.assertIn('dict is expected', str(e.exception)) with self.assertRaises(TypeError) as e: data = [(1, ), {'a': 2}] self.client.execute( 'INSERT INTO test (a) VALUES', data, types_check=True ) self.assertIn('list or tuple is expected', str(e.exception)) def test_empty_insert(self): with self.create_table('a Int8'): self.client.execute( 'INSERT INTO test (a) VALUES', [] ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '') inserted = self.client.execute(query) self.assertEqual(inserted, []) def test_insert_from_select(self): with self.create_table('a UInt64'): inserted = self.client.execute( 'INSERT INTO test (a) ' 'SELECT number FROM system.numbers LIMIT 5' ) self.assertEqual(inserted, []) def test_insert_return(self): with self.create_table('a Int8'): rv = self.client.execute( 'INSERT INTO test (a) VALUES', [] ) self.assertEqual(rv, 0) rv = self.client.execute( 'INSERT INTO test (a) VALUES', [(x,) for x in range(5)] ) self.assertEqual(rv, 5) @require_server_version(22, 3, 6) def test_insert_from_input(self): with self.create_table('a Int8'): data = [{'a': 1}] self.client.execute( "INSERT INTO test (a) " "SELECT a FROM input ('a Int8') FORMAT Native", data, settings={'session_timezone': 'UTC'} ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '1\n') def test_profile_events(self): with self.create_table('x Int32'): data = [{'x': 1}] self.client.execute( 'INSERT INTO test (x) VALUES', data ) class InsertColumnarTestCase(BaseTestCase): def test_insert_tuple_ok(self): with self.create_table('a Int8, b Int8'): data = [(1, 2, 3), (4, 5, 6)] self.client.execute( 'INSERT INTO test (a, b) VALUES', data, columnar=True ) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, '1\t4\n2\t5\n3\t6\n') inserted = self.client.execute(query) self.assertEqual(inserted, [(1, 4), (2, 5), (3, 6)]) inserted = self.client.execute(query, columnar=True) self.assertEqual(inserted, [(1, 2, 3), (4, 5, 6)]) def test_insert_data_different_column_length(self): with self.create_table('a Int8, b Int8'): with self.assertRaises(ValueError) as e: data = [(1, 2, 3), (4, 5)] self.client.execute( 'INSERT INTO test (a, b) VALUES', data, columnar=True ) self.assertEqual(str(e.exception), 'Expected 3 rows, got 2') def test_data_less_columns_then_expected(self): with self.create_table('a Int8, b Int8'): with self.assertRaises(ValueError) as e: data = [(1, 2)] self.client.execute( 'INSERT INTO test (a, b) VALUES', data, columnar=True ) self.assertEqual(str(e.exception), 'Expected 2 columns, got 1') def test_data_more_columns_then_expected(self): with self.create_table('a Int8, b Int8'): with self.assertRaises(ValueError) as e: data = [(1, 2), (3, 4), (5, 6)] self.client.execute( 'INSERT INTO test (a, b) VALUES', data, columnar=True ) self.assertEqual(str(e.exception), 'Expected 2 columns, got 3') def test_data_invalid_types(self): with self.create_table('a Int8, b Int8'): with self.assertRaises(TypeError) as e: data = [(1, 2), {'a': 3, 'b': 4}] self.client.execute( 'INSERT INTO test (a, b) VALUES', data, types_check=True, columnar=True ) self.assertIn('list or tuple is expected', str(e.exception)) with self.assertRaises(TypeError) as e: data = [(1, 2), 3] self.client.execute( 'INSERT INTO test (a, b) VALUES', data, types_check=True, columnar=True ) self.assertIn('list or tuple is expected', str(e.exception)) clickhouse-driver-0.2.11/tests/test_opentelemetry.py000066400000000000000000000065671522645447600227210ustar00rootroot00000000000000from tests.testcase import BaseTestCase from tests.util import capture_logging class OpenTelemetryTestCase(BaseTestCase): required_server_version = (20, 11, 2) def test_server_logs(self): tracestate = 'tracestate' traceparent = '00-1af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01' settings = { 'opentelemetry_tracestate': tracestate, 'opentelemetry_traceparent': traceparent } with self.created_client(settings=settings) as client: with capture_logging('clickhouse_driver.log', 'INFO') as buffer: settings = {'send_logs_level': 'trace'} query = 'SELECT 1' client.execute(query, settings=settings) value = buffer.getvalue() self.assertIn('OpenTelemetry', value) # ClickHouse 22.2+ use big-endian: # https://github.com/ClickHouse/ClickHouse/pull/33723 if self.server_version >= (22, 2): tp = '8448eb211c80319c1af7651916cd43dd' else: tp = '1af7651916cd43dd8448eb211c80319c' self.assertIn(tp, value) def test_no_tracestate(self): traceparent = '00-1af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01' settings = { 'opentelemetry_traceparent': traceparent } with self.created_client(settings=settings) as client: with capture_logging('clickhouse_driver.log', 'INFO') as buffer: settings = {'send_logs_level': 'trace'} query = 'SELECT 1' client.execute(query, settings=settings) value = buffer.getvalue() self.assertIn('OpenTelemetry', value) # ClickHouse 22.2+ use big-endian: # https://github.com/ClickHouse/ClickHouse/pull/33723 if self.server_version >= (22, 2): tp = '8448eb211c80319c1af7651916cd43dd' else: tp = '1af7651916cd43dd8448eb211c80319c' self.assertIn(tp, value) def test_bad_traceparent(self): settings = {'opentelemetry_traceparent': 'bad'} with self.created_client(settings=settings) as client: with self.assertRaises(ValueError) as e: client.execute('SELECT 1') self.assertEqual( str(e.exception), 'unexpected length 3, expected 55' ) traceparent = '00-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-yyyyyyyyyyyyyyyy-01' settings = {'opentelemetry_traceparent': traceparent} with self.created_client(settings=settings) as client: with self.assertRaises(ValueError) as e: client.execute('SELECT 1') self.assertEqual( str(e.exception), 'Malformed traceparant header: {}'.format(traceparent) ) def test_bad_traceparent_version(self): settings = { 'opentelemetry_traceparent': '01-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-01' } with self.created_client(settings=settings) as client: with self.assertRaises(ValueError) as e: client.execute('SELECT 1') self.assertEqual( str(e.exception), 'unexpected version 01, expected 00' ) clickhouse-driver-0.2.11/tests/test_query_info.py000066400000000000000000000154271522645447600222000ustar00rootroot00000000000000from contextlib import contextmanager from clickhouse_driver import errors from tests.testcase import BaseTestCase class QueryInfoTestCase(BaseTestCase): @property def sample_query(self): return 'SELECT * FROM test GROUP BY foo ORDER BY foo DESC LIMIT 5' @contextmanager def sample_table(self): with self.create_table('foo UInt8'): self.client.execute('INSERT INTO test (foo) VALUES', [(i,) for i in range(42)]) self.client.reset_last_query() yield def test_default_value(self): self.assertIsNone(self.client.last_query) def test_store_last_query_after_execute(self): with self.sample_table(): self.client.execute(self.sample_query) last_query = self.client.last_query self.assertIsNotNone(last_query) self.assertIsNotNone(last_query.profile_info) self.assertEqual(last_query.profile_info.rows_before_limit, 42) self.assertIsNotNone(last_query.progress) self.assertEqual(last_query.progress.rows, 42) self.assertEqual(last_query.progress.bytes, 42) # CH 25 fills total_rows with the actual row count; # earlier versions left it at 0. expected_total_rows = 42 if self.server_version >= (25,) else 0 self.assertEqual( last_query.progress.total_rows, expected_total_rows) if self.server_version > (22, 8): self.assertGreater(last_query.progress.elapsed_ns, 0) self.assertGreater(last_query.elapsed, 0) def test_last_query_after_execute_iter(self): with self.sample_table(): list(self.client.execute_iter(self.sample_query)) last_query = self.client.last_query self.assertIsNotNone(last_query) self.assertIsNotNone(last_query.profile_info) self.assertEqual(last_query.profile_info.rows_before_limit, 42) self.assertIsNotNone(last_query.progress) self.assertEqual(last_query.progress.rows, 42) self.assertEqual(last_query.progress.bytes, 42) # CH 25 fills total_rows with the actual row count; # earlier versions left it at 0. expected_total_rows = 42 if self.server_version >= (25,) else 0 self.assertEqual( last_query.progress.total_rows, expected_total_rows) if self.server_version > (22, 8): self.assertGreater(last_query.progress.elapsed_ns, 0) self.assertEqual(last_query.elapsed, 0) def test_last_query_after_execute_with_progress(self): with self.sample_table(): progress = self.client.execute_with_progress(self.sample_query) list(progress) progress.get_result() last_query = self.client.last_query self.assertIsNotNone(last_query) self.assertIsNotNone(last_query.profile_info) self.assertEqual(last_query.profile_info.rows_before_limit, 42) self.assertIsNotNone(last_query.progress) self.assertEqual(last_query.progress.rows, 42) self.assertEqual(last_query.progress.bytes, 42) # CH 25 fills total_rows with the actual row count; # earlier versions left it at 0. expected_total_rows = 42 if self.server_version >= (25,) else 0 self.assertEqual( last_query.progress.total_rows, expected_total_rows) if self.server_version > (22, 8): self.assertGreater(last_query.progress.elapsed_ns, 0) self.assertEqual(last_query.elapsed, 0) def test_last_query_progress_total_rows(self): self.client.execute('SELECT number FROM numbers(10) LIMIT 10') last_query = self.client.last_query self.assertIsNotNone(last_query) self.assertIsNotNone(last_query.profile_info) self.assertEqual(last_query.profile_info.rows_before_limit, 10) self.assertIsNotNone(last_query.progress) self.assertEqual(last_query.progress.rows, 10) self.assertEqual(last_query.progress.bytes, 80) total_rows = 10 if self.server_version > (19, 4) else 0 self.assertEqual(last_query.progress.total_rows, total_rows) if self.server_version > (22, 8): self.assertGreater(last_query.progress.elapsed_ns, 0) self.assertGreater(last_query.elapsed, 0) def test_last_query_after_execute_insert(self): with self.sample_table(): self.client.execute('INSERT INTO test (foo) VALUES', [(i,) for i in range(42)]) last_query = self.client.last_query self.assertIsNotNone(last_query) self.assertIsNotNone(last_query.progress) self.assertEqual(last_query.progress.rows, 0) self.assertEqual(last_query.progress.bytes, 0) if self.server_version > (22, 8): self.assertEqual(last_query.progress.elapsed_ns, 0) self.assertGreater(last_query.elapsed, 0) def test_override_after_subsequent_queries(self): query = 'SELECT * FROM test WHERE foo < %(i)s ORDER BY foo LIMIT 5' with self.sample_table(): for i in range(1, 10): self.client.execute(query, {'i': i}) profile_info = self.client.last_query.profile_info self.assertEqual(profile_info.rows_before_limit, i) def test_reset_last_query(self): with self.sample_table(): self.client.execute(self.sample_query) self.assertIsNotNone(self.client.last_query) self.client.reset_last_query() self.assertIsNone(self.client.last_query) def test_reset_on_query_error(self): with self.assertRaises(errors.ServerException): self.client.execute('SELECT answer FROM universe') self.assertIsNone(self.client.last_query) def test_progress_info_increment(self): self.client.execute( 'SELECT x FROM (' 'SELECT number AS x FROM numbers(100000000)' ') ORDER BY x ASC LIMIT 10' ) last_query = self.client.last_query self.assertIsNotNone(last_query) self.assertIsNotNone(last_query.progress) self.assertGreaterEqual(last_query.progress.rows, 100000000) self.assertGreaterEqual(last_query.progress.bytes, 800000000) total_rows = 100000000 if self.server_version > (19, 4) else 0 self.assertEqual(last_query.progress.total_rows, total_rows) def test_progress_info_ddl(self): self.client.execute('DROP TABLE IF EXISTS foo') last_query = self.client.last_query self.assertIsNotNone(last_query) self.assertIsNotNone(last_query.progress) self.assertEqual(last_query.progress.rows, 0) self.assertEqual(last_query.progress.bytes, 0) if self.server_version > (22, 8): self.assertEqual(last_query.progress.elapsed_ns, 0) self.assertGreater(last_query.elapsed, 0) clickhouse-driver-0.2.11/tests/test_settings.py000066400000000000000000000142611522645447600216530ustar00rootroot00000000000000from parameterized import parameterized from clickhouse_driver.errors import ServerException, ErrorCodes from tests.testcase import BaseTestCase from tests.util import require_server_version class SettingTestCase(BaseTestCase): def test_settings_immutable(self): settings = {'strings_encoding': 'utf-8'} self.client.execute('SELECT 1', settings=settings) self.assertEqual(settings, {'strings_encoding': 'utf-8'}) def test_int_apply(self): settings = {'max_query_size': 142} rv = self.client.execute( "SELECT name, value, changed FROM system.settings " "WHERE name = 'max_query_size'", settings=settings ) self.assertEqual(rv, [('max_query_size', '142', 1)]) def test_float_apply(self): settings = {'totals_auto_threshold': 1.23} rv = self.client.execute( "SELECT name, value, changed FROM system.settings " "WHERE name = 'totals_auto_threshold'", settings=settings ) self.assertEqual(rv, [('totals_auto_threshold', '1.23', 1)]) def test_bool_apply(self): settings = {'force_index_by_date': 1} rv = self.client.execute( "SELECT name, value, changed FROM system.settings " "WHERE name = 'force_index_by_date'", settings=settings ) self.assertEqual(rv, [('force_index_by_date', '1', 1)]) @require_server_version(1, 1, 54388) def test_char_apply(self): settings = {'format_csv_delimiter': 'd'} rv = self.client.execute( "SELECT name, value, changed FROM system.settings " "WHERE name = 'format_csv_delimiter'", settings=settings ) self.assertEqual(rv, [('format_csv_delimiter', 'd', 1)]) def test_max_threads_apply(self): settings = {'max_threads': 42} rv = self.client.execute( "SELECT name, value, changed FROM system.settings " "WHERE name = 'max_threads'", settings=settings ) self.assertEqual(rv, [('max_threads', '42', 1)]) settings = {'max_threads': 'auto'} self.client.execute( "SELECT name, value, changed FROM system.settings " "WHERE name = 'max_threads'", settings=settings ) def test_unknown_setting(self): # For both cases unknown setting will be ignored: # - rev >= DBMS_MIN_REVISION_WITH_SETTINGS_SERIALIZED_AS_STRINGS # the setting will be ignored by the server with the warning message # (since clickhouse-server does not ignore only important settings, # the one that has important flag) # - otherwise the unknown setting will be ignored by the driver. settings = {'unknown_setting': 100500} self.client.execute('SELECT 1', settings=settings) # DBMS_MIN_REVISION_WITH_SETTINGS_SERIALIZED_AS_STRINGS is 20.1.2+ @require_server_version(20, 1, 2) def test_unknown_setting_is_important(self): # In case of rev >= # DBMS_MIN_REVISION_WITH_SETTINGS_SERIALIZED_AS_STRINGS and setting # marked as important, then the query should fail. settings = {'unknown_setting': 100500} with self.created_client(settings_is_important=True) as client: with self.assertRaises(ServerException) as e: client.execute('SELECT 1', settings=settings) self.assertEqual(e.exception.code, ErrorCodes.UNKNOWN_SETTING) def test_client_settings(self): settings = {'max_query_size': 142} with self.created_client(settings=settings) as client: rv = client.execute( "SELECT name, value, changed FROM system.settings " "WHERE name = 'max_query_size'" ) self.assertEqual(rv, [('max_query_size', '142', 1)]) def test_query_settings_override_client_settings(self): client_settings = {'max_query_size': 142} query_settings = {'max_query_size': 242} with self.created_client(settings=client_settings) as client: rv = client.execute( "SELECT name, value, changed FROM system.settings " "WHERE name = 'max_query_size'", settings=query_settings ) self.assertEqual(rv, [('max_query_size', '242', 1)]) class InputFormatNullTestCase(BaseTestCase): # Min stable map version required_server_version = (21, 8, 1) @parameterized.expand([ ('a Int8, b String', [(None, None)], [(0, '')], '0\t\n'), ('a LowCardinality(String)', [(None, )], [('', )], '\n'), ('a Tuple(Int32, Int32)', [(None,)], [((0, 0), )], '(0,0)\n'), ('a Array(Array(Int32))', [(None,)], [([],)], '[]\n'), ('a Map(String, UInt64)', [(None,)], [({},)], '{}\n'), ('a Nested(i Int32)', [(None, )], [([], )], '[]\n') ]) def test_input_format_null_as_default(self, spec, data, res, cli_res): client_settings = {'input_format_null_as_default': True} with self.created_client(settings=client_settings) as client: with self.create_table(spec): client.execute('INSERT INTO test VALUES', data) query = 'SELECT * FROM test' inserted = self.emit_cli(query) self.assertEqual(inserted, cli_res) inserted = client.execute(query) self.assertEqual(inserted, res) class LimitsTestCase(BaseTestCase): def test_max_result_rows_apply(self): query = 'SELECT number FROM system.numbers LIMIT 10' settings = {'max_result_rows': 5} with self.assertRaises(ServerException) as e: self.client.execute(query, settings=settings) # New servers return TOO_MANY_ROWS_OR_BYTES. # Old servers return TOO_MANY_ROWS. error_codes = { ErrorCodes.TOO_MANY_ROWS_OR_BYTES, ErrorCodes.TOO_MANY_ROWS } self.assertIn(e.exception.code, error_codes) settings = {'max_result_rows': 5, 'result_overflow_mode': 'break'} rv = self.client.execute(query, settings=settings) self.assertEqual(len(rv), 10) rv = self.client.execute(query) self.assertEqual(len(rv), 10) clickhouse-driver-0.2.11/tests/test_substitution.py000066400000000000000000000242151522645447600225670ustar00rootroot00000000000000# coding=utf-8 from __future__ import unicode_literals from datetime import date, datetime, time from decimal import Decimal from unittest.mock import Mock from uuid import UUID from enum import IntEnum, Enum from pytz import timezone from tests.testcase import BaseTestCase from tests.util import patch_env_tz class ParametersSubstitutionTestCase(BaseTestCase): single_tpl = 'SELECT %(x)s' double_tpl = 'SELECT %(x)s, %(y)s' def assert_subst(self, tpl, params, sql): ctx = Mock() ctx.server_info.get_timezone.return_value = 'Europe/Moscow' self.assertEqual(self.client.substitute_params(tpl, params, ctx), sql) def test_int(self): params = {'x': 123} self.assert_subst(self.single_tpl, params, 'SELECT 123') rv = self.client.execute(self.single_tpl, params) self.assertEqual(rv, [(123, )]) def test_null(self): params = {'x': None} self.assert_subst(self.single_tpl, params, 'SELECT NULL') rv = self.client.execute(self.single_tpl, params) self.assertEqual(rv, [(None, )]) def test_date(self): d = date(2017, 10, 16) params = {'x': d} self.assert_subst(self.single_tpl, params, "SELECT '2017-10-16'") rv = self.client.execute(self.single_tpl, params) self.assertEqual(rv, [('2017-10-16', )]) tpl = 'SELECT CAST(%(x)s AS Date)' self.assert_subst(tpl, params, "SELECT CAST('2017-10-16' AS Date)") rv = self.client.execute(tpl, params) self.assertEqual(rv, [(d, )]) def test_time(self): t = time(8, 20, 15) params = {'x': t} self.assert_subst(self.single_tpl, params, "SELECT '08:20:15'") rv = self.client.execute(self.single_tpl, params) self.assertEqual(rv, [('08:20:15', )]) def test_datetime(self): dt = datetime(2017, 10, 16, 0, 18, 50) params = {'x': dt} self.assert_subst(self.single_tpl, params, "SELECT '2017-10-16 00:18:50'") rv = self.client.execute(self.single_tpl, params) self.assertEqual(rv, [('2017-10-16 00:18:50', )]) tpl = 'SELECT CAST(%(x)s AS DateTime)' self.assert_subst(tpl, params, "SELECT CAST('2017-10-16 00:18:50' AS DateTime)") rv = self.client.execute(tpl, params) self.assertEqual(rv, [(dt, )]) def test_datetime_with_timezone(self): dt = datetime(2017, 7, 14, 5, 40, 0) params = {'x': timezone('Asia/Kamchatka').localize(dt)} self.assert_subst(self.single_tpl, params, "SELECT '2017-07-13 20:40:00'") tpl = ( 'SELECT toDateTime(toInt32(toDateTime(%(x)s))), ' 'toInt32(toDateTime(%(x)s))' ) with patch_env_tz('Asia/Novosibirsk'): # use server timezone rv = self.client.execute( tpl, params, settings={'use_client_time_zone': False} ) self.assertEqual( rv, [(datetime(2017, 7, 13, 20, 40, 0), 1499967600)] ) query = ( "SELECT " "toDateTime(toInt32(toDateTime('{0}', 'Asia/Kamchatka'))), " "toInt32(toDateTime('{0}', 'Asia/Kamchatka'))" ).format('2017-07-14 05:40:00') rv = self.emit_cli(query, use_client_time_zone=0) self.assertEqual(rv, '2017-07-13 20:40:00\t1499967600\n') # use client timezone rv = self.client.execute( tpl, params, settings={'use_client_time_zone': True} ) self.assertEqual( rv, [(datetime(2017, 7, 14, 0, 40, 0), 1499967600)] ) query = ( "SELECT " "toDateTime(toInt32(toDateTime('{0}', 'Asia/Kamchatka'))), " "toInt32(toDateTime('{0}', 'Asia/Kamchatka'))" ).format('2017-07-14 05:40:00') rv = self.emit_cli(query, use_client_time_zone=1) self.assertEqual(rv, '2017-07-14 00:40:00\t1499967600\n') def test_string(self): params = {'x': 'test\t\n\x16', 'y': 'теÑ�Ñ‚\t\n\x16'} self.assert_subst(self.double_tpl, params, "SELECT 'test\\t\\n\x16', 'теÑ�Ñ‚\\t\\n\x16'") rv = self.client.execute(self.double_tpl, params) self.assertEqual(rv, [('test\t\n\x16', 'теÑ�Ñ‚\t\n\x16')]) params = {'x': "'"} self.assert_subst(self.single_tpl, params, "SELECT '\\''") rv = self.client.execute(self.single_tpl, params) self.assertEqual(rv, [("'", )]) params = {'x': "\\"} self.assert_subst(self.single_tpl, params, "SELECT '\\\\'") rv = self.client.execute(self.single_tpl, params) self.assertEqual(rv, [("\\", )]) def test_array(self): params = {'x': [1, None, 2]} self.assert_subst(self.single_tpl, params, 'SELECT [1, NULL, 2]') rv = self.client.execute(self.single_tpl, params) self.assertEqual(rv, [([1, None, 2], )]) params = {'x': [[1, 2, 3], [4, 5], [6, 7]]} self.assert_subst(self.single_tpl, params, 'SELECT [[1, 2, 3], [4, 5], [6, 7]]') rv = self.client.execute(self.single_tpl, params) self.assertEqual(rv, [([[1, 2, 3], [4, 5], [6, 7]], )]) def test_tuple(self): params = {'x': (1, None, 2)} self.assert_subst('SELECT * FROM test WHERE a IN %(x)s', params, 'SELECT * FROM test WHERE a IN (1, NULL, 2)') with self.create_table('a Int32'): self.client.execute('INSERT INTO test (a) VALUES', [(1, )]) self.client.execute('INSERT INTO test (a) VALUES', [(2, )]) query = 'SELECT * FROM test WHERE a IN (1)' inserted = self.client.execute(query, columnar=True) self.assertEqual(inserted, [(1,)]) def test_enum(self): class A(IntEnum): hello = -1 world = 2 params = {'x': A.hello, 'y': A.world} self.assert_subst(self.double_tpl, params, 'SELECT -1, 2') rv = self.client.execute(self.double_tpl, params) self.assertEqual(rv, [(-1, 2)]) class A(Enum): hello = 'hello' world = 'world' params = {'x': A.hello, 'y': A.world} self.assert_subst(self.double_tpl, params, "SELECT 'hello', 'world'") rv = self.client.execute(self.double_tpl, params) self.assertEqual(rv, [('hello', 'world')]) def test_float(self): params = {'x': 1e-12, 'y': 123.45} self.assert_subst(self.double_tpl, params, 'SELECT 1e-12, 123.45') rv = self.client.execute(self.double_tpl, params) self.assertEqual(rv, [(params['x'], params['y'])]) def test_decimal(self): params = {'x': Decimal('1e-2'), 'y': Decimal('123.45')} self.assert_subst(self.double_tpl, params, 'SELECT 0.01, 123.45') rv = self.client.execute(self.double_tpl, params) self.assertEqual(rv, [(0.01, 123.45)]) def test_uuid(self): params = {'x': UUID('c0fcbba9-0752-44ed-a5d6-4dfb4342b89d')} self.assert_subst(self.single_tpl, params, "SELECT 'c0fcbba9-0752-44ed-a5d6-4dfb4342b89d'") rv = self.client.execute(self.single_tpl, params) self.assertEqual(rv, [('c0fcbba9-0752-44ed-a5d6-4dfb4342b89d', )]) def test_substitute_object(self): params = object() with self.assertRaises(ValueError) as e: self.client.substitute_params(self.single_tpl, params, Mock()) self.assertEqual(e.exception.args[0], 'Parameters are expected in dict form') class ServerSideParametersSubstitutionTestCase(BaseTestCase): required_server_version = (22, 8) client_kwargs = {'settings': {'server_side_params': True}} def test_int(self): rv = self.client.execute('SELECT {x:Int32}', {'x': 123}) self.assertEqual(rv, [(123, )]) def test_str(self): rv = self.client.execute('SELECT {x:Int32}', {'x': '123'}) self.assertEqual(rv, [(123, )]) def test_escaped_str(self): rv = self.client.execute( 'SELECT {x:String}, length({x:String})', {'x': '\t'} ) self.assertEqual(rv, [('\t', 1)]) rv = self.client.execute( 'SELECT {x:String}, length({x:String})', {'x': '\\'} ) self.assertEqual(rv, [('\\', 1)]) rv = self.client.execute( 'SELECT {x:String}, length({x:String})', {'x': "'"} ) self.assertEqual(rv, [("'", 1)]) def test_array(self): rv = self.client.execute( 'SELECT {x:Array(String)}', {'x': ['a', 'b', 'c']} ) self.assertEqual(rv, [(['a', 'b', 'c'], )]) rv = self.client.execute( 'SELECT {x:Array(UInt8)}', {'x': [1, 2, 3]} ) self.assertEqual(rv, [([1, 2, 3], )]) rv = self.client.execute('SELECT {x:Array(String)}', {'x': []}) self.assertEqual(rv, [([], )]) def test_array_escaped(self): rv = self.client.execute( 'SELECT {x:Array(String)}', {'x': ["a'b", 'c\\d', 'e\tf']} ) self.assertEqual(rv, [(["a'b", 'c\\d', 'e\tf'], )]) def test_array_nullable(self): rv = self.client.execute( 'SELECT {x:Array(Nullable(String))}', {'x': ['a', None]} ) self.assertEqual(rv, [(['a', None], )]) def test_tuple(self): rv = self.client.execute( 'SELECT {x:Tuple(UInt8, String)}', {'x': (1, 'a')} ) self.assertEqual(rv, [((1, 'a'), )]) def test_nested(self): rv = self.client.execute( 'SELECT {x:Array(Tuple(UInt8, String))}', {'x': [(1, 'a'), (2, 'b')]} ) self.assertEqual(rv, [([(1, 'a'), (2, 'b')], )]) rv = self.client.execute( 'SELECT {x:Array(Array(String))}', {'x': [["a'b"], []]} ) self.assertEqual(rv, [([["a'b"], []], )]) class NoServerSideParametersSubstitutionTestCase(BaseTestCase): def test_reserved_keywords(self): self.client.execute( 'SELECT * FROM system.events LIMIT %(limit)s OFFSET %(offset)s', {'limit': 20, 'offset': 30} ) clickhouse-driver-0.2.11/tests/test_util.py000066400000000000000000000003551522645447600207670ustar00rootroot00000000000000from clickhouse_driver.columns.util import get_inner_columns_with_types def test_get_inner_columns_with_types_empty_spaces(): assert ( get_inner_columns_with_types('\n test String\n ') == [('test', 'String')] ) clickhouse-driver-0.2.11/tests/test_varint.py000066400000000000000000000007451522645447600213200ustar00rootroot00000000000000from io import BytesIO from unittest import TestCase from clickhouse_driver.varint import read_varint, write_varint class VarIntTestCase(TestCase): def test_check_not_negative(self): n = 0x9FFFFFFF buf = BytesIO() write_varint(n, buf) val = buf.getvalue() self.assertEqual(b'\xFF\xFF\xFF\xFF\t', val) buf = BytesIO(val) buf.read_one = lambda: ord(buf.read(1)) m = read_varint(buf) self.assertEqual(m, n) clickhouse-driver-0.2.11/tests/testcase.py000066400000000000000000000075541522645447600205760ustar00rootroot00000000000000import configparser from contextlib import contextmanager import subprocess from unittest import TestCase from clickhouse_driver.client import Client from tests import log from tests.util import skip_by_server_version file_config = configparser.ConfigParser() file_config.read(['setup.cfg']) log.configure(file_config.get('log', 'level')) class BaseTestCase(TestCase): required_server_version = None server_version = None clickhouse_client_binary = file_config.get('db', 'client') host = file_config.get('db', 'host') port = file_config.getint('db', 'port') secure_port = file_config.getint('db', 'secure_port') database = file_config.get('db', 'database') user = file_config.get('db', 'user') password = file_config.get('db', 'password') client = None client_kwargs = None cli_client_kwargs = None create_table_template = 'CREATE TABLE test ({}) ENGINE = Memory' @classmethod def emit_cli(cls, statement, database=None, encoding='utf-8', **kwargs): if database is None: database = cls.database args = [ cls.clickhouse_client_binary, '--database', database, '--host', cls.host, '--port', str(cls.port), '--query', str(statement) ] for key, value in kwargs.items(): args.extend(['--' + key, str(value)]) process = subprocess.Popen( args, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) output = process.communicate() out, err = output if err: raise RuntimeError( 'Error during communication. {}'.format(err) ) return out.decode(encoding) def _create_client(self, **kwargs): client_kwargs = { 'port': self.port, 'database': self.database, 'user': self.user, 'password': self.password } client_kwargs.update(kwargs) return Client(self.host, **client_kwargs) def created_client(self, **kwargs): return self._create_client(**kwargs) @classmethod def setUpClass(cls): cls.emit_cli( 'DROP DATABASE IF EXISTS {}'.format(cls.database), 'default' ) cls.emit_cli('CREATE DATABASE {}'.format(cls.database), 'default') version_str = cls.emit_cli('SELECT version()').strip() cls.server_version = tuple(int(x) for x in version_str.split('.')) super(BaseTestCase, cls).setUpClass() def setUp(self): super(BaseTestCase, self).setUp() required = self.required_server_version if required and required > self.server_version: skip_by_server_version(self, self.required_server_version) if callable(self.client_kwargs): client_kwargs = self.client_kwargs(self.server_version) else: client_kwargs = self.client_kwargs client_kwargs = client_kwargs or {} self.client = self._create_client(**client_kwargs) def tearDown(self): self.client.disconnect() super(BaseTestCase, self).tearDown() @classmethod def tearDownClass(cls): cls.emit_cli('DROP DATABASE {}'.format(cls.database)) super(BaseTestCase, cls).tearDownClass() @contextmanager def create_table(self, columns, template=None, **kwargs): if self.cli_client_kwargs: if callable(self.cli_client_kwargs): cli_client_kwargs = self.cli_client_kwargs() if cli_client_kwargs: kwargs.update(cli_client_kwargs) else: kwargs.update(self.cli_client_kwargs) template = template or self.create_table_template self.emit_cli(template.format(columns), **kwargs) try: yield except Exception: raise finally: self.emit_cli('DROP TABLE test') clickhouse-driver-0.2.11/tests/util.py000066400000000000000000000043341522645447600177310ustar00rootroot00000000000000import os from contextlib import contextmanager from functools import wraps import logging from io import StringIO from time import tzset from unittest.mock import patch import tzlocal def skip_by_server_version(testcase, version_required): testcase.skipTest( 'Minimum revision required: {}'.format( '.'.join(str(x) for x in version_required) ) ) def require_server_version(*version_required): def check(f): @wraps(f) def wrapper(*args, **kwargs): self = args[0] self.client.connection.connect() current = self.client.connection.server_info.version_tuple() if version_required <= current: return f(*args, **kwargs) else: skip_by_server_version(self, version_required) return wrapper return check class LoggingCapturer(object): def __init__(self, logger_name, level): self.old_stdout_handlers = [] self.logger = logging.getLogger(logger_name) self.level = level super(LoggingCapturer, self).__init__() def __enter__(self): buffer = StringIO() self.new_handler = logging.StreamHandler(buffer) self.logger.addHandler(self.new_handler) self.old_logger_level = self.logger.level self.logger.setLevel(self.level) return buffer def __exit__(self, *exc_info): self.logger.setLevel(self.old_logger_level) self.logger.removeHandler(self.new_handler) capture_logging = LoggingCapturer def bust_tzlocal_cache(): try: tzlocal.unix._cache_tz = None tzlocal.unix._cache_tz_name = None except AttributeError: pass try: tzlocal.win32._cache_tz = None tzlocal.unix._cache_tz_name = None except AttributeError: pass @contextmanager def patch_env_tz(tz_name): bust_tzlocal_cache() # Although in many cases, changing the TZ environment variable may # affect the output of functions like localtime() without calling # tzset(), this behavior should not be relied on. # https://docs.python.org/3/library/time.html#time.tzset with patch.dict(os.environ, {'TZ': tz_name}): tzset() yield tzset() clickhouse-driver-0.2.11/testsrequire.py000066400000000000000000000011561522645447600203500ustar00rootroot00000000000000import os import sys USE_NUMPY = bool(int(os.getenv('USE_NUMPY') or '0')) USE_ARROW = bool(int(os.getenv('USE_ARROW') or '0')) tests_require = [ 'pytest', 'parameterized', 'freezegun', 'zstd', 'clickhouse-cityhash>=1.0.2.6' ] if sys.implementation.name == 'pypy': tests_require.append('lz4<=3.0.1') else: tests_require.append('lz4') if USE_NUMPY: tests_require.extend(['numpy', 'pandas']) if USE_ARROW: tests_require.append('pyarrow') try: from pip import main as pipmain except ImportError: from pip._internal import main as pipmain pipmain(['install'] + tests_require) clickhouse-driver-0.2.11/valgrind.supp000066400000000000000000000001571522645447600177560ustar00rootroot00000000000000{ # See https://bugs.python.org/issue42176 Memcheck:Cond fun:PyUnicode_Decode }